FAQ

Frequently asked questions...

In this section I try to answer frequently asked questions. If you have a question about the xoscript project, and it is not in the list, feel free to send me an e-mail!

Why xoscript?

xoscript aims to be a minimalist scripting language, with excellent backward compatibility. Most programming languages have accrued quite some cruft. Xoscript aims to remain compact, simple and scripty.

How is xoscript different?

The most notable differences are: smalltalk-inspired syntax, dynamic scoping, fault tolerant message passing, prototypical inheritance, always pass by reference, recursion is disabled by default, asymetrical string literal boundaries, string interpolation through replacement, unit of measurement through qualifiers and True/False/None are references.

Why dynamic scoping?

Dynamic scoping is incredibly simple to reason about, if a variable is not found within the function, xoscript will look if it has been defined in one of the calling functions. That's it. Also with dynamic scoping there is no need for dependency injection patterns.

Why fault tolerant?

Sending unknown messages (calling non-existant methods) does not result in errors. This allows you to write more compact code without testing for specific conditions or relying on interfaces or contracts.

Why does space matter?

Messages are space sensitive, i.e. +2 is different from + 2. This is because messages consisting of a single character are written without a colon : therefore the lexer must know if there is a space after the message.

Why no classes?

Classes add unnecessary syntax. In xoscript you can base an object on another object by sending the new message. If you override the new message you basically create a class anyway.

Why pass by reference?

Many languages mix pass by value and pass by reference. Although most people memorize the basic rules per language, xoscript simply passes everything by reference. You need to make copies explicitly by sending the copy message. So this is easy to remember. There is just one rule. Pass by reference. In addition, this is quite memory efficient.

Why asym. string delims?

By using asymmetrical string delimiters, you don't have to escape single quotes or single string delimiters within the string literal itself (as long as it does not create ambiguity for the lexer).

How to use recursion?

You can enable recursive messaging explicitly by sending the recursive message. By default, recursion is blocked to prevent infinite loops.

No async/threads?

Async/threading is basically cooperative multitasking, it is fragile and hard. This work is delegated to the OS scheduler.

No type checking?

Although strict types and type checks allow developers to catch certain categories of bugs, this is most effective in a linting and compile step which is not suitable for a scripting language. Runtime checks defeat the purpose. In addition, programming with strict types and type checks/hints involves substantial overhead and complexity which conflicts with the design goals of xoscript.

Why single return?

xoscript functions can only have one exit point. This is a consequence of how the lexer/parser works. However, it also keeps your code easy to sync. Upon changing the return value, you never have to update additional exit points as well.

Why interwoven arguments?

xoscript messages (like smalltalk) use interwoven arguments, the arguments are part of the message. This allows you to always remember the order of arguments.

Are properties private?

No. All object properties, as specified by the own keyword are protected (not private). Only methods that are part of the inheritance tree of the object where they are defined can access them. Other objects cannot access them.

Why CGI?

CGI is the primary way to connect a xoscript application because of it's simplified programming model (compared to threading) and because on modern multicore hardware it scales well. CGI also provides process level isolation and gives you a share-nothing architecture for free, allowing the use of advanced sandboxing techniques like pledge() on OpenBSD.