The Tomo programming language
Go to file
2024-05-14 13:30:46 -04:00
builtins Bugfix for Num.near() 2024-05-14 00:40:13 -04:00
docs updated docs 2024-03-18 13:34:11 -04:00
include Hook things up so the compiler can run better without installing 2024-04-03 03:08:40 -04:00
test Support corecursive structs 2024-05-14 13:30:46 -04:00
.gitignore Ignore compiled test binaries 2024-05-02 12:51:59 -04:00
ast.c Deprecate interfaces (RIP) 2024-05-12 20:13:19 -04:00
ast.h Deprecate interfaces (RIP) 2024-05-12 20:13:19 -04:00
compile.c Support corecursive structs 2024-05-14 13:30:46 -04:00
compile.h Move arg parsing to inline logic in main() function 2024-04-20 14:55:27 -04:00
enums.c Rename SSS_HASH_VECTOR -> TOMO 2024-04-14 21:58:49 -04:00
enums.h WIP, but functional interfaces 2024-05-12 13:50:06 -04:00
environment.c Deprecate interfaces (RIP) 2024-05-12 20:13:19 -04:00
environment.h Introducing the main() function 2024-04-12 13:09:31 -04:00
LICENSE Add license 2024-04-19 13:41:38 -04:00
Makefile Deprecate interfaces (RIP) 2024-05-12 20:13:19 -04:00
parse.c Deprecate interfaces (RIP) 2024-05-12 20:13:19 -04:00
parse.h More file comments 2024-03-18 12:49:38 -04:00
README.md Syntax tweak: use ':' for blocks 2024-04-28 14:58:55 -04:00
repl.c Improved syntax for optionals 2024-04-30 13:18:47 -04:00
repl.h Adding a REPL 2024-03-30 12:14:24 -04:00
structs.c Make autogenerated equality method more compact 2024-04-23 13:24:01 -04:00
structs.h More file comments 2024-03-18 12:49:38 -04:00
tomo.c Support space indents 2024-05-02 13:48:20 -04:00
typecheck.c Support corecursive structs 2024-05-14 13:30:46 -04:00
typecheck.h Support corecursive structs 2024-05-14 13:30:46 -04:00
types.c Check function return type when promoting 2024-05-13 14:45:49 -04:00
types.h Deprecate interfaces (RIP) 2024-05-12 20:13:19 -04:00

Tomo - Tomorrow's Language

Tomo is a statically typed, safe, simple, lightweight, efficient programming language that cross-compiles to C. Tomo is designed to anticipate and influence the language design decisions of the future.

func greeting(name:Text)->Text:
	greeting := "hello {name}!"
	words := greeting:split(" ")
	return " ":join([w:capitalize() for w in words])

func main(name="World"):
	to_say := greeting(name)
	say(to_say)
$ tomo hello.tm
Hello World!
$ tomo hello.tm --name=åke
Hello Åke!
$ tomo -e hello.tm
$ ./hello --name="john doe"
Hello John Doe!

Features

Performance

  • Extremely high performance code generation with minimal overhead compared to C
  • Extremely fast parallel compilation times
  • Language-level support for out-of-the-box function caching emphasizing correctness
  • Structs with known-at-compile-time methods, not OOP objects with vtable lookups

Safety

  • Memory safety (garbage collection, compiler-enforced null safety, automatic array bounds checking, and no uninitialized variables)
  • Arithmetic overflow checking
  • Type-safe strings representing different languages with automatic prevention of code injection
  • Pattern matching with exhaustiveness checking for tagged unions

Simplicity

  • Simple, low-boilerplate type system with type inference
  • Well-defined reference and value semantics and mutability rules

User-friendliness

  • Useful and efficient built-in types: arrays, hash tables, structs, tagged unions (sum types), cords (efficient string representation)
  • Beautiful and helpful compiler and runtime error messages with emphasis on user-friendliness
  • Full UTF8 support for all text operations
  • Built-in doctests with syntax highlighting
  • Automatic command line argument parsing with type safety and no need for libraries.
  • Easy interoperability with C

Dependencies

Tomo has a very small set of dependencies:

  • The Boehm garbage collector for runtime garbage collection.
  • libunistring for unicode string support.
  • a C compiler
  • and libc/libm, which should definitely already be installed.

The Boehm GC and libunistring should be available on your package manager of choice (for example, pacman -S gc libunistring).

Building

The Tomo compiler can be compiled with either GCC or Clang by running make.

Usage

Run a Tomo file directly:

tomo foo.tm
# Runs the program

Compile a Tomo file into an object file:

tomo -c foo.tm
# Output: foo.tm.o

Transpile a Tomo file into a C header and source file:

tomo -t foo.tm
# Outputs: foo.tm.h foo.tm.c

Tomo uses the environment variables ($CC, $VERBOSE, and $AUTOFMT), which control the compilation/running behavior of Tomo. The default behavior is to use tcc (Tiny C Compiler) for fast compilation, VERBOSE=0, and AUTOFMT='indent -kr -l100 -nbbo -nut -sob' for autoformatting generated code. Any of these variables may be overridden, e.g. CC=gcc VERBOSE=1 AUTOFMT= tomo foo.tm (compile with GCC and verbose compiler output without autoformatting the code).

Installing

make && sudo make install