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.
Please visit tomo.bruce-hill.com for full documentation.
func greeting(name:Text, add_exclamation:Bool -> Text)
message := "hello $name"
message = " ".join([w.title() for w in message.split_any(" ")])
if add_exclamation
message ++= "!!!"
return message
func main(name:Text, shout=no)
to_say := greeting(name, add_exclamation=shout)
say(to_say)
$ tomo hello.tm -- world
Hello World
$ tomo hello.tm -- --name=Ã¥ke
Hello Ã…ke
$ tomo -e hello.tm
$ ./hello "john doe" --shout
Hello John Doe!!!
For more examples, see learnXinY which as an overview of many language features or the other example programs/packages in examples/.
Quick Installation
Quick script to install to ~/.local on your machine:
curl -L "https://tomo.bruce-hill.com/dist/tomo_$(uname -sm | tr ' ' '-').tar.gz" \
| tar -xz -C ~/.local --strip-components=1
Arch User Repository (AUR)
yay -Sy tomo-bin
Install Script
If you don't want to build from source but just want to install, run this script:
curl -o /tmp/install_tomo.sh https://raw.githubusercontent.com/bruce-hill/tomo/refs/heads/main/install_script.sh \
&& bash /tmp/install_tomo.sh
rm -f /tmp/install_tomo.sh
Features
Performance
- Generates performant C code with minimal overhead that runs as fast as C code, because it is C code.
- Extremely fast incremental and parallel compilation
- Language-level support for correct function caching
- 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)
- High-performance arbitrary-precision integers by default with opt-in fixed-size integers with arithmetic overflow checking
- Type-safe strings representing different languages with automatic prevention of code injection
- Pattern matching with exhaustiveness checking for enumerated types (tagged unions/enums)
- Type-safe optional values with low syntax overhead
- Efficient datastructures with immutable value semantics: lists, tables, sets, text.
- Privacy-protecting types that help prevent accidentally logging sensitive information
Simplicity
- Simple, low-boilerplate type system with type inference
- Well-defined reference and value semantics and mutability rules
- No polymorphism, generics, or inheritance
User-friendliness
- String interpolation and debug printing builtins
- Built-in datastructures with a rich library of commonly used methods: lists, tables, sets, text.
- Full-featured packages
- Full UTF8 support for all text operations
- Built-in debugging prints with syntax highlighting
- Automatic command line argument parsing with type safety
- Easy interoperability with C
- Built-in data serialization and deserialization.
- Paths are a native datatype with built-in syntax and a user-friendly API for filesystem operations.
Dependencies
Tomo has a very small set of dependencies:
- GCC version 12 or higher (might work on lower versions, but has not been tested)
- The Boehm garbage collector for runtime garbage collection.
- libunistring for unicode string support (version 1.0 or higher)
- GNU multiple precision arithmetic library for arbitrary precision integer math (version 6.2.1 or higher)
- Binutils to use
addr2linefor stack traces. - and libc/libm, which should definitely already be installed.
If you're feeling incautious, you can run make deps or
./install_dependencies.sh to install all the necessary dependencies. I can't
guarantee this works on all platforms, but has a reasonably high chance of
success.
Building
The Tomo compiler can be compiled with either GCC or Clang by running make.
The first time you build, you will need to specify the Tomo installation
location (the place where the installer will put the tomo binary, the shared
library, and the header files), the Tomo home directory (where Tomo packages
will be installed), and the default C compiler for Tomo to use when compiling
and running your programs. The answers you give will be saved in config.mk,
which you can edit at any time.
Once the configuration options have been set, make will continue along with
building tomo. The resulting compiler and shared library will be put into
./build/.
You can run make test to verify that everything works correctly.
Running Locally
To run Tomo locally (without installing), you can use the script
./local-tomo, which sets some environment variables and runs the version
of Tomo that you have built in this directory.
You can run a program like this:
./local-tomo my-program.tm
Installing
To install Tomo, run:
make install
This will install it to the location you gave during initial configuration.
After this point, you can now run tomo to invoke the compiler and run your
Tomo programs.
Usage
To run a Tomo file directly:
tomo foo.tm
To compile a Tomo file into an object file:
tomo -c foo.tm
# Output: .build/foo.tm.o
To transpile a Tomo file into a C header and source file:
tomo -t foo.tm
# Outputs: .build/foo.tm.h .build/foo.tm.c
You can see the full list of compiler options by running man tomo or tomo --help.
License
Tomo is provided under the Sustainable Use License (see LICENSE.md for full details). This is a source-available fair-code license that does not grant unlimited rights for commercial use, but otherwise has permissive rights for noncommercial use and allows distributing and modifying the source code. It does not comply with the Open Source Initiative's definition of "Open Source", which does not allow any restrictions on commercial use. If you would like to use this project commercially, please contact me to work out a licensing agreement.
1 # Tomo - Tomorrow's Language3 5 Tomo is a statically typed, safe, simple, lightweight, efficient programming6 language that cross-compiles to C. Tomo is designed to anticipate and influence7 the language design decisions of the future.10 documentation.12 ```13 func greeting(name:Text, add_exclamation:Bool -> Text)14 message := "hello $name"15 message = " ".join([w.title() for w in message.split_any(" ")])16 if add_exclamation17 message ++= "!!!"18 return message20 func main(name:Text, shout=no)21 to_say := greeting(name, add_exclamation=shout)22 say(to_say)23 ```26 $ tomo hello.tm -- world27 Hello World28 $ tomo hello.tm -- --name=Ã¥ke29 Hello Ã…ke30 $ tomo -e hello.tm31 $ ./hello "john doe" --shout32 Hello John Doe!!!33 ```36 of many language features or the other example programs/packages in39 ## Quick Installation43 ```44 curl -L "https://tomo.bruce-hill.com/dist/tomo_$(uname -sm | tr ' ' '-').tar.gz" \45 | tar -xz -C ~/.local --strip-components=146 ```48 ### Arch User Repository (AUR)50 ```51 yay -Sy tomo-bin52 ```54 ### Install Script56 If you don't want to build from source but just want to install, run this script:58 ```59 curl -o /tmp/install_tomo.sh https://raw.githubusercontent.com/bruce-hill/tomo/refs/heads/main/install_script.sh \60 && bash /tmp/install_tomo.sh61 rm -f /tmp/install_tomo.sh62 ```64 ## Features66 ### Performance68 - Generates performant C code with minimal overhead that runs as fast as C73 objects with vtable lookups75 ### Safety77 - Memory safety (garbage collection, [compiler-enforced null78 safety](docs/pointers.md), [automatic array bounds79 checking](docs/lists.md), and no uninitialized variables)81 with opt-in fixed-size integers with arithmetic overflow checking83 automatic prevention of code injection84 - Pattern matching with exhaustiveness checking for [enumerated types (tagged85 unions/enums)](docs/enums.md)87 - Efficient datastructures with immutable value semantics:91 accidentally logging sensitive information93 ### Simplicity95 - Simple, low-boilerplate type system with type inference96 - Well-defined reference and value semantics and mutability rules97 - No polymorphism, generics, or inheritance99 ### User-friendliness102 - Built-in datastructures with a rich library of commonly used methods:107 - Built-in debugging prints with syntax highlighting112 user-friendly API for filesystem operations.114 ## Dependencies116 Tomo has a very small set of dependencies:118 - GCC version 12 or higher (might work on lower versions, but has not been tested)120 garbage collection.122 string support (version 1.0 or higher)124 for arbitrary precision integer math (version 6.2.1 or higher)126 stack traces.127 - and libc/libm, which should definitely already be installed.131 guarantee this works on all platforms, but has a reasonably high chance of132 success.134 ## Building137 The first time you build, you will need to specify the Tomo installation139 library, and the header files), the Tomo home directory (where Tomo packages140 will be installed), and the default C compiler for Tomo to use when compiling142 which you can edit at any time.150 ## Running Locally152 To run Tomo locally (without installing), you can use the script154 of Tomo that you have built in this directory.156 You can run a program like this:158 ```159 ./local-tomo my-program.tm160 ```162 ## Installing164 To install Tomo, run:166 ```167 make install168 ```170 This will install it to the location you gave during initial configuration.172 Tomo programs.174 ## Usage176 To run a Tomo file directly:179 tomo foo.tm180 ```182 To compile a Tomo file into an object file:185 tomo -c foo.tm186 # Output: .build/foo.tm.o187 ```189 To transpile a Tomo file into a C header and source file:192 tomo -t foo.tm193 # Outputs: .build/foo.tm.h .build/foo.tm.c194 ```200 ## License202 Tomo is provided under the Sustainable Use License (see205 for commercial use, but otherwise has permissive rights for noncommercial use206 and allows distributing and modifying the source code. It does not comply with207 the [Open Source Initiative's definition of "Open208 Source"](https://opensource.org/osd), which does not allow any restrictions on209 commercial use. If you would like to use this project commercially, please210 contact me to work out a licensing agreement.