4 ms·
Bytecode VMs in Surprising Places
- GregDavidson 3y agoThe UCSD P-System is the ancestor of many later byte-code VMs: https://en.m.wikipedia.org/wiki/UCSD_Pascal https://en.m.wikipedia.org/wiki/UCSD_Pascal
- lunaticlabs 3y agoMultiple times in my game development career have implemented or worked with proprietary byte code in a project. I've done it on PCs, embedded devices, consoles, etc. The first game I worked on used MDL from the old Infocom days.
- fatcow 3y agoalso: Delphine software Another World.
- soulofmischief 3y agoSuch an underrated masterpiece, even with all of the praise it has gotten. Reading through the internals of the engine makes for a great evening. Highly recommended Fabien Sanglard series on Another World: https://fabiensanglard.net/another_world_polygons/index.html https://fabiensanglard.net/another_world_polygons/index.html
- cosmic_quanta 3y agoIf I remember correctly, jq (https://github.com/jqlang/jq https://github.com/jqlang/jq) also uses a bytecode interpreter under the hood
- mofosyne 3y agoLooks like you are correct https://github.com/jqlang/jq/blob/ed8f7154f4e3e0a8b01e6778de2633aabbb623f8/src/opcode_list.h https://github.com/jqlang/jq/blob/ed8f7154f4e3e0a8b01e6778de...
- cryptonector 3y agoThere are other implementations that might do other things.
- nivertech 3y agoSQLite, Bitcoin Script, Ethereum’s EVM
- r9295 3y agoNot sure if EVM is surprising though considering it means Ethereum Virtual Machine
- the_panopticon 3y agoAnd there are the examples from host firmware, from FCode in OpenFirmware https://github.com/openbios?language=forth https://github.com/openbios?language=forth that booted the IBM, Sun, and PowerPC Macs https://github.com/openbios?language=forth https://github.com/openbios?language=forth to the UEFI world's EBC https://github.com/pbatard/fasmg-ebc https://github.com/pbatard/fasmg-ebc
- KboPAacDA3 3y agoThe TrueType engine used to render the fonts on your screen uses bytecode.
- pdubroy 3y agoCool — didn't know about that one! Thanks, I added it as an addendum to the OP.
- fallingsquirrel 3y agoAnother fun one is TrueType fonts. https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions https://learn.microsoft.com/en-us/typography/opentype/spec/t...
- a_e_k 3y agoApple's reference: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM05/Chap5.html https://developer.apple.com/fonts/TrueType-Reference-Manual/... (I spent a lot of time with both of these when hand-hinting my programming font.)
- frankjr 3y agoThe SIM card in your phone is running a Java VM. > Java Card bytecode run by the Java Card Virtual Machine is a functional subset of Java 2 bytecode run by a standard Java Virtual Machine but with a different encoding to optimize for size. > Did you know, for example, that a SIM can run apps and communicate over the mobile network entirely independently of the host phone? Or that the SIM is arguably more in control of the phone baseband than the phone’s “main” operating system? Or that SIMs can support TCP/IP and run a web server? https://en.wikipedia.org/wiki/Java_Card https://en.wikipedia.org/wiki/Java_Card https://mobiforge.com/news-comment/the-sim-the-tiny-computer-in-your-pocket-thats-really-in-control https://mobiforge.com/news-comment/the-sim-the-tiny-computer...
- lxgr 3y agoYour credit and debit card is too – even when using tap and pay (it's powered wirelessly through the field)! I think the fact that it's running loadable code at all is what's unexpected here, though, not really the fact that it does so using bytecode; that's mostly for compatibility across card OS vendors. Java/the JVM was what was cool at the time these high-level programmable smartcards started becoming popular. Introduced today, they'd probably be running WASM.
- xenadu02 3y agoContactless and EMV Chip cards are the same. During provisioning the server sends a signed Java Applet to the Secure Element which validates the chain of trust then installs the applet. The EMV protocol involves "application selection" which lets the payment terminal tell the Secure Element OS which applet it wants to communicate with. ARQC (Authorization ReQuest Cryptogram) is where the applet on the card takes the payment terminal's payment request and identity info, signs it with the PK keypair unique to that provisioned card, and sends it back to the payment terminal which then hands it to the card issuer for validation and approval. A bunch of Java bytecode: the chip/SE, the payment terminal, and likely also on the server side.
- AnotherGoodName 3y agoThe really cool part is that they are powered wirelessly, boot up cold, do the signing with their key and complete the transaction in a tap.
- srcreigh 3y agoHigh throughput FizzBuzz https://codegolf.stackexchange.com/questions/215216/high-throughput-fizz-buzz/236630#236630 https://codegolf.stackexchange.com/questions/215216/high-thr...
- mxmilkiib 3y agoWasm that runs eBPF, and eBPF that runs Wasm; https://github.com/eunomia-bpf/eunomia-cc https://github.com/eunomia-bpf/eunomia-cc https://github.com/eunomia-bpf/wasm-bpf https://github.com/eunomia-bpf/wasm-bpf https://github.com/eunomia-bpf/wasm-bpf-rs https://github.com/eunomia-bpf/wasm-bpf-rs https://eunomia.dev/wasm-bpf/ https://eunomia.dev/wasm-bpf/ https://eunomia.dev/blogs/ebpf-wasm https://eunomia.dev/blogs/ebpf-wasm
- cryptonector 3y agoThere's also DTrace, which IMO clearly influenced Linux tracing (with the decidedly un-DTrace-like and disastrous SystemTap being replaced by eBPF which... is a lot more similar to DTrace than it's not). Bytecode VMs are all over the place. TFA added PostScript and TrueType, and comments here mention others. There's also Java, which is oddly not listed. And Lua. And...
- nedbat 3y agoPython pickles are bytecode programs, but different bytecode than the Python bytecode compiled from .py files. https://docs.python.org/3/library/pickletools.html#pickletools.dis https://docs.python.org/3/library/pickletools.html#pickletoo...
- klelatti 3y agoThe first software written for the first microprocessor - the Intel 4004 - powering the Busicom calculator, included a Bytecode VM. https://thechipletter.substack.com/p/bytecode-and-the-busicom https://thechipletter.substack.com/p/bytecode-and-the-busico...
- andriytyurnikov 3y agoAnd classic - Quake VM https://fabiensanglard.net/quake3/qvm.php https://fabiensanglard.net/quake3/qvm.php
- deleted 3y ago[deleted]
- tripdout 3y agoAlso Tiktok's backend: https://www.nullpt.rs/reverse-engineering-tiktok-vm-1 https://www.nullpt.rs/reverse-engineering-tiktok-vm-1
- lxgr 3y agoThat's a VM running in their users' browsers, not their backend, no?
- eatonphil 3y agoA few more: gnu bc, see execute.c; gnu awk, see eval.c. I've also been told Valgrind has one but I'm not sure where. And a few more databases [0]: Mongo, Postgres, and SingleStore. [0] https://notes.eatonphil.com/2023-09-21-how-do-databases-execute-expressions.html https://notes.eatonphil.com/2023-09-21-how-do-databases-exec...
- tekknolagi 3y agoValgrind also has a JIT, iirc!
- eatonphil 3y agoBut where! I only hear the rumors I haven't found the code. :)
- tekknolagi 3y agoThe IR is here: https://github.com/rantoniello/valgrind/blob/master/VEX/pub/libvex_ir.h https://github.com/rantoniello/valgrind/blob/master/VEX/pub/... The rest can probably be found by searching around but I'm on my phone right now
- tekknolagi 3y agoLike this: https://github.com/rantoniello/valgrind/blob/master/VEX/priv/guest_amd64_toIR.c https://github.com/rantoniello/valgrind/blob/master/VEX/priv...
- deleted 3y ago[deleted]
- mattgreenrocks 3y agoInterpretation is the most fundamental pattern in computer science, and I'd argue the most powerful. It (tries) to decouple semantics from implementation. It recurs at all levels of the stack. I'd also argue it's the most beautiful.
- senderista 3y agoI love how POCSD[0] generalizes the interpreter concept to include everything from the CPU up the stack. (Similar to how they generalize naming to include everything from physical memory addresses and registers up the stack.) [0] https://ocw.mit.edu/courses/res-6-004-principles-of-computer-system-design-an-introduction-spring-2009/ https://ocw.mit.edu/courses/res-6-004-principles-of-computer...
- alserio 3y agoAgreed. And one of the most difficult one to get right in security sensitive contexts.
- tromp 3y agoMy 25 line obfuscated BLC interpreter [1] uses a bytecode VM, with the 9th and 10th lines containing a little bytecode Basic I/O System (each byte xor-ed with 46 to make it printable). [1] https://www.ioccc.org/2012/tromp/tromp.c https://www.ioccc.org/2012/tromp/tromp.c
- burutthrow1234 3y agoVMs are a very interesting way to decompose a problem - you can implement the fundamental operations, test them thoroughly, and then generate bytecode and debug the bytecode implementation. A couple years ago I thought about giving a presentation on a Golang VM I wrote to solve a simple problem, but it was seen as kind of a heterodox approach and I didn't want to deal with a million "umm acksully" questions about whether it was a real VM.
- nxobject 3y ago* EDIT: the below statement isn't true: Integer BASIC wasn't implemented with SWEET16 – it was simply included in the ROM Apple II Integer BASIC was implemented using a 16-bit bytecode on a VM called SWEET16 to do 16-bit arithmetic, optimizing for space over speed. [1] [1] https://en.wikipedia.org/wiki/SWEET16 https://en.wikipedia.org/wiki/SWEET16
- NoNameHaveI 3y agoHere’s a fun one: A proprietary bytecode VM allows body makers to execute custom software built with Diamond Logic Builder on Navistar trucks and buses. Instead of cutting and splicing wiring harnesses, builders can add various devices and logic to operate their systems (tow winch, water pump, lift bucket, etc.) with DLB.
- RetroTechie 3y agoAnother nice one: Uxn https://100r.co/site/uxn.html https://100r.co/site/uxn.html
- miki123211 3y agoI'd add regular expression engines and the Apollo Lunar moon lander. They were extremely underpowered machines by today's standards, a standard Mac charger and most electric toothbrushes include better computers, but they still contained a bytecode interpreter.
- _nalply 3y agoMiri [0] is an interpreter for the mid-level intermediate representation (MIR) generated by the Rust compiler. MIR is input for more processing steps of the compiler. However miri also runs MIR directly. This means miri is a VM. Of course it's not a bytecode VM, because MIR is not a bytecode AFAIK. I still think that miri is a interesting example. And why does miri exist? It is a lot slower. However it can check for some undefined behavior. [0]: https://github.com/rust-lang/miri https://github.com/rust-lang/miri