Skip to content

Commit 4f96c4d

Browse files
committed
blog: Add 2025-07-28.md
1 parent c10e7ed commit 4f96c4d

1 file changed

Lines changed: 157 additions & 0 deletions

File tree

blog/2025-07-28.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: YS on jank, bb and ys
3+
date: 2025-07-28
4+
draft: false
5+
authors: [ingydotnet]
6+
categories: [Summer-of-YS]
7+
edit: blog/2025-07-28.md
8+
comments: true
9+
---
10+
11+
Last [Friday](2025-07-25.md) we got a YS program running on Go using Glojure.
12+
13+
Today we'll show how to run it on 3 other Clojure platforms:
14+
15+
1. [jank](https://github.com/jank-lang/jank) - Clojure hosted by C++ on LLVM
16+
2. [bb](https://babashka.org) - Clojure using
17+
[SCI](https://github.com/babashka/sci) and [GraalVM](https://graalvm.org)
18+
3. [ys](https://yamlscript.org) - YS can run Clojure from a YS
19+
`ys -c` compile command
20+
21+
22+
<!-- more -->
23+
24+
25+
## jank
26+
27+
jank is a work in progress, but if you can get it to compile, you can run at
28+
least some YS code through it.
29+
30+
Again, we use `ys -c` to compile the code to Clojure.
31+
In this example, we write it to a temporary file and then run it with `jank
32+
run`.
33+
34+
35+
```bash
36+
$ ys -ce '
37+
defn rng(a b): range(a b:inc)
38+
defn or?(a b): a:empty?.if(b a)
39+
say =: println
40+
41+
doseq x (1 .. 16): !:say
42+
or?:
43+
str:
44+
zero?(x % 3).when("Fizz")
45+
zero?(x % 5).when("Buzz")
46+
=>: x
47+
' | jank run $(f=$(mktemp);cat>$f;echo $f)
48+
1
49+
2
50+
Fizz
51+
4
52+
Buzz
53+
Fizz
54+
7
55+
8
56+
Fizz
57+
Buzz
58+
11
59+
Fizz
60+
13
61+
14
62+
FizzBuzz
63+
16
64+
nil
65+
```
66+
67+
68+
## bb
69+
70+
bb (aka Babashka) is a Clojure interpreter that is GraalVM compiled.
71+
It is very mature.
72+
73+
```bash
74+
$ ys -ce '
75+
defn rng(a b): range(a b:inc)
76+
defn or?(a b): a:empty?.if(b a)
77+
say =: println
78+
79+
doseq x (1 .. 16): !:say
80+
or?:
81+
str:
82+
zero?(x % 3).when("Fizz")
83+
zero?(x % 5).when("Buzz")
84+
=>: x
85+
' | bb /dev/stdin
86+
1
87+
2
88+
Fizz
89+
4
90+
Buzz
91+
Fizz
92+
7
93+
8
94+
Fizz
95+
Buzz
96+
11
97+
Fizz
98+
13
99+
14
100+
FizzBuzz
101+
16
102+
```
103+
104+
105+
## ys
106+
107+
The `ys` YS interpreter can run a lot of Clojure code.
108+
As long as it has access to the Java classes used in the code.
109+
110+
Here we use `ys` twice.
111+
It's a bit silly.
112+
But it shows that `ys` can run Clojure code with the `ys -C` flag.
113+
114+
The `-c` flag is used to compile the code to Clojure.
115+
The `-C` flag is used to **not** compile the code to Clojure.
116+
(It's already Clojure!)
117+
118+
```bash
119+
$ ys -ce '
120+
defn rng(a b): range(a b:inc)
121+
defn or?(a b): a:empty?.if(b a)
122+
say =: println
123+
124+
doseq x (1 .. 16): !:say
125+
or?:
126+
str:
127+
zero?(x % 3).when("Fizz")
128+
zero?(x % 5).when("Buzz")
129+
=>: x
130+
' | ys -C -
131+
1
132+
2
133+
Fizz
134+
4
135+
Buzz
136+
Fizz
137+
7
138+
8
139+
Fizz
140+
Buzz
141+
11
142+
Fizz
143+
13
144+
14
145+
FizzBuzz
146+
16
147+
```
148+
149+
150+
## What's Next?
151+
152+
I guess we could have also shown this evaluated by:
153+
154+
* Clojure - For the JVM
155+
* ClojureScript - For the browser and Node.js
156+
157+
or any of the other emerging Clojure platforms.

0 commit comments

Comments
 (0)