7 ms·
Owl Lisp – A purely functional Scheme that compiles to C
- hellofunk 10y agoI really like the growing interest in making lisps that compile to C, and one that is purely function is even better. I'd be curious how the GC in this compares to the fascinating work in Chicken for novel GC in C environments.
- qwertyuiop924 10y agoWhat's so novel about Chicken's GC? Cheney on the MTA is quite clearly novel (Chicken compiles to CPS and essentially GCs its stack frames IIRC, making call/cc as fast as any other procedure call), but the algorithm itself is quite ordinary, IIRC.
- etatoby 10y agoI agree that Chicken is based on a brilliant idea that turned out to work really well in practice. It's a very practical language / implementation.
- qwertyuiop924 10y agoIt's my favorite Scheme. It's minimalist, but practical, and usable for Real Work. It's everything I like about Racket, without all thinks I don't like about Racket (Racket's a fine language, it's just not my thing).
- jopython 10y agoIt is not practical enough for me to have a language which does not support native threads.
- hga 10y agoAnd as I read it sometime ago while searching for Scheme implementations with native threads, Cheney on the MTA is inherently single threaded.
- justinethier 10y agoNot necessarily, it can be extended to support multithreading: https://github.com/justinethier/cyclone https://github.com/justinethier/cyclone
- dleslie 10y agoCyclone is a new Scheme with native threads that uses cheney.
- qwertyuiop924 10y agoOnly Guile does that, AFAIK. And Chicken's threads are perfectly usable in most cases. And you can always fork(2), if you really want to.
- dleslie 10y agoThere are ways to use native threads with Chicken; it's a bit hairy, though. Chicken 5, the upcoming partial rewrite, is worth keeping an eye on.
- lispm 10y agoIf you find Lisp to C compilers interesting, then Common Lisp has a bunch for you. The first CL to C compiler was KCL (Kyoto Common Lisp from Japan in the mid 80s). It is the parent for several other compilers. Gnu Common Lisp, Embeddable Common Lisp, mkcl, mocl. There are also attempts at C++ as a target language. See CLASP. https://www.gnu.org/software/gcl/ https://www.gnu.org/software/gcl/ https://common-lisp.net/project/ecl/ https://common-lisp.net/project/ecl/ https://common-lisp.net/project/mkcl/ https://common-lisp.net/project/mkcl/ https://wukix.com/mocl https://wukix.com/mocl https://github.com/drmeister/clasp https://github.com/drmeister/clasp
- hellofunk 10y agoCool, but then you have to actually deal with Common Lisp, which is not the kind of lisp that interests me. The more functional-oriented lisps like this Owl, and Clojure, are quite different in many ways from CL.
- ZenoArrow 10y agoHow does Chicken compare to Gambit? http://dynamo.iro.umontreal.ca/wiki/index.php/Main_Page http://dynamo.iro.umontreal.ca/wiki/index.php/Main_Page https://github.com/gambit/gambit https://github.com/gambit/gambit
- qwertyuiop924 10y agoThe perf is generally comparable (each has optimizations the other does not, although gambit is a bit faster in the general case), but Chicken has really fast call/cc. Also, Gambit has a very small library collection, especially compared to Chicken's, which is among the best of all the schemes, Library-wise. Neither supports native threading, and Chicken isn't fully re-entrant, which can lead to some problems integrating some libraries. Both have excellent FFI, but Chicken's is a bit better, IMHO.
- reitzensteinm 10y agoI've got an upcoming talk at EuroClojure on the subject: http://euroclojure.org/speakers#mreitzenstein http://euroclojure.org/speakers#mreitzenstein Taking advantage of immutability and using clojure.spec generators at the top level, it specializes/simplifies the code using really simple transformations. Demo of the specialization here: http://reitzenwebserv.s3.amazonaws.com/opt/index.html http://reitzenwebserv.s3.amazonaws.com/opt/index.html
- qwertyuiop924 10y agoOwl's pretty nice, but I wish it was documented better: I can't actually get into it, because I have no idea what is valid Owl. Also, I like how it doesn't call itself Scheme, because it's not Scheme. This is a problem that annoys me: people seem to think that if you're a lisp-1, and you follow a few naming conventions, you can call yourself scheme. That's like calling yourself Common Lisp because you're a lisp-2 with setf. Scheme is a family of languages, true, but it does have a formal spec, and if you do not follow it (or at least approximate it), than you are not scheme. Scheme inspired, or scheme derived, maybe, (Racket got this one right, and changed its name once it started going too far afield, thus saving us from having to explain to 1000 confused newbies that PLT Scheme isn't Scheme, and now must only deal with people who tell newbies that Racket is Scheme) but if you don't meet IEEE or RnRS, or at least Scheme as described in AIM-349 (the original Scheme: a radically different language from Scheme today), than you're not Scheme, and if you call yourself that, than you'll confuse people. /rant
- nilved 10y agoThe title is "a purely functional Scheme..."
- qwertyuiop924 10y agoNo, no, I think Owl did well, because it didn't say that it's scheme, at least up front. It's honestly more akin to DSSSL than anything else. Saying that it's "functional scheme" is far less likely to cause confusion than some of the other things people have done. EDIT: No, it's not like DSSSL, and it's less cool than I thought it was. It's still cool, though.
- rubiquity 10y agoVery cool! By purely functional I'm guessing they mean immutable by default? Aside from Clojure, what other Scheme/Lisp implementations are immutable by default? I know Lisp-flavoured Erlang is due to being on the BEAM but I'm curious what else is out there.
- sparkie 10y agoI'm looking through the tests, and there's side effects everywhere. I'm confused as to what the author implies by "purely functional", so it would be nice to have some additional information.
- kr7 10y agoThere are definitely I/O side effects, but it looks like functions for mutating data structures (like set-cdr!) are intentionally unimplemented: https://github.com/aoh/owl-lisp/blob/master/scheme/base.scm#L393 https://github.com/aoh/owl-lisp/blob/master/scheme/base.scm#... That must be what they mean by "purely functional".
- qwertyuiop924 10y ago....soo, it's racket, but without all the shiny libraries and mcons. It sounded like it was going to be general-purpose DSSSL. That would have been so much more cool.
- 35bge57dtjku 10y agoIf I understand what you mean by "immutable by default", then it's all Scheme implementations, and probably all Lisp as well.
- nialo 10y agoCommon Lisp variables are not even a little bit immutable by default. setf is the opposite of immutable values, you can mutate any place in a way that's visible everywhere regardless of any sort of scoping. Immutable by default might be what you'd get if CL only had let to introduce/"change" variables.
- lbenes 10y agoC++ has many pure functional features that C lacks. For example immutable methods with const and Lambdas. Wouldn't these features make it easier target to C++ rather than C? Do these functional features only make it easier for a human to write functional code or is there some other reason these Lisps all use C?
- palunon 10y agoLambdas are actually just a nice way to write functions/function objects without polluting the scope. I guess a compiler have no such problems. Immutable methods are the same thing as a safety check for humans. As you want to check for these things anyway (since you probably don't want errors to come from the c++ compiler), they don't add value. (AFAIK, they may trigger optimizations, but so does passing const parameters to a free function, which is the C equivalent)
- qwertyuiop924 10y agoIf you're passing around your environments in the C code (which you should be doing anyways), than there is no reason it would be easier to target C++.
- wyager 10y agoIf you're writing a compiler, you're going to want to explicitly manage closures and function pointers anyway.
- nv-vn 10y agoSince you're compiling and not interpreting, you can do all the checks that a variable doesn't get mutated at compile-time. There's no need to defer these checks into the C code.
- zer01 10y agoaoh also wrote the very awesome Radamsa fuzzing engine in it - https://github.com/aoh/radamsa https://github.com/aoh/radamsa
- wepple 10y agoYeah, unfortunately my only exposure to owl lisp is wishing that Radamsa wasnt written in it so I could understand/modify radamsa better. Radamsa is seriously awesome.
- zer01 10y ago...and that's 100% my experience with it too :-/ Awesome fuzzing engine but modifying it is not for the faint of heart.
- ycombinatorMan 10y agoi absolutely dont understand why people are interested in languages like this
- Jeaye 10y agoIt's not purely functional if it supports side effects all willy-nilly. Scheme sans mutation (which is not the same as Racket, since Racket's stdlib still supports mutation) is no more purely functional than modern C++ sans mutation. With that said, purely functional programming is arguably just a hassle; I tend to think that "functional-first," as I call it, programming, a la Clojure, is a good balance between practical and pure. In this way, side effects are adhoc, but all definitions are immutable by default.