I wanted to show my kid some programming. I remembered, that python turtle is an easy way for kids to get started. But I don't want to teach my children an outdated language like python.
So here is the roc-turtle-platform.
Currently, it only supports linux with the surgical linker. I am not sure, if you have to install sdl2 and sdl2_image.
Here is the example app:
app [main] {
pf: platform "https://github.com/ostcar/roc-turtle/releases/download/v0.0.1/xiStykcN7qK5K0pu3NqrnriaYPPYJ7vtrxBmOjowdkU.tar.br"
}
import pf.Task
import pf.Turtle
main =
_ = Turtle.up!
_ = Turtle.goto! 0 0
_ = Turtle.down!
_ = Turtle.goto! 238.834 32.1052
_ = Turtle.goto! 372.438 190.101
_ = Turtle.goto! 459.665 166.324
_ = Turtle.goto! 505 220
_ = Turtle.goto! 450 220
_ = Turtle.goto! 440.315 263.689
_ = Turtle.goto! 264.673 393.424
_ = Turtle.goto! 274.527 452.132
_ = Turtle.goto! 176.55 530
_ = Turtle.goto! 236.751 227.086
_ = Turtle.goto! 0 0
_ = Turtle.up!
Turtle.goto! 100 200
The final goal would be to switch the zig-sdl2 host for a javascript-canvas-wasm-host to get something like this https://pythonsandbox.com/turtle So lets see how the playground with LSP support project goes.
Cool!
@Oskar Hahn
Wanted to try this out and got this error from Effect.roc:
bash> roc dev
── STATEMENT AFTER EXPRESSION in ...K0pu3NqrnriaYPPYJ7vtrxBmOjowdkU/Effect.roc ─
I just finished parsing an expression with a series of definitions,
and this line is indented as if it's intended to be part of that
expression:
1│ # this module will be replaced when effect interpreters are implemented
2│ hosted Effect
3│ exposes [
4│ Effect,
5│ after,
6│ map,
7│ always,
8│ forever,
9│ loop,
10│ forward,
11│ backward,
12│ left,
13│ right,
14│ goto,
15│ up,
16│ down,
17│ ]
18│ imports []
19│ generates Effect with [after, map, always, forever, loop]
20│
21│ # effects that are provided by the host
22│ forward : F64 -> Effect (Result {} {})
^
However, I already saw the final expression in that series of
definitions.
(My son is only 3, but I have the same exact inclination as you! Want to show him an example of a GOOD language! Hah)
We recently changed away from Effect and to Task as a built-in. So that probably needs to be updated.
I wish I had more time for Roc. I have so many ideas, but cannot implement them.
I will try to update the platform to the new roc API as soon as possible.
I released a new version, that supports the current version of roc:
https://github.com/ostcar/roc-turtle/releases/tag/v0.0.2
This looks great! However, I wanted to test it on my Macbook and I got this error:
$ roc turtle-demo.roc
I was expecting this file to exist:
/Users/ageron/.cache/roc/packages/github.com/ostcar/roc-turtle/releases/download/v0.0.2/q0zfdAsWWc0qkAOl-F20LIz0gs6yiN6aIDttQJHW_fQ/macos-x64.o
However, it was not there!
If you have the platform's source code locally, you may be able to generate it by re-running this command omitting --prebuilt-platform
I just copy/pasted the first code example from https://github.com/ostcar/roc-turtle/
Is MacOS supported?
For the start, I added the Linux build in the release.
I saw a comment somewhere, that it is currently not supported to cross compile zig with SDL from Linux to Mac. But since I did not even succeed in building SDL for Linux and dynamically linked it anyway, it should be possible to create a Mac build.
Maybe SDL was the wrong choice. Does anyone of you have an idea which library could be a better fit? It should support windows, Mac and Linux. The only required feature is to draw lines. Python turtle uses tk.
Raylib with zig works well :grinning:
My https://github.com/lukewilliamboswell/roc-ray has degraded a little and isn't currently useable. It's probably should be updated to zig 13, and use some of the latest roc syntax. The zig std lib for roc on the llvm branch here is gtg for 0.13.0.
I thought I'd mention this as I'm not likely to get any time soon to look at this, but it already works cross platform and does graphics and (some) GUI. So if anyone is interested in learning more about platform development or zig, and has an interest then this could be a good project. I'm happy to provide advice or assistance if you need.
Also, if we implemented a layout algorithm in pure roc it would also be pretty usable GUI platform too.
I already have a running version of roc turtle with raylib. It works with the surgical linker. But I run in strange errors when building it for the legacy linker. I have to look into it. As soon as this works, I try to cross compile it to mac and then create a new release.
Sounds awesome
Last updated: Jul 06 2025 at 12:14 UTC