[HN Gopher] Gren 0.4: New Foundations
       ___________________________________________________________________
        
       Gren 0.4: New Foundations
        
       Author : Skinney
       Score  : 67 points
       Date   : 2024-06-24 09:01 UTC (14 hours ago)
        
 (HTM) web link (gren-lang.org)
 (TXT) w3m dump (gren-lang.org)
        
       | SillyUsername wrote:
       | This looks like a fun language to learn if you have the time, I
       | prefer the syntax Vs Go. I have a concern that as with most new
       | new languages adoption and commercial support affects the uptake,
       | a chicken and egg scenario. Early days at 0.4 but what are the
       | future plans?
        
         | Skinney wrote:
         | On the top of my head, the major features to come are:
         | 
         | * Compile to WASM
         | 
         | * Parametric modules (OCaml functors)
         | 
         | * Structural (as opposed to nominal) unions
         | 
         | * Improvements to the Ports (FFI) mechanism while still
         | retaining purity
         | 
         | * Actors(?)
         | 
         | * Support more builtin Browser and NodeJS APIs out of the box
        
           | anentropic wrote:
           | Why not ReScript?
        
             | Skinney wrote:
             | ReScript isn't pure.
             | 
             | The big thing with Gren is that it's easy to anticipate
             | what your code will do, even when calling functions you
             | don't know the implementation of. It's hard to do this when
             | function calls can mutate state, throw unchecked exceptions
             | or perform arbitrary and unmanaged side effects.
             | 
             | Gren tries to do without these (mutation, unchecked
             | exceptions, unmanaged side-effects) without requiring too
             | much effort on the developer's part. In return, you can
             | easier reason about the behaviour of your program.
             | 
             | Elm proved, at least to me, that this was good way to write
             | programs. Gren simply tries to take it a step further by
             | including first class support for backend applications and
             | command line tools through NodeJS.
        
           | zellyn wrote:
           | You may be interested in roc-lang.org, which does some of
           | those.
        
             | Skinney wrote:
             | Thank you! I'm already aware of Richard's project and I
             | wish it all the best. You'll find that Gren and Roc differs
             | in certain aspects, though, at least today. It'll be
             | interesting to see how the languages evolve :)
        
       | anonzzzies wrote:
       | I like the explanation why it is simple. In reality people won't
       | like this because they like something like '+' to mean more
       | things. Look at how rapidly people get 'upset' with OCaml because
       | '+' and '+.' etc. Seems Gren does not go that far, but does not
       | allow + for strings or any conversion (although + is for
       | floats?).
        
         | Skinney wrote:
         | Gren will probably resemble OCaml more and more in this regard.
         | 
         | Today, you use + for numbers, and ++ to concatenate strings and
         | list.
        
       | cies wrote:
       | This (Gren), Elm (what Gren is based off), PureScript (more full
       | featured: has Haskell's type classes), Gleam (targets both on
       | BEAM and the browser) -- all really good attempts to fix the
       | JavaScript problem.
       | 
       | https://wiki.haskell.org/The_JavaScript_Problem#The_problem
        
         | otabdeveloper4 wrote:
         | It boggles the mind that none of these "solutions" can parse
         | JSON from an API endpoint, even after all these years.
         | Consuming web API's is the whole reason Javascript exists in
         | the first place!
        
           | Latty wrote:
           | Am I misunderstanding you, or are you extremely misinformed?
           | Elm can definitely consume JSON APIs.
           | 
           | https://package.elm-lang.org/packages/elm/json/latest/
           | https://package.elm-lang.org/packages/elm/http/latest/Http
        
         | zem wrote:
         | don't forget rescript and melange, which are attempts to
         | integrate ocaml into the javascript ecosystem
        
       | fermigier wrote:
       | I had a hunch reading the home page that Gren and Elm were
       | related. This is confirmed by this page:
       | 
       | https://gren-lang.org/book/appendix/faq/#what-are-the-differ...
       | 
       | IMHO it should be more prominent on the hope page or the elevator
       | pitch.
        
         | brabel wrote:
         | A big difference seems to be that it can run on NodeJS. I was a
         | bit confused that the Hello World example shows a web app, but
         | the compiler itself is being rewritten in Gren?! So, the
         | compiler can spit out an executable or JS code, besides HTML?
        
           | Skinney wrote:
           | It can. If you pass the compiler a output name that has no
           | extension it will produce an executable (js with shebang),
           | and if it has a .js extension it will output a pure js file.
        
           | mjaniczek wrote:
           | To clear a possible confusion: Elm runs on NodeJS as well.
           | The reason it's not often done is that the (1st/3rd-party)
           | published packages are heavily skewed towards frontend,
           | because Elm is a language primarily focused on frontend and
           | most of the community uses it for that.
        
             | brabel wrote:
             | Elm is a frontend language. I know there are efforts to
             | make it runnable on node, but to my knowledge, officially
             | the language is only meant for web applications. The
             | website still seems to confirm that. Can you explain a bit
             | better what you mean??
        
               | Latty wrote:
               | IIRC Lamdera is doing server-side Elm.
               | https://lamdera.com/
        
         | Skinney wrote:
         | My worry is that by making it very clear that Gren is a fork of
         | Elm, people will assume that what works in Elm also works in
         | Gren. It won't.
         | 
         | Gren isn't compatible, and will never be compatible, with Elm.
         | There is different syntax, API's and runtime characteristics.
         | And it will continue to diverge more and more.
         | 
         | That Gren is a fork, was mostly to save development time. You
         | can expect that much of the compiler and core packages to be
         | rewritten in a few years.
        
       | zellyn wrote:
       | If you're interested in Gren, you might also like Roc -- roc-
       | lang.org. It's a definite descendent of Elm too, although not a
       | fork: the compiler is written in Rust, the platforms (a
       | fascinating and powerful concept) in Rust and Zig.
        
         | tasuki wrote:
         | What are the differences and similarities between Gren and Roc?
        
           | boxed wrote:
           | I don't see how to make Single Page Apps, or really anything
           | client side in Roc. I'm quite frustrated by
           | https://github.com/roc-lang/roc/blob/main/roc-for-elm-
           | progra... which doesn't answer this which is the first
           | question imo.
        
             | zellyn wrote:
             | Roc is built by folks who love Elm. They have no desire to
             | replace Elm for web frontend.
             | 
             | IIUC, Roc is what you get if you stir together:
             | 
             | - I like Elm, and wish I could use it in other domains - I
             | have a bunch of ideas for where Elm could go, but I don't
             | want to mess with Elm - A really smart, incredibly
             | thoughtful BDFN (benevolent dictator for now)
        
       | iamdamian wrote:
       | Any plans for typeclasses?
        
         | Skinney wrote:
         | No. Gren will instead pursue parametric modules (OCaml
         | functors).
        
       | fire_lake wrote:
       | How does Green plan to distinguish itself from OCaml given that
       | you can transpile OCaml to JS and run it in Node today?
       | 
       | (I'm a big fan of MLs so this is a genuine question!)
        
       ___________________________________________________________________
       (page generated 2024-06-24 23:02 UTC)