Grain 0.4 – Cereal
grain-lang.org
grain-lang.org
I feel like I really want the "no marketing bullshit" version of that frontpage. "Grain is a new language that puts academic language features to work". Okay, but what "academic language features"? ADTs and pattern matching? Linear types? What's your pitch for developers that see new languages every 6 months, with usually more features than ADTs and a WASM backend?
I'll add that the answer to those can be "We made Grain because we wanted to, without a specific audiance in mind except ourselves" and that would be fine. I would just like some clarity on the goals and scope of Grain.
That said, I think there's so much left unexplored in the PL design space that new languages are probably worth writing, if only to explore that space.
In this case, it seems like the main feature is that it's designed specifically around the WebAssembly runtime.
Skimming the docs, it also looks like it's meant to be a kind of cleaned-up OCaml. I guess that's not very different from Reason, Rescript, or even Fable.
A "why this and not those things" document would make me more inclined to spend my energy on it. Does it run faster on Wasm than other similar languages? Does it have some interesting developer UX related to the Wasm sandboxing features? Does it have a nice build toolchain?
It's implemented in Reason, so presumably the authors see some advantage to this over Reason. Personally I think more distance from the OCaml ecosystem is a competitive advantage relative to Reason et al. Yeah, there are advantages to being able to plug into an existing ecosystem, but the disadvantage is that in practice you have to understand the host language that you're plugging into.
[1] https://reasonml.chat/ [2] https://forum.rescript-lang.org/c/general/1
> ReScript continues to have a lot of momentum
Rescript has 4k weekly downloads on npm. Typescript has 22 millions. Coffeescript 1 million. Reason 1.5k. Elm 22k and it's not the official installer. PureScript 2.5k.
I think I might not have been clear when I said that reason is dead. Let me try again: ReasonML was a sort of collaboration between bucklescript (the ocaml->js compiler) and the Reason syntax. They recently parted ways, with the bukclescript part being renamed to ReScript (as well as using their own syntax). That leaves not much to be under the name "Reason", which is basically just a syntax.
The companies that use it (such as mine) are moving to ReScript. Or, to put it more accurately, they have always been using ReScript just people referred to it as Reason at the time.
> > ReScript continues to have a lot of momentum
> Rescript has 4k weekly downloads on npm
I meant relative to Reason. (fyi: rescript used to be called bs-platform, and that continues to have 8k downloads, so it's more like 12k for rescript)
JS: Static types
OCaml: Readable, familiar syntax, presumably none of the "many standard libraries" problems. Hopefully the community is significantly less toxic.
Rust: Garbage collected. Yeah, I know that the borrow checker gives you more than just memory management, but having to deal with the borrow checker really slows most people down a lot (even if they're experienced) and most applications can't trade that much developer velocity for an extra bit of safety and performance.
> What's your pitch for developers that see new languages every 6 months, with usually more features
Presumably "fewer features"?
> OCaml: [...] Hopefully the community is significantly less toxic.
What do you mean by this?
Of course, every community has some toxic members, but in my experience they are so pervasive in the OCaml community that it virtually characterizes the entire community. And I've heard every justification including "Everyone is mean to the OCaml community, so the OCaml community is mean to everyone else".
Anyway, I don't care to get into an argument about whether or not OCaml's community is toxic, I'm happy to agree to disagree.
I'm not interested in arguing either, I was asking because I've been interested by OCaml for a long time and it's always nice to know in advance about broken stairs. Thanks for sharing.
Here's one of my favourite blog posts ever concerning open source and some expectations: https://www.catuhe.com/le-syndrome-du-puppy/
It's true that OCaml is a mature language, it's also quite stable considering its age. It has lots of relatively mature project, but it's also missing some pieces that people expect from the ecosystem of a language (the "recent" post about Darklang moving away from it because of a lack of Google Cloud libraries is an example of that).
"tends to have a ton of documentation" is wrong though. OCaml users are not blind to their own flaws, and often point out themselves that the documentation of most libraries is basically "look at the code".
About the blog post you posted, I think you're misinterpreting what people say. It's not about asking the OCaml community to put in even more work than they already did. They don't owe me anything. They don't owe a new user anything. That's a fact. However, when you're picking which language/ecosystem to invest time in, you're going to compare them. And when comparing them, you'll see that other ecosystems may have more libraries, libraries of higher quality, better documentation and/or more help for beginners. Just like the OCaml community don't owe us/me anything, I don't owe them anything and I'm free to chose whatever aligns the best with my interests.
What you interpret as "expecting a ton of hand-holding" is actually "being explicit as to why you choose something else than OCaml". You could then argue that OCaml users don't even want us and that saying this is useless. But that's not true. Here's an example of a subject in the official OCaml forum where they actively express their want for new users: https://discuss.ocaml.org/t/expanding-ocaml-appeal-to-future....
Thank you, however, for illustrating my point. :)
That's pretty consistent with the "toxic community" hypothesis. I.e., people who are attracted to toxic communities think that others are too soft/welcoming, tolerate too much "hand holding", etc.
1. I'm wrong and OCaml's community is great OR
2. The parent doesn't find the OCaml community to be toxic because he's attracted to toxic communities
I specifically didn't say that the parent was toxic, although I think his comments (including his flagged nationalist comment) speak for themselves.
> You can take this slimy behavior elsewhere
You created an account just to accost me. ¯\_(ツ)_/¯
I haven't interacted with the ocaml community enough to form any opinion, but honestly "the toxic community hypothesis", as you put it, is intellectual garbage.
With the same reasoning, one could argue that yours is a textbook example of the "overly sensible guy hypothesis", which states that only unreasonably sensible people would complain about communities rather than adapt.
It's pretty obvious that toxic communities do exist, and the "overly sensible guy hypothesis" is nonsensical, but your demeanor is implying that the user you were responding to is himself toxic, which I don't find at all reasonable.
Bringing existing languages to wasm is incredibly important, and probably that is 99% of wasm today. But a new wasm-first language that is designed specifically for wasm can do some things better.
For example, it is much easier to get tiny wasm files from a wasm-first language if it was designed for that.
Another example is wasm GC. The current proposal is making good progress but the type system will never be "perfect" for all languages (there will be extra casts, for example). A wasm-first language could (once wasm GC stabilizes) tailor itself to that for optimal results.
About the GC, that's true, but that also means that they may have to rethink significant parts of the language once the GC proposal is accepted.
Considering they talk about academic features, I could imagine something like linear types.
It's got a tutorial that goes through basics like types and functions. It's got a blog with release notes. But it could do with a sales pitch like Zig's overview doc.
Out of curiosity, what is OCaml’s baggage that you’re thinking of?
They're both MLs with familiar syntaxes.
> Out of curiosity, what is OCaml’s baggage that you’re thinking of?
Dependencies on OCaml toolchain, standard libraries, and ecosystem (which seems like it should be a feature but in practice it just means you need to understand two languages, two toolchains, and the nuances of integrating them).
Grain GitHub Repo: https://github.com/grain-lang/grain
Tiny example: https://github.com/grain-lang/grain-web-example
*NEAR example: https://github.com/grain-lang/near-simple-counter
*This is related to one of the new features in this 0.4 release announcement.
I think this is a great idea; for the lang devs to provide such a thing.
After using black & isort in pythons, the option of automatic consistent formatting for shared code really cuts down on manual formatting work.
I agree about formatting too, although every once in a while I do wish I could protect a specific section from automated formatting. Custom format and can be nice for things like mappings/tables, and certain deeply-nested JSON-like structures such as MongoDB queries.
Moreover, it's not clear who this is for.
People wanting an expressive language with good tooling will be disappointed, as there's no REPL, macros, conditions, MOP (although to be fair that's because there appears to be no object system at all), or symbolic datatype.
Meanwhile, those wanting the maximum performance possible will be disappointed at the presence of garbage collection.
Is the idea that this provides a convenient middle-ground? That might make sense, but at least from my perspective it's far enough away from that point on the efficiency/expressiveness design curve that I might as well just pick either Rust or CL.
Grain: A strongly-typed functional programming language for the modern web - https://news.ycombinator.com/item?id=26922857 - April 2021 (80 comments)
Grain: Functional Typed Language for the Web - https://news.ycombinator.com/item?id=23789383 - July 2020 (2 comments)
Grain: A strongly-typed functional programming language for the modern web - https://news.ycombinator.com/item?id=17645004 - July 2018 (153 comments)
Looks like a tidy language though, it's just unclear to me what it offers over more established alternatives.
F# is like a VERY nice OCaml in my view... so I'm biased.
"Grain, the programming language that combines the latest research innovations with the speed and portability of WebAssembly,is pleased to announce the release of v0.4 - Cereal."