views:

1670

answers:

16

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.

+1  A: 

C# has a free implementation in Linux under the Mono project, and it arguably is a very marketable skill unless you're completely anti-Microsoft.

My favorite C# book is Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition.

If you're really want exotic, F# is an OCaml style language that runs on the .NET platform and mono, and is getting a lot of attention these days.

http://msdn.microsoft.com/en-us/fsharp/default.aspx

Books for F#:
http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=f%23

Robert Harvey
Thanks, but I'm more interesting in "different" than "marketable". I don't know C# but from what I've heard it's supposed to be an improved Java. So how does it score on my criterion #2?
oggy
Please see my edit.
Robert Harvey
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)
MGOwen
F# runs on Mono
Robert Harvey
F# does not run on Mono.
Jon Harrop
@Jon, their homepage says it does. Are they wrong?
Robert Harvey
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...
Jon Harrop
+19  A: 

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.

Rainer Joswig
Thanks, that's very informative!
oggy
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.
Nathan Sanders
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).
Rainer Joswig
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.
Michael E
+8  A: 

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.

fishlips
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.
Rainer Joswig
I used SWI-Prolog (http://www.swi-prolog.org/) on linux. It even has a GUI.One of modern use of Prolog is the Semantic Web.
dmitry_vk
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.
David Thornley
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.
Attila Lendvai
@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.
fishlips
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)
Jay
+4  A: 

I'm going to recommend something that I haven't yet tried, but plan to, so you have to judge for yourself this one. There's this language, called IO, which is particular in that its prototype-based, like JavaScript, but also borrows concepts from many other languages. Its job market it's probably nonexistent, but I thought I mention this language.

Otherwise, a language from the Lisp family may be pretty different from what you already know. In that regard I'd recommend Scheme, which is, in my opinion, more elegant than Common Lisp. The new concept that you might found interesting in Scheme is continuations.

If you take the Scheme path, make some time to watch these videos from 1986. They're amazing.

Ionuț G. Stan
James Hugard
@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.
musicfreak
A: 

Lisp is a great HLL, it has everything that other languages lack. In my opinion, this is a very good language that can "satisfy" any programmers needs.

Perl is also a HLL like Lisp, it's interesting and fun at the same time. It derives from C so you can pick it up as you go. It can be hard sometimes and some people tend to get lost while learning, but it's worth knowing.

Both languages are free of use and come with Linux.

Links

Lisp: If Lisp is so great, An Introduction and Tutorial for Common Lisp

Perl: PERL -- Practical Extraction and Report Language

Books

On Lisp - Great book by Paul Graham on the Lisp language. It's free and you can download it here.

Secko
+4  A: 

Have a look at Smalltalk ! Either Cincom VWST or Smalltalk/X - dont bother with Squeak as the interface is terrible). VAST is good also but really only Windows centric. And dont bother about the sceptics that pore scorn on Smalltalk -- they arent using it and are stuck in the morass of edit-run-debug cycle languages and multiple dispirt linked libraries. :-)

Why these Smalltalks - well, they come complete wth excellent IDE, GUI tools builtin, best debugger you will ever see, online help, and is totally independent of the underlying OS. Eg a ST/X programming running under Linux can be transfered ( source code) to Windows ST/X and it should execute.

ST/X is free with only a very minor licience restrictions, Cincom offer a free NC ( Not Commercial ) version that is NOT restricted. I use ST/X as I prefer the default look & feel it offers. Their IDE interfaces are very similar.

Languages without a IDE & GUI tools are just wasting your time as the world is really GUI, no matter how terrific the underlying language is. Eg Ruby is great, but with no IDE or easy GUI tools its really frustrating.

Smalltalk is not easy to get into, and its not perfect,(what language is?) but very satisfying to learn & use. And now that the hardware and operating systems have finally caught up with Smalltalks needs . very efficient.

+3  A: 

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.

Brian Carper
+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.
Kai
+1  A: 

Of the suggestions I've seen so far, I like Lisp (see Secko) and Smalltalk (see brett), as both will give you another view of languages. Prolog even more so.

Another language that is different is Erlang -- I haven't had a chance to learn it yet, but it handles concurrency in a different way. The best link I can give you is the main website.

In terms of recommendations, Lisp is good both because it is currently used and because it is very old. The others you will have to look at sources and see which one appeals the most.

Kathy Van Stone
A: 

Scala has been very good for making me see programming in a new light. I haven't used it for anything worklike yet, but it's still affected how I write code in other languages - not just Java, but PHP. I recently wrote a simple parser for a WordPress plugin, and the code is vastly more functional and immutable than it would have been six months ago, and better for it, despite the lack of enforcement in PHP.

The only other language to have affected the way I work so dramatically is Perl, nearly a decade earlier. Perl has contributed a lot to the way I pseudo-code, even if I never touch the language itself.

Many people compare the functional aspects of Scala to Haskell. You may even imagine that knowing Haskell means you already know all Scala could teach you, but I don't believe that. The way Scala combines OO and function has a way of making it seem like that's actually the truest form of both of them.

Marcus Downing
Scala is the "truest form" of functional programming? It doesn't even have tail calls...
Jon Harrop
So what? Whether the implementation happens to use tail calls is invisible to me, the ordinary working programmer.
Marcus Downing
@Marcus: 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.
Jon Harrop
+7  A: 

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.

musicfreak
A: 

Like you, I have over a dozen languages under my belt. While shopping for something to play with for writing a cross-compiler, I ran across ML and family. Many very good ideas there, and they have taught me to write code is a much different way; for example, my JavaScript now has a decidedly functional bent.

After toying with OCaml under Windows a while (and getting frustrated with stability issues), I ran across F#, an offspring of OCaml. The two are quite similar (can cross-compile a lot of code), but OCaml apparently has a really good macro system (P4) and type-classes (in support of writing "strongly typed" operators against generic types), while F# has excellent support for asynchronous and parallel operations, monads, units-of-measure for numeric types, as well as cleaner OO syntax and awesome IDE integration (VS2008 & will be released in-the-box with VS2010). I much prefer F# these days, since I have access to the whole .NET runtime and loads of 3rd party libraries. In fact, I write most of my one-off and utility code in F# now; for me, its generally much more productive than C++, JavaScript, C#, PowerShell, or anything else.

F# works fairly well under Mono on Linux, and has a good following there. The compiler and runtime will be open sourced once stable (released with VS2010), and the developers consider Mono support enough of a priority for it to be seriously considered for non-Microsoft use.

James Hugard
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.
James Hugard
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#
Robert Harvey
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!
nlucaroni
"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.
abababa22
abababa22, mmm... thus you can link Haskell to ocaml through C... awesome. :)
nlucaroni
OCaml does not have type classes (but it does have a higher-order module system).
Jon Harrop
+2  A: 

I second Rainer's Common Lisp recommendation.

CL has all the things you're looking for and will provide a genuinely novel experience that will also make your coding efforts and approaches in other languages better.

But bring patience and persistence, you will have to grasp a lot of concepts that will seem alien at first.

skypher
+7  A: 

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.

  • 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.

Norman Ramsey
"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.
Jon Harrop
+1  A: 

Try FORTRAN, then? I hear it's still actively used by the scientific and mathemematical communities, plus it should be dissimilar enough to be a learning challenge.

Compilers:
http://gcc.gnu.org/wiki/GFortranBinaries
http://www.g95.org/
http://www.fortran.com/compilers.html
http://www.thefreecountry.com/compilers/fortran.shtml

IDEs:
http://www.eclipse.org/photran/
http://force.lepsch.com/ (FORTRAN 77 only)

Tutorials:
Introduction to Modern FORTRAN: http://www-uxsup.csx.cam.ac.uk/courses/Fortran/
FORTRAN 90 Tutorial: http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/fortran.html

You could also learn Visual Basic.NET, in case you ever get forced to maintain that. Evidently mono has a working Linux implementation of it: http://www.mono-project.com/Visual_Basic

Coding With Style
+2  A: 

You could try Tcl. It was sufficiently different to provoke an adverse reaction in my brain, so I can't really tell you how I found it different, but there's been a lot of good stuff written in it (maybe less nowadays than earlier).

David Thornley
+1  A: 

Factor is pretty radically different from everything you said you know, and also everything else listed. It's stack-based, like Forth, but has a fairly comprehensive library and a lot of interesting features.

Ada is very practical -- there's a compiler based on gcc -- but also quite different from the other imperative languages you know. I find the type system a bit stifling, but it was worth learning something about.