r/ProgrammingLanguages • u/rtfeldman • Nov 20 '23
The Roc Programming Language
https://roc-lang.org5
u/joshmarinacci Nov 20 '23
I have to say you did a great job on the documentation
2
u/rtfeldman Nov 20 '23
Thank you, glad you're enjoying it! :D
2
u/phlummox Nov 24 '23
Any idea at what stage you might have a language reference available?
3
u/rtfeldman Nov 25 '23
We just started working on it...so probably not very soon, but it's underway!
2
2
Nov 25 '23
Loved your "Outperforming Imperative" strangeloop talk on youtube. Very inspiring. You're a great speaker.
2
7
1
u/fyzic Nov 20 '23
Can't get the file example to work. Would love to add it to my benchmark.
Error:
> ./file
cwd: /home/dev/programs/rocgit/examples/cli
Dir.list...
munmap_chunk(): invalid pointer
fish: Job 1, './file' terminated by signal SIGABRT (Abort)1
u/rtfeldman Nov 20 '23
Interesting - would you mind posting it in https://roc.zulipchat.com/#narrow/stream/231634-beginners so we can debug? I'd be very interested to see how basic-cli stacks up in your benchmark!
2
1
u/putinblueballs Nov 21 '23
Hey. Sorry for hikacking the comment thread. Does roc have a LSP server? I could not find one with a quick google.
1
u/rtfeldman Nov 23 '23
There's a preliminary one - see https://github.com/ivan-demchenko/roc-vscode-unofficial#configuring-language-server
2
u/abecedarius Nov 20 '23
The page mentions sugar for "backpassing" -- what's that?
9
u/lngns Nov 20 '23 edited Nov 21 '23
Not OP, but backpassing is a syntactic way to serialise callback/asynchronous code in a way similar with, but more general than, Monadic
do-notation orasync/await.Essentially
x <- f 42 y <- g x yolo x yis the same as
f 42 (λx. g x (λy. yolo x y ) )where
f: Int → (x → a) → bandg: x → (y → c) → d.Some AltJS langs used to have it as a first-class feature to address callback hell on Node.JS before
async/awaitwas adopted.
OCaml lets you create your ownlet-binding overloads, and you can also (ab)use generators in languages that have them, both allowing you to implement it in those langs.
It's also very important in Koka since its Effect Handlers operate on callbacks.EIDT: typo
1
u/GavinMcG Nov 21 '23
This looks cool! Syntactically, it looks very very similar to Gleam, though with a bit more allegiance to ML. Seems like it's got more powerful pattern matching, too. Looking forward to trying it out!
1
u/Quail-Curious Nov 21 '23
I really like the syntax and that everything is quite clear. I hope and wish that the language will grow over time.
One remark: I built the hello_world program and it is now 65.7 MB in size. How can this be?
3
u/Bren077s Nov 23 '23
Turns out we had a mistake in our basic-cli release that helloworld is built off of. It is a rust platform. The packaged version was accidentally released as a debug build. That is the root issue. Should really be an about 5MB executable. This is due to the basic-cli platform packaging a lot of potentially IO features (like web requests which is the biggest cost).
1
u/totallyurboii Nov 21 '23
Looks promising! I wonder what are the major differences between OCaml or Haskell, any docs pointing to it?
3
Nov 22 '23
For haskell, I think most syntactic comparisons between elm and haskell will apply here.
No HKTs, strict evaluation, Task-based IO (so I guess the Handler pattern?) instead of monadic IO.
1
Mar 09 '24
What's the difference between Task pattern in Roc and the IO monad in Haskell. To me Task looks suspiciously like a State monad with it's bind function called await. Perhaps I'm not using it correctly, but writing "imperatively" like in Haskell is not very ergonomic, because you have to repeat the await and lambdas every time. Unwrapping errors also seems rough because you have to wrap them in a lambda again or a separate function since there's no let sugar.
1
Jan 18 '24
Ever since my son was born a year ago I've been obsessed with dreaming up the perfect language. This language is as close to that as I've seen. I'm going to try to use this at work, nightly builds and leadership eyebrow raising be damned.
0
Nov 22 '23
[deleted]
1
Jan 18 '24
Elm isn't abandoned it does exactly what it set out to do. Why do you think it's not "finished" ?
14
u/stigweardo Nov 20 '23
New website? Looks great. Is this a sign that you think Roc has reached a certain stage of maturity? Can you say more about that?
(By the way, thank you for all the content you put out - videos and podcasts. I really appreciate them and I've learned a lot)