DEV Community

Switching to Haskell

Trisha on February 09, 2020

Haskell is a great programming language that can be used in any domain. Ideally, it is best suited for business and logic relating to data analysis...
Collapse
 
wrldwzrd89 profile image
Eric Ahnell

Mutable state is the bane of consistency - that is true! Haskell keeps it to a minimum? Then I should learn too... thanks, Trisha!

Collapse
 
rodiongork profile image
Rodion Gorkovenko

You may have happier time trying Erlang. It also has no variables :) so no mutable state. Nor loops. Very easy. But unlike Haskell it is not strictly typed so it is much easier to start coding without being swamped by monads.

Collapse
 
gabrielfallen profile image
Alexander Chichigin

You might not be completely serious, but I feel compelled to say you're not doing justice to both Erlang and Haskell. :)

One (major) thing about Erlang is it models mutable state with process' state ("state on parameters" of recursive functions). Another thing about Erlang is it has very much traditional mutable state in the form of ETS tables which are employed very extensively in real production code (and I don't consider this a "bad thing").

And as long as you don't use state in Erlang in either form, you can do exactly the same in pretty much the same way in Haskell without monads anywhere remotely near.

Besides, strictly speaking Erlang is strictly typed, albeit dynamically. Dynamic typing is a minor shortcoming which is alleviated by Dializer. :)

And finally, using monads is simple! Even writing monads isn't hard though very rarely needed. Lenses is where all the fun begins and never ends! :D

Thread Thread
 
rodiongork profile image
Rodion Gorkovenko

Alexander, Hi!

I think I'm too stupid to understand most of the things you've mentioned :)

But I totally agree! It's hard for me to judge about either as I was not in any industrial project using Haskell - and the one with Erlang was too specific in many ways :)

is alleviated by Dializer.

I suspect it is about the tool "dialyzer"? I found this one and tried to make my colleagues using it. That was hard, mostly because dialyzer is still in far not excellent form. And as the language seems to be slowly dying, regretfully, no much hope it will be seriously improved.

And finally, using monads is simple!

Ah, all proponents of Haskell / Scala insist on something like this. Probably this simplicity is why so many articles and videos are trying their best to "explain monads in 5 minutes", generally failing to impress :)

Lenses is where all the fun begins and never ends!

I'd like to see what they will invent by next 10 years :)

Thread Thread
 
gabrielfallen profile image
Alexander Chichigin

I suspect it is about the tool "dialyzer"?

Yep, that's what I meant. :)
Last time I wrote in Erlang Dialyzer checking was built-in into VS Code plugin so I need no extra effort to reap its benefits. 🤷

Probably this simplicity is why so many articles and videos are trying their best to "explain monads in 5 minutes"

Actually you're exactly up to the point. :) People write the most about what's simple: "Write yourself a blog engine in PHP/RoR/Django", "Make an animation with CSS3", "Build a game with Unity". How many tutorials "write an intrusive concurrent AVL-tree in C" do you know? 😄

I'd like to see what they will invent by next 10 years

Unfortunately doesn't seem like much, Haskell is close to a "saturation point". The two biggest next additions to the Haskell are Linear Types and full-blown Dependent Types. The former were invented more than 30 years ago (at least Linear Logic was), the latter were invented almost 50 years ago and first implemented more than 30 years ago.

It's just most of programming languages still fail to improve upon Lisp that was invented more than 60 years ago... 😄

Thread Thread
 
rodiongork profile image
Rodion Gorkovenko

most of programming languages still fail to improve upon Lisp

Well, that's question what we define by "improvement". In the sense of business software development they improved thousand times. Not only about languages themselves, but about infrastructure around them.

Even Lisp split to zounds branches, warring to be more functional or more practical or both :)

However in the sense of the language structure, system of typization etc really progress is not impressive.

BTW, if you are curious about Haskell position - the company I mentioned is "Biocad". Check their HH - they are nice fellows and would be glad at least, I think. Though probably you know them already since Haskell world is tight enough :)

Collapse
 
rodiongork profile image
Rodion Gorkovenko

Hi Trisha!

Thanks for that gentle introduction :)

I hope you won't mind my sharing my experience with the language?

In my city (5mln population) there are no more than 3 companies hiring Haskell developers. I tried to apply to one of them. They gave me offline test project. I struggled with it for about a week and have done something. I succeeded (it was a kind of web-application which stores chemical components and their relations in the graph database).

However after it:

  • they told they will prefer to search for person "with ready industrial experience in Haskell" (very funny, provided there are almost no people or companies using it)
  • I myself decided language is not worth further trying.

Why I thought so? As you told - language is quite difficult for beginner.

Firstly - it is overburdened with abstract notions of type and maniacal preservation of type purity. That's true that strict typing simplifies error prevention in large projects - but this shouldn't come at price of pain when trying to do something which is easier with types relaxed (dealing with Json for example).

Secondly - despite all it is still not quite mature. Many string types just hint how bad things are. There is some choice of tools for building, testing, linting - but far not great.

Thirdly - it just doesn't add anything interesting. Compare with Erlang - which has threads out of the box and messages between them.

So my conclusion - just strictest typing doesn't make good language. Go will be much more popular in this field. And just boasting the language is pure functional - it isn't worth much, because far not all programming tasks well suit functional design.

Collapse
 
gabrielfallen profile image
Alexander Chichigin

First of all, let me explicitly state that I'm not trying to make fun of you in any way! As far as I can tell you're a mature experienced developer and I fully respect that. But I strongly disagree with pretty much all the statements you've made in the comment, so for the sake of alternative view for other readers I'll comment on them. Please forgive me if I will sound harsh. No offence intended!

they told they will prefer to search for person "with ready industrial experience in Haskell" (very funny, provided there are almost no people or companies using it)

Let me restate it: you tried to apply for a middle/senior position without prior experience with the language at all and you were surprised to get a reject? Frankly speaking I don't know any company that will hire for a middle/senior position without industrial experience in the language, and if there are such companies I'm very suspicious about them.

Disclaimer: I'm a "person with ready industrial experience in Haskell" now working as a C# developer.

Then your critique of Haskell is very subjective at least and sometimes just plain wrong.

Firstly - it is overburdened with abstract notions

That's an example of a subjective judgment. And a relative one in addition. The same could be said about Design Patterns in Java and C#, it's a common place to complain about "abstract factory of abstract factories". Or obscurities of Dependency Injection frameworks and so on.

but this shouldn't come at price of pain when trying to do something which is easier with types relaxed (dealing with Json for example)

And dealing with JSON could be done in Haskell easily with precisely "types relaxed" as exemplified in a great blog post.

Secondly - despite all it is still not quite mature. Many string types just hint how bad things are.

If that's a measure of maturity, then what several kinds of equality comparisons in JavaScript and PHP tell us about these languages?! Is the fact that plain string concatenation is very inefficient in Java and C# and one should reach for a StringBuilder a sign of immaturity of these languages?

Or should we compare with Erlang where there's even no libraries for comfortably working with Unicode strings? ;)

For Haskell beginners reading this: String in Haskell isn't actual string data type, that's just for educational purposes. ByteStrings and Text libraries cover both actual use cases for the production use of strings very efficiently (better than in many other languages).

Thirdly - it just doesn't add anything interesting. Compare with Erlang - which has threads out of the box and messages between them.

What about Software Transactional Memory? Not mentioning Parallel Strategies for very high-level program parallelism. Though my favourite is Lenses which gives insanely powerful and practical data query and transformation tools way beyond imaginable in any other language (save for PureScript).

So my conclusion would be that Blub Paradox is very much a thing still. :)

Again, I'm not trying to paint you stupid or something. But I do think you spent too little time and effort with Haskell, learned too little and jumped to very far-fetching but unjustified conclusions in this case. And I've tried to justify my claim with some arguments, that's all.

Collapse
 
rodiongork profile image
Rodion Gorkovenko

Please forgive me if I will sound harsh.

Oh, no problems about it :) You are pretty correct, it's better to have professional thoughts here!

you tried to apply for a middle/senior position without prior experience with the language at all and you were surprised to get a reject?

Honestly, I'm afraid you slightly misunderstand situation :) See, these fellows knew well I have no experience with Haskell, right? Nevertheless they invited me to interview, spent their time etc... Then offered the test project, spent time on reviewing it again etc...

So you may suspect they don't have a lot of choice :)

That is general problem of every team which chooses to use some rare language. I was previously hired as senior erlang dev coming from java/bigdata world.

Frankly speaking I don't know any company that will hire for a middle/senior position without industrial experience in the language, and if there are such companies I'm very suspicious about them.

Frankly speaking I'm suspicious at all about companies which choose the language for which they know it would be hard to hire developers. :)

The same could be said about Design Patterns in Java and C#

Holy truth. The lists of design patterns are also a good example of trying to invent more abstraction than we usually need. You may have noticed there are some patterns known to almost everyone - but full lists may include quite whimsical and unheard of things.

It's the same with UML for example. At least few years ago people were praising it highly, but over time it occurs that no one really cares to learn its full extent because others don't learn it too. Hard to explain things with clever diagrams which others don't understand due to their cleverness.

If that's a measure of maturity, then what several kinds of equality comparisons in JavaScript and PHP tell us about these languages?!

No objection to that again! You are pretty correct :) But we expect Haskell to be different from those, right?

To clarify: I don't object Haskell "as it was conceived". I first heard of it (and even tried some windows version) probably about 20 years ago. It seemed queer but cool.

However I don't expect good outcome from attempts to marry Haskell with needs and purposes of industrial software development. They just have different goals.

I do think you spent too little time and effort with Haskell, learned too little and jumped to very far-fetching but unjustified conclusions in this case.

That is less or more correct, I think :)

I just am trying to point out that programming languages nowadays don't live in their own universe. They need community to build libraries and tools. Community needs salaries, so needs business projects. If for some reason it is hard for language to win a lot of proponents - it becomes harder to evolve. So it is a thing to consider for language designers - how are we going to attract people.

Well about "own universe" it is not quite correct. There are languages created for amusement, or for some specific study. They don't need to rely on business, of course :)

Thread Thread
 
trishaganesh09 profile image
Trisha

Adding on to what you were saying about companies - Yes, technically speaking tech companies do hire people who know how to program and will benefit the company; however, it's more about the quality of work they can produce.

Like you said before, Haskell isn't a language most companies would choose to use when hiring their employees. They need people with more experience and passion. In addition to that, Haskell is pretty functional but I do agree that there are many other languages that are also beneficial.

According to my research, some programmers don't use Haskell, some used Haskell in the past, some still use Haskell and some programmers and never even heard of Haskell. So it depends on the ability as well as the strengths and weaknesses in every software engineer's career path.

Of course, not every programmer is at a high level of coding. One of the first programming languages I started learning was Python and I still use it for the same purposes as I used to.

By the way, Haskell isn't the language I code in. I do use it a lot for research and my data analysis work. But I use many other languages as amusement and for important obligations. I will admit I do use Haskell for fun seldom when I'm under ennui. Whenever I'm feeling lethargic I run Haskell programs on my laptop. Many Haskell programmers used to use GHCI to run Haskell programs, I use VSCode to run programs in other languages. I'm sometimes able to improve the program's performance. I used to do that a lot while I was self-teaching myself Haskell.

Although, I do appreciate your comment! Feel free to let me know what you think :)

Thread Thread
 
rodiongork profile image
Rodion Gorkovenko

Hi Trisha!

Could you by the way, in some future post, tell more about your work / research / interests as your comments leave us slightly bewildered and curious at the same time, because you pinpoint some important thoughts which, though supposedly simple, are sometimes so hard to explain to managers and leads... :)

I hope this doesn't sound impolite!

Thread Thread
 
trishaganesh09 profile image
Trisha

Not at all, I'd be happy to!

Collapse
 
nombrekeff profile image
Keff

Wow :o , what a language to start with, congrats for not becoming crazy!

Collapse
 
trishaganesh09 profile image
Trisha

lol I use others also

Collapse
 
macsikora profile image
Pragmatic Maciej

I would say I am not convinced by the arguments you provide 😉

Collapse
 
trishaganesh09 profile image
Trisha

XD

Collapse
 
trishaganesh09 profile image
Trisha

precisely