Question on categorizing a language

I would like to solicit some opinions from the community on a language concept I've been working on. I'm not sure what category to describe it as. The language is called 2e -- two e's, as in expression evaluator -- and for the most part, that is exactly what it does, evaluate an expression.

Other than the syntax used for defining functions, the whole program is one large single expression, composed of operators and operands. What looks like a statement delimiter (the ";" operator) is actually similar to the comma operator in C; it is a "join", where the expression on both sides of the operator are evaluated, and the left side result is thrown away and the right hand expression result is returned. This is why I assert that the whole program (minus function definitions) is one single expression.

Conditionals are handled via a C style inline-conditional and "while" loops are done with an iterative variant of the inline-conditional syntax, so that complex code segments can be part of a larger expression. There are no other flow control constructs (other than function calls).

On the surface, it looks like a procedural language, but it doesn't execute a sequence of steps, instead it evaluates one expression. Also, functions are recursive, and you can pass functions as arguments to other functions. These two items combined make it almost fit the requirements for a functional language. However, it includes a standard assignment operator that is used to change state of variables (the assignment operator can logically appear anywhere in an expression, just like C), so that seems to exclude it from the functional category (although there is no reason you can't program in a functional style).

So my main question is, what type of language is this, functional or procedural? Or some other type that I haven't studied? My second question is if anyone would find this language useful for any projects or research purposes. The main appeals of the language is an algebraically "clean" syntax and a rather simple easy to understand interpreter. The parser was done by hand using classical algorithms, instead of using lexx / yacc, and the interpreter is provided in the form of a library that can be imbedded into other applications. I've got some clean up to do on the code to make it usable for study (there's been some performance modifications added that end up making it harder to read; I've got plans to fix that), and more documentation is needed. I've seen mention on this site of plans that others have for creating experimental languages, feel free to grab any techniques or code that you want.

The site for 2e is, where there is some documentation and code samples, but I can post some specifics that highlight various language aspects if that helps.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Sounds "functional"

I would say that having programs structured as expressions rather than statements was the defining feature of a functional language, along with first class functions. Your description sounds very similar to ML: apart from declarations, a program is one expression; it even has the ';' operator as you describe it. The only difference would be the focus of the language - while ML has mutable variables, it favors purely functional code.


Sounds like a straightforward imperative/procedural language to me. Or perhaps an impure functional/applicative language, if you don't like the first description.

I don't really get your distinction between executing a sequence of steps and evaluating "one" expression. What's the difference between an expression, a statement, and a program, other than nomenclature? Simply the fact that they are distinct syntactic categories, which is sometimes useful for separating distinct concepts, and other times leads to unnecessary redundancy.

Doesn't an interpreter for a procedural language execute one program? Executing a particular sequence of steps is a strategy for expression evaluation; the two are not mutually exclusive. When you have either internal dependencies (definition-use) or external dependencies (memory, I/O), the valid execution sequences for evaluating a particular expression are constrained.

In the end, it doesn't really matter how you categorize the language if you find it useful. Since it sounds like a fairly simple implementation, I think your best bet would be to make it into a "build your own language" tutorial. That might lead to ideas for interesting, more researchy extensions, if that's a direction you'd like to take.

If "join" is throwing away

If "join" is throwing away the results of the previous sub-expression, that implies that these sub-expressions are modifying state somewhere that can be retrieved by other sections of the program. This would imply to me that the language is a "normal" imperative language with an elegant, psuedo-functional interpreter.