Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

First off, does the x86 solaris binary for SBCL work? You can bootstrap off that if it does.

>My understanding is that Scheme is not 100% LISP compatible, but even worse, that it runs as bytecode on a Java virtual machine. As soon as I see a language running on a virtual machine of any kind, I'm done. That won't enter my systems or my network. If I cannot compile it into straight machine code binary executable, that's it, it's out of the window, and never to return. Not on my watch! Is my finding correct, or is there a Scheme to ELF machine code binary executable compiler out there?

...ummm... wow. It's history time.

Lisp isn't a language or a standard. It's a family of languages. When you say Lisp, you're talking about Common Lisp, which is one of the two popular lisp standards today. The other is Scheme RnRS, with R5RS and R7RS being the most widely implemented. Scheme isn't Common Lisp compatible, as it is a totally different language, although still a Lisp. Some people believe that Scheme shouldn't be regarded as a lisp, but those people are crazy.

Scheme prides itself on minimalism, originating in academia, and designed for PL research and education, and so, much like POSIX, every implementation extends it in a different direction. Some Schemes are suitable for Real Work, others are not.

As scheme is a standard, it has been implemented for a variety of architectures. While it does run on the JVM, that implementation isn't very good. You're probably thinking of Clojure, which is JVM.

There are several schemes that compile to native code. Gambit and Chicken are the most popular. While Guile uses ELF, it uses it as its bytecode format, and while native compilation is planned, we probably won't get it for a good few years. Chibi is bytecode, and will probably stay that way, although it has a decent FFI. If you can live without native compilation, Guile, at least, is worth looking at.

As for Chicken vs Gambit, it's pretty evenly stacked. I know Chicken better than I know Gambit, but I'll try to give a good comparison:

  FOR CHICKEN:
  -Chicken uses Cheney-on-the-MTA compilation meaning that re-entrant continuations (think setcontext/setjmp but better) are no slower than any  function call.
  -Chicken has a really, really good library repository. For a scheme, anyway.
  -Chicken has fairly good POSIX integration
  -Previous versions of Chicken have definitely compiled on OpenSolaris.
  -Chicken has an almost ungodly helpful maintainer and community, with active mailinglists and IRC.

  AGAINST CHICKEN:
  -Chicken isn't reentrant
  -Chicken has no pthread support, only supporting fork(2) and pre-emptive coroutines.
  -Chicken has a really good compiler. You'll see why this is a mark against it in a minute.

  FOR GAMBIT:
  -Gambit has compiler that generates really, really, really good native code.
  -Gambit is, I think, reentrant
  -Gambit has okay POSIX
  -Gambit has Termite, which is erlang-style coroutines, in addition to a Chicken-like system. Guile is the only scheme I know that has pthread support, and it's not in this comparison.

  AGAINST GAMBIT:
  -Gambit's continuation implementation is slower and more limited than Chicken's.
  -Even with BlackHole and SchemeSpheres, the two module sets it has, Gambit is behind Chicken in modules
  -Gambit's FFI is harder to use than Chicken's.
  -I don't know how well Gambit supports Solaris.


First off, does the x86 solaris binary for SBCL work? You can bootstrap off that if it does.

One of them didn't work for either i86pc (that's what we call the x86 and x86_64 platform on Solaris) or sparc, and my requirement is that it has to build and run on both exactly the same, as 50% of my server park is UltraSPARC, and 50% various forms of intel-based processors. But I'd have to look at that again. Something didn't work, or else I would be running SBCL by now.

While Guile uses ELF, it uses it as its bytecode format, and while native compilation is planned, we probably won't get it for a good few years. Chibi is bytecode, and will probably stay that way, although it has a decent FFI.

Now see, that is a severe step back for me: I had bytecode back in 1984, except then the "virtual machine" was called "Commodore BASIC", and "bytecode" was known as tokens, which is what they really are when you learn about AST parsers and trees in computer science at the university. So when I see "bytecode", that's a throwback. And a very bad, bad throwback, masked with pure brute force in terms of massive amounts of memory and processing power. It was a very bad and inefficient, slow solution then, and even with all this processing power and memory, it's a very bad and inefficient, slow solution now. I have never, and will never tolerate that. No amount of programming pleasantness and syntactical sugar will change that.

The way forward is clear to me now: ANSI Common LISP.


...Did you miss the 1/2 of my post where I talked about two of the best native-code compilers scheme had to offer? Gambit and Chicken are both fantastic, and compile to C, no bytecode anywhere.

Also, your understanding of bytecode is deeply, deeply wrong. It's accurate to an extent, true, but Bytecode isn't the same thing as an interpreter, and can be much faster.

But even if bytecode is unacceptable to you, as it does indeed sacrifice performance and I won't deny that, I just gave you 2 native code compilers.

Did you just not notice that, or is there a reason you found them unacceptable?


I managed to miss it! FAIL.

Based on what you wrote, Chicken is out - I want reentrant.

...

I got Gambit to compile, simple expressions appear to work - but I cannot figure out how to compile them to a binary executable.

  cat t.scheme
  (define Hello "Hello")
  gsc t.scheme
  file t.o1 
  t.o1: ELF 32-bit LSB dynamic lib 80386 Version 1, dynamically linked, not stripped, no debugging information available
  ./t.o1
  Segmentation fault (core dumped)
...so that needs more research. I also haven't tested on sparc.


First off, the standard extension for scheme files is .scm

Not really relevant, but I thought you'd want to know.

Since Chicken's non-reentrance only matters if you're passing callbacks into C code, I'll assume you're doing that. It should be noted that Chicken can sort-of have callbacks, so it may be acceptable for your use-case. Either way, be careful to return from C calls in the same order you entered them: not doing so will crash your program. It might seem hard not to do this, but call/cc makes it very easy, and having another thread return into C causes the same problem, since scheme execution threads are pre-emptive coroutines, and are thus one thread from C's perspective.

The problem with the code above is that by default, Gambit generates a shared library for use in other compiled scheme code or a repl. To get an executable, you must specify -exe:

  gsc -exe t.scm
Note also that Gambit's configure script option page (http://gambitscheme.org/wiki/index.php/Configure_script_opti...) provides some handy options to feed to the configure script to speed up the interpreter, notes the reccomended use of GCC (although GCC is not necessary!), and also specifies how to use Sun's compiler to generate 64-bit code on SPARC architectures, if you want to do that. If you're using GCC, this shouldn't matter.

Also, I'd reccomend reading both gambit's manual and the R5RS standard. Knowing the standard and your implementation's deviations and extensions to it is important. Be sure to read the wiki as well, as gambit's manual is not as complete as the wiki.

schemers.org and the scheme wiki have a lot of aids for learning scheme, especially some of the stranger parts, like call/cc.

The Scheme Programming Language Third edition (not the 4th edition, which covers the much-maligned R6RS), and The Little/Seasoned/Reasoned Schemer series can help you think like a Schemer. Scheme is thoroughly multi-paradigm, so this is important.

Finally, there's a lot of gambit libraries all around. The Black Hole and SchemeSpheres module systems contain most of them, although some of SchemeSpheres is linux-specific. You may also take advantage of SLIB, one of the few portable scheme libraries, which contains a wide variety of handy utilities, and SXML, for processing and outputting HTML/XML without the hell.

Whatever you do, you'll probably have to write a lot of FFI code, because the library you want probably isn't wrapped. It's a little better in other schemes, mostly Chicken, but not really that much. It's just the price you pay for using a less popular language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: