cajyu 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/bin/cajyu.js +1 -1
- package/logos/README.md +8 -0
- package/logos/logo-128.png +0 -0
- package/logos/logo-256.png +0 -0
- package/logos/logo-64.png +0 -0
- package/package.json +1 -1
- package/src/compiler-ast-note.md +16 -0
- package/examples/comparison/README.md +0 -51
- package/examples/comparison/cajyu/click-counter.cjy +0 -17
- package/examples/comparison/cajyu/live-chat.cjy +0 -16
- package/examples/comparison/cajyu/simple-server.cjy +0 -10
- package/examples/comparison/js/simple-server.js +0 -20
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Cajyu
|
|
2
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/abs-js/Cajyu/main/logos/logo-128.png" alt="Cajyu Logo" width="128">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
3
7
|
**A clean, practical programming language that transpiles to JavaScript.**
|
|
4
8
|
|
|
5
9
|
Cajyu gives you a simpler, more expressive syntax while staying fully compatible with the JavaScript ecosystem.
|
package/bin/cajyu.js
CHANGED
|
@@ -9,7 +9,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
|
|
11
11
|
const CAJYULIBS_REPO = 'https://github.com/abs-js/CajyuLibs.git';
|
|
12
|
-
const VERSION = '1.
|
|
12
|
+
const VERSION = '1.2.0';
|
|
13
13
|
|
|
14
14
|
const args = process.argv.slice(2);
|
|
15
15
|
const command = args[0];
|
package/logos/README.md
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# AST Migration in progress
|
|
2
|
+
|
|
3
|
+
The compiler now has a real Tokenizer + recursive descent Parser that builds an AST.
|
|
4
|
+
|
|
5
|
+
Current status:
|
|
6
|
+
- Tokenizer handles strings, numbers, identifiers, keywords correctly
|
|
7
|
+
- Parser builds AST for var, fn, if/elif/else, while, for, class, return, expressions
|
|
8
|
+
- Code generator emits JavaScript from the AST
|
|
9
|
+
|
|
10
|
+
Still being completed:
|
|
11
|
+
- Full import resolution
|
|
12
|
+
- Builtins (range, typeCheck)
|
|
13
|
+
- Async (sync/wait)
|
|
14
|
+
- One-liners and more edge cases
|
|
15
|
+
|
|
16
|
+
This is the foundation for a robust parser.
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Comparison: JavaScript vs TypeScript vs Cajyu
|
|
2
|
-
|
|
3
|
-
Three identical features implemented in three languages.
|
|
4
|
-
|
|
5
|
-
## 1. Simple HTML Server
|
|
6
|
-
|
|
7
|
-
| Language | File | Lines (approx) | Notes |
|
|
8
|
-
|------------|-----------------------------------|----------------|-------|
|
|
9
|
-
| JavaScript | `js/simple-server.js` | 18 | Direct `http` module |
|
|
10
|
-
| TypeScript | `ts/simple-server.ts` | 18 | Same + types |
|
|
11
|
-
| Cajyu | `cajyu/simple-server.cjy` | 10 | Uses `CajyuLibs.http` |
|
|
12
|
-
|
|
13
|
-
**Cajyu is the shortest.** The HTTP library abstracts the boilerplate.
|
|
14
|
-
|
|
15
|
-
## 2. Click Counter
|
|
16
|
-
|
|
17
|
-
| Language | File | Lines (approx) | Notes |
|
|
18
|
-
|------------|-----------------------------------|----------------|-------|
|
|
19
|
-
| JavaScript | `js/click-counter.js` | 35 | Manual route + inline HTML/JS |
|
|
20
|
-
| TypeScript | `ts/click-counter.ts` | 35 | Same + types |
|
|
21
|
-
| Cajyu | `cajyu/click-counter.cjy` | 16 | `server.post` + `server.file` |
|
|
22
|
-
|
|
23
|
-
Again, Cajyu is more concise because of the built-in server abstraction.
|
|
24
|
-
|
|
25
|
-
## 3. Live Chat (WebSocket)
|
|
26
|
-
|
|
27
|
-
| Language | File | Lines (approx) | Notes |
|
|
28
|
-
|------------|-----------------------------------|----------------|-------|
|
|
29
|
-
| JavaScript | `js/live-chat.js` | 45 | Uses `ws` package + full HTML |
|
|
30
|
-
| TypeScript | `ts/live-chat.ts` | 45 | Same + types |
|
|
31
|
-
| Cajyu | `cajyu/live-chat.cjy` | 12 | Uses `CajyuLibs.websocket` (broadcast only) |
|
|
32
|
-
|
|
33
|
-
Cajyu version is shorter but currently only shows the WebSocket server side.
|
|
34
|
-
|
|
35
|
-
## Summary
|
|
36
|
-
|
|
37
|
-
| Aspect | JavaScript | TypeScript | Cajyu |
|
|
38
|
-
|---------------------|-----------------|------------------|------------------------|
|
|
39
|
-
| Boilerplate | Medium | Medium | Low |
|
|
40
|
-
| Type safety | None | Strong | Optional runtime |
|
|
41
|
-
| Learning curve | Low | Medium | Low (if you know JS) |
|
|
42
|
-
| Ecosystem | Huge | Huge | Small (growing) |
|
|
43
|
-
| Abstraction level | Low-medium | Low-medium | Higher |
|
|
44
|
-
| Best for | Production | Large projects | Prototyping / learning |
|
|
45
|
-
|
|
46
|
-
**Conclusion:**
|
|
47
|
-
- **JavaScript** is the baseline.
|
|
48
|
-
- **TypeScript** adds safety with almost no extra cost.
|
|
49
|
-
- **Cajyu** reduces boilerplate the most, especially for servers, but is still a prototype language.
|
|
50
|
-
|
|
51
|
-
All examples are in `examples/comparison/`.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Server from CajyuLibs.http
|
|
2
|
-
import print from CajyuLibs.serial
|
|
3
|
-
|
|
4
|
-
var clicks = 0
|
|
5
|
-
var server = new Server(3001)
|
|
6
|
-
print("Cajyu click server at http://localhost:3001")
|
|
7
|
-
|
|
8
|
-
var html = "<!DOCTYPE html><html><body><h1>Click Counter (Cajyu)</h1><button id='btn'>Click me</button><p>Total clicks: <span id='count'>0</span></p><script>const btn=document.getElementById('btn');const count=document.getElementById('count');btn.onclick=async()=>{const r=await fetch('/click',{method:'POST'});const data=await r.json();count.textContent=data.clicks;};</script></body></html>"
|
|
9
|
-
|
|
10
|
-
server.file("/", html)
|
|
11
|
-
server.file("index.html", html)
|
|
12
|
-
|
|
13
|
-
server.post(fn b {
|
|
14
|
-
clicks = clicks + 1
|
|
15
|
-
print("Click #" + clicks)
|
|
16
|
-
return { code: 200, clicks: clicks }
|
|
17
|
-
})
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import WS from CajyuLibs.websocket
|
|
2
|
-
import print from CajyuLibs.serial
|
|
3
|
-
|
|
4
|
-
var wss = new WS.Server(3002)
|
|
5
|
-
print("Cajyu live chat WebSocket on port 3002")
|
|
6
|
-
|
|
7
|
-
wss.on("connection", fn client {
|
|
8
|
-
print("Client connected")
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
wss.on("message", fn msg, client {
|
|
12
|
-
print("Message: " + msg)
|
|
13
|
-
wss.broadcast(msg)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
print("Open a WebSocket client to ws://localhost:3002 to chat")
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Server from CajyuLibs.http
|
|
2
|
-
import print from CajyuLibs.serial
|
|
3
|
-
|
|
4
|
-
var server = new Server(3000)
|
|
5
|
-
print("Cajyu simple server running at http://localhost:3000")
|
|
6
|
-
|
|
7
|
-
var html = "<!DOCTYPE html><html><head><title>Simple Server</title></head><body><h1>Hello from Cajyu!</h1><p>This is a simple text served by a Cajyu server.</p></body></html>"
|
|
8
|
-
|
|
9
|
-
server.file("/", html)
|
|
10
|
-
server.file("index.html", html)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Simple HTML server - JavaScript
|
|
2
|
-
import http from 'http';
|
|
3
|
-
|
|
4
|
-
const server = http.createServer((req, res) => {
|
|
5
|
-
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
6
|
-
res.end(`
|
|
7
|
-
<!DOCTYPE html>
|
|
8
|
-
<html>
|
|
9
|
-
<head><title>Simple Server</title></head>
|
|
10
|
-
<body>
|
|
11
|
-
<h1>Hello from JavaScript!</h1>
|
|
12
|
-
<p>This is a simple text served by a Node.js server.</p>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|
|
15
|
-
`);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
server.listen(3000, () => {
|
|
19
|
-
console.log('JS server running at http://localhost:3000');
|
|
20
|
-
});
|