Hacker News new | ask | show | jobs
by dickler 4708 days ago
There's little reason to use python instead of haskell these days.

- compiled code, fast

- cleaner, nicer, conciser syntax

- type safety built in

- pattern matching

- numpy equivalents are now available

- purity (see John Carmack talking about how it helps when codebases get large)

To switch from python to haskell easily within minutes, realize that a python function is simply do notation in haskell. So replace assignment (=) with arrow (<-) and write with "func v1 v2 = do".

Then pure functions are those without do and no assignment written lisp/scheme style. "$" means you can get rid of the parentheses.

After that, declaring types is equivalent to expressing how syntax tree can be written. You can use these to plan out how you attack your problem and then let compiler help you when writing out your functions. You could even just write out types and outsource the function writing to someone else (similar to your oo architects can parcel out code writing).

So, all python, golang, and ruby programmers - you really should check out haskell and realize it's superiority. They've taken your niche.

(If anyone wants to pay me to code in haskell, send me an email at haskellpostgresprogrammer@gmail.com, looking for telecommute work)

3 comments

It's a completely different language with different goals. It's like you said "there's little reason to eat eggs instead of drinking wine these days." Python was expressly NOT intended to be a compiled language with heavy emphasis on type safety.
That sounds plausible on paper, but as a matter of practical fact when I want to get a job done in a hurry and I try to do it in Haskell I get treated to the challenge of solving a series of puzzles in type theory, whereas when I try to do it in Python I just write code and it works, so while I agree Haskell is an interesting and elegant language, when what I care about is accomplishing a result rather than the mechanics of the language, I reach for Python.
It is very nice and I would agree with you. I had a lot of problems interacting with the IO monads in the beginning though, and the type system in a production environment is a lot more intricate than what most of the literature purports ;).. Other than that it was pretty easy to start writing code without knowing much.