10 ms·
Elm Compiler Written in Elm
- de_keyboard 5y agoVery cool! However, could they not compile the Haskell Elm compiler to JS using GHCJS and then write Elm bindings for it?
- raffomania 5y agoOne of their stated goals is to show people how to write a compiler in Elm, and another is to allow programmers familiar with Elm to hack on the Elm compiler without needing to learn Haskell.
- pd-andy 5y agoThe compiler written in Haskell relies on some extensions and/or optimisation tricks that make it not possible to compile with GHCJS. The 0.18 compiler (or maybe it was 0.17) was compiled with it though, it was what Ellie (third-party online playground) used.
- mjaniczek 5y agoOne thing to note is that writing the compiler in Elm instead of just compiling the Haskell compiler to JS allows us to expose bits of the compiler as an Elm library. I mean, being able to bootstrap is nice and nerdy and so on, but I believe exposing the parser, optimizer, type inference etc. as standalone functions will be the most impactful aspect of the repo, in terms of enabling better tooling in the Elm ecosystem.
- lisardman 5y agoSad that they have to put a massive "Non-goals" full of emojis so the main Elm team does't feel threated. A languange doesn't lose anything with an extra compiler - a competing compiler is actually what Elm needs right now.
- vanderZwan 5y agoI don't see how the emojis have anything to do with that section, since they're all over the readme anyway. Aside from that: what they're stating is that they "don't want to and aren't planning to divide the community into multiple Elm derivatives, and will actively try to prevent that". Not dividing the community is not the same thing as threatening the main Elm team. And for a smallish language like Elm it makes sense to me that they want to keep everyone on the same team.
- tester89 5y agoI assume it's a reference to https://lukeplant.me.uk/blog/posts/why-im-leaving-elm/ https://lukeplant.me.uk/blog/posts/why-im-leaving-elm/
- lisardman 5y agoTo give a bit context, Elm main team has been defensive against forks. They are preventing development of features they don’t think worth to them. It’s not possible to publish packages with low-level access without Elm main team approval. The compiler even has built-in DRM about that. My point is more compilers is exactly what Elm needs to flourish. C has several compilers. Python has even”jython”. That doesn’t make a language community weaker.
- otabdeveloper4 5y agoWe may live to see the day, hopefully, (a long time ago in a galaxy far, far away) where language designers join the 1970's and learn about open standards. Their mind will be blown, probably.
- deleted 5y ago[deleted]
- square_usual 5y ago> It’s not possible to publish packages with low-level access without Elm main team approval. The compiler even has built-in DRM about that. Not calling you out or anything, but could you give a reference on that? I'm curious about what they're doing with a "DRM" in the compiler.
- Ciantic 5y agoI like it! I gather now you can compile Elm in the browser? It allows many things, similarly as F# with Fable, which allows to compile F# code in browser without a server. Ability to compile code in browser allows to do sandboxes, or tools that otherwise would require a server.
- pd-andy 5y agoI think the project is a while off of being properly usable. I think it's mostly written with Node in mind, but shouldn't be too difficult to swap out the Fs bits for browser-specific code.
- mjaniczek 5y agoAs pd-andy says, it's not finished yet, but yes you're right, that's one of the things it will enable: interpreting Elm code from within Elm - an eval function of sorts.
- yladiz 5y agoSerious question: how popular is Elm? I've recently seen some tutorials showing up and anecdotally know some friends that have played around with it, but I haven't seen any job postings for it and so I'm wondering if it's just hyped up or if there is real demand for Elm developers professionally.
- gampleman 5y agoI write Elm full time, so there are definitely jobs out there. That said, I suspect that given how fun the language is to write, supply probably outpaces demand a bit. Which is actually good, in the sense that for many companies adopting a somewhat less mainstream language one of the main concerns is "will I be able to hire for this?", which generally the answer is "yes, especially for more senior positions".
- pd-andy 5y agoNeither, really. I'd say it has the largest community out of the various compile-to-js statically typed FP langs, at least with an explicit front-end focus. - PureScript has a small but passionate community, one of the biggest players in that community laid off their whole ps team so that doesn't bode well. - ReasonML fractured into ReScript but left half the Reason community behind, it's a confusing space to navigate now. - GHCJS... Most (perhaps even all) of the job postings end up on the elm slack (rather than, say, reddit or other more visible places). There was some controversy with the release of 0.19 a couple of years ago, and general contempt (in the wider community, not inside Elm) for the way the language is developed and run which means there isn't a great deal of buzz about it outside of those already using it.
- mjaniczek 5y agoHello! Author here. Didn't expect to land on HN before the compiler is actually useful - Oto, you'll pay for this! :) Feel free to ask me anything about the project, although bear with me - I'm learning compilers/... on the go, didn't study them or anything.
- andrewzah 5y agoI know you're not trying to replace the official Elm compiler, but that's precisely what is needed. I really, really wanted to like Elm but the way it's managed is horrible and antithetical to the idea of Open Source software. With the current compiler I wouldn't touch Elm with a 39.5" pole, even if Elm is a joy to work with.
- savanaly 5y agoOne's attitude towards Elm directly correlates with the degree to which one likes to dig into and tinker with the internals of their tools and frameworks and rearrange things. Unfortunately that means it's a hard sell around HN-- in a way it's antithetical to "hackers". But I don't think it's antithetical to John Carmack's proverbial "engineer"-- someone who wants to do what they can do with what they've actually got. Elm lets me do what I want to do, exceedingly efficiently and makes it fun, and that should make it a good choice for plenty of projects.
- andrewzah 5y agoI don't buy this argument. I am also someone who just wants to get shit done. I've never had an issue with php, c#, ruby, crystal, go, rust, haskell, erlang etc's compilers/interpreters in terms of letting me get what I want done. Yeah, I haven't actually forked or patched those compilers but neither have they been hostile to their users. The reason I would use literally any of those except Elm is that the maintainer(s) of Elm act like they're Steve Jobs. How can I "get things done" if I'm being told "oh no, you're not allowed to do <standard-thing-X>, we've decided that only us on the Elm team can do that". With other languages, I'm not worried about a version bump pulling the rug out under me, effectively trapping me in the ecosystem unless I want to rewrite everything in a different language. That is also directly the opposite of being productive and getting things done. There is nothing about an autocratic "you're holding the compiler wrong" governance model that makes any part of a language itself more efficient or fun. Plenty of other languages are as (or more) efficient and fun as Elm, but without the patronizing and condescending attitude of "you're not as smart as us, so do as you're told, and no you can't discuss this with us". There is no way I could justify the risk of adopting elm professionally given the entire rest of the programming language world... doesn't do this. Let me be the one who decides to shoot my own foot off; even Rust (a language pitched on memory safety) allows this with unsafe, etc. If one wants to control everything exactly and go against almost every other language and most F/OSS projects, then just... make proprietary/source-available software. F/OSS is a give-and-take, and nearly all of us have taken far more than we've given. And I don't know what John Carmack's "proverbial engineer" is, but I think just about any engineer would prefer to be in control of their tooling and not at the whims of maintainers.
- rishav_sharan 5y agoI really would love to have this compiler have a llvm backend. I like the idea of a small FP language with amazing error messages. Haskell is too big and complex for me.
- mjaniczek 5y agoI've briefly looked at LLVM and how to interface with it but back then I didn't find much else than some C++ Builder API. I'd hope for some textual format that I could give to LLVM as an input. I assume it exists and that I've just been googling wrong :) Would definitely appreciate some pointers in that regard. Other than that my best bet for native binaries is most likely compiling to C or GraalVM (which already exists as an experimental backend in elm-in-elm via Truffle!)
- adjav 5y agoThe textual representation is known as the LLVM IR (the reference is at https://llvm.org/docs/LangRef.html https://llvm.org/docs/LangRef.html). My understanding (as purely an amateur enthusiast) is that generally using a higher-level builder, like the ones for C++ or OCaml, is recommended, but that it's entirely possible to generate the IR directly.
- MobiusHorizons 5y agoAs the other comment says, LLVM has a text based IR. But you may also want to look into QBE which is simpler and lighter weight than LLVM but has a similar text interface so you could start with that to get up and running, and then add support for llvm later.
- lioeters 5y agoTo save anyone else a search: QBE: Compiler Backend - https://c9x.me/compile/ https://c9x.me/compile/ QBE vs LLVM - https://c9x.me/compile/doc/llvm.html https://c9x.me/compile/doc/llvm.html
- rishav_sharan 5y ago
- leshow 5y agoAFAIK Elm can't actually write to the filesystem, how does the compiler get around that? Or has Elm changed such that it can work outside the browser now?
- mjaniczek 5y agoI use ports to write to the filesystem. There is a small amount of JS that initializes Elm, which runs in Node and has the ability to write to the filesystem. Of course if you'll be running elm-in-elm in the browser, you won't be able to do that. But there are more interesting things to do with a compiler in the browser :)
- k_bx 5y agoPorts let you communicate with Elm from pure js, for example here’s the cli wrapper for node https://github.com/elm-in-elm/compiler/blob/master/cli/index.js https://github.com/elm-in-elm/compiler/blob/master/cli/index...
- tpoindex 5y agoeie.io would be an awesome domain name for this project. Too bad it's already parked by a squatter as a "premium name". (For non-native or non-Western English speakers, it's a line from the children's song "Old McDonald Had a Farm".)
- forgotpwd16 5y agoPremium names aren't squatted but designated as such by the central registry. For the TLDs .ac, .io, and .sh those are previously unavailable short domains that are now released to public and auctioned by Divido, the company that has set up the site you see.
- neolog 5y ago> EIEIO (“Enhanced Implementation of Emacs Interpreted Objects”) provides an Object Oriented layer for Emacs Lisp, following the basic concepts of the Common Lisp Object System (CLOS). It provides a framework for writing object-oriented applications in Emacs. https://www.gnu.org/software/emacs/manual/html_node/eieio/ https://www.gnu.org/software/emacs/manual/html_node/eieio/
- astrange 5y agoAlso relevant to compilers, it's a fence instruction in PowerPC: > eieio (Enforce In-Order Execution of I/O) instruction > Ensures that cache-inhibited storage accesses are performed in main memory in the order specified by the program.
- terezasokol 5y agoGreat work, Martin! Excited to see how the project turns out <3