7

Ask HN: Why would anyone choose Haskell to develop applications?

 2 years ago
source link: https://news.ycombinator.com/item?id=30577911
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Ask HN: Why would anyone choose Haskell to develop applications?

Ask HN: Why would anyone choose Haskell to develop applications? 32 points by jamesdco 1 hour ago | hide | past | favorite | 25 comments Why would anyone choose Haskell to develop applications? Does it offer any actual practical benefits over other languages?

When I asked my current employer why they chose it, they simply responded that it attracts the "right" people. From a business perspective, any language is arbitrary. What matters is having clever people around to solve problems.
s.gif
I think that's more true in the negative sense. It's not that it attracts the "right" people, it's that it repels the "wrong" people. There plenty of clever efficient devs working in Java or JS but they're surrounded by a sea of mediocrity.

And since the interview process is imprecise the point of being broken, it's very useful to attract the right people in the first place.

s.gif
Maybe the same applies to building a RESTful API and choosing Go instead of js :)
s.gif
You will get slightly better people but still the wrong people. JS is almost never the right tool for the job, Go is occasionally the right tool for the job, mainly if you need to write something that moves bytes from one fd to another without much in the way of business logic.

TBH if you are building something boring you should just use Spring w/Java or Kotlin. This will attract pragmatists that ship code that works in ways that anyone else that works with these tools will instantly understand also. In a way it attracts mediocrity but in the good way where you get nice standard code that can be maintained cheaply for a long time and it's easy to hire for the skillset.

If you are prototyping extremely quickly then maybe Ruby on Rails might be the right tool for the job (and thus attract the right kind of people).

Go attracts mediocrity and not in a good way, it also actively repels the "right " people if you want to hire for highest intellectual horsepower for a given budget.

In the same category as Haskell you also have OCaml, the Lisps (Clojure in particular) and Erlang all of which will yield you lots of the "right" people. None of these people will be cheap but none of the good people that write the other languages are cheap either, however there is a strong correlation between interest and proficiency in these languages and high intellectual horsepower - hence "right" in this context.

s.gif
Go doesn’t attract mediocrity it attracts pragmatism.

I worked on a Scala team for a couple years, had a lot of devs that were “smart”, problem was they wrote really fancy code no one could understand.

I then switched to a Go team and it was night and day. I was wildly more productive and the people in the community were not lacking intelligence.

Go prioritizes community, it believes that “us” is more impactful than “me”. This is its biggest strength, and is often lost on people looking in from the outside.

s.gif
> If you are prototyping extremely quickly then maybe Ruby on Rails might be the right tool for the job (and thus attract the right kind of people).

I am puzzled by this because my early experience of Ruby On Rails (and I mean early -- 2005) is that every Rails developer I encountered knew much less than they were letting on.

> Go attracts mediocrity and not in a good way, it also actively repels the "right " people if you want to hire for highest intellectual horsepower for a given budget.

I really think this needs backing up with at the very least a juicy horror story! I'm not convinced by this at all.

s.gif
This can cut both ways.

Yes, if you choose Haskell, a Lisp, or something like Erlang, you can get smarter/better devs. But the flip side of that is that the types of people who tend to gravitate toward those languages are often more interested in programming for it's own sake and not the domain they're working in. So you get things like people burning hours writing their own libraries and endless tinkering with programming minutiae instead of getting sh* done.

On the other hand, a mediocre programmer who taught themselves Python, may not be winning any programming competitions, but will often have significant domain expertise and a bias toward getting things done.

You need to ask yourself whether or not the stuff you're working on really demands the absolute best programmers (it very rarely does). If it does, go with the Erlang/Haskell/Lisp crew, otherwise go with the Python/JS/Go crew.

s.gif
This is where I differ. I think the Python/JS/Go crew gets you stuff that is built poorly and becomes expensive to maintain.

I much prefer the JVM and ASP.NET crew because they are 9-5 programmers, their tools aren't constantly changing so for the most part they only need to spend time actually doing work. No fighting with package managers, no updating the latest framework and solving backwards incompatibilities for weeks, no random runtime bugs and shitty native extensions that cause said runtime bugs or memory leaks outside of runtime level heap accounting, etc.

Boring tech is the way to go for 99% of problems and to me JS/Go/Python don't qualify because they break too much and require too many workarounds for too many problems. I want my programmers to be thinking about how to solve my business problem, not problems with their tools.

s.gif
> I think the Python/JS/Go crew

Genuine question: are these people a crew? I doubt very much each individual constituency in that trio would think so.

JS and Go are really very different things with different mindsets. Python vs JS likewise.

s.gif
No, it just means the people that tend to be attracted to these types of languages. Easy to get started languages that hide much of the inner workings from you as a dev.
s.gif
"JS is almost never the right tool for the job"

Except, you know, in the browser...

s.gif
Yeah I didn’t get that part, JS is one of the most used languages because of the browser
It is very easy to build languages, dsls and compilers in. A lot of language writers at least build a first version or prototype in it. I like it because in my head, all programming is just moving data from one type to another and although this is possible in any language, Haskell and also Idris 2 fit my mental model well. Unfortunately when I have to work with other humans, Haskell never makes the cut, so I only built side projects in it.
It's a pure functional language. You can do functional programming in many languages, but Haskell enforces it by design. From what I've seen of the type system, it's quite nice as well.

Functional programming allows a great deal of confidence in your code,

For your good old boring business software - ADTs and patter matching combo is, IMO, the most visible, practical benefit over "traditional" languages used in the industry. And something I miss the most when not writing in Haskell.
If we focus only on the benefits, her are two basic but distinguishing features that make it a very pleasant and productive language in my experience: - knowing through the type systems that a function’s result depends only on its parameters makes testing more reliable - the syntax and type inference makes it possible to write down many algorithms extremely tersely, which is also helpful in getting the implementation right
s.gif
This also provides maintenance benefits. It's not _quite_ that if it compiles (after you make whatever change you wanted to) that it's correct, but it's not far off either.
s.gif
> but it's not far off either.

How "far "off" is it, in terms of correctness, compared to other, more conventional statically typed languages like C++ or Java or Rust?

s.gif
Sadly, there is not an obvious metric through which this can be answered, but the type system is much more advanced than that of C++ or Java, and as such you can be more precise about the inputs and outputs of a piece of code.

As long as take advantage of the type system, the compiler tends to permit far fewer programs that compile, but do the wrong thing, than is the case in C++/Java. You will notice you spend more time editing code to make it compile, and less time debugging code that does compile.

Rust should not be grouped with C++ or Java, as its type system is essentially that of Haskell with the addition of lifetimes. The developer experience is similar in that you tend to spend more time getting code to compile, and less time debugging.

I once used it for mathematical code in my thesis. Basically I had everything written with C++ code but it just didn't work. Also tried Matlab but I'm just not made to use it efficiently, so I tried Haskell for interfacing with the GNU GSL library. In the end I changed back to C++ but it helped me a great deal to understand what I was doing and to clean things up. Some nice features include obviously dealing only with constant expressions and being forced to write only mathematical transformations. A bit unexpected was that you can actually swap variable declarations, declaration order doesn't seem to matter much. Quite a big pain relieve when dealing with a lot of variables.

Actually ImplicitCAD is written in Haskell which implements CSG (very tricky to efficiently implement)

Because some people know it, like it, and because they can. It’s like asking why Facebook still uses PHP. But also, every language has something it’s particularly skilled at. There are still business applications out there in COBOL because there are some features hard to replicate in modern ones. No language ever dies.
s.gif
I suspect PHP's popularity has really only waned in the US. Just my very anecdotal observations.
Something Haskell programmers commonly experience is that their programs typically work the first time they compile, due to the type system. I was skeptical of this but I've experienced it myself too -- it's kind of fun! What this means is that you spent most of your time thinking about how to express your code elegantly in the type system, but once you do it usually just works. That's a huge practical benefit you don't see in other languages without such an expressive type system.
s.gif Applications are open for YC Summer 2022
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search:

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK