Common Expression Language interpreter written in Rust
github.com
github.com
[1] https://github.com/clarkmcc/cel-rust/blob/master/example/src...
Haven't measured the footprint of cel-rust yet, but I expect it's orders of magnitude smaller than cel-go. The Go runtime itself is the culprit with cel-go.
This Rust implementation may let us port to CEL after all, while maintaining Pax's <100KB wasm footprint. Nice work!
---
At first blush Go seems incompatible with WASM in terms of maintaining Go's strengths—the two runtimes have different memory models and stack representations. I'm curious why one would choose Go if WASM were a target to begin with.
asm is a dead art.
while true do
print("meow?")
end
In contrast, each CEL expression has a maximum depth which directly determines how long it takes to execute. (More precisely: by calculating the maximum costs up the expression tree from leaves to root.)But anyway they achieve that by being much more restrictive than just "not Turing complete", e.g. you can't define functions.
It certainly sounds like an attractive feature, but how much benefit is it really to restrict a language so much that it will probably run quickly enough compared to just setting a timeout or computation limit? The only advantage I can think of is that you get some kind of computation constraints that don't depend on the data... But this is a pretty niche requirement.
The whole point of a feature like this is that you don't know what will be required. It's going to be pretty annoying when a user does find they need something that's impossible with CEL and they can't do it because the devs think they'll write slow code.
Lua is not very nice IMO, but I've used Rhai successfully in the past. It even has an operation limit feature already:
Few people write just Lua (although professionally speaking, that was me for several years) but many people write some Lua. It adds up.
I had needed a small interpretive environment that would be highly controlled, used in a proprietary configuration templating solution for parametrizing various values.
I wrote https://github.com/ayourtch/aycalc - very rudimentary by default with just basic arithmetic, but easy to give different security guarantees, depending on the context - the references to functions and variables can be either separate from each other or share the space, also it’s easy to special-case the handling for both variables and functions.
The entire source code for the library is just around 400 lines, so i thought it can be a different enough type of a beast to mention, in case someone finds it useful.
> The required components of a system that supports CEL are:
> The textual representation of an expression as written by a developer. It is of similar syntax to expressions in C/C++/Java/JavaScript
Ok
> A binary representation of an expression. It is an abstract syntax tree (AST).
> A compiler library that converts the textual representation to the binary representation. This can be done ahead of time (in the control plane) or just before evaluation (in the data plane).
> A context containing one or more typed variables, often protobuf messages. Most use-cases will use attribute_context.proto
> An evaluator library that takes the binary format in the context and produces a result, usually a Boolean.
Why? All of these sound like implementation details to me, some of which I prefer not to have, such as the necessity for binary representation.
https://en.wikipedia.org/wiki/Object_Constraint_Language
insofar as there is an expression language inside of OCL. OMG uses OCL in many parts of standards that can use that functionality.
In particular is there a spec for what expressions are admissible for predicates or transformations for example here (https://arrow.apache.org/docs/python/generated/pyarrow.datas...) or in Substrait?
This is awesome work.