SBCL: The Ultimate Assembly Code Breadboard

12 years ago (pvk.ca)

I am still trying to get a handle on Lisp and Scheme, but blog posts and projects like this, and the Common Lisp OS posted here previously [0] make me really impressed and confused about why people, if you dislike the Lisp style and philosophy, cannot admire its bizarre powers. I mean, I see most languages from that paradigm (why hate when you can be entertained, either by the good or bad), but this is very cool and way over my head.

[0] https://news.ycombinator.com/item?id=146670

  • > cannot admire its bizarre powers

    Pure jealousy =]. People like to rag on lisp, but their language dujour just got what lisp's been packing for at least 20 years. Between the interactive programming model, compiling to machine code, real threading, macros, and many other features, it's the perfect secret weapon.

    • As much as I find lisp interesting, I've always hated the kind of smug comment like yours that every discussion on Lisp inevitably brings. Lisp is certainly far from perfect, and there are a ton of good technical reasons why people use other languages.

      3 replies →

    • > People like to rag on lisp, but their language dujour just got what lisp's been packing for at least 20 years.

      Strong static typing? ;o)

      4 replies →

SBCL is an amazing project. I use it for some personal projects, but where the SBCL community really shined, in my experience, was on an AI for medical records project I worked on several years ago. We had some issues with SBCL that were fixed very quickly. A nice experience.

The only thing I would point out is that "free" FXCH isn't free. It has quite a lot of baggage inside the microprocessor and was something that designers made a conscious decision to support (see Pentium vs. AMD K5).

There are good reasons why hardware supports registers instead of a stack. However, given where x86 was at the time, the hardware designers of the time took the penalties because the gains to the software folks justified it.

Those choices no longer hold.

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.

      9 replies →

    • 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.

      3 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.

  • 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, ...

      4 replies →

Thank you! I did not know about SBCL, or Paul Khuong, before. This is the most interesting thing I've read this week. This kind of article is why I come to Hacker News.

Site is currently down for me, presumably deluged by traffic. A Google cache exists, but at least on Chrome it still needs to load something from pvk.ca before it displays any portion of the webpage. Therefore, here is the page source with most of the markup removed; you can get from it some idea of what the page is about.

http://pastebin.com/JL7aRcpn

  • It looks like he (accidentally?) included a gigantic scanned image in the post. However most of the comments on the last pvk.ca post submitted here were also about how it's down (https://news.ycombinator.com/item?id=7286655), so the blog config/hosting might just be borked.

    Google Cache seems to always try to load the images and hang for a while if the site is unreachable (not sure why, since if the site were reachable I wouldn't be on Google Cache in the first place). You can click "text-only version" in the top-right to stop that.

    • Thanks for the heads up on the scan! That's what I get for publishing just before rushing to dinner.

      The blog is just a bunch of static files, so there shouldn't be any issue. This situation is really annoying; I'll figure something out soon.

djb once wrote a FORTH-like interpreter.

Anyone get that old code to run today?

I have always thought think LISP/Scheme's "best" use is to write code generators (e.g., that output C or asm). I know there's at least one LISP/Scheme project that outputs C, so I know I'm not alone in thinking this can be useful.

FORTH has always seemed better suited to driving hardware than any LISP/Scheme.

This is some sort of bias perhaps. These are both very flexible languages.

What if historically programmers tried to use FORTH for "AI" and LISP as a "portable assembler"?

  • Bigloo Scheme (among others) generates C code. I've used it on a few projects to process, reformat, and visualize some meteorology data and was pleased with the result. I know some other people that used it for other scientific application development (including 3D graphics) and it performed beautifully. One of my friends used Chicken Scheme to write some interesting web scraping tools. It also has the ability to compile to C.

  • > What if historically programmers tried to use FORTH for "AI" and LISP as a "portable assembler"?

    Then I guess the Burroughs B5000 and its ilk might have become a popular machine for AI research. We would have had Stack Machines instead of LISP Machines.