4 ms·
I can read and understand procedural and OOP, but I've never been able to make sense of Lisp or Haskell code. Like, not even the super simple examples which sh
by oarabbus_ 7y ago
I can read and understand procedural and OOP, but I've never been able to make sense of Lisp or Haskell code.
Like, not even the super simple examples which show you a side-by-side comparison.
- 6thaccount2 7y agoYea, but did you open a book on either language? I've trudged through a few Lisp books and tutorials and at least part of a Haskell book. You're right that syntax-wise they're very different than Python & Java, but the simple examples aren't hard once you learn more. Granted, I can't write even moderately advanced Haskell code, but quick-sort and some list comprehension code shown in "Learn you a Haskell" is pretty straightforward. "Real World Haskell" is also not too bad (at least the first few chapters). If you're even aware of Lisp & Haskell, you'll be able to pick them up at least at a superficial level with a little effort. Lisp is just weird due to the parentheses and the pre-fix notation, but the principles are very simple and allow you to directly manipulate the syntax tree as there is no difference between code and data. For example the simple lisp expression (+ 2 2) returns 4. What about (* 2 (+ 2 2))? The inner expression returns 4 and that is passed to the multiplication operator with 2: (* 2 (+ 2 2))###### (* 2 (4))###### (* 2 4)###### 8###### Edit: I have no idea how to format things on HN, so I out six "#" to represent a new line. Btw...David Touretsky's Common Lisp book is extremely high level and approachable. My biggest issue with many lisps is that installing and learning the tooling (Ex: Emacs) is a huge pain. I'd recommend you start with Racket as it is like Python in that it comes with a simple IDE, so you can focus on the language and not the tooling. Racket also has a lot of libraries for a niche language.
- andredz 7y ago(* 2 (+ 2 2)) (* 2 (4)) (* 2 4) 8
- 6thaccount2 7y agoThank you good soul!
- andredz 7y agoYou are welcome. Here's how to format comments: https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc
- proverbialbunny 7y agoIf you're looking to learn more FP, may I recommend SICP? https://github.com/sarabander/sicp https://github.com/sarabander/sicp If you google around you'll find it highly regarded. After the first chapter or two you can move away from working in the trenches and work on a more abstract level. The concepts are what make FP shine, and once you know them, you can bring those concepts into many OOP languages to your advantage.