Live data from Hacker News

Basics of Haskell – Code and exercises

github.com

21–30 of 47 posts

Re: Basics of Haskell – Code and exercises

#21

Earlier quoted context omitted.

I did my interpreter class in Scheme in university. The main thing it taught me was I never wanted to use scheme (or lisp) and put me off of functional programming for many years. I re-did the interpreter from that class in C++ and it made insanely more sense to me than the scheme version. I could see where scheme was going and why it was a good fit but just hated it. That same professor taught our C++ class (while l…

We learned Scheme, Haskell, Prolog and Clips in one semester for Programming Paradigms course. I can still remember the homework for each programming language (this was 6 years ago): - Something with genetic algorithms in Scheme - 2048 implementation in Haskell - Searching in an infinite space in Prolog - Phutball in Clips Pretty dope if you ask me. :)

Glad it was good for you. It was not for me.

Re: Basics of Haskell – Code and exercises

#22

Earlier quoted context omitted.

We learned Scheme, Haskell, Prolog and Clips in one semester for Programming Paradigms course. I can still remember the homework for each programming language (this was 6 years ago): - Something with genetic algorithms in Scheme - 2048 implementation in Haskell - Searching in an infinite space in Prolog - Phutball in Clips Pretty dope if you ask me. :)

Glad it was good for you. It was not for me.

It's interesting to have intense negative reactions to a language. Could you give details what annoyed you with scheme ?

I hope it goes beside the syntax.

Re: Basics of Haskell – Code and exercises

#23
post #4

Writing interpreters in Haskell (which is what some of the lessons seem to be about) is a great way to learn the language. It naturally motivates recursion, algebraic data types, strong types, higher-order functions and later, when effects such as state and errors are needed, monads arise naturally. The best part? It takes a ridiculously small amount of code to do all that, maybe around a hundred or less. Languages w…

compiler, evaluator constructs should be the bottom of the next set of mainstream languages (possibly being born today by former haskell programmers?) imagine free monad lisp

Re: Basics of Haskell – Code and exercises

#25

Earlier quoted context omitted.

Glad it was good for you. It was not for me.

It's interesting to have intense negative reactions to a language. Could you give details what annoyed you with scheme ? I hope it goes beside the syntax.

Many people who like scheme and functional languages have an averse reaction to more procedural or OOP languages. It's interesting that people don't grok it can go the other way. But this is HN so I guess I'll explain.

A few things (and for context this was 1996).

With the class I disliked they were trying to teach me a language and a complex concept at the same time. In a 4 month semester, half of it was spent just getting basically proficient in the language. So instead of learning one concept I'm learning 2. We were essentially using scheme to build a interpreter for a simplified scheme. I understand why we were implementing scheme, it's one of the simplest languages to implement and maps well to many concepts in CS. this is actually why the game studio I worked at used it, not that it was the right language, in fact it's caused a lot of trouble and they have a lot of c/python like in the language now

Scheme seemed like a pretty useless language as well. The book for it listed (in the forward) out how amazing it was and showed all the amazing projects done with lisp-like languages. That list started with emacs and then the rest was academic things I'd never heard of, which seemed like a joke. If I recall scheme had some pretty weak language library functions at the time as well. Also at the time I cared about drawing triangles on the screen.

[I will lose points for this but it's my POV] I tend to find people who strongly like functional languages a bit insufferable, especially academics. I tend to learn by getting a real world project done, and I like tools that let you build real world things. I don't care anywhere near as much about form of the solution. . Functional languages seem to gel better with people who care about the beauty of a simple proof. I hate proofs. Also in much of the work I've done, the folks who really pushed for functional languages didn't really understand that most of their coworkers were juts not capable of understanding those languages or thinking that logically. There's a reason (imho) that they're not as popular of languages.

I have written stuff in these languages since then. I did work in the (gp reference) scripting language and on its implementation in the engine. This got me real features (like a mission in an AAA game, and features for my mission designers in the engine). This seemed useful to me.

I spent about 3 months trying to use Clojure to do a highly parallel data processing work. It seemed to map well to the problem. However it was insufferably slow, and with required type hinting was essentially complicated java (lost the benefit). I re-wrote it in C++ in about a week and brought the processing time from 15 minutes to 32 seconds by leveraging the deeper parts of the machine (buffers, disk cache, physical cores) which were not as available inside the abstraction.

So it also comes down to I haven't found a problem that maps well to something like scheme that I need to solve. When I do stuff with interpreters I just grab ANTLR and java/go/c++. This is more maintainable for everyone I work with.

Re: Basics of Haskell – Code and exercises

#26

Earlier quoted context omitted.

I think most programmers aren't actually coming from university currently.

I did my interpreter class in Scheme in university. The main thing it taught me was I never wanted to use scheme (or lisp) and put me off of functional programming for many years. I re-did the interpreter from that class in C++ and it made insanely more sense to me than the scheme version. I could see where scheme was going and why it was a good fit but just hated it. That same professor taught our C++ class (while l…

I did my interpreter/PLT class in OCaml and absolutely loved it. I yearn for things like ADTs and pattern matching in other languages I use now :'(

Another benefit (I guess the primary benefit) was that my interpreter programs written in OCaml ended up looking nearly identical to my proofs/definitions. Doing it imperatively would add a nasty layer of indirection.

Re: Basics of Haskell – Code and exercises

#27

I also recommend http://learnyouahaskell.com/ . Super cool and easy to understand

I think that a lot of people find that LYAH makes you feel like you're learning, but have difficulty actually applying/using the concepts. This is compounded by the lack of exercises.

I definitely agree with this review: https://bitemyapp.com/blog/functional-education/

> The material often bores learners and leaves them feeling like they're not "getting" it. This is because they're being "talked at" and demo'd to. They're not engaging with and solving problems.

Re: Basics of Haskell – Code and exercises

#28

Earlier quoted context omitted.

It's interesting to have intense negative reactions to a language. Could you give details what annoyed you with scheme ? I hope it goes beside the syntax.

Many people who like scheme and functional languages have an averse reaction to more procedural or OOP languages. It's interesting that people don't grok it can go the other way. But this is HN so I guess I'll explain. A few things (and for context this was 1996). With the class I disliked they were trying to teach me a language and a complex concept at the same time. In a 4 month semester, half of it was spent just…

You’re not alone. My brain works in steps, not proofs. If all code looked like Haskell and friends I doubt I’d ever have gotten into it in the first place.

[edit] algos, over proofs, would probably be a better way to put it.

Re: Basics of Haskell – Code and exercises

#29

Earlier quoted context omitted.

It's interesting to have intense negative reactions to a language. Could you give details what annoyed you with scheme ? I hope it goes beside the syntax.

Many people who like scheme and functional languages have an averse reaction to more procedural or OOP languages. It's interesting that people don't grok it can go the other way. But this is HN so I guess I'll explain. A few things (and for context this was 1996). With the class I disliked they were trying to teach me a language and a complex concept at the same time. In a 4 month semester, half of it was spent just…

I think your view’s totally reasonable. In my experience, the benefit of FP is To teach good program design: I’ve observed that functional programming languages encourage good practices that can be practiced in any language. For example: pushing I/O to the leaves of your program, dependency injection, eradicating global state, focus on functional interfaces.

These are patterns that you can do in any language, but functional languages kind of compel you to follow them. Many people first learned these patterns from FP, and carry them over to OOP, which they have to write at work.

I don’t know if there are many problems that are elegantly defined for FP, as you suggest. I think people just get comfortable in their cages. :)

Re: Basics of Haskell – Code and exercises

#30
post #4

Writing interpreters in Haskell (which is what some of the lessons seem to be about) is a great way to learn the language. It naturally motivates recursion, algebraic data types, strong types, higher-order functions and later, when effects such as state and errors are needed, monads arise naturally. The best part? It takes a ridiculously small amount of code to do all that, maybe around a hundred or less. Languages w…

Agreed! I've been trying to learn haskell for a long time, and this guy writes a json parser live, giving his intuition along the way. It's helped me immensely. https://www.youtube.com/watch?v=N9RUqGYuGfw
Post reply on HN