Re: Lisp and OCaml, why?



casioculture@xxxxxxxxx wrote:
> It's perhaps no immediate concern for me but at a future point I may
> want to look into those two languages as I want to learn as many
> interpreted languages as possible over time, if not to use them at
> least to know what's out there. I can't help but feel a wonder about
> lisp and OCaml though - why would someone use them in preference to
> more modern languages such as perl, python and ruby? What advantages do
> they still have that would make them recommendable to someone who's
> learning to program in 2005/2006?

Your statements seem to be based upon several misconceptions. Firstly,
neither Lisp nor OCaml are necessarily interpreted, indeed both are
usually compiled to native code to achieve performance far in excess of
most Perl, Python and Ruby programs. Secondly, OCaml was invented in
1996 and the most recent update to the language was last week! Although
Lisp was one of the first programming languages, it has also evolved in
the intervening decades and there are now dozens of variants of Lisp,
some of which expose many new ideas.

Lisp has many advantages over Perl, Python and Ruby. I know more about
OCaml so I'll list the relative benefits of OCaml and leave Lisp to
Rob: ;-)

1. Strong, static typing catches type errors at compile time, reducing
development time and improving program reliability. Otherwise
error-prone programs can be written in a way that leverages the type
system in order to prove that they contain no sources of type errors.
2. Type inference computes the types of all subexpressions, reducing
code size without sacrificing static type checking and providing
machine-checked documentation.
3. Expressive type system allows data structures and algorithms to be
written simply and clearly whilst benefitting from static typing:
tuples, records, variants, polymorphic variants, objects.
4. Syntax can be extended using camlp4 macros.
5. Interactive top-level, byte-code and native-code compilers.
6. Easy syntax for the common functional constructs currying, HOFs etc.
7. Native lists and arrays.
8. Parametric polymorphism - functions are inferred to be polymorphic.
9. Built-in polymorphic comparisons and hashing.
10. Modules for a more statically checked alternative to OO (which is
also available).
11. Pattern matching allows complicated data structure manipulations to
be represented clearly, succinctly and (because pattern matching is a
fundamental part of the language) pattern matches are compiled into
very efficient code.
12. Lexing and parsing tools: OCaml is bundled with stream- and
lex/yacc-based tools for writing recursive descent and LALR(1) parsers,
respectively.

For a ray tracing benchmark that includes Lisp and OCaml, have a look
at:

http://www.ffconsultancy.com/free/ray_tracer/languages.html

I have also written a book on OCaml:

http://www.ffconsultancy.com/products/ocaml_for_scientists/

I am in the process of writing a detailed explanation of the benefits
of OCaml, including extra detail on dynamic vs static typing.

Cheers,
Jon.

.



Relevant Pages

  • Re: Program compression
    ... Haskell, SML, OCaml, Mathematica, F# and Scala all allow real ... problems to be solved much more concisely than with Lisp. ... for simple lists those three languages equal Lisp in conciseness. ... and thus there's no need for concurrent GC. ...
    (comp.programming)
  • Re: Alternatives 4
    ... This does show something interesting about lisp, ... And the OCaml code demonstrates how other languages can provide both ... performance and brevity at the same time, which is the power of OCaml. ... Emacs is the best there is as far as an IDE for OCaml goes ...
    (comp.lang.lisp)
  • Re: a LISP raytracer
    ... > None of the free Lisp compilers come close to the capabilities of Stalin. ... > OCaml does has camlp4 macros. ... My languages professor right now is a huge fan ... on OCaML, and not so much with LISP. ...
    (comp.graphics.rendering.raytracing)
  • Re: Very poor Lisp performance
    ... >> not opt for OCaml quickly. ... but hugely expressive languages like Mathematica and "fast" but archaic ... > slower than the slowest lisp programs). ... All this makes any given benchmark or set of benchmarks suspect ...
    (comp.lang.lisp)
  • Re: Flamebait if I ever saw it
    ... Since a couple of months, we have a guy spamming this newsgroup with advertisements for his F# and OCaml "expertise", in the form of books, websites, what have you. ... Apparently that guy has picked Lisp as one of his favorite competitors, ... The fact that you narrowed down your question to the two languages that are typically at the center of that guy's attention is a strong evidence in favor of this assumption. ...
    (comp.lang.lisp)