开发者

Clojure for a lisp illiterate [closed]

开发者 https://www.devze.com 2023-01-01 05:35 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
开发者_运维问答

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

I am a lifelong object-oriented programmer. My job is primarily java development, but I have experience in a number of languages. Ruby gave me my first real taste of functional programming. I loved the features Ruby borrowed from the functional paradigm such as closures and continuations. Eventually, I graduated to Scala. This has been a great way to gradually learn to approach non-trivial problems in a functional manner.

Now I am interested in Clojure. I know all the sexy features that make it enticing (software transactional memory, macros, etc.), but I just can't get used to "thinking in lisp". I've seen Rich Hickey's screencasts aimed at java programmers, but they are geared towards explaining language features and not approaching real world problems.

I am looking for any advice or resources which have made this transition easier for others.


Its now 11 months after I originally asked this question. I've just started a new project to help beginners make the transition to clojure. Its called 4clojure, and it challenges you to solve fill-in-the-blank style interactive problems.

  • 4Clojure.com


My first introduction to Lisp was: Paradigms of Artificial Intelligence Programming of Peter Norvig. It is a very readable and gentle introduction to many features of Common Lisp and functional programming concepts.

Starting directly with some Clojure books could be preferable for you, because there are several differences between Common Lisp and Clojure which may become confusing if you're trying to learn both at the same time.

At the same time, try to get hands on experience messing with the Clojure REPL, doing some exercises like Project Euler which you then can contrast with other Clojure and imperative Java solutions.

Furthermore, if you have any questions on Clojure programming and idiomatic style, do not hesitate to discuss your code with other Clojurians. There are several options to do this, such as: Clojure on Google Groups, the #clojure IRC channel on Freenode, Twitter via hashtag #clojure, and of course here on Stackoverflow!


Going right to Clojure from OOP, I'd only recommend the excellent Programming Clojure by Stuart Halloway.

I love it, and it does a great job of covering a lot of Clojure and a fair bit of funcational programming in the process.

The Little Schemer and SICP are great, but they're not so relevant for Clojure, if that is what you want to learn.


I'd recommend getting the MEAP version of The Joy of Clojure. I have it, and right now the MEAP offers a total of 12 chapters. So far, it's by far the best book I've ever read on a programming language. Those 12 chapter are plenty to get you started with Clojure, all the way up to some advanced topics. The current MEAP (which gets updates with new chapters quite frequently) combined with the ociweb Clojure tutorial, stackoverflow.com, and the #clojure IRC channel on freenode, I think you'll be fine.

While I agree that Programming Clojure is a great introduction to Clojure, and does a very good job, we can't deny the fact that it gets more and more outdated every week. You have to keep in mind that Programming Clojure was written for Clojure 1.0. Right now, we are fast approaching the release of Clojure 1.2. For example, with the inclusion of defrecord, structs are going to be obsolete.


I really like Brian Twill's series of Clojure videos on youtube as a painless introduction to some of clojure's ideas. They don't assume any great knowledge of Lisp or functional programming languages.

As far as books go, I agree with Isaac that Programming Clojure is an excellent resource. You might also consider some forthcoming books on clojure:

The Joy of Clojure

Clojure in Action

Both have early access available online if you buy now. Also I think both have discounts available -- try looking on clojure.org.

The Lisp books that Peter and Norman mention are probably good choices (I like SICP, but haven't read the others). But the differences in syntax with Clojure might get a bit frustrating if you're just starting out. For that reason I recommend starting with Clojure-specific books at the beginning.

(Edited to fix link.)


For a raw beginner, How to Design Programs will get you thinking like a Lisper. If you get impatient, go faster :-) Another good book is On Lisp by Paul Graham, which as a bonus is now free online.

I don't care for Structure and Interpretation of Computer Programs; if you know Lisp or Scheme, already, it's a great intellectual tour de force and very satisfying—but my students and I have not found it a good book to learn from. The Little Schemer has lots of good information if you can stomach its dialectical organization and cutesie-pie style. I can't.


All the answers so far are great. I would add:

  • Purely Functional Retrogames is an excellent series on how to design old school video games in a functional, side effect free manner. If you go through this and grasp how to write Pac-Man without side effects, then you will have gone a long way to inducing the mindset necessary to solve many/most other problems functionally.
  • Halloway's Programming Clojure is the best general introduction to Clojure, and gives some idea of how to think about problems in a functional rather than object-oriented way, particularly the snake game example.
  • Seibel's Practical Common Lisp is an excellent practical guide to solving real-world problems functionally, such as building a database. Though written for CL rather than Clojure, which allows mutable data, the concepts carry over without much modification, and the full text is available online for free from the author's website. Worth at least a glance.


If you're looking for an introduction to "Lispy thinking", I'd recommend Practical Common Lisp . It's a good read and IMHO perfect for seasoned programmers coming from a non-lisp background.

The downside is that it targets Common Lisp, not Clojure; the main reason being that Clojure is much more functional in its approach. You'll probably want a Clojure specific book too.

0

精彩评论

暂无评论...
验证码 换一张
取 消