https://github.com/orphoros/shark
Shark programming language
https://github.com/orphoros/shark
compiler go golang language lexer parser programming-language virtual-machine
Last synced: 9 days ago
JSON representation
Shark programming language
- Host: GitHub
- URL: https://github.com/orphoros/shark
- Owner: Orphoros
- License: gpl-3.0
- Created: 2023-08-12T13:25:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-25T20:08:09.000Z (6 months ago)
- Last Synced: 2025-07-26T03:28:14.884Z (6 months ago)
- Topics: compiler, go, golang, language, lexer, parser, programming-language, virtual-machine
- Language: Go
- Homepage:
- Size: 714 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
The Shark Programming Language
Shark is a programming language with a language server, compiler and virtual machine
## About
Shark is written in Go aiming to be a simple, dynamically typed language with a focus on simplicity and ease of use. The language is compiled to bytecode that a virtual machine can run. It is inspired by languages like TypeScript and Dart.
## Key Features of SharkLang
- Dynamically typed
- Optional type annotations
- Compiles to bytecode that a virtual machine can run
- Garbage collected
- VS Code extension for syntax highlighting
- Language server
- Caching
> [!NOTE]
> Shark is currently in development and there is no release yet.
## Example
```shark
let reduce = (arr: array, initial: i64, f: func<(i64, i64)->i64>) => {
let iter = (arr: array, result: i64) => {
if (len(arr) == 0) {
result
} else {
iter( rest(arr), f(result, first(arr)) )
}
} iter(arr, initial)
};
let sum = (arr: array) => {
reduce(arr, 0, (initial: i64, el: i64): i64 => {
initial + el
})
};
let result = sum(1..5);
puts(result);
```
For more examples, look at the [examples](./examples) directory.
## Benchmarks
The following Shark code is executed:
```shark
let fibonacci = (x) => {
if (x == 0) {
return 0;
} else {
if (x == 1) {
return 1;
} else {
fibonacci(x - 1) + fibonacci(x - 2);
}
}
};
fibonacci(50);
```
### Results
The results were recorded at `February 3rd, 2025`. The results include VM caching enabled with the cache size of `1024`.
#### Time
```
BenchmarkRecursiveFibonacci-10 1000000000 0.0003148 ns/op 0 B/op 0 allocs/op
```
#### Memory Usage
```
Showing nodes accounting for 5034.07kB, 100% of 5034.07kB total
Showing top 10 nodes out of 16
flat flat% sum% cum cum%
1762.94kB 35.02% 35.02% 1762.94kB 35.02% runtime/trace.Start
1184.27kB 23.53% 58.55% 1184.27kB 23.53% runtime/pprof.StartCPUProfile
1184.27kB 23.53% 82.07% 1184.27kB 23.53% shark/vm.New
902.59kB 17.93% 100% 902.59kB 17.93% compress/flate.NewWriter (inline)
0 0% 100% 902.59kB 17.93% compress/gzip.(*Writer).Write
0 0% 100% 2947.21kB 58.55% main.main
0 0% 100% 2947.21kB 58.55% runtime.main
0 0% 100% 902.59kB 17.93% runtime/pprof.(*profileBuilder).build
0 0% 100% 902.59kB 17.93% runtime/pprof.profileWriter
0 0% 100% 1184.27kB 23.53% shark/vm.NewDefault
```