
The Kernel Programming Language - adgasf
http://web.cs.wpi.edu/~jshutt/kernel.html
======
orthoxerox
I wonder if it's possible to infer the types of a Kernel program.

~~~
sparkie
Certainly not with our existing type systems. It might be possible if somebody
could come up with a new system with the _vau_ calculus at its core rather
than lambda calculus (as Hindley-Milner etc. are).

I think it would be a dead-end with kernel-standard though. The presence of
mutability and cyclic data structures seems like the problem would be as
unsolvable as the halting problem. For any serious investigation of type
inference, you would probably need to stick to an immutable Kernel subset. The
Kernel Report does make mutability optional.

~~~
CuriousSkeptic
Hmm, I don’t see why vau-calculus should change things. Fexpr are more or less
like expression trees in C# no? (Which are statically typed, at least where
they compose with the rest of the program). Granted, dynamic languages in
general can be a challenge, but TypeScript is a good argument for it being
feasible at least.

------
klibertp
The same idea - allowing a procedure to get either a reference to a value or
syntactic description of the value coupled with the dynamic environment from
the procedure call-site - is implemented in Io language.

Io is a purely OO language influenced by Smalltalk and Self the most; it has
only objects and no classes, objects have named slots which reference other
objects (some of which are "activatable" \- callable, IOW - and they're then
called methods) and all computation happens by sending messages between
objects. If a message name corresponds to the slot name which holds a method,
that message send (by default) results in the method being called.

Messages are just objects, which carry both dynamic environments from the
place they were sent and the arguments, which are passed as message objects
themselves. The method may then choose to evaluate some of the messages passed
as arguments or not; but it can also change the messages before evaluating
them, as the Message objects are mutable and respond to many of the same
messages that Lists respond to, including `setAt(idx, val)` for example.

(One tricky part of all of this is getting the relation between Message
objects and message-sends in Io. In short, Messages are objects which have
target, name, and a list of arguments. These objects can be both serialized
into, and read from a string, in which case they look like this:

    
    
        target msgName(arg1, arg2, ...)
    

The place in program _text_ and the _lexical_ environment at that point is a
_message-send_ , while Message is a runtime representation of that message-
send and it references _dynamic_ environment at the point of call.

And BTW, in the syntax of message-send above, both `target` and `(arg1, ...)`
are optional. In Io, code like this:

    
    
        1
    

is, in fact, a message send with `name` set to `"1"`; it's first sent to the
current `this` object, and then bubbles up the inheritance chain to `Object`,
which handles the message by returning a Number object with value of `1`.)

The effect is really interesting: the language is incredibly expressive, with
metaprogramming support rivaling Lisp (Io is also homoiconic), but with a very
different set of metaphors/concepts it's built on. It could be more
approachable for normal devs (than Lisps), as its syntax is arguably closer to
the mainstream, and the OO metaphor is widely known (although not really
understood in a way Smalltalk, Self or Io understand it).

Anyway, being able to write functions which can decide whether they want, and
how exactly, evaluate their arguments is a powerful technique. I think REBOL
and Red are also able to do this, and I think TCL too. Factor would also
count, probably. It's a shame it's not supported in more mainstream languages
- may be hard to implement efficiently, or may not be that useful with non-
homoiconic languages or something like that.

~~~
oddity
I’m a big fan of Io, but, sadly, it is no longer maintained. I’ve toyed around
with writing a more minimalistic implementation suitable for lua-style
embedding, but have never found the willpower to finish it.

~~~
klibertp
That's true, although I'd say it's still _maintainable_ , and Steve Dekorte
still accepts Pull Requests. I had a bit of an adventure with Io last year[1],
which was part of a side-project I had in mind for a very long time, namely a
MUD server in the style of LPMUDs. I learned a lot and even wrote some of the
code for the server, then decided to port pyparsing (parser combinator
library) to Io, and then - as usual - the life happened and I forgot about it.
Still, that project was with me for the past 20 years, and I believe I will
get back to it at some point[2]... all that just to say that I'm not going to
become the main maintaner, but if there are just a few interested people, I'd
be willing to help :)

[1]
[https://klibert.pl/posts/adding_destructuring_bind_to_io.htm...](https://klibert.pl/posts/adding_destructuring_bind_to_io.html)

[2] Fortunately for me, Io has all I would need for this project, including
async I/O and lightweight co-routines.

------
fake-name
> The _Kernel_ Programming Language

Because no one uses `kernel` for anything already.

I mean, holy fucking hell, if you're creating a programming language, choose a
name that you can fucking search for.

~~~
coldtea
> _Because no one uses `kernel` for anything already._

Because people will seriously be perplexed between an esoteric experimental
programming language and operating system kernels, right?

Like that huge fiasco in the early 50s, when people confused OS kernels with
corn...

~~~
fake-name
People, no. Pretty much every search engine ever? Ohhhhh yeeeaaahhh.

Besides, the Linux kernel has a specific-enough dialect of C that I assumed
this was about linux kernel programming based on the title.

~~~
leadingthenet
> the Linux kernel has a specific-enough dialect of C that I assumed this was
> about linux kernel programming based on the title

Yeap, same here. This is a really poor naming choice.

