Active development here: github.com/n8ta/jawk
An (INCOMPLETE) jit compiled awk (jawk) implementation leveraging GNU libjit. The goal is the to be the fastest awk for all programs.
In reality, it will never be faster for programs like BEGIN { print "A" }
since an interpreter has less overhead.
But for all programs >1ms (in say gawk or mawk) jawk aims to be faster.
sudo apt-get install autoconf pkg-config libtool flex bison automake make g++
cargo build --release
brew install autoconf automake libtool gcc
For now you need to use WSL and follow the ubuntu instructions
cargo build
./target/debug/jawk '{ print "Some awk program!}" }'
./target/debug/jawk -f run.awk some_file.txt
cargo run -- --debug 'BEGIN { print "this will print debug info including the AST and runtime calls" }'
- Reading from stdin
- Support for awk functions
- Functions are mutually recursive but not first class. Global too.
- Cannot be declared within each other.
function a() { b() }; function b() { a () };
is fine
- Native math functions like sin, cos, etc, rand, srand (libjit supports many of these)
- Native string functions gsub, index, length, match, split, sprintf, sub, substr, tolower, toupper
- Regex expressions matched/not-matched (in JIT or runtime)
- Array support
- Redirect output to file
- close() function
- Missing Operators
- expr in array a in b
- Parsing / Lexing negative numbers
- ARGV / ARGC and other ENV vars
- Pattern Ranges
- Parser need to be able to print the where it was when shit went wrong and what happened
- Do we actually need numeric strings???
- The columns runtime needs to be much faster and lazier.
- Make this compile on Windows!
- Divide by 0 needs to print an error (tests for this will probably need to be bespoke)
GNU Libjit is GPLv2. This repo is MIT licensed.
Install other awks to test against (they should be on your path with these exact names)
- gawk (linux/mac you already have it)
- mawk - build from src
- goawk - need the go toolchain, then go get
- onetrueawk - super easy and fast build from src
Tests by default just check correctness against other awks and oracle result.
cargo test
If you want to run perf tests set the env var "jperf" to "true" and do a cargo build --release
and cargo test -- --test-threads=1
first. This will test the speed of the release binary against other awks.
Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.