Re: New Computer Language Shootout?



On Jul 20, 1:34 am, André Thieme <address.good.until.
2007.dec...@xxxxxxxxxxx> wrote:
Jon Harrop schrieb:

For example, a parser and evaluator for a simple dynamically typed
functional language with first-class lexical closures that can interpret
the following program:

let rec fib n =
if n=0 then 0 else
if n=1 then 1 else
fib(n - 1) + fib(n - 2) in
fib 35

may be written in only 49 lines of OCaml:

When making a line count then Lisp often is not the best.
This has several reasons:
In Lisp functions, variables and macros usually have longish names.
These have to fit into 80 chars wide lines. This is a style descision.
If you want to write to a file it could for example look like this in
Lisp:
(with-open-file (out "/path/to/file"
:direction :output
:if-does-not-exist :create
:if-exists :overwrite)
...)

It takes up 4 LOC and it looks like a 4 liner, while it really is just
one line. The arguments (that start with a colon ":") could well have
been compressed into a cryptic string:
(w/file (out "oco" "/path/to/file")
..)

and suddenly it looks like a one-liner.

Also other style elements will make Lisp code using up more lines.
Let's take this simple accumulator producing function:
(defun make-accumulator (n)
(lambda (i)
(incf n i)))

In some other languages the same solution could look like
fun makeAccumulator n = (i -> n inc i)

To factor out these style implications you could try to compare
the source code when it is packed. The best packers for code should be
compilers, I think.

For example you can look at the file size of a compiled OCaml function
and the file size of a (with clisp) compiled function.

André
--

Very-long-and-descriptive-names are one of the strengts that I
learned from the lisp culture and I use it in all the languages I
encounter. As soon as your programm becomes non-trivial there is more
interest with reading & understanding code than line count,
especially if there are other programmers involved or even for
yoyrself after few motnhs. For a good style namings look at :
http://www.cs.northwestern.edu/academics/courses/325/readings/names.html
from
http://www.cs.northwestern.edu/academics/courses/325/readings/

.



Relevant Pages

  • Re: a dozen cpus on a chip
    ... there are several compilers still available which implement ISO M2. ... By the time the full spec was published most industrial people had moved to other languages for purely commercial reasons. ... Some of the better static analysis tools for Modula2 can see into the program and find very deep faults that would not be found in normal execution. ... It is a common misconception that Lisp is always interpretted. ...
    (sci.electronics.design)
  • Re: How Common Lisp sucks
    ... smattering of scripting languages around the edges). ... using different compilers on every ... SBCL/x86 virtual machine with a program compiled for the clisp virtual ... None of this is meant to detract from lisp. ...
    (comp.lang.lisp)
  • When static typing is worth it
    ... typed languages like Lisp. ... developed more quickly in modern statically typed languages than ... static type system and remove run-time checks. ... incurs a run-time error if the list is ...
    (comp.lang.lisp)
  • Re: merits of Lisp vs Python
    ... intelligent machines you need another path, that is what has not been ... Lisp compilers will generate better and better code. ... languages like C where much of the work has been done. ...
    (comp.lang.lisp)
  • Re: What is Lisp used for?
    ... My main languages are Perl, Java, and ColdFusion. ... Lisp PHP FlamingThunder). ...
    (comp.lang.lisp)

Loading