RSSAmplifier

Blog

Asrp Blog

Blog at A Self-Referential Place

blog.asrpo.comRSS feed ↗26 posts

Latest posts

Flpc internals: model and bootstrapping

The Forth Lisp Python Continuum (Flpc) is a small high dynamic programming language I'm making. In these series of posts, I will describe and discuss its inner workings, more or less in the order that they are run when the program starts. This will hopefully help with others making programming languages and serve as some kind of documentation. Though Flpc was designed to be relatively easy to…

Instruction level just-in-time programming

Just-in-time programming is a workflow for creating a program top-down, while a program is running. This is typical in Smalltalk environments like Squeak . In this post, I want to describe an instruction level variant of this. I think the best way to describe instruction level just-in-time programming (IL-JIT programming) is by showing how it works. I'll start with the classic Fibonacci example (…

Adding a minimal foreign function interface to your language

A foreign function interface (FFI) is a way for one language to call functions from another language. The most common FFIs are C FFIs where the target language is C. I just pushed a new version of Flpc where I added a very limited FFI for calling Python. Highlights of some other changes are:

Speed improvements using hash tables

I wrote the Forth Lisp Python Continuum (Flpc)'s self hosted compiler in stages. When I completed the parser and gave it larger and larger pieces of its own source code, it was running too slow. I tried many things to speed it up, one that helped was using hash tables. They helped make dictionaries [names] which can An example of a dictionary:

Flpc is now self-hosted

The Forth Lisp Python Continuum (Flpc) can now compile its own source code! Get it from Github . So instead of $ python compiler.py file1.flpc file2.flpc file3.flpc > output.f you can now run $ ./flpc precompiled/compiler.f > push: output.f init_g > push: file1.flpc compile_file > push: file2.flpc compile_file > push: file3.flpc compile_file

Roll your own GUI automation library

Sikuli is a tool for automating repetitive tasks. To automate a program, it makes use of screenshots and image recognition to decide where to click and type [automation_methods]. As you can see above, Sikuli uses Python for its script's language (plus rendered image). But under the hood, its implemented in Java and runs Jython. Since nothing Sikuli uses really needs Java, we'll try to implement…

Nand to CPU

Nand to Tetris is a course that teaches you how to build a computer up from nand gates and then program Tetris for your computer. Nand game cover the first 3 projects of the course using a nice drag-and-drop interface Nand game includes a number of (in my opinion) improvements to the presentation. I feel it really lets me get to the crux of the matter quickly. This post contains solutions to Nand…

Making a low level (Linux) debugger, part 3: our first program

This continues a series where we make a debugger and live editor for (re)creating assembly and C programs. In part 1 , we got the assembly parts: read/write registers and memory, single step, single instruction execution, function calls (although not perfect), set/restore breakpoints, memory allocation and examining upcoming instructions. In part 2 , we got the C parts: read/write variables using…

Making a low level (Linux) debugger part 2: C

Last time , we started making a debugger and live editor for (re)creating assembly and C programs. We got all the assembly parts: read/write registers and memory, single step, single instruction execution, function calls (although not perfect), set/restore breakpoints, memory allocation and examining upcoming instructions. This post will try to do similar things in the C portion. Next time, we'll…

Making a low level (Linux) debugger

gdb and lldb are the best known debuggers to me. While they are both customizable with scripts, there are many times where I'd like have much more control over how my debugger works (both the interactive portion and its internal representation). Being able to recreate flpc in a more interactive ways is one of these times. In this post, I try to make a debugger from more primitive pieces: the…

Describing animations

Flipbooks provide the simplest of animation and the basic principle remain the same with computers. Display a sequence of images fast enough and the eye perceives motion. In this post, I want to look at possible architectures and APIs for an animations library (to potentially be used with Make these slides or plain guitktk ).

Collaborative software trades

There are many computer programs I'd like to use and modify that do not exist. In this post, I put forth the idea of a (different?) kind of collaboration to achieve this that I've had for a while now. Trades Basically, the idea is to coordinate with a group where each person makes one program and when we are all done, the union contains many programs that each person wants.

Combining all my github projects into one

I've been making projects avaible on Github for a while now. The last one was guitktk . What I didn't say much about is that all the repositories are intended to form one big project. (Most of them also have uses on their own.)

Removing polling checks in guitktk

Updating a rectangular bounding box of a selection was a bit of a hack in guitktk : every frame the selection was checked for changes and the rectangle recreated if needed. In this post, I'll show how to remove that check using "formulas" for parameter values.

Are there any interpreted languages?

Update : This post got many good comments and useful answers summarized at the very end. Or rather, are there any widely used implementations of a popular-enough language that directly interpret ASTs (or similar)? [1] Anything that doesn't compile to assembly to bytecode would do.

Debugging C like it's Python

I use the Python interpreter interactively and pdb (as well as ipdb ) a lot and they let me understand my programs' state and test new things out quickly. When writing Flpc in C, I found it a difficult to transition. In this post, I describe how to use gdb to get a similar workflow.

Adding a new statement to Python's syntax in python_terp

This stackoverflow answer [1] shows how to add an until statement to Python. In this post I will show how to do that in python_terp and how to debug these modifications.

Another tutorial for writing a Forth interpreter in assembly (Part 3)

Direct link to the final (pregenerated) interpreter at the end of this tutorial . Try running nasm -f elf64 forth.asm -o forth.o ;and ld forth.o ;and ./a.out < test2.f inside forth22 .

Another tutorial for writing a Forth interpreter in assembly (Part 2)

With the major part of Forth written in Forth, we can now them in "Forth-style" assembly (using call / ret ). We will still have to write all the primitive functions in assembly.

Another tutorial for writing a Forth interpreter in assembly (Part 1)

This tutorial will teach you how to make a Forth interpreter in assembly with initial prototype simulators made in Python.

The chicken or the egg problem in bootstrapping

Which came first? The chicken or the egg? This post discusses bootstrapping: the first step when trying to make something new. Bootstrapping is needed in many places.

Making a GUI toolkit

A step is missing between pymetaterp , the (eventual) Python-like interpreter, and tkui the self modifying GUI editor: a GUI toolkit. Tkinter fills that role right now.

Visual explanation of a Google Codejam 2017 question

This is the last question from the Google Codejam 2017 qualification round .

Allowing multiple read-only servers in pyzdb

I finally changed pyzdb to support multiple servers. Actually, multiple read servers with a single write server. This post discusses the design and implementation selected. The pyzdb README now contains an example of how to use it.

Messing with Python's sort function

There are many interesting things about python's sort function like how its adapts depending on the input, how its stable in-place, how its in other languages and how it could give the wrong result . This post is about none of those.

Python list and dict with undo

I've made some python list and dict with undo and redo so I can play back and forth the operations applied to them. Its on Github .