Skip to content

All language #4

Closed
1 of 1 issue completed
Closed

Description

@Sazwanismail

Introducing Lingua: A Minimalist, Expressive Language for Creative Coding

(Inspired by Lisp, Python, and Forth)

Lingua combines symbolic expressiveness with functional simplicity. Here’s the full specification:


1. Core Principles

  • Everything is an atom or a list: (operator arg1 arg2 ...)
  • No keywords: Operations are defined by symbols.
  • Dynamic typing: Values carry their type.
  • Concise syntax: Minimal punctuation.

2. Syntax & Data Types

; Atoms (immutable)
42              ; int
3.14            ; float
"hello"         ; string
:quit           ; symbol (interned)

; Lists (evaluated as operations)
(+ 1 2)         ; → 3
(print "Hi")    ; Output: Hi

3. Special Forms

Form Meaning Example
(def x 10) Define variable x → 10
(fn [a b] ...) Define function ((fn [a b] (+ a b)) 2 3) → 5
(if cond T F) Conditional (if (> 3 2) "Y" "N") → "Y"
(quote x) Prevent evaluation (quote (+ 1 2)) → (+ 1 2)
'(a b c) Shorthand for (quote (a b c)) '(1 2 3) → list (1 2 3)

4. Functions

; Named function
(def sq (fn [x] (* x x)))
(sq 4)  ; → 16

; Anonymous function
(map (fn [x] (* x 2)) '(1 2 3))  ; → (2 4 6)

5. Conventions

  • Arithmetic: (+ 1 2 3) → 6 (n-ary)
  • Comparison: (> 5 3) → :true
  • Logic: (and :true :false) → :false
  • Lists:
    • (head '(1 2 3)) → 1
    • (tail '(1 2 3)) → (2 3)

6. Memory Management

  • Garbage-collected: No manual memory handling.
  • Persistent data structures: All values immutable.

7. Standard Library

Function Action
(range 5) → (0 1 2 3 4)
(zip a b) Pair lists: (zip '(1 2) '(a b)) → ((1 a) (2 b))
(fold + 0 '(1 2 3)) → 6
(io/write "file.txt" "data") Write to file

8. Sample Program: Fibonacci

(def fib
  (fn [n]
    (if (< n 2)
        n
        (+ (fib (- n 1)) (fib (- n 2))))))

(print (fib 10))  ; → 55

9. Unique Features

  1. Homoiconicity: Code is data (manipulate code as lists).
  2. REPL-Driven: Interactive development.
  3. Macro System:
    (defmacro unless [cond body]
      (list 'if (list 'not cond) body))
    
    (unless (> 3 4) (print "Safe!"))  ; Prints "Safe!"

Why Lingua?

  • Learn in 10 minutes: Syntax fits on a notecard.
  • Extensible: Add features via macros.
  • Embeddable: <200 KB runtime.

Example interpreter (Python):

def eval(expr, env):
    if isinstance(expr, int): return expr
    if expr[0] == '+': return eval(expr[1], env) + eval(expr[2], env)
    # ...

Run it: lingua script.lg


Design your own dialects, explore symbolic programming, and create freely! 🚀

Activity

  1. self-assigned this
    on Jul 18, 2025
  2. linked a pull request that will close this issueSLSA3 Workflow #13on Oct 21, 2025
  3. linked a pull request that will close this issueCreate Setting slsa.dev #22on Mar 11, 2026
  4. linked a pull request that will close this issueCreate MIT License #23on Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

StrategicKecekapan semulajadidocumentationImprovements or additions to documentationenhancementNew feature or requesthelp wantedExtra attention is needed

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions