The Kogut FAQ

by Daniel Ehrenberg

What is Kogut?

From the homepage:

Kogut is an experimental programming language which supports functional and scripting-style programming, and a non-traditional flavor of object-oriented programming. Its semantics is most similar to Scheme or Dylan, but the syntax looks more like ML or Ruby.

Where did the name come from?

The name “Kogut” means “Rooster” (“Cock”) in Polish and is pronounced like KOH-goot. Please don't confuse this with the American English other meaning for this word :) As far as the author of this FAQ knows, the alternate meaning does not apply in Polish.

Where can I find an overview of the language?

Right now, check the Kogut homepage.

Why won't Kogut compile?

Make sure that if you don't already have Kogut installed that you're using the bootstrapped version of Kogut. Also make sure that you have a few basic Unix utilities: a C compiler, make, and a Bourne or Bash-style shell. If you're on Windows or Mac OS X, this probably means downloading Cygwin or Fink to get these tools. If all else fails, post your error to the Kogut mailing list.

Why do Kogut and other Kogut programs take so long to compile?

The generated C programs made by Kogut are rather large, and this is not likely to change in the future. In fact, as further optimizations such as inlining are implemented, the output files will probably be even larger. But don't worry; this makes things much more efficient.

Why another programming language?

There are several things that Kogut does that other programming languages don't do as well, so Marcin thought that a new language was needed. Kogut is the first language to call itself a "functional scripting language", and it truely deserves that title. Kogut combines the functional paradigm, ie. minimization of side effects and first-class functions, with a scripting language, which makes it easy to write small programs. Other scripting languages like Perl, Python and Ruby, while good for writing small scripts, were imperitive and inconsistant. And functional languages like Haskell or SML were bad for making small programs and had other problems (SML feels hackish, Haskell is too puritanical).

Why isn't Kogut object-oriented?

Kogut is object-oriented, just not in the traditional sense. Instead of classes, Kogut uses types. To hold instance variables, Kogut uses fields (ie. records or structs). For inheritance, Kogut uses subtyping. For methods, Kogut uses functions that dispatch on the types of their arguments. These are more like multimethod than traditional single-dispatch message-passing systems. For private methods, Kogut uses privacy in modules. For class methods, Kogut can either have functions that dispatch on the type TYPE (which all types are in) or you can simply use modules.
When discussing Kogut, it is typical to hear people using object to mean any first-class thing. This is typical of functional programmers and does not mean something set up to recieve messages, as it would in a language with traditional object-orientation.

Why isn't Kogut more functional?

In a pure functional language like Haskell, functions are all referentially transparent. So if x == y, then f(x) == f(y). This may sound good at first, but it really causes a lot of problems. For example, say you want a function to generate random numbers. Typically, you would expect this to return a different result (usually) whenever it was called (with no arguments). But in Haskell, that would break referential transparency, so you send something to the function that is different every time, authorizing it to break this rule. All of the code dealing with the random number generator also needs to know what the new value of this is, so that it too can break referential transparency. In Haskell, this is encapsulated in the IO monad, but the problem still exists. Kogut does away with referential transparency at the expense of a few academic goals, but it gains much more.

How does Kogut compare to other languages?

Here is a very incomplete table comparing Kogut and some other languages:

Language: Kogut Python Perl C Java OCaml Haskell Scheme
Typing: Strong dynamic Moderately strong dynamic Weak dynamic Weak static Strong static Strong static Strong static Moderately strong dynamic
Lines in canonical "hello world": 1 1 1 5 5 2 2 2
Syntax: Insignificant whitespace and newlines; innovations like -> and => Significant whitespace and newlines Looks like linenoise to the untrained eye Insignificant whitespace and newlines Insignificant whitespace and newlines Insignificant whitespace and newlines; untraditional Significant whitespace and newlines Sexprs

Why doesn't Kogut use a simpler, sexpr-based syntax?

Although it's easier to implement sexprs than Kogut syntax, sexprs are just too verbose for certain things. For example, if you are making a thunk, with s-expr syntax it would probably be
(lambda () code)
or, at best, it might be
(thunk code)
but in Kogut syntax, it's simply
To many programmers, including the Kogut author, sexprs are also aesthetically displeasing because they lead to very deep nesting of parentheses and many levels of indentation.

Where can I find a complete reference manual of Kogut?

Unfortunately, one doesn't exist yet, but hold on; it shouldn't be too long. Right now, Kogut doesn't have that many users, but we expect more people to help eventually. The focus of the development of Kogut is making the code work correctly, not make it well-documented. Once Kogut has a stable codebase with tons of libraries, Marcin will spend more time on improving the documentation, but until then, it's up to the community.

Who's this Marcin guy you keep talking about?

Marcin 'Qrczak' Kowalczyk is the creator of Kogut. So far, he's written all of the code by himself, which is impressive considering the shear volume of it. If you're wondering about his name, he's Polish. Don't bother trying to pronounce it :)