https://github.com/mesabloo/mini-noc
Playing around with very unsafe Haskell code
https://github.com/mesabloo/mini-noc
Last synced: about 1 month ago
JSON representation
Playing around with very unsafe Haskell code
- Host: GitHub
- URL: https://github.com/mesabloo/mini-noc
- Owner: Mesabloo
- Created: 2022-06-03T17:26:44.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-06T08:50:41.000Z (almost 3 years ago)
- Last Synced: 2025-01-20T23:48:58.534Z (3 months ago)
- Language: Haskell
- Size: 107 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This code is the result of experimenting with Haskell's unboxed/unlifted types in order to maximise the raw performance by avoiding allocations as much as possible.
The code was originally put into a gist ([https://gist.github.com/Mesabloo/96aef8da87903201ee76edd6c909c2ff](https://gist.github.com/Mesabloo/96aef8da87903201ee76edd6c909c2ff)) but has been migrated here and somehow broken also.
The goal is to implement a minimalistic virtual machine (VM) to run a very small subset of the [Noc language](https://github.com/noc-lang).
Low performance is an issue.Here are the last known performance results on my machine:
| | `fact(15)`⁽¹⁾ | `ack(3,6)` | `fib(28)`⁽¹⁾ |
| :------: | :--------------: | :--------: | :-------------: |
| Mini-Noc | ~4µs | ~26ms | ~92ms |
| Python | ~1.8µs | ~22.4ms | ~105ms |Note that this is meant to be 100% Haskell code.
Github detects some C code from a `.h` file which is meant only to use some constants across multiple modules.
If you read it, you will even find that this is not valid C code.⁽¹⁾ The functions tested were all coded using the naive recursive approaches.
---
:warning: This is very experimental.
Expect to see some weird and ugly very unsafe Haskell code, relying on GHC's own internal libraries and boot packages (and nothing else).
I am proud of what I have been able to do, though I would not recommend anybody doing this at all.---