Introduction

Croc is a dynamically-typed scripting language in the vein of Lua, ECMAScript (JavaScript), and Squirrel. Many languages have had varying levels of influence on Croc:

  •  Lua, for the underlying execution and memory model, the native API design, and, well, a lot of the language;
  •  Squirrel, for showing that a Lua-like language could look very different and include features such as class-based object orientation, exceptions, arrays, integers, and weak reference objects;
  •  D, for its clear syntax, wonderful array handling (concatenation and slicing in particular), scope action statements, modules, metamethod naming scheme, and nice mix of high-level concepts and fast, low-level mechanisms;
  •  Io, for its prototype-based object model (from which Croc's class model adopts many features);
  •  Python, for comprehensions, decorators, and a simple but flexible standard library;
  •  Haskell and  Bla, for shorter syntax for function declarations, lambdas, and calls.

Croc was originally known as MiniD, a name which echoes its distant origins as an interpretable subset of D. It has developed along its own trajectory for many years, and although the two languages are very different superficially, Croc has at least followed a design approach that is similar to D's. Rather than being built around a single concept like objects or functions, or trying to be completely conceptually orthogonal, Croc has instead aggregated useful features, large and small, from other languages, focusing more on practicality than on conceptual purity. Also much like D, it provides high-level features while maintaining the ability to write performant code when necessary. Keeping a mindful eye on the performance aspects of every feature that has made it into the language shows: the reference implementation is nearly as fast as Lua, and it's continually getting closer. It already beats most other scripting languages without issue, and it does this while remaining expressive and terse, much like Lua.

Why Croc?

A question that I've been asked is "why does Croc exist? Why bother making another scripting language, when there are already so many to choose from which seem to work just fine?" I'm sorry, but I just can't take this view seriously. If the status quo were good enough, change would not occur. But change does occur, which implies that the status quo isn't good enough. Twenty years ago, how many of the numerous, popular programming languages that exist today were around? Why did their inventors feel the need to invent new languages?

I didn't come up with Croc to make a name for myself or to make money. I came up with it because I wanted to learn how to implement a language. I did it for fun. I'm just drawing lines in the sand. If Croc never becomes successful, oh well. There's a very small number of languages that ever do. Invention is a bit like a genetic algorithm looking for a global optimum. Ideas are recombined, evolved, mutated, and selected according to their fitness, resulting in a slow - but inexorable - progression towards perfection. If no one invents, progress halts. Maybe Croc won't be fit enough to survive, but I'll have at least learned something from making it, and if it inspires someone else to create, that's progress.

So perhaps a much more pertinent question to ask is: "why should I choose Croc over another language?" Well, that's a bit more subjective.

Maybe you tried Lua, and you were impressed by how much power and performance could be packed into such a tiny language; but you couldn't shake some bad taste about it -- its loose-feeling semantics, or how you have to implement OOP yourself, or how it lacks some very basic control statements that almost anyone takes for granted, or even just that damn ~= inequality operator.

Maybe you tried Python, and liked how comprehensive its libraries were, how terse and readable the code was, and how it seemed every contingency and feature was accounted for; but you couldn't help but feel that it was like using a  shuttle crawler to drive to the corner, or like the language was expressly designed to allocate heap memory as often as possible.

Maybe you want to automate something and feel like shell scripting languages are some kind of cruel joke, and want to use something sane.

Or maybe you're just a language nerd, like me.

From a more aesthetic standpoint, I can't tell you anything, because whether or not you like Croc is up to you. I enjoy its terse syntax, its efficient mechanisms, and its small but orthogonal set of core features; that's just my opinion. People can argue about syntax and semantics all day. If you don't like Croc, don't use it. But please let me know what you don't like about it and I'll either attempt to provide a justification for why it's that way or take your suggestion into consideration.

Okay, I think I'll get down from the soapbox now.