top | item 36010689

Wrench Embedded Interpreter

56 points| wryun | 2 years ago |northarc.com

20 comments

order

remexre|2 years ago

Huh, didn't the best-forgotten BeanShell [0, 1] do a similar thing with the "structs are just another kind of function"?

[0]: https://jcp.org/en/jsr/detail?id=274 [1]: http://beanshell.org/

nunobrito|2 years ago

Similar, yes. Albeit for different languages of course.

From my review of available options earlier this year, Wrench is the one closest to C-like scripting which is great to writing apps on TF cards.

noelwelsh|2 years ago

I feel that these languages represent an era of language design that we're leaving behind. I think the experience in industry is that things like ad-hoc type coercions, which are sold as being simple and intuitive, are anything but that. The "Wat Javascript" talk is a great example.

elinnnn|2 years ago

Yeah, I've never understood how people can find dynamic typing "simple and easy to use", types are wonderful for catching errors and documenting the code and makes refactoring much easier - I even avoid auto/var/type interference as much as possible because I like seeing what types things are.

giraffe_lady|2 years ago

So far there seems to have been a pretty consistent ebb and flow. That approach is deeply out of favor right now but I wouldn't put money on it being permanently gone.

fbdab103|2 years ago

Does anyone know which/any of the microlanguages (Wren, Janet, Gravity, Nelua, etc) have seen larger deployments. Lua has a large number of use cases, but it feels like it is tough to dethrone.

giraffe_lady|2 years ago

In terms of number of things they're embedded in? None of those are within an order of magnitude of lua except maybe tcl.

mappu|2 years ago

Would you count Squirrel in this category? It's quite widely deployed

skybrian|2 years ago

You don't have to do it this way, but it looks like the code to be interpreted is normally compiled to bytecode stored in a constant in a C header. So it's all in flash anyway, and you'd update the flash the same way as changing C code.

If you're going to do that, why not generate C and skip the interpreter? Is it because bytecode is more compact than native code?

I guess there would still need to be a runtime to handle array memory garbage collection.

sriku|2 years ago

"structs are functions that preserve the stack frame" is a cute idea/perspective. It doesn't look like this view leads to anything distinguishable from the usual approach with constructors though. Any examples that might point out things you can do that you can't do with usual struct+constructor?

camgunz|2 years ago

Very cool; in particular the GC-only-for-arrays thing feels like it falls out of some elegant design; does this basically mean it's RAII everywhere?