aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 90eb13df11c002b8105a6817a30ddd03293c46cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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}!"
	return greeting:title()

>> greeting("world")
= "Hello World!"
```

## Features

- Extremely high performance code generation with minimal overhead compared to C
- Extremely fast parallel compilation times
- Memory safety (garbage collection, compiler-enforced null safety, automatic
	array bounds checking, and no uninitialized variables)
- Arithmetic overflow checking
- Simple, low-boilerplate type system with type inference
- Useful and efficient built-in types: arrays, hash tables, structs, tagged
	unions (sum types), cords (efficient string representation)
- Well-defined reference and value semantics and mutability rules
- Language-level support for out-of-the-box function caching emphasizing
	correctness
- Type-safe strings representing different languages with automatic prevention
	of code injection
- Full UTF8 support for both source code and standard library
- Pattern matching with exhaustiveness checking for tagged unions
- Beautiful and helpful compiler and runtime error messages with emphasis on
	user-friendliness
- Structs with known-at-compile-time methods, not OOP objects with vtable
	lookups
- Built-in doctests with syntax highlighting
- Easy interoperability with C

## Dependencies

Tomo has a very small set of dependencies:

- The [Boehm garbage collector](https://www.hboehm.info/gc/) for runtime
	garbage collection.
- [libunistring](https://www.gnu.org/software/libunistring/) for unicode
	string support.
- a C compiler
- and libc/libm, which should definitely already be installed.

Both of which 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:

```bash
tomo foo.tm
# Runs the program
```

Compile a Tomo file into an object file:

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

Transpile a Tomo file into a C header and source file:
```bash
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
```