← Back to context

Comment by jgalt212

12 years ago

People love to go on and on about the power of macros, but for me, what separates Lisp from the crowd is that it's a compiled language with a REPL.

Are they any other usable compiled languages with a REPL?

Haskell, OCaml, Erlang, Scala, C#, C, C++ (!) and many others. This really doesn't set Lisp apart any more.

  • If by Haskell's REPL you mean GHCi, I think it probably qualifies, but it lacks one of the nicer features of a REPL, which is that you can type the same code interactively that you can load from a file. In fact that's how SLIME works with Lisp, by literally copying forms from a Lisp file into the interactive session. If you copy/paste Haskell code out of your .hs files into GHCi you get errors, because the syntax is slightly different, which I find a bit confusing & inconvenient.

    • Meh. You want to do imperative stuff in the repl, and you can't do that at the top-level in Haskell. The way ghci works is solid. When you are in the ghci repl, you are coding inside the do-notation for the IO monad.

      Really, IMHO, jumping back and forth between the editor and the REPL with constant reloading is a better approach than pasting things into the REPL. I remember when I was playing with Common Lisp, I would always have trouble keeping the code on disk and the code loaded into the REPL synced.

      8 replies →

  • I have used the REPL in all those languages except for Erlang. Trust me. Nothing compares to Common Lisp's Slime. Not all REPLs are equal.

    • Erlang has Distel, which is a pretty powerful SLIME like mode: https://github.com/massemanet/distel (and written by Luke Gorrie, the same guy who wrote SLIME).

      I haven't used either Distel or SLIME extensively enough to say if it's comparable, but it looks fairly similar.

    • Sadly, true. I would cheerfully murder somebody for something as good as Slime for OCaml.

  • The CLIs in these languages are mostly not widely used, provide only few features and are poorly integrated in the language.

    Plus, most don't implement Lisp's READ EVAL PRINT LOOP, but a simpler command line interface.

    • Well none of these languages have anything like Lisp's `read`, but Haskell's interactive loop is fairly usable and extensible. You can add vi-like keybindings and interact with other programs like hoogle, which lets you look up things based on types.

      2 replies →

  • Yes, it is merely an implementation issue as I mentioned in another thread.

    What I think still sets Lisp and Smalltalk apart, is their environments at Xerox PARC.

    We are still far from having back this type of live editing experience in more mainstream languages.

  • Oh please. Besides the fact, that CL has a ton of other features which set it apart any of mentioned langs, none of their REPLs are comparable in power. We have interactive debuggers built in and a language designed for it.

    Take this simple example:

      > (+ 1 "foo")
      
      The value "foo" is not of the expected type NUMBER.
         [Condition of type TYPE-ERROR]
      
      Restarts:
       0: [USE-VALUE] Use a new value of type NUMBER instead of "foo".
       ...
    
       > 0<RET>41<RET>
    
       => 42
      >

Most implementations of Javascript give you a REPL (assuming that JIT counts) in the sense that there's no hard distinction between code loaded from a file and code typed at the console prompt.

FORTH comes to mind.

  • Cool. No idea FORTH had a REPL. Do you use FORTH or have cool project examples?

    • OpenFirmware, such as the various implementations on http://www.openbios.org/ always comes with a Forth prompt.

      I was part of the team that wrote the original Open Source implementation (under GPL terms) named OpenBIOS. The project now also hosts all kinds of other implementations that were later published under BSD terms by their owners (and had 10+ years of market experience under their belt at that time).

      When FORTH started out, one of its differentiators was its live environment: you could test one step (part of an algorithm or similar) at the prompt, then define a "word" (= function) that implements it using the statements you tried, repeat until you finished your program using the words you defined earlier.

      1 reply →

Well, I wouldn't say Forth is specially "usable," (I'm far from an expert, so this may be it) but it applies: compiled with a REPL.

Does it matter if it is a bare-bone systems language with no GC or automated memory management?

Erlang and Elixir, a new language for the Erlang VM with a different syntax, are compiled languages with REPLs. I also think about Scala and others for the JVM, but I have a feeling you do not think of those as examples because of the VM or the lack of native code compilation. I could be wrong.

Any language can have a REPL, it is a plain implementation issue.

  • It's not. You will detect that in many cases it is a language issue, too. If you look at Lisp, you can see that the language definitions are optimized for interactive use and have a lot of facilities defined at the language level: incremental definitions, evaluation, effects of loading code, a robust interactive error system, ...

    • How come it is not?

      - Create an interpreter library for language X

      - Offer a GUI/CLI application using the said library

      Not all repls need to work at function level like LISP does.

      3 replies →