5 ms·
The Kernel Programming Language (2010)
- haskal 6y agoIsn't this a terrible language for a computer language? Let alone I have to search "Ruby programming" or "Python programming", "Kernel" is not even the top result for "Kernel language". Naming things, indeed the hardest thing in CS.
- dang 6y ago"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something." https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html Threads are super sensitive to initial conditions, so it's particularly important not to do this when the thread is fresh.
- breckinloggins 6y agoI was obsessed with this for a little while several years ago and ended up making my own version based on the same paper: https://github.com/breckinloggins/vau/blob/master/README.md https://github.com/breckinloggins/vau/blob/master/README.md It was my second try at a lisp, the first being erlisp (https://github.com/breckinloggins/erlisp https://github.com/breckinloggins/erlisp). Neither of these projects really went anywhere, but they really scratched an itch I had and I learned so much about programming language implementation while working on them. If you haven't tried yet I highly recommend writing a little lisp of your own. It doesn't need to take over the world to be a meaningful project in your life.
- JoelMcCracken 6y agoIndeed, Kernel is to Scheme as Scheme is to Common lisp. Kernel really is a truly beautiful little idea.
- ungamedplayer 6y agoI played around with erlisp and lfe for a little while. I didnt write anything substantial but it got me interested in common lisp.
- xianwen 6y agoWould you recommend Common Lisp as the lisp dialect for a new beginner and for an eventual hobby project? Do you recommend SBCL over other Common Lisp implementations?
- varjag 6y ago(not the parent poster) Depending on the nature of your project. If it's some purely academic CS exploration, Scheme sometimes (but not always) allows you to express the concepts more eloquently. If it has to deal with practicalities of the broader world however, CL quickly takes over. The development experience is generally smoother in CL too. If you run your things on a major architecture (x86 or aarch64) SBCL is a great starting point. However on certain platforms other compilers are more feature complete.
- ungamedplayer 6y agoHowever most if what you write in one lisp can be ported over to another lisp without too much hassle.
- reitzensteinm 6y agoMy current side project is an implementation of a Clojure like language greatly inspired by and built similarly to Kernel. Absolutely everything user accessible is a first class immutable closure that takes two objects, for arguments and calling environment. If your object has been sent a message, you need to inspect it - by sending the message a message! Then maybe the message messages the environment to evaluate your message, which... The turtles all the way down dependency is handled by equality testing being short circuited in the case of a pointer compare. If you (msg* my-list [:first]), my-list will message [:first] its own [:first] to inspect it. But if you send it the interned [:first] message, it'll recognize it implicitly. This is, as you can imagine, absolutely horrendously slow - as the Kernel inventor found their own implementation to be. The core.clj file [1], which basically implements fn, destructuring let and cond, takes twenty seconds and 88 million function calls to execute. However, the simplicity of evaluation (there aren't even local variables built in) and pervasive immutability means you get partial evaluation almost for free. Running in partial mode, eval evaluates what expressions it can and returns simplified code containing the unbound variables. E.g. where x is unbound and y is 2, (+ (+ 1 y) x) => (+ 3 x) You can partially evaluate multiple times as more arguments are known. In theory this allows you to elide all of the boilerplate when compiling. I'm working on the compiler now. You can also cache whatever you want by writing it to disk, even if it closes over its environment. Every result is written and read to enforce that this works. The initial objects are written in a bootstrap language (js). The goal is to keep that under 1k lines, although it could probably be half that. Then Clojure-like is bootstrapped, although not cleanly. Then the compiler is written in Clojure, which lets you JIT to js and get sane performance. I also have a C version using tcc, but it's harder to develop and significantly lags the js version. It's been pretty interesting, although I struggle to see any practical uses. Writing code in a language with the clean mental model of something like the SICP metacircular evaluator is a joy. [1] https://gist.github.com/reitzensteinm/d95d13609f6d6fd96291332b5dc1247d https://gist.github.com/reitzensteinm/d95d13609f6d6fd9629133...
- QuesnayJr 6y agoI didn't realize that Kernel ends up being necessarily very slow. Can you give a quick explanation of why?
- transfire 6y agoCan anyone explain this in more layman terms?
- orthoxerox 6y agoMost languages have subroutine/function calls that receive evaluated arguments and special constructs that don't. For example, in `sin(x)` the sin() function receives the value of x, but `if (x) { print(1); } else { print(2); }` doesn't evaluate both arms. Even homoiconic languages like various Lisps have so-called special forms which treat their arguments differently from regular functions. Kernel makes everything a special form, so `(sin x)` actually receives a symbol x and a way to evaluate it in the context of its caller, which it immediately does. It's not of much practical use, but it's a very beatiful design, reducing the number of concepts required to describe the semantics of a language even further.
- afranchuk 6y agoI hope you mean it's not of much practical use to languages that already support macro definitions :) because otherwise, some would consider it very useful to be able to define arbitrary macros/syntactic forms!
- orthoxerox 6y agoMost popular languages don't let you define custom syntactic forms. C and C++ have a preprocessor, Scala has macros and you can squint and pretend that passing blocks in Ruby counts, but that's it. It's not a killer feature for the vast majority of programs, Go's boneheaded straightforwardness is a good counterexample.
- sparkie 6y agoKernel's operatives aren't syntactic forms. They're first-class expressions which are evaluated at runtime. The behavior is quite different from macros and provides greater abstractive power. IMO, Kernel is the ideal playground for testing out language designs and features. It's performance limits it from being a practical language for deploying applications.
- iovrthoughtthis 6y agoI remember reading this thesis and implementing just such a lisp like language. The separation of lambda i to vau and wrap was really mind bending at the time but I was really interested in the fewest primitives required to bootstrap a whole language.