Re: Lisp and OCaml, why?
- From: "Dr Jon D Harrop" <jon@xxxxxxxxxxxxxxxxx>
- Date: 5 Nov 2005 16:12:47 -0800
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.
.
- References:
- Lisp and OCaml, why?
- From: casioculture
- Lisp and OCaml, why?
- Prev by Date: Re: Java or C++?
- Next by Date: Re: Java speed: Reality versus theory?
- Previous by thread: Re: Lisp and OCaml, why?
- Next by thread: Java speed: Reality versus theory?
- Index(es):
Relevant Pages
|