Slashdot Mirror


Lisp as an Alternative to Java

Joseph Dale writes "Lisp as an Alternative to Java is a detailed and well-reasoned study comparing Lisp to Java and C++ in terms of execution time, memory consumption, and developer effort. The author, Erann Gat, was the principal software architect for the Mars Science Microrover, the prototype for the Mars Pathfinder rover."

23 of 372 comments (clear)

  1. I'm a professional who uses Java by under_score · · Score: 5, Informative

    This is quite an interesting study. I use java professionally for most things that I do (I have also used C, Objective-C and a few others in the past). I have had to work with lisp a bit. Of course I took a lisp oriented AI class in school, but since then I have also had to do some porting from lisp to Java! Perhaps it was just a factor of the people who developed the lisp code, but I found it incredibly difficult to read - and my complaint wasn't with the nesting of parentheses. It wasn't strongly typed (is there such a lisp?) and the singular type of syntax (lists) make many aspects of the code difficult to unravel. That said, there are some things I really like about lisp, in particular its dynamic nature where you can build lisp functions at runtime and execute them at runtime. Sometimes I really wish I could do this easily with Java (its possible to do, just a huge pain in the butt). I think the real issue right now is that Java (and C++) are used in the "real world", whereas lisp is mostly isolated to academia. The article point this out. I've used Java for huge projects because it is no longer considered a risky language by large organizations. For whatever reason, lisp has not developed such a reputation. Does lisp have application servers? Does lisp has db connectivity? Does lisp have CORBA bindings? Does lisp have asynchronous messaging? Does lisp have naming and directory bindings? Does lisp have web page templating functionality? I'm sure all that stuff could be built, but I doubt most of it exists right now. Therefore, lisp is not acceptable for corporate use at this time.

    1. Re:I'm a professional who uses Java by Lambdaknight · · Score: 5, Informative

      > Does lisp have application servers?

      Yes

      > Does lisp has db connectivity?

      Yes

      > Does lisp have CORBA bindings?

      Yes

      > Does lisp have asynchronous messaging?

      Yes

      > Does lisp have naming and directory bindings?

      Yes

      > Does lisp have web page templating functionality?

      Yes.

      Two points more:

      1. Doubt is not knowledge. Many people THINK they know about the popularity of Lisp because they don't hear as much about it as they hear from the hype languages (which is quite logical).

      There are far more Lisp projects going on than people imagine, only people don't scream out "HEY! COOL! I'M DOING IT WITH LISP!" they go "Yepp, I'm using Lisp." the Yahoo Store engine for instance. Microsoft's Bob. Many industrial applications (not only the academia!).

      2. The syntax isn't hard to read, it's just hard for people not used to it. This is, of course, true for every language.

      Besides: Common Lisp is not strongly typed but you can strongly type a specific function by declaring what types the arguments will have. That makes Lisp a "strong typing on demand"-language in my point of view.

      --
      -- Beware the Jabberwock, my son!
    2. Re:I'm a professional who uses Java by under_score · · Score: 2, Informative

      Ah. Well, I do appologize for my ignorance. As I mention in another comment, then perhaps unity of promotion and standards might be other issues. The question remains: why is lisp not used more in enterprise settings while Java is rapidly overtaking c++?

    3. Re:I'm a professional who uses Java by aerique · · Score: 2, Informative
      The homepages of some Lisp vendors will get you most of the things in the list. Handy link with a lot of information http://ww.telent.net/cliki/

      More Lisp vendors:

      'Free' (whatever the current definition of that is nowadays) Lisps:

  2. Re:It's about the API by Anonymous Coward · · Score: 1, Informative

    Lisp has libraries that implement calls to/from native code, OOP (with much more powerful overriding and multiple dispatch), database access, and GUIs. Data structures are its forté (as befits its AI origins). Java (which doesn't even have #'remove-if) is still a toy in comparison. Its only advantages are the sandbox (and I admit the world desperately needs safe mobile code) and a baroque syntax that doesn't hurt the poor C programmers' little heads.

  3. Re:It's about the API by redhog · · Score: 5, Informative

    Nahnah. You haven't touched a LISP the last 20 years or so, have you? There's a popular LISP dialect called Scheme. It has a huge function library called slib, and there are bindings for a hell lot of C libraries for Scheme (it is also very easy to create new such bindings for most implementations of scheme).

    --
    --The knowledge that you are an idiot, is what distinguishes you from one.
  4. Re:Learning Lisp? by Lambdaknight · · Score: 3, Informative

    Yes.

    Read "Structure and Interpretation of Computer Programs" by Abelson and Sussman.

    It is a fabulous book for introduction into functional thinking and shows many enlightening things about what you can do with Lisp in general and in this case Scheme.

    Your next step might be "ANSI Common Lisp" by Paul Graham, giving an introduction into the Lisp dialect with which major applications in the industry are done (REALLY done, Franz Inc. and Xanalys, both commercial Lisp implementors and vendors have increasing sales over the years) - also a very clear and easy to follow book with lots of examples and exercises and a very cool reference which I tend to use a lot while Lisp coding.

    If you prefer online information, you can find many links and pointers to Lisp on the webpage of the Association of Lisp Users (ALU, http://www.alu.org).

    (Yes, I'm paid to code in Lisp)
    (Yes, it's a lot of fun)

    --
    -- Beware the Jabberwock, my son!
  5. Ocaml instead of Lisp by Ronniec95 · · Score: 2, Informative

    For max performance and easy integration with C-APIs try this language at http://www.ocaml.org. I only heard about it from the ICFP contest but it is a very cool language IMHO.

    1. Re:Ocaml instead of Lisp by Sarunas · · Score: 2, Informative

      http://www.bagley.org/~doug/shootout/editorial.sht ml The programming language shootout gives some more reasons why ocaml is good.

  6. There is more data available for other languages.. by crealf · · Score: 5, Informative
    The article about Lisp is a follow-up of an article by Lutz Prechelt in CACM99 (a draft is available on his page along with other articles).

    However there is more data now, as, Prechelt itself widdened the study, and published in 2000 An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl (a detailed technical report is here).

    If you look, from the developer point of view, Python and Perl work times are similar to those of Lisp, along with program sizes.
    Of course, from the speed point of view, in the test, none of the scripting language could compete with Lisp.

    Anyway some articles by Prechelt are interesting too (as many other research papers ; found via citeseer for instance)

  7. Re:Writeability vs. Readability of LISP/JAVA by jonathan_ingram · · Score: 3, Informative

    Recursion is neither evil nor unnatural. It's the natural way to define many things.

    For example, what's the natural way to define the factorial, n! ?

    0! = 1
    n! = n * (n-1)! if n > 0

    Clear and simple.

    Suppose I have to perform a function on every node of a rooted tree:

    starting with the root:

    walk through any children.
    process the current node.

    And that will translate directly into clear and easy to understand (and easy to debug) code.

    You think and use recursion every day, you just don't recognise it. That's not to say that recursion is the only thing that should be used, but when used correctly it makes code very easy to understand.

  8. Re:It's about the API by gawi · · Score: 5, Informative

    From what I've seen of SLIB, it is not comparable with the Java 2 platform (standard edition) version 1.4. :

    Threads

    I/O (blocking or non)

    Reflection API

    Weak references (and the likes)

    Networking (including http client, ipv6 support, URLs, datagrams, network interface)

    RPC (RMI, CORBA)

    Security (permission, keys)

    Relational database API (implemented by MANY vendors, you can often *choose* your implementation...)

    Text formatting

    Data structures (OK, needs functional improvements, I agree)

    Useful classes: date, calendar, locale, time zones, currency, timer...

    Logging

    Regexp

    Zip

    Preferences

    Accessibility

    Imaging API

    Naming API (directories, ldap)

    Printing API

    GUI API (awt, Swing)

    XML parser + DOM + SAX

    XSLT

    Components (java beans)

    Sound

    Should I continue with enterprise edition?

    I think no langage can compete with Java in terms of API richness and uniformity.

    --
    All humans are mortal. Socrates is a human. Socrates is dead.
  9. I've written 2 Lisp and 4 Java books by MarkWatson · · Score: 4, Informative
    First, great topic!

    I have written 2 Lisp books for Springer-Verlag and 4 Java books, so you bet that I have an opinion on my two favorite languages.

    First, given free choice, I would use Common LISP for most of my devlopment work. Common LISP has a huge library and is a very stable language. Although I prefer Xanalys LispWorks, there are also good free Common LISP systems.

    Java is also a great language, mainly because of the awesome class libraries and the J2EE framework (I am biased here because I am just finishing up writing a J2EE book).

    Peter Norvig once made a great comment on Java and Lisp (roughly quoting him): Java is only half as good as Lisp for AI but that is good enough.

    Anyway, I find that both Java and Common LISP are very efficient environments to code in. I only use Java for my work because that is what my customers want.

    BTW, I have a new free web book on Java and AI on my web site - help yourself!

    Best regards,

    Mark

    -- www.markwatson.com -- Open Source and Content

    1. Re:I've written 2 Lisp and 4 Java books by MarkWatson · · Score: 2, Informative
      Hello Rinikusu,

      The Xananlys free educational system is very usable as-is. The only real constraints on the free personal version is that it will only run for 5 hours (then you simple have to restart the IDE) and that you can not save small stand-alone executables.

      That said, try the free personal version, and if later you need to distribute small compiled applications for Linux or Windows, then buy the Pro version.

      Under Linux, CMU Common LISP is free and generates very fast compiled code. Under Windows, Linux, etc., CLisp is free and although uses compiled pseudo-code, it is fairly fast, and uses very little memory so it is very appropriate for writing small scripts and utility programs.

      -Mark

  10. Why Java succeeded, LISP can't make headway now by joneshenry · · Score: 5, Informative
    Java was never marketted as the ultimate fast language to do searching or to manipulate large data structures. What Java was marketted as was a language that was good enough for programming paradigms popular at the time such as object orientation and automatic garbage collection while providing the most comprehensive APIs under the control of one entity who would continue to push the extension of those APIs.

    In this LinuxWorld interview look what Stroustrup is hoping to someday have in the C++ standard for libraries. It's a joke, almost all of those features are already in Java. As Stroustrup says, a standard GUI framework is not "politically feasible".

    Now go listen to what Linux Torvalds is saying about what he finds to be the most exciting thing to happen to Linux the past year. Hint, it's not the completion of the kernel 2.4.x, it's KDE. The foundation of KDE's success is the triumph of Qt as the de facto standard that a large community has embraced to build an entire reimplementation of end user applications.

    To fill the void of a standard GUI framework for C++, Microsoft has dictated a set of de facto standards for Windows, and Trolltech has successfully pushed Qt as the de facto standard for Linux.

    I claim that as a whole the programming community doesn't care whether a standard is de jure or de facto, but they do care that SOME standard exists. When it comes to talking people into making the investment of time and money to learn a platform on which to base their careers, a multitude of incompatible choices is NOT the way to market.

    I find talking about LISP as one language compared to Java to be a complete joke. Whose LISP? Scheme? Whose version of Scheme, GNU's Guile? Is the Elisp in Emacs the most widely distributed implementation of LISP? Can Emacs be rewritten using Guile? What is the GUI framework for all of LISP? Anyone come up with a set of LISP APIs that are the equivalent of J2EE or Jini?

    I find it extremely disheartening that the same people who can grasp the argument that the value of networks lies in the communication people can do are incapable of applying the same reasoning to programming languages. Is it that hard to read Odlyzko and not see that people just want to do the same thing with programming languages--talk among themselves. The modern paradigm for software where the money is being made is getting things to work with each other. Dinosaur languages that wait around for decades while slow bureaucratic committees create nonsolutions are going to get stomped by faster moving mammals such as Java pushed by single-decision vendors. And so are fragmented languages with a multitude of incompatible and incomplete implementations such as LISP.

  11. Re:Why Lisp is just academic by Anonymous Coward · · Score: 1, Informative
    I just can't resist this one.

    Lisp blurs the lines between library and language. Much of its advantage comes from crafting the tool to fit the problem. It's a change in thinking. MS is re-innovating it in Intentional Programming (honestly taking it in some new directions), and many tricks in C++ try to emulate this power.

    Perhaps you consider it academic because it requires thinking?

  12. Re:Writeability vs. Readability of LISP/JAVA by e40 · · Score: 2, Informative

    Yep, it enables easily-written self-modifying code.

    If you can't see the futility of this in most non-AI environments, god help you.

    Huh?? I've never written a single AI program in my life. Program and data being the same are good for far more than self-modifying programs. To name some uses: program analysis, program configuration (read and eval the data), and macros. The latter is probably the single most important thing in lisp. Unlike pattern substitution in most other languages, macros in lisp are really powerful. See this for more info on macros.

  13. Re:Writeability vs. Readability of LISP/JAVA by hding · · Score: 3, Informative

    Why is it relevant how readable a program written in some language one doesn't know is? I don't think there's anything wrong with Russian because I can't gain any understanding from looking at a Russian text. I think people who know (i.e. use regularly, not studied for two weeks one semester in school) Lisp find it perfectly readable.

  14. Lisp is standarized. by ArmorFiend · · Score: 2, Informative

    Moderators, if you're still here: please mod this up.

    > I find talking about LISP as one language compared
    > to Java to be a complete joke. Whose LISP? Scheme?
    > Whose version of Scheme, GNU's Guile? Is the Elisp
    > in Emacs the most widely distributed
    > implementation of LISP? Can Emacs be rewritten
    > using Guile? What is the GUI framework for all of
    > LISP? Anyone come up with a set of LISP APIs that
    > are the equivalent of J2EE or Jini?

    There are exactly two dialects of Lisp that have relevance to this discussion.

    ANSI COMMON LISP is designed for large application development by a large team of programmers. It is the first object oriented langauge to have an ANSI standard. (circa 1990).

    Scheme is a minimalist language designed for ease of learning. It is specified by R5RS.

  15. Some hopefully useful points by dlakelan · · Score: 2, Informative

    First off, one of the best spokespersons for Lisp is Paul Graham, author of "On Lisp" and "ANSI Common Lisp". His web site is Here.

    Reading through his articles will give you a better sense of what lisp is about. One that I'd like to see people comment on is: java's cover ... It resonates with my experience as well. Also This response to his java's cover article succinctly makes a good point that covers most of the bickering found here...

    I personally think that the argument that Lisp is not widely known, and therefore not enough programmers exist to support corporate projects is bogus. The fact that you can hire someone who claims to know C++ does NOT in any way shape or form mean that you can hire someone who will solve your C++ programming problem! See my own web site for more on that.

    I personally believe that if you have a large C++ program you're working on and need to hire a new person or a replacement who already claims to know C++, the start up cost for that person is the same as if you have a Lisp program doing the same thing, and need to hire someone AND train them to use Lisp. Why? the training more than pays for itself because it gives the new person a formal introduction to your project, and Lisp is a more productive system than C++ for most tasks. Furthermore, it's quite likely that the person who claims to know C++ doesn't know it as well as you would like, and therefore the fact that you haven't formally trained them on your project is a cost you aren't considering.

    One of the points that the original article by the fellow at NASA makes is that Lisp turned out to have a very low standard deviation of run-time and development time. What this basically says is that the lisp programs were more consistent. This is a very good thing as anyone who has ever had deadlines knows.

    Yes, the JVM version used in this study is old, but lets face it that would affect the average, but wouldn't affect the standard deviation much. Java programs are more likely to be slow, as are C++ programs!

    The point about lisp being a memory hog that a few people have made here is invalid as well. The NASA article states:

    Memory consumption for Lisp was significantly higher than for C/C++ and roughly comparable to Java. However, this result is somewhat misleading for two reasons. First, Lisp and Java both do internal memory management using garbage collection, so it is often the case that the Lisp and Java runtimes will allocate memory from the operating system this is not actually being used by the application program.

    People here have interpreted this to mean that the system is a memory hog anyway. In fact many lisp systems reserve a large chunk of their address space, which makes it look like a large amount of memory is in use. However the operating system has really just reserved it, not allocated it. When you touch one of the pages it does get allocated. So it LOOKS like you're using a LOT of memory, but in fact because of the VM system, you are NOT using very much memory at all.

    The biggest reasons people don't use Lisp are they either don't understand Lisp, or have been forced by clients or supervisors to use something else.

    --
    ((lambda (x) (x x)) (lambda (x) (x x))) http://www.endpointcomputing.com a scientific approach to custom computing.
  16. Re:It's about the API by reflective+recursion · · Score: 2, Informative
    It has a massively restricted API.
    Oh my god. Please. Get CMUCL or CLISP. These are Common Lisp implementations (not Scheme). I am simply amazed at the library features available that even C does not have. And they do have a FFI (foreign function interface) which allows you to call C functions (albeit, not portably).

    Do yourself a favor and learn about Common Lisp. Not all members of the LISP family are equal. You are most likely thinking of Scheme. Scheme is a reduced API (on purpose) used mostly for academic purposes. It is most likely what you are taught in CS at the University. Common Lisp is the API heavy LISP with everything (probably the kitchen sink too! though I haven't found it yet).

    Great place to start
    The Common Lisp HyperSpec (The ANSI CL standard reference) -- view this for the API features

    Java's great strength is that it has a huge set of APIs, all in a unified form, making programming a less repetitive and painful experience. Java is for people who understand that recoding the same search tree three hundred times is not going to make them richer, cooler or a better programmer. LISP is for people with time to waste.
    You obviously do not know or understand LISP (the entire family). Learn it (CL would be your best bet). Do not just trash it without understand what it is all about.
    --
    Dijkstra Considered Dead
  17. Lisp: OO or functional? by sigue · · Score: 2, Informative

    One of the beauties of Common Lisp is precisely that it supports both OO and functional (in the loose sense) styles of programming well. It supports each better than Java does. Common Lisp is Object Oriented, while Java is Object Obsessed. Common Lisp's object system is basically a superset of Java's. You could limit yourself to programming in a Java style in CL, but why would you want to?

    Almost any language with functions/methods can support functional programming (in the loose sense) to some degree. Some encourage it more than others. Java discourages it by, for example, not allowing true first class functions/methods, by having many constructs such as IF that don't return values, by insisting that every single bit of code must belong to a single class, etc.

    I agree to some extent that the set of available libraries is often the most important thing when deciding on a language for a project. Many of the Java APIs are made unnecessarily complex due to limitations of the language. But there sure are a lot of them.

    It's a desert topping AND a floor wax.

  18. Re:Writeability vs. Readability of LISP/JAVA by mdalgarno · · Score: 2, Informative

    It may be worth mentioning that much Lisp code is automatically generated using Lisp's macro mechanism. Lisp's simple syntax makes this possible.

    Another point is that Lisp programs tend to be much shorter than programs in languages like Java / C++ for the equivalent functionality. See the figures in the study for example.

    This makes them significantly easier to modify and maintain.

    Mark