Live data from Hacker News

Becoming Productive in Haskell

mechanical-elephant.com

161–170 of 213 posts

Re: Becoming Productive in Haskell

#161

Earlier quoted context omitted.

If you have an array that fills a significant fraction of your memory (say, tens of Gigabytes), you don't have another choice but to use mutation (Haskell doesn't support that). While quite fast, it is not in the league of low level programming languages. If you need ridiculous speeds, you don't have another choice but to use C, C++ or Fortran. Python has a lot of very useful modules. If I can solve my problem with b…

i write incredibly mutation heavy code in haskell on a nearly daily basis. I've even added compiler support for doing hardware prefetch to the most recent version of ghc https://downloads.haskell.org/~ghc/7.10.1/docs/html/librarie... there are many lovely mutable data structuers in haskell http://hackage.haskell.org/package/vector-0.5/docs/Data-Vect... is one for unboxed C-struct style arrays, http://hackage.haskell.…

Sorry. I seriously didn't know. I only ever used the immutable parts of Haskell. Thanks for the correction.

Re: Becoming Productive in Haskell

#162

Scripting languages try to seduce you to just fiddle around until the output looks like something you want. While that quickly gives you some results, I think it's a huge roadblock in the mid- to longterm. Especially when programmers are only familiar with "easy" scripting languages, there are rarely insights about the general approach to the problem until the project already grew to become an abomination. While fidd…

Ability to fiddle isn't tied to static or dynamic programming, it's just every static language platform I've seen including The Haskell Platform neglects making it easier to fiddle.

When trying to build complex software in Haskell, I find myself spending a lot of time commenting/uncommenting swaths of code, just so I can get part of a algorithm to load in GHCi. It sucks. What I wish would happen is GHCi allowed me to load just the things that type check, and skip the rest, so I can fiddle. This is definitely possible. Not compiling is great for production, but not while developing.

Software is built in pieces, if I'm working on one piece, another statically unrelated piece shouldn't prevent me from working. In this regard Haskell GHCi (and many static languages), makes developing more complex than dynamic languages, but again it's not intrinsic.

I also wish when I run my tests, it listed all the type errors, as well as run tests on the code that do type check. Having more safety mechanism in Haskell helps with writing correct code, but compiling doesn't mean the code works. Automated testing is still more useful for writing software that works. Haskell isn't as safe as many people think [1].

    sort a = a ++ a  -- it compiles, so it must sort
[1] http://hackage.haskell.org/package/base-4.8.0.0/docs/Prelude...

Re: Becoming Productive in Haskell

#163
post #162

Scripting languages try to seduce you to just fiddle around until the output looks like something you want. While that quickly gives you some results, I think it's a huge roadblock in the mid- to longterm. Especially when programmers are only familiar with "easy" scripting languages, there are rarely insights about the general approach to the problem until the project already grew to become an abomination. While fidd…

Ability to fiddle isn't tied to static or dynamic programming, it's just every static language platform I've seen including The Haskell Platform neglects making it easier to fiddle. When trying to build complex software in Haskell, I find myself spending a lot of time commenting/uncommenting swaths of code, just so I can get part of a algorithm to load in GHCi. It sucks. What I wish would happen is GHCi allowed me to…

> What I wish would happen is GHCi allowed me to load just the things that type check

Use `-fdefer-type-errors` (should work with both GHC and GHCi), all errors become warnings, and if you try to use a function which was compiled with an error, you get a runtime error.

Re: Becoming Productive in Haskell

#164
post #139

Could you guys explain to me what Haskell would be mostly useful for. For instance, can it be used to make a web app backend or a GUI app? Or is it mostly for mathematical calculations and such. I tried to pick up Haskell once, but I guess I just couldn't get it. I mean, I got the core concepts, wrote a bunch of starter code, like prime checker and the like. But after going through several tutorial chapters, I still…

Haskell is useful for just about everything that Python, Ruby, Java, C#, etc are useful for. For the last 5 years my day job has been writing Haskell. Most of that has been web apps, but there have been other things like machine learning applications, a nice command-line interface to Amazon Redshift, an automated ETL tool for a large production application, and most recently a complex interactive browser app (using GHCJS to compile Haskell to Javascript).

Re: Becoming Productive in Haskell

#165
post #138
post #55

Earlier quoted context omitted.

I've personally found it very easy to handle "exceptions" in Haskell. Partial answers feel "bad" in Haskell because all the core functionality is clean enough to not need them, but on the other hand that makes for some of the best tools around for dealing with partiality.

> Partial answers feel "bad" in Haskell because all the core functionality is clean enough to not need them Not to need them, sure, but not not to use them. (I swear that's the right number of 'not's.) I don't understand why something like Neil Mitchell's `Safe` isn't just the way that things are done by default.

Even better than safe, all this has been consolidated very nicely in the errors package.

Re: Becoming Productive in Haskell

#166
post #147

Earlier quoted context omitted.

> Could you guys explain to me what Haskell would be mostly useful for. For instance, can it be used to make a web app backend or a GUI app? Yes, and yes. > Also, can you recommend a good book or resource that uses real world examples to teach Haskell? The obvious thing to recommend here is Real World Haskell [0], which directly addresses some of the areas you raise. Also, Write Yourself a Scheme in 48 Hours [1] is m…

Thanks, I think Real World Haskell was the resource I was looking for. I'll try to get through it in the next month and see how it goes.

It's worth noting that it was written quite a while ago, so while it's still a great book, there are portions that have a wee bit of code rot. In the event that one of those sections trips you up, I'd encourage you to visit the #haskell IRC channel!

Re: Becoming Productive in Haskell

#167
post #7

Nice article. I find FP incredibly elegant and I'd like to learn Haskell, but every time I search, there are never any jobs in it, so it seems like Scala is the better choice for where I live... Speaking of which, I found "Functional Programming in Scala" excellent for teaching someone with an imperative background how to "think functionally". Monads are explained in an easy to understand way. I can imagine that with…

If you wait for the jobs to come, you'll be late to the party. Very few people will want to hire someone who doesn't know Haskell for a Haskell development position. Learn it now so you'll be up to speed when more jobs start appearing. Or better yet, learn it and then create the Haskell jobs yourself.

Your last sentence is basically what we did. It's hard, but it's doable.

Re: Becoming Productive in Haskell

#168

Earlier quoted context omitted.

The parenthetical statement by ffn, although a bit tongue-in-cheek, is largely "men want sex more than women." Which, judging by the statistical consumption of porn across the world, is resoundingly true. I get your point about not perpetuating gender stereotypes, but the whole spirit of that movement (feminism, equality, what have you) is to not perpetuate gender stereotype types where they are irrelevant - as in wh…

so men want sex more than women because of some statistic that you didn't even bother to fully pull out of your ass? nice

Here's a study (scroll to page 6 for the table):

http://www.hawaii.edu/hivandaids/Gender_Differences_in_Porno...

Now combine that with some data from Christian Rudder's Dataclysm (just a link to a info-pic + summary article here):

http://www.bloomberg.com/bw/articles/2014-09-04/mining-okcup...

Men consume a lot more porn than women and hunt for casual sex a lot more than women. Actually, if you weren't so rustled, you could've just google'd "consumption of porn by gender" and gotten a lot more results than the two I put up there. But yeah, way to not walk away and accept that someone else has a valid point, and feel free to continue loudly cry "no, your stats suck", "give more sources", while hiding behind a throw-away account and throwing out sensational accusations of "sexism!" for the sake of accruing karma on your main one.

Re: Becoming Productive in Haskell

#169

Earlier quoted context omitted.

so men want sex more than women because of some statistic that you didn't even bother to fully pull out of your ass? nice

Here's a study (scroll to page 6 for the table): http://www.hawaii.edu/hivandaids/Gender_Differences_in_Porno... Now combine that with some data from Christian Rudder's Dataclysm (just a link to a info-pic + summary article here): http://www.bloomberg.com/bw/articles/2014-09-04/mining-okcup... Men consume a lot more porn than women and hunt for casual sex a lot more than women. Actually, if you weren't so rustled, yo…

For the record, that really isn't me. I didn't think your comment deserved a response so I ignored it. I don't have a way to prove it to you. Sorry.

Re: Becoming Productive in Haskell

#170
post #137

Earlier quoted context omitted.

No. The debugging time, refactor/rewrite time of writing in scripting languages is substantially longer, harder work, and distinctly unpleasant compared to just thinking and using good tools to do it right in Haskell. In Haskell, I'll often have a problem and just stare at my laptop and think for an hour. Then write a dozen lines of simple, straightforward code. The code is easy to test, and the problem is marked as…

Pausing for an hour to think about and understand your problem is important in any language. Probably more important than testing honestly.

Indeed. I'd argue that strongly typed languages represent many problems in the type system, often letting you know very quickly that you'll have to spend that hour.
Post reply on HN