News for hackers. Stuff that matters.
Re:Elm: declarative language that compiles to HTML, CSS and JS by dbaupp on Monday December 10, 2012 @11:41AM (#4899868)
Previous submission (with discussion): https://news.ycombinator.com/item?id=3322082

(Presumably that submission is why this one (is) was forced to (incorrectly) have an extra /)

Re:Elm: declarative language that compiles to HTML, CSS and JS by jessaustin on Monday December 10, 2012 @12:19PM (#4900235)
From that discussion it seems that not much of this system was usable at that time. Fortunately it appears more complete now. He got his thesis done too.
Re:Elm: declarative language that compiles to HTML, CSS and JS by MattRogish on Monday December 10, 2012 @02:59PM (#4901196)
MVC web app development test-driven development has always bothered me. I can easily test my models/controllers but to verify that the app HTML isn't borked I have to rely on strict HTML compilation tools (like HAML) and/or slow/painful frontend integration tests that require button clicking, HTML parsing, and form-element filling.

I've always wanted a higher-level way to author and test HTML and I always come back to a more programmatic/declarative way of generating HTML as the best way. I'm not sure if Elm is the answer but I think it's at least a good discussion starter.

Re:Elm: declarative language that compiles to HTML, CSS and JS by blake8086 on Monday December 10, 2012 @04:30PM (#4901613)
You could build your HTML as a hierarchical data structure instead of a string.
Re:Elm: declarative language that compiles to HTML, CSS and JS by kv85s on Monday December 10, 2012 @11:36AM (#4899835)
visiting the link yields:

Parse error at (line 1, column 1): unexpected end of input expecting reserved word 'module', reserved word 'import' or at least one datatype or variable definition

Re:Elm: declarative language that compiles to HTML, CSS and JS by ojii on Monday December 10, 2012 @11:37AM (#4899840)
the link seems to have an extra slash at the end, http://elm-lang.org/ works for me.
Re:Elm: declarative language that compiles to HTML, CSS and JS by wheatBread on Monday December 10, 2012 @01:15PM (#4900597)
Can you specify which link you visited? Or what platform you are on?
Re:Elm: declarative language that compiles to HTML, CSS and JS by TeMPOraL on Monday December 10, 2012 @11:49AM (#4899914)
Which suggests the site is generated in some unsafe way that could possibly be exploited.
Re:Elm: declarative language that compiles to HTML, CSS and JS by wheatBread on Monday December 10, 2012 @01:18PM (#4900612)
While this massive bit of speculation is exciting, this is not the case. It is a compiler error indicating that the poster somehow compiled an Elm file without any content in it. I suspect my servers are having a bad time right now, so the file may have been only partially read for some reason.

I am trying to scale my servers up now!

Re:Elm: declarative language that compiles to HTML, CSS and JS by gliptic on Tuesday December 11, 2012 @08:53AM (#4904479)
You get the error when you go to http://elm-lang.org//
Re:Elm: declarative language that compiles to HTML, CSS and JS by pohl on Tuesday December 11, 2012 @02:05PM (#4906141)
Thank you for posting this link again. It has led me to an interesting paper on a related paper co-authored by Martin Odersky called "Deprecating the Observer Pattern with Scala.React"

http://infoscience.epfl.ch/record/176887/files/DeprecatingOb...

Interestingly, the farther I read into this paper, the more I think the Mozilla Rust community should get behind functional reactive programming. After all, an experimental language created with the intention of being used for creating an experimental browser should probably give serious consideration of the abstractions used for event handling.

I also found a talk on FRP, for anyone who's curious:

http://www.youtube.com/watch?v=4HMKNexdyOw

...the slides for which are here:

http://www.slideshare.net/edwardamsden/introduction-to-funct...

Re:Elm: declarative language that compiles to HTML, CSS and JS by mcmire on Monday December 10, 2012 @02:43PM (#4901129)
A couple of questions:

1) Is this a subset of Haskell, or a brand new language inspired by Haskell?

2) It appears that FRP (which by the way is a cool idea) isn't necessarily language-specific, is this true? My guess is that Elm just brings FRP to the forefront in the same way Lisp brings FP to the forefront?

Re:Elm: declarative language that compiles to HTML, CSS and JS by wheatBread on Monday December 10, 2012 @03:15PM (#4901263)
1) Brand new language inspired by Haskell's syntax, but it is really much closer to ML (strict evaluation, no type classes). More info: http://www.testblogpleaseignore.com/2012/06/21/why-elm/

2) That is totally true! The idea is quite general. I think it works best in a strongly typed language like OCaml or Haskell, but it could work anywhere. FrTime is a Scheme/Lisp/Racket version of FRP. My personal opinion is that it works best in Elm though :P

Re:Elm: declarative language that compiles to HTML, CSS and JS by scarmig on Monday December 10, 2012 @06:11PM (#4902125)
Briefly, how would you summarize the semantics of FRP in your language as compared to Yampa in Haskell?
Re:Elm: declarative language that compiles to HTML, CSS and JS by wheatBread on Monday December 10, 2012 @08:33PM (#4902632)
A generalization. Arrowized FRP (as introduced in Yampa) can be entirely embedded in Elm.

The Automaton library is the beginnings of such an embedding: http://elm-lang.org/docs/Automaton.elm

To be more concrete, in Elm you can work directly with signals if you want. In Yampa you cannot; you only get "signal functions" (which Elm has as well in the form of Automatons).

Re:Elm: declarative language that compiles to HTML, CSS and JS by michaelsbradley on Monday December 10, 2012 @03:09PM (#4901239)
Flapjax[1], an FRP library for JavaScript, has been around for several years and can be used purely as a JS library[2], or you can use its compile-to-js DSL to build page/app templates[3]:

[1] https://github.com/brownplt/flapjax

[2] http://www.flapjax-lang.org/docs/

[3] http://www.cs.brown.edu/~sk/Publications/Papers/Published/mg...

A couple of years ago, I began (somewhat naively, on my own) hacking together a "next gen" version which was intended to generalize the functionality of Flapjax-as-a-library. I learned a lot, and ended up coming face-to-face with monads and monad transformers (though I didn't realize it at the time) and the limitations and complications that mutable data structures (as opposed to immutable ones) imply for dataflow/FRP frameworks. My work on that library stopped when I shifted from NodeJS to Clojure/ClojureScript for my day-to-day work. Now that I'm a bit more experienced with functional programming, monads, etc., I hope to find some time to restart that effort, using ClojureScript (and protocol-monads[4]?) as the foundation.

[4] https://github.com/michaelsbradleyjr/protocol-monads

Re:Elm: declarative language that compiles to HTML, CSS and JS by anonymousDan on Wednesday December 12, 2012 @05:55PM (#4912937)
Apart from syntax, I fail to see how this code:

    getPhotos tags =
        let photoList  = send (lift requestTag tags) in
        let photoSizes = send (lift requestOneFrom photoList) in
            lift sizesToPhoto photoSizes
...is any clearer than the equivalent callback code:

  function getPhoto(tag, handlerCallback) {
        asyncGet(requestTag(tag), function(photoList) {
            asyncGet(requestOneFrom(photoList), function(photoSizes) {
                handlerCallback(sizesToPhoto(photoSizes));
            });
        });
In particular, you still have to nest the elm signals in 'let ... in' blocks.
Re:Elm: declarative language that compiles to HTML, CSS and JS by desireco42 on Monday December 10, 2012 @04:56PM (#4901736)
I find language lacking, promise of single language to handle html, css and js is simply not delivered.

I kind of imagined something like components where you would have html, css and js and you can say

login_form = new loginForm(loginProcess)

where loginProcess would be callback that would get username and password... or something along those lines.

I guess those are html components that someone was writing about...

Re:Elm: declarative language that compiles to HTML, CSS and JS by larskinn on Monday December 10, 2012 @05:00PM (#4901745)
Callbacks are actually one of the things this is explicitly trying to avoid: http://elm-lang.org/learn/Escape-from-Callback-Hell.elm
Re:Elm: declarative language that compiles to HTML, CSS and JS by larskinn on Monday December 10, 2012 @12:04PM (#4900090)
Very nice, accessible examples and documentation. Can't wait to try it out (after exams)
Re:Elm: declarative language that compiles to HTML, CSS and JS by woah on Monday December 10, 2012 @01:44PM (#4900776)
Is this actually useful? Has anyone tried it? The examples are quite simplistic. I would like to see a more full featured app or site before I invest any time into investigating it.
Re:Elm: declarative language that compiles to HTML, CSS and JS by wheatBread on Monday December 10, 2012 @02:15PM (#4900959)
I think so, but I am biased (lead dev and designer :P)

The entire site is written in Elm (excluding the code editor which relies on CodeMirror). If you click the "View Page Source" in the top right corner of every page, you can see the full source for it.

For example: http://elm-lang.org/edit/Examples.elm

Here's the [full source for the website](https://github.com/evancz/elm-lang.org/tree/master/public) and a [game of Pong](http://elm-lang.org/blog/games-in-elm/part-0/Making-Pong.htm...).

Re:Elm: declarative language that compiles to HTML, CSS and JS by wyclif on Monday December 10, 2012 @03:17PM (#4901278)
I always think about the MUA when anyone says "Elm": http://www.instinct.org/elm/

I guess that means I'm old.

Re:Elm: declarative language that compiles to HTML, CSS and JS by cincinnatus on Monday December 10, 2012 @10:43PM (#4902920)
Was the first thing to come to my mind as well. Used it every day in the mid to late 80s.
Re:Elm: declarative language that compiles to HTML, CSS and JS by shortlived on Monday December 10, 2012 @02:15PM (#4900958)
Is elm-server just another web server or does it serve up elm files directly?

PS - this project looks really great! It makes me interested in web dev again.

Re:Elm: declarative language that compiles to HTML, CSS and JS by wheatBread on Monday December 10, 2012 @02:20PM (#4900994)
It serves Elm files directly. You just start it up, and can use F5 to recompile files from the browser.

PS. Thank you! :D I actually like web programming these days because of it :)

Re:Elm: declarative language that compiles to HTML, CSS and JS by at-fates-hands on Monday December 10, 2012 @01:05PM (#4900540)
I'm seeing a lot of inline styles on elements on the site. Not sure if this is part of how the language is supposed to work.
Re:Elm: declarative language that compiles to HTML, CSS and JS by scarmig on Monday December 10, 2012 @12:44PM (#4900421)
Oh, I hadn't seen the pong example before!

Reminds me of the old paper on Space Invaders.

Re:Elm: declarative language that compiles to HTML, CSS and JS by mgaudin on Monday December 10, 2012 @11:44AM (#4899878)
Epic fail.
Re:Elm: declarative language that compiles to HTML, CSS and JS by sidcool on Monday December 10, 2012 @12:35PM (#4900358)
It's a pretty old submission. I wonder what prompted it to be upvoted again. But it's fine, as long as it's related to Technology and Programming.