Writing your own VM - Programming Language
Develop a VM within 2 hours, and implement an Assembler for it.
Presented by:
Professional Software Engineer & Digital Media Marketing Manager, Hobbyist Game Developer, Husband & Father. Hello, I'm Don Duvall (Tazd'ij), I write marketing software which runs primarily on Linux servers. I now use only FOSS at home, and as much as possible at work.
Linux Distro:
I have started creating my own (baseless) Linux Distro "Apoc. Linux", focusing on Installation and Upgrades without an internet connection. Bundle based Package Management, Offline Usability, Lightweight, and Performance Conscious. It is nowhere close to being show-able, but the ideas are set! Now to find time to create the needed software.
Development:
I absolutely love writing software, for just about any thing for any reason. And, when I get the chance to use C99, C11 or FreePascal, I get all kinds of happy. One day I want to be able to develop FOSS for a living. (It's the dream, am i right?)
Programming Language Development - via Virtual Machines
I don't know about you, but programming language design and development has always interested me. Why and how a language handles Objects, Functions, Pointers, References, and more. At first it seemed like only the Coding Wizards could do something so complex. But then I learned about VM's and Assembly, it has changed my entire outlook on developing my own programming language and "Interpreter" and/or Compiler.
Let's take a couple hours and implement our own VM, which runs our very own Assembly like machine code. We will run through developing a Stack Based Virtual Machine, and then a quick Assembler to convert our text based Assembly to our VM's Binary Machine Code format.
Why bother?
First, it is crazy cool and then the usual. Looks good to have in your github account, you will learn a lot, and there are actually very good use cases for a Domain Specific Language (DSL) think about SQL for a little. That is a very successful DSL. What if you have a need to enable scripting in your project? Is reaching for Lua or Python really the best choice? Why not just bake features into your VM and language, specific to your project. That is what Godot did after all, and it turned out to be very successful.
What if it is to advanced for me?
It most likely isn't. If you have a basic understanding of a C-like language or even Python, with some intuition about what Assembly is, you will do just fine. Maybe this will help calm your nerves: We are going to start with creating an Array of Bytes (which we will load from a file), then we will create another Array of Bytes (all zeroed). This is our Program Memory (PM) and Storage Memory (SM), respectively. SM will contain both Stack and Heap, while PM will only contain the instructions (ByteCode) of the program (resembling a Harvard Architecture). We will create a function for each Instruction our VM understands (i.e. ADDI, SUBI, MULI, DIVI, MODI, JEQI, JMP, CALL, etc.) which will look something like
void vmi_jmp(VMState* state) {
/* Code to update vm state */
}
and a main loop function that starts from the first byte of PM and reads bytes until it reaches the end, calling the individual functions for each Instruction encountered.
If this sounds like fun, please consider joining me, and get your first VM based DSL up and running in about 2 hours.
Possible Bonus Round
If time permits, we can even fly through the implementation of my NymphVM and Nymph language compiler (Lexer/Parser/Generator). This is a VM I am developing for use in my FOSS Marketing Automation project Sociomauto, for inter-module communication and querying. Designed to be used with multiple Languages from Lisp variants to BASIC inspired languages.
- Date:
- 2018 April 28 - 02:30
- Duration:
- 2 h
- Room:
- CC-201 TUT1
- Conference:
- LinuxFest Northwest 2018
- Language:
- Track:
- Code
- Difficulty:
- Medium
- Harness the power of Kubernetes and Istio
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-202 TUT2
- Video & Audio Production on Linux
- Start Time:
- 2018 April 28 02:30
- Room:
- HC-108
- Writing your own VM - Programming Language
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-201 TUT1
- Introducing DistroTweaks… A New Way to Share Linux
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-235
- JavaScript in a Bottle
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-236
- Watch out for that tree!
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-208
- Security Theatre
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-200
- Incompossibilities: Limitations and Trade-offs in Technology Design
- Start Time:
- 2018 April 28 02:30
- Room:
- G-103
- Bellingham Publicly Owned Fiber Optic Network
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-114
- Introduction to Git (even for non-developers)
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-115
- Using GIS in Postgres
- Start Time:
- 2018 April 28 02:30
- Room:
- HC-103 Postgres
- Build and Program Your First NXT Robot
- Start Time:
- 2018 April 28 02:30
- Room:
- CC-234 BAIRS
- Linux Professional Institute: Linux Essentials Cram Session
- Start Time:
- 2018 April 28 03:30
- Room:
- HC-112 LPI
- Linux Sucks. Forever.
- Start Time:
- 2018 April 28 03:45
- Room:
- HC-108
- Harmonize or Resist? A Global Survey of Strategies for Software
- Start Time:
- 2018 April 28 03:45
- Room:
- CC-114
- Linux File System Forensics
- Start Time:
- 2018 April 28 03:45
- Room:
- CC-200
- Perkeep
- Start Time:
- 2018 April 28 03:45
- Room:
- CC-235
- How to Deploy Your React Application While Saving Time and Energy
- Start Time:
- 2018 April 28 03:45
- Room:
- CC-208
- Visual Studio and VS Code for Linux C/C++ development
- Start Time:
- 2018 April 28 03:45
- Room:
- CC-236
- Pop!_OS - A visionary tale of an OS that will.
- Start Time:
- 2018 April 28 03:45
- Room:
- CC-115
- EFF Open Forum
- Start Time:
- 2018 April 28 03:45
- Room:
- G-103
- Migrating MSSQL TO POSTGRES, An Open Source War Story
- Start Time:
- 2018 April 28 03:45
- Room:
- HC-103 Postgres