forge-lang 0.4.0

Forge โ€” Internet-native programming language with natural syntax, bytecode VM, and built-in HTTP/database/crypto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
<div align="center">

# โš’๏ธ Forge

### The internet-native programming language that reads like English.

Built-in HTTP, databases, crypto, AI, and a JIT compiler.<br>
**18 modules. 238+ functions. Zero dependencies.**

[![CI](https://github.com/humancto/forge-lang/actions/workflows/ci.yml/badge.svg)](https://github.com/humancto/forge-lang/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/humancto/forge-lang?color=%23ff6b35&style=flat-square)](https://github.com/humancto/forge-lang/releases)
[![License: MIT](https://img.shields.io/badge/license-MIT-64ffda?style=flat-square)](LICENSE)
[![Built with Rust](https://img.shields.io/badge/built_with-Rust-%23f74c00?style=flat-square)](https://www.rust-lang.org/)
[![Tests](https://img.shields.io/badge/tests-862_passing-64ffda?style=flat-square)](#project-status)
[![Stars](https://img.shields.io/github/stars/humancto/forge-lang?color=%23ff6b35&style=flat-square)](https://github.com/humancto/forge-lang/stargazers)
[![crates.io](https://img.shields.io/crates/v/forge-lang?color=%23ff6b35&style=flat-square)](https://crates.io/crates/forge-lang)

[๐Ÿ“ฅ **Download Book**](https://github.com/humancto/forge-lang/releases/latest/download/programming-forge.pdf) ยท [๐Ÿ“– **Language Spec**](https://humancto.github.io/forge-lang/spec/) ยท [๐ŸŒ **Website**](https://humancto.github.io/forge-lang/) ยท [๐Ÿ’ฌ **Discussions**](https://github.com/humancto/forge-lang/discussions) ยท [๐Ÿ› **Issues**](https://github.com/humancto/forge-lang/issues)

</div>

---

```bash
brew install humancto/tap/forge    # install
forge learn                        # 30 interactive tutorials
forge run app.fg                   # run a program
```

---

## โšก See It In Action

<table>
<tr>
<td width="50%">

**REST API โ€” 3 lines, zero deps**

```forge
@server(port: 3000)

@get("/hello/:name")
fn hello(name: String) -> Json {
    return { greeting: "Hello, {name}!" }
}
```

</td>
<td width="50%">

**Database + Crypto โ€” built in**

```forge
db.open(":memory:")
db.execute("CREATE TABLE users (name TEXT)")
db.execute("INSERT INTO users VALUES ('Alice')")

let users = db.query("SELECT * FROM users")
term.table(users)

say crypto.sha256("password")
```

</td>
</tr>
</table>

> **No framework. No packages. No setup.** Just `forge run`.

---

## ๐Ÿ“– Table of Contents

|                                                      |                                 |                                       |
| ---------------------------------------------------- | ------------------------------- | ------------------------------------- |
| [โšก Quick Example]#-see-it-in-action               | [๐ŸŽฏ Why Forge?]#-why-forge    | [๐Ÿ“ฆ Installation]#-installation     |
| [๐Ÿ—ฃ๏ธ Dual Syntax]#๏ธ-dual-syntax                      | [๐Ÿš€ Quick Tour]#-quick-tour   | [๐Ÿ—๏ธ Type System]#๏ธ-type-system       |
| [๐Ÿ“š Standard Library]#-standard-library-18-modules | [โšก Performance]#-performance | [๐ŸŽฎ GenZ Debug Kit]#-genz-debug-kit |
| [๐Ÿ”ง CLI]#-cli-commands                             | [๐Ÿ“‚ Examples]#-examples       | [๐Ÿ›๏ธ Architecture]#๏ธ-architecture     |
| [๐Ÿ“• Book]#-the-book                                | [๐Ÿ—บ๏ธ Roadmap]#๏ธ-roadmap         | [๐Ÿค Contributing]#-contributing     |

---

## ๐ŸŽฏ Why Forge?

Modern development means installing dozens of packages before writing a single line of logic:

```bash
# Python: pip install flask requests sqlalchemy bcrypt python-dotenv ...
# Node:   npm install express node-fetch better-sqlite3 bcrypt csv-parser ...
# Go:     go get github.com/gin-gonic/gin github.com/mattn/go-sqlite3 ...
```

**Forge: everything is built in.**

| Task               |    Forge    |    Python     |      Node.js       |        Go        |
| ------------------ | :---------: | :-----------: | :----------------: | :--------------: |
| REST API server    | **3 lines** |  12 + flask   |    15 + express    |     25 lines     |
| Query SQLite       | **2 lines** |    5 lines    | 8 + better-sqlite3 | 12 + go-sqlite3  |
| SHA-256 hash       | **1 line**  |    3 lines    |      3 lines       |     5 lines      |
| HTTP GET request   | **1 line**  | 3 + requests  |   5 + node-fetch   |     10 lines     |
| Parse CSV          | **1 line**  |    4 lines    |   6 + csv-parser   |     8 lines      |
| Terminal table     | **1 line**  | 5 + tabulate  |   4 + cli-table    | 10 + tablewriter |
| Retry with backoff | **1 line**  | 12 + tenacity |  15 + async-retry  |  20 + retry-go   |

> ๐Ÿ’ก **Forge ships with 0 external dependencies needed** for HTTP, databases, crypto, CSV, regex, terminal UI, shell integration, AI, and more.

---

## ๐Ÿ“ฆ Installation

```bash
# Homebrew (macOS & Linux) โ€” recommended
brew install humancto/tap/forge

# Cargo (Rust)
cargo install forge-lang

# Install script
curl -fsSL https://raw.githubusercontent.com/humancto/forge-lang/main/install.sh | bash

# From source
git clone https://github.com/humancto/forge-lang.git && cd forge-lang && cargo install --path .
```

**Verify:**

```bash
forge version          # โ†’ forge 0.4.0
forge learn            # 30 interactive tutorials
forge                  # start REPL
```

---

## ๐Ÿ—ฃ๏ธ Dual Syntax

Write it your way. Both compile identically.

<table>
<tr>
<td width="50%">

**โœฆ Natural โ€” reads like English**

```forge
set name to "Forge"
say "Hello, {name}!"

define greet(who) {
    say "Welcome, {who}!"
}

set mut score to 0
repeat 5 times {
    change score to score + 10
}

if score > 40 {
    yell "You win!"
} otherwise {
    whisper "try again..."
}
```

</td>
<td width="50%">

**โš™ Classic โ€” familiar syntax**

```forge
let name = "Forge"
println("Hello, {name}!")

fn greet(who) {
    println("Welcome, {who}!")
}

let mut score = 0
for i in range(0, 5) {
    score += 10
}

if score > 40 {
    println("You win!")
} else {
    println("try again...")
}
```

</td>
</tr>
</table>

<details>
<summary><strong>๐Ÿ“‹ Full syntax mapping (click to expand)</strong></summary>

| Concept    | Classic                    | Natural                     |
| ---------- | -------------------------- | --------------------------- |
| Variables  | `let x = 5`                | `set x to 5`                |
| Mutable    | `let mut x = 0`            | `set mut x to 0`            |
| Reassign   | `x = 10`                   | `change x to 10`            |
| Functions  | `fn add(a, b) { }`         | `define add(a, b) { }`      |
| Output     | `println("hi")`            | `say` / `yell` / `whisper`  |
| Else       | `else { }`                 | `otherwise { }` / `nah { }` |
| Async      | `async fn x() { }`         | `forge x() { }`             |
| Await      | `await expr`               | `hold expr`                 |
| Structs    | `struct Foo { }`           | `thing Foo { }`             |
| Methods    | `impl Foo { }`             | `give Foo { }`              |
| Interfaces | `interface Bar { }`        | `power Bar { }`             |
| Construct  | `Foo { x: 1 }`             | `craft Foo { x: 1 }`        |
| Fetch      | `fetch("url")`             | `grab resp from "url"`      |
| Loops      | `for i in range(0, 3) { }` | `repeat 3 times { }`        |
| Destruct   | `let {a, b} = obj`         | `unpack {a, b} from obj`    |

</details>

---

## ๐Ÿš€ Quick Tour

### Variables & Functions

```forge
let name = "Forge"              // immutable
let mut count = 0               // mutable
count += 1

fn add(a, b) { return a + b }
let double = fn(x) { x * 2 }   // lambda with implicit return
```

### ๐ŸŽค The Output Trio

```forge
say "Normal volume"              // standard output
yell "LOUD AND PROUD!"          // UPPERCASE + !
whisper "quiet and gentle"       // lowercase + ...
```

### Control Flow & Pattern Matching

```forge
if score > 90 { say "A" }
otherwise if score > 80 { say "B" }
otherwise { say "C" }

// When guards
let label = when temp {
    > 100 -> "Boiling"
    > 60  -> "Warm"
    else  -> "Cold"
}

// Algebraic data types + pattern matching
type Shape = Circle(Float) | Rect(Float, Float)
match Circle(5.0) {
    Circle(r) => say "Area = {3.14 * r * r}"
    Rect(w, h) => say "Area = {w * h}"
}
```

### ๐Ÿ”‘ Innovation Keywords

```forge
safe { risky_function() }                         // returns null on error
must parse_config("app.toml")                     // crash with clear message
check email is not empty                          // declarative validation
retry 3 times { fetch("https://api.example.com") } // automatic retry
timeout 5 seconds { long_operation() }             // enforced time limit
wait 2 seconds                                     // sleep with units
```

### Collections & Functional

```forge
let nums = [1, 2, 3, 4, 5]
let result = nums
    .filter(fn(x) { x % 2 == 0 })
    .map(fn(x) { x * 2 })
say result   // [4, 8]

let user = { name: "Alice", age: 30 }
say pick(user, ["name"])            // { name: "Alice" }
say get(user, "email", "N/A")      // safe access with default
```

### Error Handling

```forge
fn safe_divide(a, b) {
    if b == 0 { return Err("division by zero") }
    return Ok(a / b)
}

match safe_divide(10, 0) {
    Ok(val) => say "Got: {val}"
    Err(msg) => say "Error: {msg}"
}

// Propagate with ?
fn compute(input) {
    let n = parse_int(input)?
    return Ok(n * 2)
}
```

---

## ๐Ÿ—๏ธ Type System

Define data types, attach behavior, enforce contracts, and compose with delegation.

<table>
<tr>
<td width="50%">

**โœฆ Natural โ€” thing / give / power**

```forge
thing Person {
    name: String,
    age: Int,
    role: String = "member"
}

give Person {
    define greet(it) {
        return "Hi, I'm " + it.name
    }
}

power Describable {
    fn describe() -> String
}

give Person the power Describable {
    define describe(it) {
        return it.name + " (" + it.role + ")"
    }
}

set p to craft Person { name: "Alice", age: 30 }
say p.greet()                      // Hi, I'm Alice
say satisfies(p, Describable)      // true
```

</td>
<td width="50%">

**โš™ Classic โ€” struct / impl / interface**

```forge
struct Person {
    name: String,
    age: Int,
    role: String = "member"
}

impl Person {
    fn greet(it) {
        return "Hi, I'm " + it.name
    }
}

interface Describable {
    fn describe() -> String
}

impl Describable for Person {
    fn describe(it) {
        return it.name + " (" + it.role + ")"
    }
}

let p = Person { name: "Alice", age: 30 }
println(p.greet())                 // Hi, I'm Alice
println(satisfies(p, Describable)) // true
```

</td>
</tr>
</table>

### Composition with `has`

```forge
thing Address { street: String, city: String }
thing Employee { name: String, has addr: Address }

give Address {
    define full(it) { return it.street + ", " + it.city }
}

set emp to craft Employee {
    name: "Charlie",
    addr: craft Address { street: "123 Main St", city: "Portland" }
}

say emp.city        // delegated to emp.addr.city โ†’ "Portland"
say emp.full()      // delegated to emp.addr.full() โ†’ "123 Main St, Portland"
```

| Keyword                 | Purpose                                     |
| ----------------------- | ------------------------------------------- |
| `thing` / `struct`      | Define a data type                          |
| `craft`                 | Construct an instance                       |
| `give` / `impl`         | Attach methods to a type                    |
| `power` / `interface`   | Define a behavioral contract                |
| `has`                   | Embed a type with field + method delegation |
| `it`                    | Self-reference in methods                   |
| `satisfies(obj, Power)` | Check if an object satisfies a contract     |

---

## ๐Ÿ“š Standard Library (18 Modules)

Every module is available from line 1. No imports. No installs.

### ๐ŸŒ HTTP Server & Client

```forge
// Server โ€” 3 lines to production
@server(port: 3000)
@get("/users/:id")
fn get_user(id: String) -> Json {
    return db.query("SELECT * FROM users WHERE id = " + id)
}

// Client โ€” just fetch
let resp = fetch("https://api.github.com/repos/rust-lang/rust")
say resp.json.stargazers_count
```

### ๐Ÿ—„๏ธ Database (SQLite + PostgreSQL + MySQL)

```forge
db.open(":memory:")
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)")
db.execute("INSERT INTO users (name) VALUES ('Alice')")
let users = db.query("SELECT * FROM users")
term.table(users)

// MySQL โ€” parameterized queries, connection pooling
let conn = mysql.connect("mysql://root:pass@localhost/mydb")
let users = mysql.query(conn, "SELECT * FROM users WHERE age > ?", [21])
mysql.close(conn)
```

### ๐Ÿ” JWT Authentication

```forge
let token = jwt.sign({ user_id: 123, role: "admin" }, "secret", { expires: "1h" })
let claims = jwt.verify(token, "secret")
say claims.user_id       // 123
say jwt.valid(token, "secret")  // true
```

### ๐Ÿš Shell Integration

```forge
say sh("whoami")                           // quick stdout
let files = sh_lines("ls /etc | head -5")  // stdout as array
if sh_ok("which docker") { say "Docker installed" }
let sorted = pipe_to(csv_data, "sort")     // pipe Forge data into shell
```

### ๐Ÿ–ฅ๏ธ Terminal UI

```forge
term.table(data)                   // formatted tables
term.sparkline([1, 5, 3, 8, 2])   // inline charts โ–โ–…โ–ƒโ–ˆโ–‚
term.bar("Progress", 75, 100)     // progress bars
say term.red("Error!")             // ๐Ÿ”ด colored output
say term.green("Success!")         // ๐ŸŸข
term.banner("FORGE")               // ASCII art banner
```

### ๐Ÿ” Crypto + ๐Ÿ“„ CSV + ๐Ÿ“ File System

```forge
say crypto.sha256("forge")                    // hash anything
say crypto.base64_encode("secret")             // encode/decode

let data = csv.read("users.csv")               // parse CSV files
csv.write("output.csv", processed_data)         // write CSV

fs.write("config.json", json.stringify(data))   // file I/O
let exists = fs.exists("config.json")
```

<details>
<summary><strong>๐Ÿ“‹ All 18 modules at a glance (click to expand)</strong></summary>

| Module     | Functions                                                                                                                            |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| **math**   | sqrt, pow, abs, sin, cos, tan, pi, e, random, random_int, clamp, floor, ceil, round                                                  |
| **fs**     | read, write, append, exists, list, mkdir, copy, rename, remove, size, lines, dirname, basename, join_path, is_dir, is_file, temp_dir |
| **crypto** | sha256, md5, base64_encode/decode, hex_encode/decode                                                                                 |
| **db**     | SQLite โ€” open, query, execute, close                                                                                                 |
| **pg**     | PostgreSQL โ€” connect, query, execute, close                                                                                          |
| **mysql**  | MySQL โ€” connect, query, execute, close (parameterized queries, connection pooling)                                                   |
| **jwt**    | sign, verify, decode, valid (HS256/384/512, RS256, ES256)                                                                            |
| **json**   | parse, stringify, pretty                                                                                                             |
| **csv**    | parse, stringify, read, write                                                                                                        |
| **regex**  | test, find, find_all, replace, split                                                                                                 |
| **env**    | get, set, has, keys                                                                                                                  |
| **log**    | info, warn, error, debug                                                                                                             |
| **term**   | colors, table, sparkline, bar, banner, box, gradient, countdown, confirm, menu                                                       |
| **http**   | get, post, put, delete, patch, head, download, crawl                                                                                 |
| **io**     | prompt, print, args_parse, args_get, args_has                                                                                        |
| **exec**   | run_command                                                                                                                          |
| **time**   | now, format, parse, sleep, elapsed                                                                                                   |
| **npc**    | Fake data โ€” name, email, username, phone, number, pick, bool, sentence, id, color, ip, url, company                                  |

</details>

---

## โšก Performance

Three execution tiers โ€” pick your tradeoff:

| Engine         |  fib(30) |   vs Python    | Best For                              |
| -------------- | -------: | :------------: | ------------------------------------- |
| ๐Ÿ”ฅ `--jit`     | **10ms** | **11x faster** | Compute-heavy hot functions           |
| โš™๏ธ `--vm`      |    252ms |   ~2x slower   | General bytecode execution            |
| ๐Ÿ“ฆ Interpreter |  2,300ms |  ~20x slower   | Full feature set + all 238+ functions |

<details>
<summary><strong>๐Ÿ“Š Full cross-language benchmark โ€” fib(30)</strong></summary>

| Language                |     Time | Relative |
| ----------------------- | -------: | -------: |
| Rust 1.91 (-O)          |   1.46ms | baseline |
| C (clang -O2)           |   1.57ms |    ~1.1x |
| Go 1.23                 |   4.24ms |    ~2.9x |
| Scala 2.12 (JVM)        |   4.33ms |    ~3.0x |
| Java 1.8 (JVM)          |   5.77ms |    ~4.0x |
| JavaScript (Node 22/V8) |   9.53ms |    ~6.5x |
| **Forge (JIT)**         | **10ms** |  **~7x** |
| Python 3                |    114ms |     ~79x |
| Forge (VM)              |    252ms |    ~173x |
| Forge (interpreter)     |  2,300ms |  ~1,575x |

The JIT compiles hot functions to native code via [Cranelift](https://cranelift.dev/), placing Forge alongside Node.js/V8 for recursive workloads.

</details>

---

## ๐ŸŽฎ GenZ Debug Kit

Debugging should have personality. Forge ships both classic and GenZ-flavored debug tools.

```forge
sus(my_object)         // ๐Ÿ” inspect any value (= debug/inspect)
bruh("it broke")       // ๐Ÿ’€ crash with a message (= panic)
bet(score > 0)         // ๐Ÿ’ฏ assert it's true (= assert)
no_cap(result, 42)     // ๐Ÿงข assert equality (= assert_eq)
ick(is_deleted)        // ๐Ÿคฎ assert it's false (= assert_false)
```

**Plus execution tools:**

```forge
cook { expensive_op() }           // โฑ๏ธ profile execution time
slay 1000 { fibonacci(20) }      // ๐Ÿ“Š benchmark (1000 iterations)
ghost { might_fail() }           // ๐Ÿ‘ป silent execution (swallow errors)
yolo { send_analytics(data) }    // ๐Ÿš€ fire-and-forget async
```

---

## ๐Ÿ”ง CLI Commands

| Command               | What It Does             |
| --------------------- | ------------------------ |
| `forge run <file>`    | Run a program            |
| `forge`               | Start REPL               |
| `forge -e '<code>'`   | Evaluate inline          |
| `forge learn [n]`     | 30 interactive tutorials |
| `forge new <name>`    | Scaffold a project       |
| `forge test [dir]`    | Run tests                |
| `forge fmt [files]`   | Format code              |
| `forge build <file>`  | Compile to bytecode      |
| `forge install <src>` | Install a package        |
| `forge lsp`           | Language server          |
| `forge chat`          | AI assistant             |
| `forge version`       | Version info             |

---

## ๐Ÿ“‚ Examples

```bash
forge run examples/hello.fg        # basics
forge run examples/natural.fg      # natural syntax
forge run examples/types.fg        # type system โ€” thing/give/power/craft/has
forge run examples/api.fg          # REST API server
forge run examples/data.fg         # data processing + visualization
forge run examples/devops.fg       # system automation
forge run examples/showcase.fg     # everything in one file
forge run examples/functional.fg   # closures, recursion, higher-order
forge run examples/adt.fg          # algebraic data types + matching
forge run examples/result_try.fg   # error handling with ?
forge run examples/jwt_demo.fg     # JWT authentication
forge run examples/mysql_demo.fg   # MySQL database CRUD
```

---

## ๐Ÿ›๏ธ Architecture

```
Source (.fg) โ†’ Lexer โ†’ Tokens โ†’ Parser โ†’ AST โ†’ Type Checker
                                                     โ†“
                            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                            โ†“                        โ†“                        โ†“
                       Interpreter              Bytecode VM              JIT Compiler
                     (full features)           (--vm flag)             (--jit flag)
                            โ†“                        โ†“                        โ†“
                     Runtime Bridge            Mark-Sweep GC          Cranelift Native
                  (axum, reqwest, tokio,       Green Threads              Code
                   rusqlite, postgres)
```

**~26,000 lines of Rust.** Zero `unsafe` blocks in application code.

<details>
<summary><strong>๐Ÿ”ฉ Core dependencies</strong></summary>

| Crate                                              | Purpose         |
| -------------------------------------------------- | --------------- |
| [axum]https://github.com/tokio-rs/axum           | HTTP server     |
| [tokio]https://tokio.rs                          | Async runtime   |
| [reqwest]https://github.com/seanmonstar/reqwest  | HTTP client     |
| [cranelift]https://cranelift.dev/                | JIT compilation |
| [rusqlite]https://github.com/rusqlite/rusqlite   | SQLite          |
| [ariadne]https://github.com/zesterer/ariadne     | Error reporting |
| [rustyline]https://github.com/kkawakam/rustyline | REPL            |
| [clap]https://github.com/clap-rs/clap            | CLI parsing     |

</details>

---

## ๐Ÿ“• The Book

<p align="center">
  <a href="https://github.com/humancto/forge-lang/releases/latest/download/programming-forge.pdf">
    <img src="docs/cover.jpeg" alt="Programming Forge โ€” The Internet-Native Language That Reads Like English" width="280">
  </a>
</p>

<p align="center">
  <strong>Programming Forge: The Internet-Native Language That Reads Like English</strong><br>
  36 chapters ยท Foundations ยท Standard Library ยท Real-World Projects ยท Internals<br><br>
  <a href="https://github.com/humancto/forge-lang/releases/latest/download/programming-forge.pdf">๐Ÿ“ฅ Download PDF (Free)</a> ยท <a href="docs/PROGRAMMING_FORGE.md">๐Ÿ“– Read Online</a>
</p>

---

## ๐Ÿ“Š Project Status

Forge is **v0.4.0**. The language, interpreter, and standard library are stable and tested.

| Metric                   |                      Value |
| ------------------------ | -------------------------: |
| Lines of Rust            |                    ~27,000 |
| Standard library modules |                         18 |
| Built-in functions       |                       238+ |
| Keywords                 |                        80+ |
| Tests passing            | 862 (528 Rust + 334 Forge) |
| Interactive lessons      |                         30 |
| Example programs         |                         15 |
| Dependencies (CVEs)      |        344 crates (0 CVEs) |

### Known Limitations

> [!NOTE]
> Forge is a young language. These are documented, not hidden.

- **No parameterized SQL queries** โ€” use string concatenation for now. Be cautious with user input.
- **Three execution tiers with different trade-offs** โ€” The interpreter supports all 238+ functions. Use `--jit` for compute-heavy code (11x faster than Python) or `--vm` for bytecode execution.
- **VM/JIT feature gap** โ€” The JIT and VM execute a subset of the language. Use the default interpreter for full stdlib, HTTP, database, and AI features.
- **`regex` functions** take `(text, pattern)` argument order, not `(pattern, text)`.

---

## ๐Ÿ—บ๏ธ Roadmap

| Version     | Focus                                                                                             |
| ----------- | ------------------------------------------------------------------------------------------------- |
| **v0.3** โœ… | Type system (thing/power/give/craft/has), 73 new functions, GenZ debug kit, NPC module, 822 tests |
| **v0.4** โœ… | JWT authentication, MySQL with parameterized queries, 18 modules, 862 tests                       |
| **v0.5**    | WASM target, expanded JIT coverage, LSP completions                                               |
| **v1.0**    | Stable API, backwards compatibility guarantee                                                     |

See [ROADMAP.md](ROADMAP.md) for the full plan. Have ideas? [Open an issue](https://github.com/humancto/forge-lang/issues).

---

## โœ๏ธ Editor Support

**VS Code** โ€” Syntax highlighting available in [editors/vscode/](editors/vscode/):

```bash
cp -r editors/vscode ~/.vscode/extensions/forge-lang
```

**LSP** โ€” Built-in language server:

```bash
forge lsp
```

Configure your editor's LSP client to use `forge lsp` as the command.

---

## ๐Ÿค Contributing

```bash
git clone https://github.com/humancto/forge-lang.git
cd forge-lang
cargo build && cargo test
forge run examples/showcase.fg
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for the architecture guide and PR guidelines. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community standards.

---

## ๐Ÿ”’ Security

To report a security vulnerability, please email the maintainers directly instead of opening a public issue. See [SECURITY.md](SECURITY.md).

---

## ๐Ÿ“„ License

[MIT](LICENSE)

---

<div align="center">

**Stop installing. Start building.**

Built by [**HumanCTO**](https://www.humancto.com) ยท [GitHub](https://github.com/humancto) ยท [LinkedIn](https://www.linkedin.com/in/archithr/)

</div>