You are not logged in.

#1 2009-05-02 15:38:31

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

OCaml and Lisp hackers come hither [SOLVED]

I'm thinking of starting to program again and I wanted to try something outside of anything that I've ever used before. I want something very fast, well supported, stable, robust, can compile to byte and native code, has at least a fair amount of industry usage, and isn't C. My search has led me to OCaml and Lisp. Within the Lisp family it looks like SBCL is one of them with a native compiler. Both OCaml and Lisp look promising.

What this thread is about is to hear from people that use this software regularly what their thoughts are in terms of a comparison between the two. There's a lot of general information and I'm not asking you for something that takes five seconds to search for. I want to know how you feel about these as a user, what practical strengths and limitations you have run into, if you prefer one over the other and why, etc.

Offline

#2 2009-05-02 16:06:36

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: OCaml and Lisp hackers come hither [SOLVED]

AFAIK, though SBCL can compile Lisp to machine code and it can also generate stand-alone executables, they're huge. (A hello world here is compiling to 40MB, and that's not a typo).

(defun main ()
  (format t "Hello World!~%"))

(sb-ext:save-lisp-and-die "hello.exe" :toplevel 'main :executable t)

and then running

sbcl --load hello.lisp

But maybe I'm doing something wrong? I'm not very good at compiling Lisp apps, I confess.


(lambda ())

Offline

#3 2009-05-02 16:55:21

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: OCaml and Lisp hackers come hither [SOLVED]

andre.ramaciotti wrote:

AFAIK, though SBCL can compile Lisp to machine code and it can also generate stand-alone executables, they're huge. (A hello world here is compiling to 40MB, and that's not a typo).

Yikes, holy crap, and ouch! A basic OCaml program ( http://www.ctan.org/tex-archive/fonts/u … s/otftofd/ ) compiles into a little tiny thing as I would expect.

--EDIT--

Here's the explanation ( http://www.esden.net/blog/2006/07/10/co … with-sbcl/ ):

But now comes up the Question. It is a coredump so what does it contain? Well there it comes. It contains everything. Really everything including all libraries and the lisp compiler. So when I compile the robots game I introduced in the previous post here I get a binary of 23MB (yes megabytes). That is pretty much. Sure it does not count if you have a really big system that is 100 times bigger but still that sucks somehow. I informed myself and now I know that there is something called "headless" in the works that will enable sbcl to create coredump with an integrated dynamic linker. This will make the binary significantly smaller and when you run your program it will dynamically link the libraries it needs. Just as it should be. Next thing is from the slime world. There is a profiler in the works that will be able to even more optimize the code so that you will be able to create really small binaries.

--EDIT 2--

A standalone 'Hello World' program in OCaml weighs in at 164.5 KB. That's somewhat more attractive. It's still a lot larger than the same in C though. C is only 6.6 KB. The OCaml code seems to grow very quickly also. The first link above compiles to 495.8 KB.

--Last EDIT--

I see. SBCL brings in the whole run-time library, so code shouldn't grow too fast unless a lot of external stuff is added. OCaml is compiling in it's run-time libraries as it goes. C executables seem to be small because the run-time libraries are already present on Linux systems. glibc itself is 35MB.

Offline

#4 2009-05-03 07:34:33

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: OCaml and Lisp hackers come hither [SOLVED]

skottish wrote:

I see. SBCL brings in the whole run-time library, so code shouldn't grow too fast unless a lot of external stuff is added.

Indeed it does. Everything from the compiler on up. Other Lisps produce smaller programs (CLISP gives just a few megs iirc, which will pale in comparison to your actual program). Allegro Common Lisp and Lispworks (commercial implementations) come with tree-shakers that let you strip out a lot of cruft your users won't need. If you're in business, licensing those is a good investment, and if you're not, you can just go free software and ship only the source. I'm not trying to pretend the problem away, but I don't write or distribute "Hello World" very often. It's definitely not something I worry about.

I've been a happy Lisper for a few years now. Common Lisp is certain fast, stable, and robust. It will go where you taking, but it's not budging on its own. My impression of Ocaml is that it looked like a hassle, syntax-wise and otherwise, which I only mention to explain why I never looked deeply into it. I don't know enough about it to actually judge.

Other neat languages that might be unlike anything you've used before are Factor and Qi (which comes with an e-textbook).

Offline

#5 2009-05-03 07:49:20

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: OCaml and Lisp hackers come hither [SOLVED]

Out of curiosity, what made you exclude Haskell? Is it the lack of industry adoption, simply no interest or do you already know it?

I ask because I've got it stuck in my mind that I want to learn Haskell next (several things about it appeal to me, both practically and philosophically) and it would be interesting to know what you disliked about it.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#6 2009-05-03 08:10:52

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: OCaml and Lisp hackers come hither [SOLVED]

Thanks pauldonnelly,

Your posts are the main reason why I became interested in Lisp. smile Maybe I'm not correct here, but it feels like CLISP is more well rounded than SBCL. At least that's what it seems like when I'm searching. What about GCL and it's ability to compile to C code? I didn't find much information on it. Well, it doesn't compile here anyway.

Interestingly I came across OCaml by searching for performance for the various Lisp's. Over and over again I kept finding it without even trying. It was totally out of my consciousness before that. I started to pay attention and the more that I read, the more that I liked. The code for otftofd posted above looks really nice. Although, given the nature of the code, I'd bet it would look good in a lot of languages.

One thing to note: I have two pieces of code on this machine that do basically the same thing, otftofd (OCaml) and otfinst (Python) using the same external tools. They are written by different people and I can't say if one does more than the other. But I can say that the OCaml code is of magnitudes faster than the Python code, and that's with otftofd not being compiled to native code.

Hiya Xyne,

The short answer: speed. I've read that Haskell is supposed to be extremely elegant, which is very appealing. I read a post from the main developer speaking on Haskell's need for much higher performance, and that kind of turned me off. If I'm going to learn something, I'd like it to be as fast as possible. Why? I don't know. It just feels right.

--EDIT--

Wow! There are a ton of Haskell packages in AUR. Maybe I'll take another look and see if I missed something.

Offline

#7 2009-05-03 08:24:38

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: OCaml and Lisp hackers come hither [SOLVED]

skottish wrote:

The short answer: speed. I've read that Haskell is supposed to be extremely elegant, which is very appealing. I read a post from the main developer speaking on Haskell's need for much higher performance, and that kind of turned me off. If I'm going to learn something, I'd like it to be as fast as possible. Why? I don't know. It just feels right.

Do you happen to remember where you read that? I've seen mixed information regarding Haskell's speed. Some sources say that it can reach the same league as C for many things but not all. My understanding is that it's actually quite fast, just not as fast as C, but I'm not that informed.

For what it's worth, I've also seen OCaml come up over and over again when looking into languages, usually in a positive light.

*edit*

skottish wrote:

--EDIT--

Wow! There are a ton of Haskell packages in AUR. Maybe I'll take another look and see if I missed something.

Yeah, I've noticed that too. The Arch-Haskell community appears to be very well organized (if a bit reclusive).

Last edited by Xyne (2009-05-03 08:30:20)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#8 2009-05-03 08:31:49

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: OCaml and Lisp hackers come hither [SOLVED]

This one is more favorable than not:

http://neilmitchell.blogspot.com/2008/0 … mance.html

It's hard to remember where all I've seen this stuff. It's mostly been through haskell vs lisp, lisp vs ocaml, scheme vs R2D2, kind of searches, then launching out from there. Whenever I opened this post this morning, right now is when I'm stopping. My mind hurts.

If it's true that Haskell is capable of very high performance, I may try it. The code that I've seen is hyper-readable. That says a lot for a language that I'm not familiar with.

Another note: I've seen only one negative page against OCaml. I wonder if everyone writing about it works for Jane Street Capital.

Another good read:

http://www.oreillynet.com/mac/blog/2006 … you_p.html

*** Question for anyone ***

What's up with the ton of AUR packages if GHC is 557MB installed? Are they just for the other compilers?

Offline

#9 2009-05-03 12:35:42

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: OCaml and Lisp hackers come hither [SOLVED]

Hi :-)

I can't really contribute towards OCaml vs Lisp, but when you said haskell has speed problems I knew i had to reply ;-)
I'd say haskell is at least on par with lisp implementations as well as ocaml.

One nice place to look at when comparing language speeds is always http://shootout.alioth.debian.org.
(If you compare lisp/ocaml to haskell, you'll notice that haskell tends do be quite a bit faster.)
While those numbers are not the final answer they may help you to do a rough comparison.

Other than that I can definitely recommend haskell.

Regards

raf

Last edited by raf_kig (2009-05-03 12:38:00)

Offline

#10 2009-05-03 14:16:08

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: OCaml and Lisp hackers come hither [SOLVED]

skottish wrote:

Maybe I'm not correct here, but it feels like CLISP is more well rounded than SBCL. At least that's what it seems like when I'm searching. What about GCL and it's ability to compile to C code? I didn't find much information on it. Well, it doesn't compile here anyway.

SBCL feels less rounded maybe because of its interpreter shell. OTOH, SBCL runs much faster and has a better threads support, among other things.

About the AUR haskell packages, AFAIK, they're for GHC.


(lambda ())

Offline

#11 2009-05-03 16:35:13

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: OCaml and Lisp hackers come hither [SOLVED]

raf_kig wrote:

One nice place to look at when comparing language speeds is always http://shootout.alioth.debian.org.
(If you compare lisp/ocaml to haskell, you'll notice that haskell tends do be quite a bit faster.)
While those numbers are not the final answer they may help you to do a rough comparison.

I never figured out how to read those charts. Although, there's a bunch of OCaml users that site that page to state that their language is the second fastest after C. See:

http://www.cs.ubc.ca/~murphyk/Software/ … ocaml.html

As you pointed out though, while it means something, but it's hardly definitive. Of course that page is from 2002.

If anyone is curious, I'll probably be diving into Python at the same time. I do have some Python experience, but it would be cool to have a lot more. It was suggested here ( http://bbs.archlinux.org/viewtopic.php?id=57119 ) to learn more than one language at a time. I think that it's a brilliant idea:

Dusty wrote:

These threads come up periodically. Rather than suggest a specific language (python :-D), I suggest you study and learn several languages. At once. Each one will teach you different aspects of what it means to be a good programmer and in different ways.

Offline

#12 2009-05-03 17:21:06

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: OCaml and Lisp hackers come hither [SOLVED]

skottish wrote:

I never figured out how to read those charts.
[...]
As you pointed out though, while it means something, but it's hardly definitive. Of course that page is from 2002.

They are not particulary hard to read, if the charts are confusing you look at the numbers below first, than you'll get what they mean.
As it stands today at the language shootout haskell is faster than both, ocaml and lisp.

/e some explanation:
http://shootout.alioth.debian.org/u32q/ … caml&box=1
If you look at that graph:  the bars next to 'time' mean

runtime( problem 1, haskell )/ runtime ( problem 1, ocaml )
...
runtime( problem n, haskell )/ runtime ( problem n, ocaml )

So a result < 1 means haskell is faster
and a result > 1 means ocaml is faster

same for memory etc

regards

raf

Last edited by raf_kig (2009-05-03 17:26:08)

Offline

#13 2009-05-03 17:39:58

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: OCaml and Lisp hackers come hither [SOLVED]

Thanks raf_kig,

That totally clears it up.

Another question would be how do people prototype with Haskell? Which is to say, are people using Hugs, an internal interpreter, or just compiling everything?

--EDIT--

No matter what happens here, OCaml is out because it seems that Haskell is a logical, better supported choice. With that being said, Lisp is extremely attractive and still may fit better. I don't think that anyone here would disagree with the idea that Lisp is incredibly well suited for almost any use.

Check this out. It's great:

http://lukeplant.me.uk/blog.php?id=1107301645

Offline

#14 2009-05-03 21:00:20

Arkane
Member
From: Switzerland
Registered: 2008-02-18
Posts: 263

Re: OCaml and Lisp hackers come hither [SOLVED]

The first thing you (I) do in a Haskell project is think about types. Once you've understood how to plug the types of your library functions together and decided what the types of your main functions should be, you pretty much know what code you're going to write.

Then you start putting functions into a file, regularly loading it into GHCi (or Hugs, matter of taste I guess) to see if it compiles (when Haskell code typechecks it's usually correct. Really.) and call your functions interactively to see what they do.


Regarding the amount of Haskell packages: the PKGBUILDS for Haskell packages on AUR are automatically generated from the package description files of packages from Hackage, so there's a lot of them (1052 out of 1250, according to the last Arch-Haskell report).


Finally, I definitely recommend learning Haskell too. My personal and partial opinion is that any language that calls itself functional without being pure (be it Lisp, OCaml, or F#) is a half-assed compromise.


What does not kill you will hurt a lot.

Offline

#15 2009-05-03 21:25:32

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: OCaml and Lisp hackers come hither [SOLVED]

Arkane wrote:

Finally, I definitely recommend learning Haskell too. My personal and partial opinion is that any language that calls itself functional without being pure (be it Lisp, OCaml, or F#) is a half-assed compromise.

In all fairness, both OCaml and Lisp rightfully claim to be multi-paradigm languages, not pure functional languages. I know very little of F# other than it's MS and it has a concurrent gc.

Offline

#16 2009-05-04 03:12:08

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: OCaml and Lisp hackers come hither [SOLVED]

I settled on OCaml after all. I like the idea that it's a multi-paradigm language, it seems more simple than Haskell, and creates much smaller binaries (for small programs) of the three.

Thanks for all of your input. It's been educational.

Offline

#17 2009-05-04 07:14:58

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: OCaml and Lisp hackers come hither [SOLVED]

raf_kig wrote:

I'd say haskell is at least on par with lisp implementations as well as ocaml.

Yeah, my impression is that Haskell is quite snappy these days, especially in the hands of someone who understands it well.

skottish wrote:
Arkane wrote:

Finally, I definitely recommend learning Haskell too. My personal and partial opinion is that any language that calls itself functional without being pure (be it Lisp, OCaml, or F#) is a half-assed compromise.

In all fairness, both OCaml and Lisp rightfully claim to be multi-paradigm languages, not pure functional languages. I know very little of F# other than it's MS and it has a concurrent gc.

In my experience, the people calling Lisp a functional language are usually people who don't know Lisp especially well. Lisp itself doesn't claim to be anything, as far as I know. tongue I know it was a popular AI language at one time, but I don't think it ever got smart enough to invent a self identity.

Offline

#18 2009-05-05 15:51:58

&#32 Greg
Member
Registered: 2009-02-08
Posts: 80

Re: OCaml and Lisp hackers come hither [SOLVED]

pauldonnelly wrote:
raf_kig wrote:

I'd say haskell is at least on par with lisp implementations as well as ocaml.

Yeah, my impression is that Haskell is quite snappy these days, especially in the hands of someone who understands it well.

skottish wrote:
Arkane wrote:

Finally, I definitely recommend learning Haskell too. My personal and partial opinion is that any language that calls itself functional without being pure (be it Lisp, OCaml, or F#) is a half-assed compromise.

In all fairness, both OCaml and Lisp rightfully claim to be multi-paradigm languages, not pure functional languages. I know very little of F# other than it's MS and it has a concurrent gc.

In my experience, the people calling Lisp a functional language are usually people who don't know Lisp especially well. Lisp itself doesn't claim to be anything, as far as I know. tongue I know it was a popular AI language at one time, but I don't think it ever got smart enough to invent a self identity.

Despite the multi-paradigm nature of say, Scheme, I'd call it a Functional Programming Language simply because of how it's used. Someone programming with set!s probably isn't doing a lot of LISP programming.

Offline

#19 2009-05-05 18:23:33

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: OCaml and Lisp hackers come hither [SOLVED]

  Greg wrote:

Despite the multi-paradigm nature of say, Scheme, I'd call it a Functional Programming Language simply because of how it's used. Someone programming with set!s probably isn't doing a lot of LISP programming.

Yeah, Scheme is weird.

Offline

#20 2009-05-06 15:26:59

&#32 Greg
Member
Registered: 2009-02-08
Posts: 80

Re: OCaml and Lisp hackers come hither [SOLVED]

I like Scheme; it makes sense to me (not that I'm that great at programming in it- or anything else).

Offline

#21 2009-05-06 17:11:04

Bison
Member
From: Jacksonville, FL
Registered: 2006-04-12
Posts: 158
Website

Re: OCaml and Lisp hackers come hither [SOLVED]

I wouldn't consider scheme/lisp functional, just because it support higher order functions and tail recursion.

And while haskell can be slow for some things, its also very fast for others, as is the case with all languages

Offline

#22 2009-05-06 18:28:10

&#32 Greg
Member
Registered: 2009-02-08
Posts: 80

Re: OCaml and Lisp hackers come hither [SOLVED]

Well, then you need to look at the argument of how you define a functional language. Some would argue that treating everything as a first class object constitutes a functional language, for instance, while others would simply state that treating everything like math makes a language functional, and of course a number of other views.

Offline

#23 2009-05-07 10:36:03

TPJ
Member
From: Gliwice, Poland
Registered: 2005-12-21
Posts: 33

Re: OCaml and Lisp hackers come hither [SOLVED]

First of all, it should be pointed that Lisp usually refers to the whole family of languages. SBCL and CLISP (mentioned in this thread) are only two Common Lisp implementations, and Common Lisp is just one of the Lisp dialects.

I was considering switching from Java/Python to something else. There were only two languages I was thinking about: OCaml and Lisp (some dialect). I excluded OCaml because because of (the power of) macros in Lisp and because of more programming paradigms support in Lisp (OCaml supports only OO and FP).

For some time I was trying to use Common Lisp (SBCL; I wouldn't have used CLISP for licensing reasons). I'm interested in developing portable software, and - in my opinion - Common Lisp falls short here. On *nices the choice is impressive, but when it comes to Windows (my secondary development platform, and my primary targeted one) there are only some commercial solutions (the SBCL port isn't even official!). Why it's so? Because "Lisp programmers don't want to provide good quality solutions for the Windows platform for free". Seriously, I found such an answer somewhere in the net!

I also failed to install additional CL libraries on Windows. That was the moment I said "no, thank you" to Common Lisp.

I tried Scheme and all my problems went away. I can make native executables (without long discussions on what they really are) on both Linux and Windows, and the installation of libraries is also nice (on the Scheme implementations I use).

So, if anyone is considering using Lisp (not: Common Lisp, which is a different case), I recommend to take a look at Scheme.

Offline

#24 2009-05-07 10:42:29

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: OCaml and Lisp hackers come hither [SOLVED]

TPJ wrote:

So, if anyone is considering using Lisp (not: Common Lisp, which is a different case), I recommend to take a look at Scheme.

Won't that make portability problems even worse?

Offline

#25 2009-05-07 16:05:09

&#32 Greg
Member
Registered: 2009-02-08
Posts: 80

Re: OCaml and Lisp hackers come hither [SOLVED]

Not that I've used it, but I know that a lot of people really like Clojure as a LISP, as you get the speed, portability, and libraries of the JVM.

Offline

Board footer

Powered by FluxBB