The Tomo programming language
Go to file
Bruce Hill 8f346b48aa Fix up some compiler flags around floating point numbers so they work
better with -Ofast and have more standardized behavior
2024-10-03 14:19:23 -04:00
.pandoc
docs Update array:sample() to use optional weights and do more error checking 2024-10-02 14:42:51 -04:00
examples Rename from_unsafe_text to without_escaping 2024-09-24 13:26:49 -04:00
stdlib Fix up some compiler flags around floating point numbers so they work 2024-10-03 14:19:23 -04:00
test Add datetime literal and tests 2024-09-30 13:55:55 -04:00
.gitignore
ast.c Simplify code by making name := use ... a Use AST instead of a Declare 2024-09-27 14:56:24 -04:00
ast.h Add datetime literal and tests 2024-09-30 13:55:55 -04:00
compile.c Update array:sample() to use optional weights and do more error checking 2024-10-02 14:42:51 -04:00
compile.h
cordhelpers.c
cordhelpers.h
enums.c Rename TypeInfo -> TypeInfo_t and fix up some typeinfo code 2024-09-30 14:39:30 -04:00
enums.h
environment.c Rename TypeInfo -> TypeInfo_t and fix up some typeinfo code 2024-09-30 14:39:30 -04:00
environment.h Add '$' prefix on all user code 2024-09-24 14:54:22 -04:00
LICENSE.md
Makefile Fix up some compiler flags around floating point numbers so they work 2024-10-03 14:19:23 -04:00
parse.c Fix up some compiler flags around floating point numbers so they work 2024-10-03 14:19:23 -04:00
parse.h
README.md
repl.c Rename TypeInfo -> TypeInfo_t and fix up some typeinfo code 2024-09-30 14:39:30 -04:00
repl.h
structs.c Rename TypeInfo -> TypeInfo_t and fix up some typeinfo code 2024-09-30 14:39:30 -04:00
structs.h
tomo.1 Add -I flag for installing 2024-09-22 14:59:40 -04:00
tomo.1.md Add -I flag for installing 2024-09-22 14:59:40 -04:00
tomo.c Fix up some compiler flags around floating point numbers so they work 2024-10-03 14:19:23 -04:00
typecheck.c Fix up some compiler flags around floating point numbers so they work 2024-10-03 14:19:23 -04:00
typecheck.h
types.c Bugfix for Int*Num typechecking 2024-10-03 13:46:59 -04:00
types.h Add DateTime 2024-09-29 20:06:09 -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, add_exclamation:Bool)->Text:
    message := "hello $name"
    message = " ":join([w:title() for w in message:split($/{space}/)])
    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/modules in examples/.

Features

Performance

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

Safety

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

Dependencies

Tomo has a very small set of dependencies:

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

Building

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

Usage

Run Tomo interactively as a REPL (limited functionality):

tomo
# Starts a REPL session

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

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.