This is a very early version of a programming language I'm currently working on.
git clone https://github.com/akyoto/q
cd q
go build
This will produce the q
compiler in your current directory.
./q build examples/hello
./examples/hello/hello
- Fast compilation (<1 ms for simple programs)
- Small binaries ("Hello World" is 247 bytes)
- High performance (compete with C and Rust)
- Tokenizer
- Scanner
- Parallel function compiler
- Error messages
- Expression parser
- Function calls
- Infinite
loop
- Simple
for
loops - Simple
if
conditions - Syscalls
- Detect pure functions
- Immutable variables
- Mutable variables via
mut
- Variable lifetime tracking
-
return
values -
import
standard packages -
expect
for input validation -
ensure
for output validation - Data structures
- Heap allocation
- Type system
- Type operator:
|
(User | Error
) - Stack allocation
- Hexadecimal, octal and binary literals
-
match
keyword -
import
external packages - Error handling
- Cyclic function calls
- Multi-threading
- Lock-free data structures
- Multiple return values
- Rewrite compiler in Q
- ...
- Exclude unused functions
- Function call inlining
- Assembly optimization backend
- Disable contracts via
-O
flag - Expression optimization
- Loop unrolls
- ...
- Unused variables
- Unused parameters
- Unused imports
- Unmodified mutable variables
- Unnecessary newlines
- Ineffective assignments
- ...
-
+
,-
,*
,/
-
==
,!=
,<
,<=
,>
,>=
-
=
-
+=
,-=
,*=
,/=
-
&=
,|=
-
<<=
,>>=
-
<<
,>>
-
&&
,||
-
&
,|
-
%
- ...
- x86-64
- WASM
- ARM
- ...
- Linux
- Mac
- Windows
- ...
- No binary dependencies (not even libc)
- No compiler dependencies (no LLVM, no GCC, ...)
- No global state (all mutable variables are local)
- No side effects when importing a package
- No name shadowing, names never change their meaning
- No complicated classes, just simple data structures
- Type system (reduce bugs at compile time)
- Linters (reduce bugs at compile time)
- Tests (reduce bugs at test time)
- Contracts (reduce bugs at run time)
- Simple dependency management
- Auto-formatter for source code
- User-friendly compiler messages
- benchmarks contains benchmarks for compilation speed
- build contains the actual compiler source
- cli contains the command line interface
- examples contains a few examples that are also used in tests
- lib contains the standard library
q build -a
q build --assembly
q build -O
q build --optimize
This will disable all expect
and ensure
checks.
q build -t
q build --time
sudo ln -s $PWD/q /usr/local/bin/q
q system
The output should look like this:
Platform: linux
Architecture: amd64
Go version: go1.13.5
Working directory: /home/eduard/projects/akyoto/q
Compiler path: /home/eduard/projects/akyoto/q/q
Standard library: /home/eduard/projects/akyoto/q/lib
Last modified: 2019-12-27 11:06:47.841459978 +0900 KST
CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
CPU threads: 12
There is a simple VS Code extension with syntax highlighting.
git clone https://github.com/akyoto/vscode-q ~/.vscode/extensions/vscode-q
Unlikely. There will be changes in the near future.
There are currently 2 builtin functions, syscall
and print
. In the future we'd like to remove print
so that syscall
becomes the only builtin function.
go test -coverpkg=./...
go test -bench=. ./benchmarks
Please take a look at the style guidelines if you'd like to make a pull request.