64 points · by pjmlp · 5y ago · 50 comments
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.
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.
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."