What to learn? Lisp or OCaml or...?

14,773

Solution 1

Neither Lisp nor OCaml is super far afield from what you already know. Here are four suggestions chosen partly for intrinsic interest and partly to stretch your horizons.

  • A logic programming language, probably Prolog. I haven't found good materials online, but the book The Art of Prolog by Sterling and Shapiro is excellent. The more basic textbook by Clocksin and Mellish is also good. The main point of interest is programming with relations, not functions.

  • A pure object-oriented language, either Smalltalk or Self. If you've only used hybrid object-oriented languages you'll be amazed how beautiful pure object-orientation can be. I've linked to the Squeak implementation of Smalltalk. I personally would recommend learning Smalltalk before tackling Self; there's a very large and active community and the software is well developed. Self stands on Smalltalk's shoulders and is an even more inspiring design, but the community is much smaller. For those who have access to the ACM Digital library I recommend the excellent talk by Dave Ungar at HOPL-III; the paper is also pretty good.

  • The Icon programming language has two great things going for it; a powerful and unusual evaluation model with implicit backtracking, and a user-extensible model of string processing that beats regular expressions all hollow. I'm sorry to say that Icon has never quite kept pace with the times, and of all my recommendations it is the least practical. In fact I fear the language is moribund. But it will stretch your mind almost as much as Haskell, and in wildly different directions. Icon is still very useful for string-processing tasks of modest size.

    You can read about Icon string processing in an article by Ralph Griswold from Computer Journal.

  • The Lua programming language is my last and least radical suggestion. Its interest is not so much in novel language features or paradigms but in the superb engineering of the language and its implementation. Lua occupies a number of niches, including scripting, gaming, string processing, and lightweight functional programming. But its main point of interest is its seamless integration with C, and to get the full benefit, you should bind a C library into Lua.

    The HOPL-III web site also contains an excellent talk and paper about Lua.

Solution 2

Both Common Lisp and Ocaml are certainly useful to learn. If you already know Haskell, CL might be the more different experience.

SBCL and Clozure CL are both very useful implementations of Common Lisp on Linux. (Overview about various implementations: Common Lisp survey.)

As a starting point I would recommend to use Peter Seibel's excellent book Practical Common Lisp, that is both available online and printed.

Community pointers are here: CLIKI.

Solution 3

Prolog may be what you are looking for.

Edit

The first commenter is right, my answer was pretty short and not very useful, so:

My preferred implementation is SWI-Prolog. I personally learned from Prolog Programming for Artificial Intelligence. It's style is pretty clear and it contains many examples, but I don't own any other book on logic programming (it's a shame, really :) so I have no basis for comparison.

Solution 4

Erlang is pretty interesting to learn because of its super efficient concurrency model, and the ease with which you can write distributed systems (for an example of this, CouchDB was written in Erlang). It's a dynamically typed functional language, but you can also write code in a procedural fashion. The tutorial I learned it with is called "Getting Started with Erlang", which covers just about every part of the language.

Solution 5

If you want to make use of your Java and functional programming knowledge, and you want to learn a Lisp, then try Clojure.

The implementation is free and cross-platform including Linux, because it runs on the JVM. Being a Lisp, it's different enough (in useful and wonderful ways) from most other languages to make things interesting. Some features such as immutable data structures, multimethods, metadata support, focus on safe concurrency, etc. are fairly novel compared to the languages you listed. Clojure is geared heavily toward being a practical and useful language rather than an academic one. It's a functional language but not "pure", which is arguably a good thing. You can also trivially make use of any Java library from within Clojure.

Clojure is a new language, so the only book out so far is Programming Clojure, but it's a pretty good one. There's also a wiki which may not be entirely up-to-date, because the language is still evolving very quickly. The mailing list and IRC channel are very friendly, welcoming places to ask questions. The official website is also a good resource, of course.

Share:
14,773
oggy
Author by

oggy

Updated on June 01, 2022

Comments

  • oggy
    oggy almost 2 years

    I already have a few languages under my belt (in a rough order of expertise): Python, C, C++, PHP, Javascript, Haskell, Java, MIPS, x86 assembler. But it's been almost 2 years since I learned a new one, and I'm starting to get the itch. I have a few criteria:

    1. Must (repeat: must) have a free Linux implementation
    2. Should be different from the languages I already know. In other words, it should have features that get me thinking about solving problems in a new way.
    3. Should have some potential for practical use. It doesn't need to be the next Java, but this rules out Brainf* and Shakespeare :) I don't really care how many job postings does it have, but real-world apps and libraries are a plus.
    4. Should have at least just enough free learning materials to get me started in it.

    I was thinking Lisp (CL? something else?) or OCaml. I already have some experience with functional languages with Haskell (yes I know that Lisp/OCaml are multi-paradigm). I'm not an expert - e.g. parts of code from Real World Haskell can still contort my brain, but I understand the basic concepts and some advanced ones (functors, monads).

    Which one to choose? Any other languages that I have overlooked? Also, could you please include some useful links to good books/tutorials etc.

  • Rainer Joswig
    Rainer Joswig almost 15 years
    you would get an upvote from me if you point to an implementation and an introductory book. Prolog is very underrated. Deserves more attention, IMHO.
  • oggy
    oggy almost 15 years
    Thanks, that's very informative!
  • dmitry_vk
    dmitry_vk almost 15 years
    I used SWI-Prolog (swi-prolog.org) on linux. It even has a GUI. One of modern use of Prolog is the Semantic Web.
  • MGOwen
    MGOwen almost 15 years
    If you've never developed with a .NET language and all that comes with it (Visual Studio 2008, the BCL, etc) this could be more of an eye-opener than any other option (though this of course violates you criterion #1)
  • Nathan Shively-Sanders
    Nathan Shively-Sanders almost 15 years
    Once you've gotten a feel for the language, focus on macros and the object system, since that's where Common Lisp differs most from the languages you already know. On Lisp (www.paulgraham.com/onlisp.html) is the best in-depth book on macros that I know of.
  • James Hugard
    James Hugard almost 15 years
    While IO is interesting, it isn't optimized very well. It is "pure objects all the way" like smalltalk, but I suspect this dispatcher is farily trivial; compare performance at the Language Shootout compared to, say, OCaml: shootout.alioth.debian.org/gp4/….
  • James Hugard
    James Hugard almost 15 years
    By the way, Haskel makes my brain hurt in bad ways. Haskel and Erlang (and Scheme?) are close-universe systems, in that everything must be created using libraries written in them. I've never been able to warm up to Lisp and children, so CL, Scheme, and Closure hold little interest. Prolog has its niche and following, but not useful for much of what I do. C# is just Java with syntax changes and a different class library; I like it, but not much here to help you think differently.
  • Rainer Joswig
    Rainer Joswig almost 15 years
    nah, Lisp has been designed for evolutionary and interactive development of symbolic software. So code is data and data is code, which goes beyond 'macros'. Learn to use declarative programming, interactive development, symbolic computation, etc. That's the core of Lisp. Macros are just a techniques in symbolic programming. Learn to work with a programmable programming language. 'On Lisp' is useful for hackers. Better are PAIP, AMOP, PCL, SICP, LisP, ... (acronyms for various Lisp books).
  • Yinda Yin
    Yinda Yin almost 15 years
    That's the beauty of F#. It is a fully functional language, but it provides unfettered access to the .NET framework, procedural/imperative language constructs, and interoperability with other .NET languages such as C#
  • nlucaroni
    nlucaroni almost 15 years
    ocaml also has the ability to interoperate with many other languages -- perl, python, java, and C (C is out of the box). I use ocaml to interface with clapack with great results. And you don't need to install Mono, bleh! --tried it for F# work on Fedora, tons of problems!
  • John Smith
    John Smith almost 15 years
    "Haskel and Erlang (and Scheme?) are close-universe systems, in that everything must be created using libraries written in them." You can link C libraries to Haskell code.
  • Sasha Chedygov
    Sasha Chedygov almost 15 years
    @James: Well, it's also a fairly new language; I'd expect it to become on par with others after a couple years in terms of performance. That said, I'd just rather use Smalltalk.
  • nlucaroni
    nlucaroni almost 15 years
    abababa22, mmm... thus you can link Haskell to ocaml through C... awesome. :)
  • David Thornley
    David Thornley almost 15 years
    It does have the great advantage of being extremely different, and it has some potential use. I found I didn't like it all that much, but I learned stuff along the way.
  • Kai
    Kai almost 15 years
    +1 I have almost all the same experience as the OP and learning Clojure was still an eye-opener. Other LISP implementations won't let you see things like Java interop and Clojure concurrency.
  • Attila Lendvai
    Attila Lendvai almost 15 years
    you can implement and seamlessly integrate prolog semantics into Lisp, so i still suggest Lisp. e.g. see screamer for an example of how to add/integrate backtracking to Common Lisp.
  • fishlips
    fishlips almost 15 years
    @Attila: Integrating Prolog semantics into Lisp is a nice possibility. I don't see how this implies that Oggy shall learn Common Lisp instead of Prolog.
  • Michael Ekstrand
    Michael Ekstrand almost 15 years
    Common Lisp will teach/allow you to think in abstractions at a level that I don't think I've seen in any other language. That and its unique object system are what I find most compelling about it as a language for brain-growing. Ocaml gives you static typing and tools to create nuanced descriptions of data state. One of its creators has put forth the statement "make illegal state unrepresentable", and working with OCaml (or SML or Haskell) lets you practice that. Working in that mindset is quite beneficial to programming thinking in general.
  • Jay
    Jay almost 15 years
    Other good free Prolog implementations are GNU Prolog and YAP (Yet Another Prolog). For a mix of Prolog, Haskell and Lisp, see Qi (but it has a very small community at this moment)
  • Totti
    Totti over 14 years
    F# does not run on Mono.
  • Totti
    Totti over 14 years
    Scala is the "truest form" of functional programming? It doesn't even have tail calls...
  • Yinda Yin
    Yinda Yin over 14 years
    @Jon, their homepage says it does. Are they wrong?
  • Marcus Downing
    Marcus Downing over 14 years
    So what? Whether the implementation happens to use tail calls is invisible to me, the ordinary working programmer.
  • Totti
    Totti over 14 years
    Yes, they are wrong. I have repeatedly tried to get F# to run under Mono over the years and it consistently dies with obscure internal error messages. Many basic features like tail calls are completely broken in Mono. I just tried again and it is still broken...
  • Totti
    Totti over 13 years
    "Neither Lisp nor OCaml is super far afield from what you already know". Both Lisp and OCaml have powerful macro systems and the OP has apparently never encountered that feature.
  • Totti
    Totti over 13 years
    So many common functional idioms are prone to causing stack overflows in Scala. Describing it as the "truest form" of functional programming is absurd. Scala is no more functional than C# 3.
  • Totti
    Totti over 13 years
    OCaml does not have type classes (but it does have a higher-order module system).
  • defhlt
    defhlt almost 12 years
    Can you please point me out where I can read about Icon string processing vs regex? I can't google it.
  • Norman Ramsey
    Norman Ramsey almost 12 years
    @ArtemIce linked an article. The phrase to google for is "Icon programming language".
  • BitTickler
    BitTickler over 3 years
    I looked into clojure for about an afternoon (after a few months of Common Lisp experience). In a purely explorative manner (no long studies, no books - just diving in) and I found the documentation is abundant but not very easy to use for solving the "next problem" you encounter in my explorative approach. One of the first things I tried was to call java functions, because that is its main selling point, right? I found no good tutorial on that, for example.
  • BitTickler
    BitTickler over 3 years
    If you have prior .net experience, I recommend learning F# instead of ocaml. A) because you can re-use your .net library knowledge and B) because it is as fast or faster than the compiled ocaml programs (which should NOT be the case but sadly is). Between an ML dialect or Common Lisp my recommendation is a resounding "Both". Common Lisp is deep - i.e. you can even change how it compiles on the fly. Its like C++ + LLVM all interactive and modifiable without lengthy rebuilds.