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 the strange quotes?

By using asymetric string boundaries, you don't have to escape single quotes or string boundaries 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.

Are xo-strings dangerous?

Passing/outputting unencoded user input directly is dangerous in any programming language, so this does not really matter. Always use the appropriate encoder. For the web, use an HTML encoder for instance.

Can I use threads?

xoscript focuses on simplicity. Threading is not supported. Nor is async. Callbacks can be used to implement async logic to a certain degree through delegation. Most batch processing scripts, web scripts and GUI apps do not need async logic anyway.

Can I use types?

xoscript has been designed to be a typeless scripting language. Typed languages can prevent certain categories of bugs, however they also come with additional overhead and complexity.

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.

Can I use AI?

Generating code in AI can improve your productivity speed. AI systems should be able to process the basic rules of xoscript easily. So yes, these systems can help. However, please always review your AI generated code to avoid security issues.