Skip to content
🌟 The Q programming language.
Go q
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmarks
build
cli
examples
lib
.drone.yml
.editorconfig
.gitignore
.golangci.yml
LICENSE
README.md
go.mod
go.sum
main.go

README.md

q

Godoc Report Tests Coverage Sponsor

This is a very early version of a programming language I'm currently working on.

It produces machine code and ELF binaries directly without using an external assembler or compiler.

Installation

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

Goals

No...

  • No binary dependencies (not even libc)
  • No compiler dependencies (no LLVM, no GCC, ...)
  • No global state (all mutable variables are local)
  • No classes or methods: There is just a) data and b) functions that can operate on data
  • No name shadowing, names never change their meaning
  • No side effects when importing a package

Yes...

  • Fast compilation (<1 ms for simple programs)
  • Small binaries ("Hello World" is 247 bytes)
  • High performance (compete with C and Rust)
  • Contracts (reduce bugs at run time)
  • Testing (reduce bugs at test time)
  • Linting (reduce bugs at compile time)
  • Format source code
  • Packages should be highly reusable
  • Statically typed with type inference
  • User-friendly compiler messages

Todo

Compiler

  • 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
  • Exclude unused functions
  • require for input validation
  • ensure for output validation
  • Data structures
  • Stack allocation
  • Heap allocation
  • Type system
  • Type operator: | (User | Error)
  • Hexadecimal, octal and binary literals
  • match keyword
  • import external packages
  • Error handling
  • Cyclic function calls
  • Multi-threading
  • Lock-free data structures
  • Multiple return values
  • Expression optimization
  • Assembly optimization
  • ...

Operators

  • +, -, *, /
  • ==, !=, <, <=, >, >=
  • =
  • +=, -=, *=, /=
  • &=, |=
  • <<=, >>=
  • <<, >>
  • &&, ||
  • &, |
  • %
  • ...

Linter

  • Unused variables
  • Unused parameters
  • Unused imports
  • Ineffective assignments
  • ...

Architecture

  • x86-64
  • WASM
  • ARM
  • ...

Platform

  • Linux
  • Mac
  • Windows
  • Browser
  • ...

FAQ

How do I navigate the source code?

  • benchmarks contains tests 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

How do I run the tests?

go test -v ./...

How do I run the benchmarks?

go test -run=^$ -bench=. ./...

How do I view the produced assembly output?

Use -v or --verbose:

q build -v examples/loops

How can I make a performance optimized build?

Use -O or --optimize:

q build -O examples/loops

Is the syntax final?

No, the syntax will be changed in the future.

Which builtin functions are available?

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.

Which editor can I use to edit Q code?

There is a simple VS Code extension with syntax highlighting.

git clone https://github.com/akyoto/vscode-q ~/.vscode/extensions/vscode-q

Is there a community for this project?

There is a Discord channel and a Telegram group for sponsors.

Style

Please take a look at the style guidelines if you'd like to make a pull request.

Sponsors

Cedric Fung Scott Rayapoullé Eduard Urbach
Cedric Fung Scott Rayapoullé Eduard Urbach

Want to see your own name here?

You can’t perform that action at this time.