A programming language in the making

eXperimental

eXperimental is a compiler for x, a fast, compact programming language. x is compatible with PureBasic (PureBasic code is x code), and C-style spellings work alongside it, in the same program.

Two styles, one language

These two programs are the same. Use whichever reads best to you, or mix them.

; PureBasic style
Procedure.i Square(n.i)
  ProcedureReturn n * n
EndProcedure

OpenConsole()
For i = 1 To 3
  PrintN(Str(Square(i)))
Next
// C style
int Square(int n) {
  return n * n
}

OpenConsole()
for (int i = 1; i <= 3; i++) {
  PrintN(Str(Square(i)))
}

Both print 1, 4 and 9. A new line ends a statement, so no ; is needed, and names aren't case-sensitive: PrintN, printn and PRINTN are the same.

What it does today

  • Writes the executable itself. There's no linker, no assembler and no C compiler involved: eXperimental turns your source straight into a program.
  • Small programs. Only the library procedures a program uses are included, so "Hello, world" is about 3.5 KB.
  • 64-bit Windows and Linux. A Linux program is a single file with no dependencies, not even the C library: it talks to Linux directly. The compiler runs on both, and makes programs for either.
  • A library written in x. Strings, files, lists, maps, arrays, sorting, maths, memory, time and threads, with PureBasic's names and arguments. See the library index for every function.
  • Strings that look after themselves. Unicode (UTF-16), counted and shared, and only copied when one copy changes.
  • Threads. Threads, mutexes and semaphores, and Threaded variables. A program only pays for thread safety when it uses threads.
  • The rest of the language. Procedures, structures and pointers, constants and enumerations, macros, modules, interfaces, data sections, conditional compilation, and calling the operating system.

On the way

  • More targets: macOS, ARM64 and RISC-V, and for retro machines, the 68000 (Atari ST and Amiga) and the Z80N (ZX Spectrum Next).
  • 8-bit strings (UTF-8), as a type of their own.
  • Threading built into the language, such as loops that run in parallel.
  • A compiler written in x. Today's compiler is written in PureBasic; the aim is for eXperimental to compile itself.

eXperimental is still being written, and isn't available to download yet. The reference below grows with it: ✅ marks what works, 🟡 what partly works, and 🔜 what's still to come.

The reference

  1. Getting started
  2. Syntax basics
  3. Types and variables
  4. Operators and expressions
  5. Control flow
  6. Procedures
  7. Strings
  8. Arrays
  9. Structures and pointers
  10. Constants and enumerations
  11. Calling the operating system
  12. Compiler functions
  13. Source files and includes
  14. Macros
  15. Lists and maps
  16. Data sections
  17. Conditional compilation
  18. Modules
  19. Interfaces
  20. Parallel code
  21. Classes