1 unstable release
Uses old Rust 2015
0.2.0 | Jun 7, 2017 |
---|
Used in 3 crates
(2 directly)
57KB
1.5K
SLoC
PumpkinScript
PumpkinScript is a minimalistic concatenative, stack-based language inspired by Forth.
It is used in PumpkinDB to operate a low-level database "virtual machine" — to manipulate, record and retrieve data.
This is an ultimate gateway to flexibility in how PumpkinDB can operate, what formats can it support, etc.
Reasoning
Why is it important?
In previous incarnations (or, rather, inspirations) of PumpkinDB much more rigid structures, formats and encoding were established as a prerequisite for using it, unnecessarily limiting the applicability and appeal of the technology and ideas behind it. For example, one had to buy into ELF, UUID-based event identification and HLC-based timestamps.
So it was deemed to be important to lift this kind of restrictions in PumpkinDB. But how do we support all the formats without knowing what they are?
What if there was a way to describe how data should be processed, for example, for indexing — in a compact, unambiguous and composable form? Or even for recording data itself? Well, that's where the idea to use something like a Forth-like script was born.
Instead of devising custom protocols for talking to PumpkinDB, the protocol of communication has become a pipeline to a script executor.
So, for example, a command/events set can be recorded with something like this (not an actual script, below is pseudocode):
<command id> <command payload> JOURNAL <event id> <event payload> JOURNAL
This offers us enormous extension and flexibility capabilities. To name a few:
- Low-level imperative querying (as a foundation for declarative queries)
- Indexing filters
- Subscription filters
Features
- Binary and text (human readable & writable) forms
- No types, just byte arrays
- Dynamic code evaluation
- Zero-copy interpretation (where feasible; currently does not apply to the most important part, the storage itself as transactional model of LMDB precludes us from carrying these references outside of the scope of the transaction)
Dependencies
~2.5MB
~47K SLoC