[HN Gopher] Grain 0.4 - Cereal
___________________________________________________________________
Grain 0.4 - Cereal
Author : pjmlp
Score : 57 points
Date : 2021-09-24 10:15 UTC (12 hours ago)
(HTM) web link (grain-lang.org)
(TXT) w3m dump (grain-lang.org)
| lucraft wrote:
| This website is nice, but here's something it could do with: a
| page describing what makes Grain different and amazing.
|
| 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.
| pharmakom wrote:
| The home page gives clear benefits front and center
| https://grain-lang.org/
|
| I have to wonder if you are really here shilling for Zig?
| dang wrote:
| Whoa, that last bit is seriously against the site guidelines-
| please review
| https://news.ycombinator.com/newsguidelines.html and stick to
| the rules when posting here!
| qsort wrote:
| I'm sorry, but as someone who literally learned about Grain's
| existence by opening that link, I agree with parent comment.
|
| The bullet points the homepage features are as follows:
|
| - "A modern web staple."
|
| Which means nothing.
|
| - "Grain is a new language that puts academic language
| features to work."
|
| Also claimed by most new languages and runtimes, and also an
| empty sentence.
|
| - "Powered by WebAssembly. Enter the future. Grain compiles
| directly to WebAssembly, taking full advantage of its speed
| and efficiency."
|
| This is the first meaningful and informative point. It's nice
| to know it compiles to WASM, but this is neither unique, nor
| (by itself) a compelling point.
|
| - "Sensible Types. No runtime type errors, ever. Every bit of
| Grain you write is thoroughly sifted for type errors, with no
| need for type annotations."
|
| Type-safe languages with type inference aren't exactly new,
| many popular languages could make an identical claim.
|
| - "Functional Yet Flexible. Grain has its roots in functional
| programming, but is flexible enough to accommodate different
| programming styles for various applications."
|
| Not really sure what this is supposed to mean. Wouldn't the
| same sentence apply word for word to, say, Rust, Elixir or
| Javascript?
|
| Again, please understand that this is not an indictment of
| Grain itself. I know literally nothing about it, it could be
| the world's best programming language for all I know. But
| from the perspective of a developer that doesn't know
| anything about Grain, the homepage doesn't do a good job at
| convincing me to try it out.
| dkersten wrote:
| Agreed. On top of that, I still have no idea what the
| language even looks like. I clicked around for a while and
| couldn't find a clear bit of example code. I looked through
| the first few pages of the tutorial but all it showed me
| was individual lines of code for individual features. I
| just wanted to see what a little program would look like. I
| gave up.
| throwaway894345 wrote:
| Personally I clicked into the "getting started" page and the
| examples answered more of my questions, however indirectly.
| "Oh, this is an ML dialect with a readable syntax (and
| presumably none of the OCaml baggage)! It's a bit like Rust
| with a GC!"
| glenda wrote:
| Other than immutability by default and pattern matching I
| don't see the Rust connection.
|
| Out of curiosity, what is OCaml's baggage that you're
| thinking of?
| throwaway894345 wrote:
| > Other than immutability by default and pattern matching I
| don't see the Rust connection.
|
| 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).
| nerdponx wrote:
| For the people like me who felt like the website was lacking in
| rationale, I found a presentation by one of the authors that goes
| into more detail: https://youtu.be/O8tyml3xBMM
| Jcowell wrote:
| ,kk Pngofp is
| dang wrote:
| Past related threads:
|
| _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)
| de_keyboard wrote:
| This looks like F# but with a noisier syntax. Perhaps it will be
| more familiar feeling to JS devs?
|
| Looks like a tidy language though, it's just unclear to me what
| it offers over more established alternatives.
| nobleach wrote:
| I was thinking, "This is JavaScript with a mut modifier from
| Rust... and a tiny bit of OCaml thrown in for good measure"
|
| F# is like a VERY nice OCaml in my view... so I'm biased.
| Chris2048 wrote:
| > Grain format provides an opinionated code formatter tool for
| Grain source code
|
| 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.
| jagger27 wrote:
| gofmt is another excellent example.
| nerdponx wrote:
| I strongly agree. It makes it much easier for a language to
| compete with incumbent languages if it already has basic
| developer tools like a test suite, a build system, etc. it also
| has the benefit of centralizing in standardizing the developer
| experience, compared to some languages where it's difficult for
| a beginner because there is no obvious correct way to do
| things.
|
| 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.
| Chris2048 wrote:
| Hmm, the advantage of an "official" formatter, is that the
| language itself could maybe support formatting directives?
| marcusr wrote:
| Formatter author here - we do have the ability to protect
| specific sections with a // formatter-ignore comment before
| the section you want the formatter to leave as-is.
| jrumbut wrote:
| When there are announcements like this, I really love it when
| they begin with just a few words to orient me on what the project
| is about.
|
| "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."
| beardyw wrote:
| Yes, assuming that anyone knows what this thing is seems a
| unbelievably optimistic.
| fouric wrote:
| The website isn't very descriptive, as others have pointed out -
| it's difficult to get basic information (and any details) about
| the language.
|
| 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.
| Zababa wrote:
| A big missing piece is the why. From what I can understand, it's
| garbage collected, it has ADTs, lists and arrays, it compiles to
| WASM, it has a "modern" syntax. What's the use case? Who's the
| target audiance? What are the tradeoffs comapred to JS, OCaml and
| Rust? I don't see any milestones or projets on Github. Is there a
| roadmap? What's the goal? A fullstack language?
|
| 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.
| nerdponx wrote:
| I agree that a programming language should have a strong
| rationale behind its design, especially if they expect people
| to use it and take it seriously.
|
| 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?
| Zababa wrote:
| Totally agree, my criticism are only for the website, not for
| the language itself.
| throwaway894345 wrote:
| > 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.
|
| 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.
| pbiggar wrote:
| Reason doesn't really exist anymore. "Native Reason" was
| just reskinned Ocaml, and the thing previously referred to
| as ReasonML continues life as ReScript.
| Zababa wrote:
| Reason does actually still exists. Rescript is a modified
| ReasonML syntax + BuckleScript. ReasonML is between the
| two, a foot in the OCaml world, a foot in the JavaScript
| world.
| pbiggar wrote:
| It may claim to be that, but in practice it is not. Most
| of the Reason repos have barely been touched in months,
| while ReScript continues to have a lot of momentum. The
| reasonml forums [1] are down to 3 posts in the last
| month, vs 85 in the rescript forum [2]. I don't know what
| you mean by "still exists", but in practice you can
| consider ReasonML to be dead, replaced by ReScript.
|
| [1] https://reasonml.chat/ [2] https://forum.rescript-
| lang.org/c/general/1
| Zababa wrote:
| It may not look active from the outside, but I'm sure
| that the companies that used it still use it, while
| Rescript is still very young.
|
| > 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.
| [deleted]
| pbiggar wrote:
| > It may not look active from the outside, but I'm sure
| that the companies that used it still use it, while
| Rescript is still very young.
|
| 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)
| throwaway894345 wrote:
| > What are the tradeoffs comapred to JS, OCaml and Rust?
|
| 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"?
| Zababa wrote:
| That's a great overview, and I think Grain would benefit from
| a page like this. "X for Y programmers" is a useful pattern.
|
| > OCaml: [...] Hopefully the community is significantly less
| toxic.
|
| What do you mean by this?
| throwaway894345 wrote:
| OCaml's community has always struck me as really toxic and
| hostile to newbies. If a newbie asks a question however
| politely, they're frequently berated as though asking for
| help is cheating and everyone should learn things the hard
| way as they did. Alternatively, if the community doesn't
| have a good answer (e.g., "How do I do X in OCaml?"), they
| often respond with some variation of "You're stupid for
| trying to do X" or "If Jane Street can make millions
| without X, then your company doesn't need it either!".
|
| 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.
| Mikeb85 wrote:
| And Americans often expect a ton of hand-holding. OCaml
| is a mature language with lots of relatively mature
| projects, tends to have a ton of documentation, etc...
|
| Here's one of my favourite blog posts ever concerning
| open source and some expectations:
| https://www.catuhe.com/le-syndrome-du-puppy/
| Zababa wrote:
| This is not an "Americans" thing. This is about the
| community of programmers in general growing at a very
| fast rate, and many people not having formal education,
| and formal education not always giving people the real
| world skills they need.
|
| 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....
| throwaway894345 wrote:
| Hah, weird to make this nationalist. I studied at a top-
| tier French university without much hand-holding (and
| indeed tutored my French and English counterparts with
| their computer science lessons), but I guess I'm still
| not qualified to inquire of the OCaml community.
|
| Thank you, however, for illustrating my point. :)
| Mikeb85 wrote:
| I've just heard every community described as 'toxic' and
| honestly 9/10 times I disagree.
| throwaway894345 wrote:
| > I've just heard every community described as 'toxic'
| and honestly 9/10 times I disagree.
|
| 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.
| Mikeb85 wrote:
| I don't participate in any communities except HN, but
| thanks for calling me toxic. Just an observation though.
| Reading docs, code examples and blogs is where I get info
| about languages.
| kafkatrapsahoy wrote:
| This is a disgusting kafka trap you just tried to stuff
| another person in by implying the only reason anyone
| could disagree with you is if they're an abuser. You can
| take this slimy behavior elsewhere and it only shows that
| your remarks about the OCaml community are suspect.
| throwaway894345 wrote:
| It's not a Kafka trap. I'm responding to the specific
| rebuttal "OCaml can't be toxic because _I_ don 't find it
| toxic" by explaining that there are a couple of
| possibilities:
|
| 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. -\\_(tsu)_/-
| qsort wrote:
| 3. onus probandi?
|
| 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.
| Zababa wrote:
| > 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.
| throwaway894345 wrote:
| That makes sense. My "I'm not interested in arguing"
| wasn't directed to you per se, but to any who might be
| interested in responding argumentatively.
| azakai wrote:
| I think an interesting advantage of Grain is that it not only
| compiles to wasm but is wasm-first.
|
| 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.
| Zababa wrote:
| I honestly don't know enough about WASM to know how important
| being WASM-first is. That could be a nice thing to add to the
| website.
|
| 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.
| cgarvis wrote:
| Kinda feels like a JavaScript version of Elixir
| Mikeb85 wrote:
| It would be nice if they showed code on the front page. Lots of
| marketing words, no idea how it works, what the language looks
| like, etc...
| 1MachineElf wrote:
| Basics section of their language guide: https://grain-
| lang.org/docs/guide/basics
|
| 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.
___________________________________________________________________
(page generated 2021-09-24 23:03 UTC)