I have a distrust for languages that advertise themselves as "strongly-typed" or "bringing sanity to the front-end" - the former doesn't have a single clear definition and the latter - while not the case here - is questionable in it's own right.
Moreover, they don't really show anything to make their point — I can't see any type annotations on the frontpage.
Grain: A strongly-typed functional programming language for the modern web
51–60 of 156 posts
Re: Grain: A strongly-typed functional programming language for the modern web
#52The main page doesn't do a great job of showing what's interesting about Grain vs. JavaScript. The only hint is this: "No runtime exceptions, ever. Every bit of Grain you write is thoroughly sifted for type errors, with no need for any type annotations." Maybe show some examples of errors Grain would catch that JavaScript wouldn't, like Elm does: http://elm-lang.org/
> No runtime exceptions, ever. I'm curious how they handle JSON parsing. For example in Scala/Play you define the class you want to parse to, and if the JSON passed in at runtime doesn't match the shape of that class then you get a runtime exception. Obviously it'd be nice if that didn't happen, but I can't think of any alternative that would make sense.
Re: Grain: A strongly-typed functional programming language for the modern web
#53I 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.
Re: Grain: A strongly-typed functional programming language for the modern web
#54Earlier quoted context omitted.
Like comparing to Rust compilation to WebAssembly for example?
Does Rust have any DOM integration?
The shiny new toy is wasm-bindgen (https://github.com/rustwasm/wasm-bindgen), which will soon allow the use of WebIDL (https://heycam.github.io/webidl/) to wrap the entire browser API, if I understand correctly.
In practice, it all seems to work pretty well. But for public-facing sites, you need to watch the number of dependencies you include and keep the *.wasm size down.
Re: Grain: A strongly-typed functional programming language for the modern web
#55Earlier quoted context omitted.
Does Rust have any DOM integration?
Yes. For a while, you've been able to embed JavaScript wrappers using stdweb ( https://github.com/koute/stdweb ). There are pre-built libraries covering much of the DOM. But you may need to submit PRs if you get heavily into or something else with non-standard APIs. The shiny new toy is wasm-bindgen ( https://github.com/rustwasm/wasm-bindgen ), which will soon allow the use of WebIDL ( https://heycam.github.io/webidl…
Re: Grain: A strongly-typed functional programming language for the modern web
#56The main page doesn't do a great job of showing what's interesting about Grain vs. JavaScript. The only hint is this: "No runtime exceptions, ever. Every bit of Grain you write is thoroughly sifted for type errors, with no need for any type annotations." Maybe show some examples of errors Grain would catch that JavaScript wouldn't, like Elm does: http://elm-lang.org/
I think the marketing page is not doing a great job. Grain is a language compiled to WebAssembly. So comparing it with either Javascript or Elm is pointless
This ability is a tool and nothing precludes a wasm target for Elm (in fact Evan specifically expressed interest in it: https://github.com/WebAssembly/gc/pull/1#discussion_r1115011...).
Either way, comparing Grain to JS or Elm is anything but pointless, at the end of the day it's competing with them.
Re: Grain: A strongly-typed functional programming language for the modern web
#57The main page doesn't do a great job of showing what's interesting about Grain vs. JavaScript. The only hint is this: "No runtime exceptions, ever. Every bit of Grain you write is thoroughly sifted for type errors, with no need for any type annotations." Maybe show some examples of errors Grain would catch that JavaScript wouldn't, like Elm does: http://elm-lang.org/
> No runtime exceptions, ever. I'm curious how they handle JSON parsing. For example in Scala/Play you define the class you want to parse to, and if the JSON passed in at runtime doesn't match the shape of that class then you get a runtime exception. Obviously it'd be nice if that didn't happen, but I can't think of any alternative that would make sense.
Returning a sum of success + error, as e.g. Rust's Serde[0] or Elm's Json.Decode[1] do.
The developer gets the feedback that the operation has failed at runtime, but they also get the feedback that the operation can fail and they must handle it somehow at compile-time, even ignoring the issue is an explicit decision.
[0] https://docs.serde.rs/serde_json/de/fn.from_str.html
[1] http://package.elm-lang.org/packages/elm-lang/core/latest/Js...
Re: Grain: A strongly-typed functional programming language for the modern web
#58What is meant by "zero runtime errors?" An example of a "runtime error" is the head of an empty list; how does Grain handle this?
Re: Grain: A strongly-typed functional programming language for the modern web
#59Re: Grain: A strongly-typed functional programming language for the modern web
#60The main page doesn't do a great job of showing what's interesting about Grain vs. JavaScript. The only hint is this: "No runtime exceptions, ever. Every bit of Grain you write is thoroughly sifted for type errors, with no need for any type annotations." Maybe show some examples of errors Grain would catch that JavaScript wouldn't, like Elm does: http://elm-lang.org/
I wonder how they handle array out-of-bounds accesses...
Or they don't support indexing at all.