Live data from Hacker News

Grain: A strongly-typed functional programming language for the modern web

grain-lang.org

61–70 of 156 posts

Re: Grain: A strongly-typed functional programming language for the modern web

#61
post #35

Earlier quoted context omitted.

Poking around in the sources, it looks like this is the OCaml compiler, with the frontend apparently tweaked to accept the new syntax. But this is not mentioned anywhere that I can see. The "Copyright copyright 2017-2018 Philip Blair and Oscar Spencer." line in the README is highly misleading in this context, since most of the actual source files are marked with OCaml's copyright header.

Many files are taken from the OCaml compiler and then adapted, but changes seems a bit deeper than just a different syntax. It would indeed seem fair for the authors to at least make it clear in the toplevel README that the front-end (parsetree representation and type-checking) is indeed / started as a fork of the OCaml code base. Considering ongoing efforts to create a WebAssembly backend for OCaml (and thus Reason)…

Even syntactically, this looks a lot like if you took ReasonML, disallowed type annotations, did away with its ecosystem, and compiled to WebAssembly.

Aside from the wasm compilation, I don't see why this exists.

Re: Grain: A strongly-typed functional programming language for the modern web

#62
post #32

Earlier quoted context omitted.

I wonder how they handle array out-of-bounds accesses...

Looks like they're using an indexed Algebraic Data Type. https://github.com/grain-lang/grain/blob/master/src/grain-st...

There's no indexing in that.

Re: Grain: A strongly-typed functional programming language for the modern web

#63
post #42

How does this compare to Elm and F# (Fable)?

It seems as if Grain compile to web assembly vs compiling to JS.

Nothing requires Elm or Fable to compile to js. I don't know about Fable but both Elm's maintainer and its community are interested in eventually targeting wasm.

Re: Grain: A strongly-typed functional programming language for the modern web

#64
post #41

Has anyone found in the sources if/how they treat garbage collection?

No, I would be interested in that too. I don't know anything about Web Assembly but maybe GC is handled by Web Assembly?

There are plans to eventually integrate GC into wasm, but at the moment the GC has to be implemented and bundled in the wasm file. That is in fact one of Rust's advantages there. And of course wasm supporting a GC does not mean languages targeting wasm will want to use it (and lose the flexibility of providing their own).

Re: Grain: A strongly-typed functional programming language for the modern web

#65

What is meant by "zero runtime errors?" An example of a "runtime error" is the head of an empty list; how does Grain handle this?

Grain seems way unfinished and the stdlib does not seem to have any such function[0], so here's how Elm handles it instead as it has the same target/ethos of avoiding runtime errors: http://package.elm-lang.org/packages/elm-lang/core/latest/Li...

[0] it's not very useful either if you have pattern matching on lists, you can just match the list directly.

Re: Grain: A strongly-typed functional programming language for the modern web

#66
post #35

Earlier quoted context omitted.

Many files are taken from the OCaml compiler and then adapted, but changes seems a bit deeper than just a different syntax. It would indeed seem fair for the authors to at least make it clear in the toplevel README that the front-end (parsetree representation and type-checking) is indeed / started as a fork of the OCaml code base. Considering ongoing efforts to create a WebAssembly backend for OCaml (and thus Reason)…

Even syntactically, this looks a lot like if you took ReasonML, disallowed type annotations, did away with its ecosystem, and compiled to WebAssembly. Aside from the wasm compilation, I don't see why this exists.

That was my question only having recently started looking into ReasonML seriously. Sounds like I'll just stick to Reason!

Re: Grain: A strongly-typed functional programming language for the modern web

#68

I mean, this looks interesting, but why was this posted prematurely? Now I have to remember to look this up again in two months when they actually have a website that isn't 3% done. Basically all of the docs are in the "todo" stage. I always get a bit annoyed when people post their pages way too early.

"If you are not embarrassed by the first version of your product, you've launched too late." -Reid Hoffman

In this case, publicising, and getting more contributors can help fix these problems.

Re: Grain: A strongly-typed functional programming language for the modern web

#70
post #69

Why do all new languages aimed at the browser seem to be "strongly typed, functional". I have no objection whatsoever, but we've seen Elm, Purescript and now this. Or is my perception skewed by the "HN Echo Chamber"?

I think it's just that JS caters to those features the least, so that's where you see new languages from people that want them.
Post reply on HN