Congrats! I've been wanting a kinda-next-gen statically-typed functional language useful for both scripting and general programming for a long time; there's lots of lessons that have been learned since OCaml and Haskell were conjured up. I'm hoping Roc becomes that!
Random question about compile-time evaluation of pure functions, is there some heuristic or limit on how long it will try to spend on it? ie, if I do x = compute_grahams_number(99) it's a pure function, will that try to get evaluated at comptime?
Longer answer is that this hasn't been a problem in practice so far (especially since we cache compile-time-evaluated code and it often doesn't get run again during rebuilds), but there is obvious design tension between "Expressions should always be evaluated at compile time when they depend on no runtime inputs" and "Builds should always finish quickly no matter what program you give the compiler." Can't have both in a Turing-complete language!
My general thinking is that there will always be multiple ways you can get pathologically long builds, e.g. just giving the compiler a giant amount of source code to chew through, and there isn't much difference between pathologically long builds due to source inputs vs compile-time execution being the cause of it. Either way you're probably going to either terminate the build yourself, or if it's being run from CI or a tool with automatic timeouts, it'll get stopped by those.
I think it's simplest and most flexible to let you do whatever you want with pure functions at compile time, and accept the downside that pathological pure code can make your build take excessively long (but basically nothing worse than that, e.g. it can't give you a virus or exfiltrate secrets or anything like that, since those all require effects).
Thanks; I shall be watching with interest to see how it turns out! There very much is a tension between "compile fast" and "do more at comptime" which I doubt will ever have a single "best" solution, so exploring this space is interesting.
Random thought: Ever considered having a "delay" operation of some kind that lets a user tell the compiler it shouldn't try to evaluate something at comptime? I can definitely imagine times where I'd have a nominally pure operation that I really do want to put off until runtime -- mostly big numerical things, but also benchmarks, tests, etc. I think Rust's black_box() does something like this, basically tells the compiler "don't inline this value away".
Yeah, the idea I've had (but haven't implemented; will see if it proves necessary/worthwhile) is to treat 0-arg pure functions specially in this way. There's no possible reason to go out of your way to write and then directly call a 0-arg pure function other than wanting to delay the computation, so the intent would be clear and we could just respect that by not evaluating it until the call site.
Another reason we might add something like that is if the compile-time-evaluated function isn't too slow, but puts a big constant in the binary, and maybe you care about binary size and would prefer to execute it at runtime. But in that situation (as well as in the other case) you might want it to get automatically memoized so that the computation doesn't get redone multiple times.
Of course, as soon as memoization is on the table, then thread-safety becomes a concern, at which point there become tradeoffs around how to do locking etc...so I'm holding off on implementing anything in this area until we see what problems (if any) people actually run into in practice.
Nice! fwiw my main thoughts for when you'd want to delay evaluation were "video game generating/optimizing assets at startup" and "big long scientific computation you really want to run once". Either of those could take a command line arg or read a file or something, but that'd just be extra work for prototyping. The zero-argument function approach would work fine for those use cases... Still, speculating in a vacuum isn't very useful, so I guess I should find an excuse to write some Roc~
On that front: is it easy to profile the compile-time execution? I could see someone with a larger codebase looking at a thing and wanting to really figure out what part of their source might be causing problems
I'd be interested in hearing what @rtfeldman did do and focus on when starting the community around the language. Seems very successful in getting fellow compiler writers on board :)
Nothing in particular, honestly - mostly just tried to talk about what the goals were and what the current progress was, and then be welcoming and mentor people when they expressed interest in getting involved.
I didn't immediately recoil from this like most neolangs do. Nice. What would be nice is perhaps a bit more meaty examples earlier in the docs, e.g. how would I wrap a syscall or a WIT interface.
The syntax guide is useful but a bit long winded coming from other languages too; I know what expression-statements are from rust, for example - there was a great guide a while back titled something like "Objective-C for C++ developers" that mapped the concepts between each and allowed me to learn Objective-C in basically one sitting, quickly. I'd love a similar guide for Roc. Perhaps a wide assumption, but most of the earlier adopters will already be coming from other languages rather than Roc being the first a newbie reaches for.
Is this a semantic version number (e.g. semver where this is still a 0.x release, and comes with zero backward compatibility promises), or just "1.0 looks scary, even though it's just numbers and as the first real release this is absolutely 1.0"? =D
We plan to follow semver from here on, yeah. So the next release will likely be 0.1.1, which is planned to be bugfixes and performance improvements, and then sometime in the future we'll do an 0.2.0 which will have some number of backwards-incompatible changes.
As long as you're on 0.x the rest of the numbers basically mean nothing, every version on 0.x is potentially breaking if you're following semver. So that also unfortunately means that treating "0.2" as a breaking change on top of "0.1" is not proper semver use: 0.1.1 was just as breaking as 0.2 as far as semver is concerned.
That's why it's so valuable to not treat 1.0 as some magic number: whatever your first stable-enough release is, that's your 1.0 and then you just start semver'ing based on the work that lands rather than some milestone or release cadence. It's purely a versioning promise that lets folks know whether upgrades are safe or not =)
1.0 doesn't mean you reached all your goals. 1.0 just says "this is stable" and now the real work starts. If you pretend 1.0 means "it is done", you will never hit 1.0
I believe the separation of pure and effectful code is a step in a good direction. I’d like to see a capability-based model where main requests specific capabilities from the platform, such as read/write access to a particular directory, access to OS randomness, or an HTTP client restricted to GET requests to a single domain. main would pass each effectful function only the capabilities it needs. I would also love to see support for WASI.
The "platform" idea in Roc is pretty much a capabilities system if you squint a tiny bit; it just applies to the entire binary. It'd be cool if you could have dynamically scoped sub-platforms or something, which would basically be a full capability system. Anyway, the platform thing is one of the things I'm most excited for about Roc.
Earlier this year Pierre Thierry was talking about capabilities oriented security and I've taken his advice and been trying to learn more about it ever since. I wasn't very familiar with these systems, but I've been gradually adopting more and more of these concepts across my platforms. Here is the relevant section from the native Windows platform in case your interested in what this looks like with a concrete example roc-native-windows/#capability-boundary
Roc isn't trying to be the best possible language for high-performance compiler development, but it is trying to have a high-performance compiler. The best tool for that job is a language other than Roc, so that's what we're using!
Roc showcases how performant it is, fast and cross compiles. Why not self-host?
Could I interest you in some interactive syntax highlighting for the code examples on your website?
I would be happy to write a Roc parser in BABLR, which is like tree-sitter if tree-sitter was designed from the ground up for the web (comment moved from HN since the thread here is yours)
I've seen you talk about this in other communities and I see you mentioning it here pretty often, but I must say, I still fail to see how it's useful? Of course, hobby projects don't have to be useful, but it feels like you have some groundbreaking idea that I'm failing to grasp, would love it if you could explain.
Let's take the example on the website you posted. Not only does it look unpolished (screenshot), but you also need to:
import 6 (!) BABLR packages to use it,
reinvent the wheel by writing a grammar for yet-to-be-supported languages,
pollute your page with JS just to get slightly better syntax highlighting, even though that's something that can (and should) be done either server-side or through a static site generator.
Apart from that, the output doesn't seem very useful? The coloring is very bare bones and the AST-like tooltips seem annoying for accessibility on top of not telling me anything I couldn't intuit from either my experience as a software developer or context/colors themselves.
Hey, hello! I know I talk a lot, but I'd take a skeptic response over silence any day.
You are entirely correct that the UI lacks polish. There's about 5 years of work invested into getting the BABLR APIs right and only about 5 days of work invested in the 300 LOC making up the Bedazzlr UI. I'm choosing to focus instead on front-loading all the breaking changes.
Bedazzlr requiring 6 imports right now is because I am embracing the Linux "batteries not included" approach. In that example 3 are parsers and 3 are core packages. My reasoning is that re-packagers will take care of making "distros" which do make certain common setups as easy as one import. This is not very different from tree-sitter's approach...
Grammars are in every (single) way easier to write than tree-sitter grammars. There's no compile step, there's better tooling and more powerful APIs (like say guarded spans). Languages can extend other languages at runtime. My hope is that eventually the question will be why anyone would waste time struggle-bussing tree-sitter.
Yeah there's JS in the page. I think I can sell it. It can be better for site operators because they're not paying centrally for CPU and bandwidth. Every cost you centralize must be coupled with some means of extracting monetary value from your users to pay that cost. The pitch to users is that pages load faster, are richer in information, and are less likely to go offline.
Actually the last great thing for users is the colors, because the system is 100% theme-able with CSS. Take a look at the HTML behind that example and how it's actually getting styled! If you want to write you own theme any and all the information you could need is already there.
Finally BABLR is designed to realize Sebmck's original vision of Rome: replacing and unifying the ESLint, Babel, and Prettier core architecture to make Javascript an ultimate tooling powerhouse platform to rival Rust.
Ah, I should have been more clear. My annoyance with syntax highlighting is that it helps you read code if you already know what the code means. When I'm reading a brand-new-to-me language, the colors aren't immediately useful.
What I'm offering is sort of like being able to embed ASTExplorer into code examples. You get both the colors, and also the ability to answer queries about what a given piece of syntax means, which especially helps users who don't already know.
icefox | 11 hours ago
Congrats! I've been wanting a kinda-next-gen statically-typed functional language useful for both scripting and general programming for a long time; there's lots of lessons that have been learned since OCaml and Haskell were conjured up. I'm hoping Roc becomes that!
Random question about compile-time evaluation of pure functions, is there some heuristic or limit on how long it will try to spend on it? ie, if I do
x = compute_grahams_number(99)it's a pure function, will that try to get evaluated at comptime?[OP] rtfeldman | 8 hours ago
Short answer is yes.
Longer answer is that this hasn't been a problem in practice so far (especially since we cache compile-time-evaluated code and it often doesn't get run again during rebuilds), but there is obvious design tension between "Expressions should always be evaluated at compile time when they depend on no runtime inputs" and "Builds should always finish quickly no matter what program you give the compiler." Can't have both in a Turing-complete language!
My general thinking is that there will always be multiple ways you can get pathologically long builds, e.g. just giving the compiler a giant amount of source code to chew through, and there isn't much difference between pathologically long builds due to source inputs vs compile-time execution being the cause of it. Either way you're probably going to either terminate the build yourself, or if it's being run from CI or a tool with automatic timeouts, it'll get stopped by those.
I think it's simplest and most flexible to let you do whatever you want with pure functions at compile time, and accept the downside that pathological pure code can make your build take excessively long (but basically nothing worse than that, e.g. it can't give you a virus or exfiltrate secrets or anything like that, since those all require effects).
icefox | 8 hours ago
Thanks; I shall be watching with interest to see how it turns out! There very much is a tension between "compile fast" and "do more at comptime" which I doubt will ever have a single "best" solution, so exploring this space is interesting.
Random thought: Ever considered having a "delay" operation of some kind that lets a user tell the compiler it shouldn't try to evaluate something at comptime? I can definitely imagine times where I'd have a nominally pure operation that I really do want to put off until runtime -- mostly big numerical things, but also benchmarks, tests, etc. I think Rust's
black_box()does something like this, basically tells the compiler "don't inline this value away".[OP] rtfeldman | 8 hours ago
Yeah, the idea I've had (but haven't implemented; will see if it proves necessary/worthwhile) is to treat 0-arg pure functions specially in this way. There's no possible reason to go out of your way to write and then directly call a 0-arg pure function other than wanting to delay the computation, so the intent would be clear and we could just respect that by not evaluating it until the call site.
Another reason we might add something like that is if the compile-time-evaluated function isn't too slow, but puts a big constant in the binary, and maybe you care about binary size and would prefer to execute it at runtime. But in that situation (as well as in the other case) you might want it to get automatically memoized so that the computation doesn't get redone multiple times.
Of course, as soon as memoization is on the table, then thread-safety becomes a concern, at which point there become tradeoffs around how to do locking etc...so I'm holding off on implementing anything in this area until we see what problems (if any) people actually run into in practice.
icefox | 7 hours ago
Nice! fwiw my main thoughts for when you'd want to delay evaluation were "video game generating/optimizing assets at startup" and "big long scientific computation you really want to run once". Either of those could take a command line arg or read a file or something, but that'd just be extra work for prototyping. The zero-argument function approach would work fine for those use cases... Still, speculating in a vacuum isn't very useful, so I guess I should find an excuse to write some Roc~
rtpg | 2 hours ago
On that front: is it easy to profile the compile-time execution? I could see someone with a larger codebase looking at a thing and wanting to really figure out what part of their source might be causing problems
gulbanana | 13 hours ago
that's an attractive set of features! i'll have to sit down and learn roc some time soon
quad | 13 hours ago
Perfect timing for AoC. I see you @rtfeldman.
[OP] rtfeldman | 12 hours ago
haha I was hoping to get it out the door last week, but ended up needing the Thanksgiving weekend to finish the announcement post!
If anyone wants to try Roc for Advent of Code, there's a thread going on Roc Zulip with beginner advice:
https://roc.zulipchat.com/#narrow/channel/358903-advent-of-code/topic/Howto.202026
gignico | 12 hours ago
Congratulations for the effort and perseverance! I once started my own programming language. I endured for two months 😂
janiczek | 11 hours ago
I'd be interested in hearing what @rtfeldman did do and focus on when starting the community around the language. Seems very successful in getting fellow compiler writers on board :)
[OP] rtfeldman | 10 hours ago
Hey Martin!
Nothing in particular, honestly - mostly just tried to talk about what the goals were and what the current progress was, and then be welcoming and mentor people when they expressed interest in getting involved.
junon | 10 hours ago
I didn't immediately recoil from this like most neolangs do. Nice. What would be nice is perhaps a bit more meaty examples earlier in the docs, e.g. how would I wrap a syscall or a WIT interface.
The syntax guide is useful but a bit long winded coming from other languages too; I know what expression-statements are from rust, for example - there was a great guide a while back titled something like "Objective-C for C++ developers" that mapped the concepts between each and allowed me to learn Objective-C in basically one sitting, quickly. I'd love a similar guide for Roc. Perhaps a wide assumption, but most of the earlier adopters will already be coming from other languages rather than Roc being the first a newbie reaches for.
olex | 9 hours ago
I've been eyeing Roc for quite a while now, and I definitely will write something in it in the hopefully near future.
P.S: ~rtfeldman could you please add the rss feed to your website, been enjoying your past write ups and I wouldn't like to miss next one :)
Pomax | 11 hours ago
Is this a semantic version number (e.g. semver where this is still a 0.x release, and comes with zero backward compatibility promises), or just "1.0 looks scary, even though it's just numbers and as the first real release this is absolutely 1.0"? =D
[OP] rtfeldman | 10 hours ago
We plan to follow semver from here on, yeah. So the next release will likely be 0.1.1, which is planned to be bugfixes and performance improvements, and then sometime in the future we'll do an 0.2.0 which will have some number of backwards-incompatible changes.
Pomax | 8 hours ago
As long as you're on 0.x the rest of the numbers basically mean nothing, every version on 0.x is potentially breaking if you're following semver. So that also unfortunately means that treating "0.2" as a breaking change on top of "0.1" is not proper semver use: 0.1.1 was just as breaking as 0.2 as far as semver is concerned.
That's why it's so valuable to not treat 1.0 as some magic number: whatever your first stable-enough release is, that's your 1.0 and then you just start semver'ing based on the work that lands rather than some milestone or release cadence. It's purely a versioning promise that lets folks know whether upgrades are safe or not =)
[OP] rtfeldman | 8 hours ago
I should clarify, then - I plan to treat 0.x.y as:
So I guess while 0 is the first digit, we're essentially doing ComVer https://gitlab.com/staltz/comver
Pomax | 8 hours ago
Ah, yeah better to use that name (and link =D) then.
pralkarz | 11 hours ago
From the post:
Pomax | 10 hours ago
1.0 doesn't mean you reached all your goals. 1.0 just says "this is stable" and now the real work starts. If you pretend 1.0 means "it is done", you will never hit 1.0
pralkarz | 4 hours ago
Fair, I see now that I misinterpreted the snippet I quoted, sorry!
josephjnk | 11 hours ago
This looks awesome, the language seems to have come a long way since the time that I first heard about it. I think I’ll be giving this a spin soon!
tomas | 8 hours ago
I believe the separation of pure and effectful code is a step in a good direction. I’d like to see a capability-based model where main requests specific capabilities from the platform, such as read/write access to a particular directory, access to OS randomness, or an HTTP client restricted to GET requests to a single domain. main would pass each effectful function only the capabilities it needs. I would also love to see support for WASI.
Relax | 6 hours ago
The "platform" idea in Roc is pretty much a capabilities system if you squint a tiny bit; it just applies to the entire binary. It'd be cool if you could have dynamically scoped sub-platforms or something, which would basically be a full capability system. Anyway, the platform thing is one of the things I'm most excited for about Roc.
lwboswell | 3 hours ago
Earlier this year Pierre Thierry was talking about capabilities oriented security and I've taken his advice and been trying to learn more about it ever since. I wasn't very familiar with these systems, but I've been gradually adopting more and more of these concepts across my platforms. Here is the relevant section from the native Windows platform in case your interested in what this looks like with a concrete example roc-native-windows/#capability-boundary
hojberg | 9 hours ago
Congrats!! Roc is super cool!
antonmedv | 5 hours ago
Roc showcases how performant it is, fast and cross compiles. Why not self-host?
[OP] rtfeldman | 3 hours ago
We actually have a FAQ entry about this!
https://www.roc-lang.org/faq#self-hosted-compiler
antonmedv | 5 hours ago
Question: why type called Try and not Err?
[OP] rtfeldman | 3 hours ago
We had a discussion about this - https://roc.zulipchat.com/#narrow/channel/304641-ideas/topic/.E2.9C.94.20Result.20name/near/547152673 - originally the type was called Result (like in several other languages), and this 2025 proposal was to give the name Try a try (pun intended) for the reasons at the top of that link. It ended up proving popular in practice, so it stuck.
willhbr | 19 minutes ago
Is there some more info about async operations? https://www.roc-lang.org/fast says:
but I can't see an example of how this looks in practice, for example doing two network requests and waiting for the responses concurrently.
conartist6 | 13 hours ago
Could I interest you in some interactive syntax highlighting for the code examples on your website? I would be happy to write a Roc parser in BABLR, which is like tree-sitter if tree-sitter was designed from the ground up for the web (comment moved from HN since the thread here is yours)
https://docs.bablr.org/reference/bedazzlr/
pralkarz | 12 hours ago
I've seen you talk about this in other communities and I see you mentioning it here pretty often, but I must say, I still fail to see how it's useful? Of course, hobby projects don't have to be useful, but it feels like you have some groundbreaking idea that I'm failing to grasp, would love it if you could explain.
Let's take the example on the website you posted. Not only does it look unpolished (screenshot), but you also need to:
Apart from that, the output doesn't seem very useful? The coloring is very bare bones and the AST-like tooltips seem annoying for accessibility on top of not telling me anything I couldn't intuit from either my experience as a software developer or context/colors themselves.
conartist6 | 11 hours ago
Hey, hello! I know I talk a lot, but I'd take a skeptic response over silence any day.
You are entirely correct that the UI lacks polish. There's about 5 years of work invested into getting the BABLR APIs right and only about 5 days of work invested in the 300 LOC making up the Bedazzlr UI. I'm choosing to focus instead on front-loading all the breaking changes.
Bedazzlr requiring 6 imports right now is because I am embracing the Linux "batteries not included" approach. In that example 3 are parsers and 3 are core packages. My reasoning is that re-packagers will take care of making "distros" which do make certain common setups as easy as one import. This is not very different from tree-sitter's approach...
Grammars are in every (single) way easier to write than tree-sitter grammars. There's no compile step, there's better tooling and more powerful APIs (like say guarded spans). Languages can extend other languages at runtime. My hope is that eventually the question will be why anyone would waste time struggle-bussing tree-sitter.
Yeah there's JS in the page. I think I can sell it. It can be better for site operators because they're not paying centrally for CPU and bandwidth. Every cost you centralize must be coupled with some means of extracting monetary value from your users to pay that cost. The pitch to users is that pages load faster, are richer in information, and are less likely to go offline.
Actually the last great thing for users is the colors, because the system is 100% theme-able with CSS. Take a look at the HTML behind that example and how it's actually getting styled! If you want to write you own theme any and all the information you could need is already there.
Finally BABLR is designed to realize Sebmck's original vision of Rome: replacing and unifying the ESLint, Babel, and Prettier core architecture to make Javascript an ultimate tooling powerhouse platform to rival Rust.
vincent-uden | 13 hours ago
As far as I can see there is already interactive syntax highlighting in the code example? The colours change when I edit the code
conartist6 | 13 hours ago
Ah, I should have been more clear. My annoyance with syntax highlighting is that it helps you read code if you already know what the code means. When I'm reading a brand-new-to-me language, the colors aren't immediately useful.
What I'm offering is sort of like being able to embed ASTExplorer into code examples. You get both the colors, and also the ability to answer queries about what a given piece of syntax means, which especially helps users who don't already know.
conartist6 | 2 hours ago
To all the people who marked the only on-thread offer to contribute to Roc as spam, I'd like to take this moment to say a quick fuck you.