Eta – A powerful language for building scalable systems on the JVM
eta-lang.org
eta-lang.org
Ironically it says "A powerful language for building scalable systems on the JVM" but this literally doesn't scale as quicksort does.
http://stackoverflow.com/questions/7717691/why-is-the-minima...
https://wiki.haskell.org/Introduction#Quicksort_in_Haskell
This is related to the "Genuine Sieve of Eratosthenes", which is also an imperative algorithm and NOT a functional one:
https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
This brings to mind the slur "Haskell (Lisp) programmers know the value of everything but not the cost".
I have seen in-place quicksort in Haskell and it is not pretty.
It's not performant, though, and should not be considered a real quicksort implementation. So it's not showing you the cost of this particular abstraction.
First, this is not a good implementation of quicksort. Second, it is not often that people will be implementing quicksort.
I don't have one and I confess that worries me. In trying to teach my children, I have actually grown away from the "this is what the code looks like" to examples. And I commend the site for doing that. 2048 seems like an odd example, but conciseness is the goal, I'm guessing. Still a fun one. (Snake would be more fun for kids, I'm guessing. But that is just a guess.)
Why make another language anyway, if your experiment shows that Haskell is readable? You're saying that the problem with Haskell adoption are lack of tooling and documentation, which can surely be resolved without having to design another language. In fact, I don't think bad language design hindered adoption of any language ever (examples: COBOL, APL, MUMPS, BASIC, PHP, Javascript).
I wish you wouldn't break compatibility with Haskell, ever. I think it would make both languages stronger (if they were just one), since everybody could just reuse code. I don't see a reason for having another language just to fix minor syntactic problems.
Edit: I think what I am not clear about is where exactly do you intend to break the compatibility with Haskell and how do you think that action will help adoption of your language.
It seems to me that the Eta language is basically Haskell 2010 compliant compiler/runtime (correct me if I am wrong) for JVM.
Which actually is great and useful and I really like that about the project. I just think the project shouldn't be called "another language", but rather "Haskell 2010 compiler with some GHC extensions for the JVM". I actually don't even care if you avoid Haskell in the name, as long as you keep the compatibility.
When we say "Haskell" it's difficult to separate it from "GHC's Haskell" which is a much more confusing beast, full of half-discarded research projects, dependency on offshoot libraries, and a ton of tribal culture.
It's sort of like the CLHS and CLisp vs Clojure.
That's a bit harsh. GHC is a pretty old beast and its source isn't as nice as I wish it was (if only imports were qualified and every GHC source file didn't start off with a huge list of imports), but it is hardly as bad as you make it sound. It is pretty darn-well maintained. Heck, it is even one of the examples in "Architecture of Open Source Applications" [0].
That aside, I completely agree with the spirit of your comment.
I don't know the degree to which you want to make it sound bad. I think it's just the reality of GHC Haskell. There are many language extensions and while at any given year a given set are normal, as time goes on that set changes. But in many cases, we don't get new libraries that switch to new extensions, so we end up supporting a rather large superset of Haskell in ghc over time.
So while yeah, the GHC codebase itself is fine, the culture and the community providing the library ecosystem has made things challenging.
What's more, some of the core concepts haskellers lean on are just... I dunno. Underbaked? I've used a lot of lens libraries and conduit libraries now and they always feel a bit undercooked.
Pick 100 random (really random) programmers and I'm betting a lot more of them will feel more comfortable with the imperative version over all the others.
"Whenever you find yourself on the side of the majority, it is time to pause and reflect. (Mark Twain, ~150 years ago)"
That seems to be exactly what hota_mazi is saying.
Mark Twain's quote is also often misunderstood. It doesn't mean you should never be in the majority, it's about always questioning your choices.
Personally, I go one step further and I always pause and reflect, whether I'm in the majority or not.
2. This goes far above and beyond what most other language designers do, which seems to be "write the kind of language I want to use." Nothing wrong with that, either, but no sense in criticizing the language designers doing more research than most for not doing enough research.
I'm not expecting you to give me a tutorial here in the comments and I'm 100% sure I could read a tutorial and understand in a few minutes but it doesn't seem particularly obvious if you don't know haskell.
Its easy to misread familiar as obvious.
Perhaps it's not surprising that the common advice is to learn functional programming for the insights, since quicksort is not at all quick in its very clear functional programming form.
Basically, this project used to be a fork of the Haskell compiler to support the JVM. Now it's a fork of the Haskell compiler that may or may not be compatible for your use case depending on their opinion of GHC's features.
maybe it's for the best? a ghc-is-the-spec approach to developing a haskell implementation seems... well, perhaps convenient, but less hygienic for the overall language. (that said i don't actually know what eta's philosophy here is.)
I agree with the grandparents disappointment somewhat though. At the very least there is still room for someone to build a JVM compatible backend for GHC, since this is no longer a goal of Eta.
VPRI's research has shown that one important method for constructing large-scale systems that can be understood by small teams is to have a pipeline of problem-specific languages that express major portions of the system. they were able to reduce LOC for a typical OS with networking and graphics by 3 or 4 orders of magnitude.
general-purpose languages can't compete with DSLs in terms of expression, and yet we keep inventing them. i think our lack of imagination is starting to show. compilation and language design will need to become much more common-place if we expect to continue scaling up.
a tower of babel in computing is healthy, no matter how much employers want us to be easily-replaceable cogs in an IT machine.
(2) A good general-purpose language is good at creating pseudo-DSLs, also known as abstractions or APIs. This can include customized syntax, but usually it's not a brilliant idea. DSLs using the common syntax are quite prevalent in Lisp / Scheme / Clojure, or in Ruby. Haskell is reasonably good at creating DSLs, much better than e.g. Java.
languages like haskell, lisp, or ruby may make it easy to create new control structures that blend well with the existing syntax, but new control structures don't help if it's still annoying to write, say, very long lines of free-form text -- a problem that xml handles more gracefully than lisp. syntax makes a difference.
i think it's unlikely we'll win a several-orders-of-magnitude decrease in complexity by confining ourselves to the syntax decisions of one language.
I think where your criticism is really valid is that they are building tools that they think will help them address the real problem. But it's not clear that they have a real problem yet and that they fully understand it. If they do and Eta is their "DSL" to solve it, then that's great.
I have way too often fallen into the trap of finding (or dreaming about) the right language / IDE / etc. to solve my problem instead of actually working on the problem and gaining a better understanding of it. It's so easy to spend all your time on technical details because it's fun when you really should be worrying about the stuff that pays the bills.
Haskell <> JVM with Eta[1]
Scala <> Native with Scala Native[2]
One language to rule them all. Personally am rooting for both becoming a success, though Eta may have the easier path given that it can piggy back on the JVM, while Scala Native will have to, for example, come up with a plausible GC solution (i.e. matching JVM's world class GC is a tall task to say the least) along with porting myriad Java/Scala libs to native.
And this is the blog post from the co-founder of Typelead (the company behind Eta) discussing about it: https://blog.typelead.com/https-blog-typelead-com-introducin...
* https://github.com/typelead/eta/blob/master/docs/source/faq....
Now there's issues with this approach too! You'd end up with a massively convoluted set of mappings of Haskell's factory defaults to the JVM's. We're talking the equivalents of `Prelude` module, `base` package, the RTS (garbage collector and much more.. ouch!), and for each and every individual instance deciding where to draw the line between Java's built-ins' semantics and GHC's would be a massive challenge.
What's with GHC's existing LLVM backend, does LLVM not have their own Java byte-code backend(s)? (OTOH, additional major dependencies always kinda bite..)
Unfortunately, the "(that happens to be Haskell)" part is completely left out on the entry page. This gives a terrible first impression, because it seems like if someone would be trying to bootleg those 26 years that went into Haskell and sell them of as their own achievement. The documentation does a reasonable effort to set this straight, but the aftertaste from the first impression remains.
Often programming language support for streams will feel a little second class, and I'd love to have something as first class seeming as Haskells lazy list - but that's a minority of the time for me.
I believe the right implementation should be something like:
main :: IO ()
main = print $ quicksort [1, 123, 42, 90, 1, 23, 24, 12, 3]
quicksort [] = []
quicksort (x:xs) = quicksort left ++ [x] ++ quicksort right
where left = [ y | y <- xs, y < x ]
right = [ y | y <- xs, y >= x ]It's not how people should choose a language, but I'd wager it plays a non-trivial part even if only from laziness alone.
We have to remember we aren't marketing to perfect* developers but more to the average if an aim is mass adoption.
*Perfect as in follows general programming best practices. Following best practices is not always best. Not trying to make a value judgment here.
Edit: Darn, I'm stupid. It's a port of Haskell to JVM.
I'm quite disapointed by the decision regarding GHC8, though. Overloaded record labels adresses a problem which the community was quite annoyed with, for instance.
I'm curious about how the jvm will behave in regards to laziness and typeclasses (MTL-like libraries, in particular).
I think this is the biggest gap in the Haskell ecosystem right now. Every time I try to write something in Haskell, I remember I cannot "talk to my program" easily and just give up.
If you change one of the inequalities, say ">" to ">=", then it does sort (without removing duplicates). It still wouldn't feel fair to call it "quicksort" because it isn't in place.
The stock image on the about-us page threw me off. Great going guys!
We have already been sold on Kotlin... but Eta looks interesting.
(and I don't care for it to be JVM. but I do care for it to be be Haskell... OCaml is not Haskell and has too many weird dark corners imho)
And that's probably true.
As for specifically competing with Clojure... frankly, who cares? The two are so different as to render such a comparison fairly useless: Lisp-y s-expressions versus ML-style syntax. Strict Hindley-Milner-style type system vs Lisp-style dynamic typing. Lazy evaluation versus strict. Pure versus impure. The list goes on and on.
Clojure is an interesting language, no doubt. But your response would seem to imply it's the end-all and be-all of programming languages, and given how subjective such an assessment would be, it strikes me as a fairly vacuous claim...
So if someone is going to sell me on a better JVM language, they need to at least give me a pro/con list vs Clojure. While HN might disagree, the market (people who work in companies that live for revenue, not VC) will agree in my interest for that comparison.
Clojurescript is just wonderful. I'm not even sure a Haskell-like language that compiles to JavaScript (Elm, PureScript, GHCJS) with really good tooling can beat it, though I haven't tried. Would be an interesting experiment to do a comparison by writing the same app in all the languages.
Just compare:
foo.bar(baz)
to: (.bar foo baz)
Same number of parens...they're just in different places.Sure CommonLisp has a ton of parens, but thats CL and it has its own set of issues.
One more example:
Runnable foo = new Runnable() {
Object run(Object bar)
{
return bar;
}
}
vs (reify Runnable
(run [bar]
bar))
Less parens, no brackets, no semicolons, and no ceremony. This "parens are killing Clojure" meme is just a straw-man.Clojure and Haskell are two almost completely different beasts. Thanks to clojure's simplicity (as a dialect of lisp), it could BECOME haskell if you wrote the DSLs for it, but the reverse is much harder, I would think.
Eta is not looking to convince clojurists to use haskell on the jvm instead of clojure, it's (most likely, I don't maintain the project) to enable those who want to use haskell but want to also use the JVM to do so.
Regardless of whether Haskell is a better choice for your project or clojure is, the eta team (or any other team for that matter) is under no obligation to find that out for you, or even to make your search any easier. That's your job -- if clojure still fits your needs and doesn't have any glaring issues, absolutely use it.
I think the statement is almost axiomatic. Lisp is multi-paradigm, by way of simplicity/choices not being made for you. Haskell is decidedly functional (which is something I love about it). Making a more specific thing into a less specific thing (while possible in this case), seems like a more difficult task than molding the clay that is LISP to look like haskell.
So let's say I have a function that needs :name and :addr and it adds a new field calls :name+addr. Now in most (all?) statically typed languages I would have to say that this function takes a "name and addr" and returns "name, addr, and name+addr". So I have a type conversion, right? If the time comes that I need to modify these types, I have to do some sort of refactor.
In Clojure we'd just take a hash map and add a new k/v pair to the hash map we get. Any hash map will work, as long as it has the proper entries, and we'll just add a new entry to that. So if the time comes that I want to call this function with a "company" instead of a "person", it just works, as long as I have the proper keys. And to help check this sort of stuff we do have spec (https://clojure.org/about/spec).
TL;DR -- my belief having programed in both static and dynamic languages is that deep refactoring is primarily driven by the inflexibility of static types.
As crazy as it sounds, I could imagine myself making such a claim, but only because of Clojure's position as a dialect of lisp.
The reason I think I could make a claim is because of lisp's dedication to simplicity -- technically most general-purpose languages are equivalent, but lisps stand apart for me because they generally focus on giving the programmer the tools to build what they want and nothing else. As a result of this, lisps are generally (if not always): multi-paradigm, DSL-friendly, etc.
This is getting long, but the basic point is, I could see lisp being an end-all be-all of programming languages, because it gives the programmer the right tools, and I can almost always easily envision going from lisp -> some other language (ex. haskell) than I can going from some other language (ex. haskell) -> lisp. You could also of course say similar things about assembly or other languages that give the programmer even less, but lisp strikes what I think is the best balance I've seen for giving just enough power, without requiring too much in return from the user, specifically talking about language ergonomics (leaving out implementation details like garbage collection, etc).
Yeah, no one does that.
There's a reason other languages exist and Lisp hasn't simply supplanted them. If I want a HM-style strictly typed, lazily evaluated programming language, I'm not going to build it myself on top of lisp. I'm going to find a language that suits my preferences and simply use it.
Besides, you could make the same claim about any programming language. "Hey, C is the ultimate language because I could use it to build a compiler for the language I actually want!" Correct in theory. Meaningless in practice.
As for being multi-paradigm, balance between functionality and simplicity, etc, those are all personal preference. A Haskeller could equally say they like an opinionated language that gives them a rich set of tools to build correct programs more easily. These are factless value-judgements. Which is why HN sees new programming language announcements every other week...
What you're saying is true, but there's not that much you can say about languages that ISN'T personal preference, in the end. What I'd really like to hear is from someone that's enjoyed lisps, AND other languages, and feels that another language would be the one on which to make this claim (the claim that a language was the "end-all-be-all" of programming languages).
You mentioned not building it yourself on top of lisp, but that wasn't my point. My point is that if I DID have to build it myself, I would choose lisp as the language to amend, not that it makes sense that everything is built on lisp. That's what makes me think of it as a possible end-all-be-all language for me, and what makes me think I could make that claim about it. I can't think another language that is as expressive, flexible, yet as simple as lisp.
My point was that, knowing and liking languages other than lisp, Lisp is the only language that I could consider making such a claim about. A haskeller COULD easily say they like an opinionated language, and that would totally be their choice, and they'd be right, for them. I simply offered my opinion why I could imagine myself making that claim.
I agree, which is why I said your original comment (that these guys need to prove their language is somehow better than Clojure, because Clojure is, in your opinion, the "best" language on the JVM) was a bit vacuous. ;)
Incidentally, I will say I'm enormously pleased that Clojure has seen some non-trivial success, and I'm happy you've found a language that you seem to enjoy so much. Lisps have a lot to offer the world, and it's nice to see a mainstream, Lisp-derived language running on a modern platform like the JVM!
I happen to feel the same way about projects like this one that are bringing ML-derived languages to the JVM (incidentally, I also happen to be an F# fan on the CLR for the same reason).
And the fact that you could happily use both for different parts of a problem domain in the same project makes me happier still!
Indeed, why would you; Mark Tarver already built something like that, calling it Qi.
> Yeah, no one does that.
You just don't know about it because these languages typically look like Lisp on a superficial level. Those who don't know the second thing about Lisp can't see what has been done, just symbols or parentheses. Nothing visually says "I am lazily evaluated and typed" or whatever.
Many Lispers don't want to build the language they want, simply because that language is Lisp.
For example, consider a sort function. The types can tell me that I passed in a collection of a particular type and I got a collection of the same type back. However, what I really want to know is that the collection contains the same elements, and that they're in order. This is what you really care about at the end of the day, does the function do what I intended.
This is difficult to express using most type systems out there. You could use dependent to express that, but it certainly wouldn't be something that you get for free with Haskell.
So, you'll still have to write tests to ensure that the function is semantically correct for anything non-trivial.
It's also worth noting that Clojure Spec lets me express exactly what I care about using the same language semantics I'm already using to write regular Clojure code:
(s/def ::sortable (s/coll-of number?))
(s/def ::sorted #(or (empty? %) (apply <= %)))
(s/fdef mysort
:args (s/cat :s ::sortable)
:ret ::sorted
:fn (fn [{:keys [args ret]}]
(and (= (count ret)
(-> args :s count))
(empty?
(difference
(-> args :s set)
(set ret))))))
The specification will check that the arguments follow the expected pattern, and that the result is sorted, and I can do an arbitrary runtime check using the arguments and the result. In this case it can verify that the returned items match the input.Thanks for the example! My point was not that you can't test effectively in Clojure, but just that doing things like refactoring is much easier in Eta because of the numerous static checks.
This is where the ease of refactoring with static typing comes into play. An argument could be made that static typing facilitates writing code that has a lot of coupling between components.
Dynamic typing forces you to break things up into independent components much more aggressively. I think that it's a very good thing. Low coupling allows for higher code reuse, and reduced mental overhead when reasoning about code.
If you look at the Clojure ecosystem, most of it consists of small focused libraries that solve a particular problem.
Conversely, projects are structured using small independent modules that implement a particular piece of functionality. These modules can be tested at the API level.
When I make any changes, I run the API tests and if those pass, then I know that the modules does what it's supposed to. Now we also have Spec that makes it even easier to express constraints and document intent of the code.
I've never found the need to do TDD or have unit tests when working with Clojure. When I'm developing new functionality, I use the REPL, and I know exactly what my code is doing at any time.
Once the functionality is implemented and the code is doing what I need, I turn the REPL session into tests at that point.
I have the opposite experience with Haskell vs. Common Lisp or Python, but possibly because Haskell is purely functional, while CL and Python are imperative. I tend to write smaller functions in Haskell, where in CL and Python I create bigger functions with intermediate variables and bindings.
Another reason is probably absence of keyword arguments in Haskell which kind of forces you to make functions in Haskell to do only one thing and not too many things.
However, I'm not referring to writing shorter functions in that comment, but rather about higher level components like namespaces.
Refactoring becomes painful when a particular piece of data is used in many parts of the application. When you change the shape of that data, then you have to make sure you update every place that uses it. This is where static typing can help ensure that you didn't miss anything in your refactoring.
What I really like about Lisps is the ability to define DSLs with functions and macros. I thought Haskell cannot do it very well, although I recognized that the most useful ability of macros - to selectively evaluate arguments - can be replaced with Haskell's lazy evaluation. Then I read the article http://www.haskellforall.com/2012/06/you-could-have-invented... and I became sold instantly. Not only Haskell can define DSLs that are on par with DSLs in Lisp, but it also gives you typechecking in those for free!
There are still some use cases where Lisp macros can be stronger than standard Haskell, but not that many.
The other thing I was worried with Haskell was the static typechecking. I am fan of dynamic languages, because they let me write the code without having to type types everywhere. But in practice with Haskell, I was pleasantly surprised; if you stick to the standard things, you don't really need to specify types that much (although I try to specify them for function arguments), Hindley-Milner inference will figure it all out. Specifying types upfront is still a trade off, but I found I don't really mind it if I don't have to write them everywhere as I have in Java or C.
Haskell also isn't complicated language, it turns out, most features are either some obscure typing extensions to HM which you will avoid as a beginner anyway or just syntactic sugar over some kind of function composition.
And I really like the functional approach, such as monadic representation of side-effects (which gives you ability to reinterpret actions done by some function differently). It's a powerful paradigm I think even though I am not very good at it yet.
I even joke that it's simpler than Java, because the Java people have to be really smart to work with all those objects and patterns, where I can make do with types and functions (and an occasional type class), and I am not so smart, so I prefer Haskell. (There is truth to it, IMHO, the relatively clean and abstract design of Haskell makes many high order things more straightforward than in Java.)
feet2Meters :: Feet -> Meters
feet2Meters (Feet ft) = Meters $ ft * 0.3048
meters2Feet :: Feet -> Meters
meters2Feet (Meters m) = Feet $ m * 0.3048So, the compiler won't run on the JVM... if it did, there could be haskell dev on-the-device for Android...
Is Eta strict or lazy?
On the other hand, in a strict language with a laziness monad, the difference between, say, `foo -> bar` and `foo lazy -> bar` (ML syntax) is as clear as daylight. The types tell you what's going on.
if x then error "bad" else thing
to let z = error "bad" in if x then z else thing
Which isn't a valid transformation in any strict language. This general idea is pervasive in the code I write, where the act of binding something is immaterial to its evaluation. I think we use this style a lot more than we give ourselves credit for in Haskell. You can of course wrap this in a thunk, and some of the usage style can be approximated by a monadic type. But this is all just really cumbersome and annoying to do pervasively. It's the best benefit I get from laziness, to structure code this way. You also end up duplicating a lot of strict-vs-lazy code either way you pick, since "crossing the streams" is generally either forbidden by the type system (in your example) or you need the different implicit characteristics (like in Haskell). It's not really clear to me this is a win overall.I'm not opposed to strict languages, but IMO, I think if you want a strict language, you're better off just forgoing the whole thing, and using lambdas (thunks) where needed for small delays, and a good macro system to define control structures for everything else rather than trying to shoehorn laziness into your types or whatever. Random thunks you occasionally need aren't really the benefit. Being able to decouple definition from evaluation is.
As Go language shows, even having a name that matches one of the most common English words goes not hurt too much; people will come up with a searchable moniker (like "golang") pretty soon.
Again.
Technology is fair and there is a reason why haskell is not used apart from niche or academic projects. If you want to use jvm to deliver functionality for your users just a "boring" technology. No user, never, cared about the programming paradigm.
While haskell doesn't have as wide adoption as the top languages, your comment is not true. Even facebook uses haskell for fighting spam.
> If you want to use jvm to deliver functionality for your users just a "boring" technology
You're entitled to your preference, but I assume you'd say the same about about Clojure and Scala then, since, after all, everyone should just be using Java?
This is an old straw man. No one is trying to sell the language to users, but rather to developers; and developers look for toolchains that let them deliver features to users.