Live data from Hacker News

Show HN: CEL by Example

celbyexample.com

31–40 of 41 posts

Re: Show HN: CEL by Example

#31

Earlier quoted context omitted.

You can estimate cost of CEL program using static analysis before running it. "estimate" only because size of runtime data is generally unknown (but obv you could limit that).

"You can" - in theory, or does this actually exist?

https://pkg.go.dev/github.com/google/cel-go/cel#Env.Estimate...

Re: Show HN: CEL by Example

#32

Earlier quoted context omitted.

Ease/ability to embed in other language safely. Predictability of memory, execution. Known constraints like guaranteed to terminate is useful. no Doom running on cel. I recently wanted to expose some basic user auto tagging/labeling based on the json data. I chose cel, over python, SQL because I could just import the runtime in C++, or any language that implements it (python, js etc..) Safely running a sandboxed pyth…

> Known constraints like guaranteed to terminate is useful. "Guaranteed to terminate" actually means "guaranteed to terminate in finite but possibly arbitrarily large time" which is really not a useful property. There's no practical difference between a filter that might take 1 billion years to run and one that might take more than a billion years.

Yes but when you combine it with the other guarantees on performance.

https://github.com/google/cel-spec/blob/master/doc/langdef.m...

And your service puts an upper bound on input size and cel expression size. (True for all practical applications.)

You can actually get a guarantee tha t you can't construct a billion year expression. And even guarantee that all expressions will evaluate in let's say 60 secs.

Turing completeness by itself does not guarantee this but it is a necessary prerequisite for these guarantees.

Re: Show HN: CEL by Example

#34

Earlier quoted context omitted.

You can estimate cost of CEL program using static analysis before running it. "estimate" only because size of runtime data is generally unknown (but obv you could limit that).

"You can" - in theory, or does this actually exist?

With certain macros disabled like .map the runtime is O(code length)!

Re: Show HN: CEL by Example

#35

Does CEL have any way to import other files? i.e. could it serve as a general purpose config language like jsonnet?

That's an anti pattern, at least the way we use it. If you need to add complexity, you define custom functions. If that's not enough, CEL probably isn't the right choice, and you'd be doing yourself no favors banging it into that square hole.

Re: Show HN: CEL by Example

#36
CEL is useful for any custom computation you want to do on your critical path without having that blow out in a ridiculous fashion.

Yes you can embed other languages however constraining evaluation costs is not a first class feature.

Re: Show HN: CEL by Example

#38
post #27

I would love if languages like Scala, Swift or F# had something like Cel but running at compile time so your program was evaluated against those restrictions. I believe a language called Idris has something like this

Are you suggesting to compile CEL into native code and run the compiled code at runtime (i.e. as a predicate function)? I think this is doable and I vaguely remember this was how it's implemented initially. But most use cases are treating CEL as a user provided config, which requires runtime parsing and execution.

I was thinking of something like this:

type MyType{ myName: string where size > 8, year: number where number > 2000 }

Then, whenever this type is used, at compile time, an evaluation is done to ensure that the type restrictions are enforced.

Re: Show HN: CEL by Example

#39

Earlier quoted context omitted.

You can estimate cost of CEL program using static analysis before running it. "estimate" only because size of runtime data is generally unknown (but obv you could limit that).

"You can" - in theory, or does this actually exist?

There’s a whole section on this on TFA: https://celbyexample.com/execution-cost/
Post reply on HN