• Colony #16 - Design and Implementation - Small String Object

    I explore the complexities of garbage collection, reference counting, and the intriguing concept of immortal objects in the Colony programming language. I kick off the discussion by simplifying the model, removing bytes, and focusing on UTF-8 encoded strings, which are more commonly used by developers. I also introduce the concept of ‘small string objects’, strings that can fit within 128 bits. The first 64 bits are reserved for the ‘kind’ of the object, and the remaining 64 bits are used for the string itself. This optimization is particularly applicable to strings because they are immutable by default.

    As the video progresses, I delve into the concept of ‘immortal objects’. These are objects with a special value of reference count and will have a flag marking them as immortal. Built-in types such as bytes, array, dict, etc., will be marked as immortal as it doesn’t make sense to increment and decrement their reference count every time. I also demonstrate how to use these small strings, assuring viewers that the complexities of this implementation will be hidden behind the scenes, making it easier for developers to use.

    In conclusion, this video provides a comprehensive overview of the design and implementation of small string objects in Colony. It offers valuable insights into garbage collection, reference counting, and the concept of immortal objects. I believe it’s a must-watch for anyone interested in the inner workings of programming languages.

  • Colony #15 - Design and Implementation - kind/value/obj

    I dive deep into the development of the Colony Programming Language, focusing on the implementation of C-level objects (co_obj_t) and other core types. In the beginning, I discuss the key components of the language, such as the object model, syntax, grammar, and parser. I explain the importance of packing these components in a way that minimizes memory usage and maximizes access speed. I also touch on the concept of reference counting, which is a form of garbage collection used in the language. The discussion then moves on to the different types of objects in the language, including bytes, strings, arrays, dictionaries, and functions, among others.

    As the video progresses, I delve into the intricacies of the language’s structure, discussing the implementation of different types of objects and how they interact with each other. I also explore the concept of context in the language, explaining how it is used when executing functions and importing modules. I emphasize the importance of reducing indirections to simplify the language’s implementation and improve its performance.

    In the ending of the video, I focus on the concept of ‘generic’ in the Colony Programming Language. I explain how it can be combined with functions, structs, and unions to create new types. I also discuss the idea of ‘generic structs’, which are structs that can take another struct and produce a new generic struct. I wrap up the video by discussing the potential for creating native executables from the language’s instructions, highlighting the importance of making the integration with code generators as straightforward as possible.

  • Colony #14 - Design and Implementation - List

    In my latest video, I take you on a journey through the design and implementation of List which is implemented as Dynamic Array data structures.

  • Colony #13 - Design and Implementation

    Throughout the video, I guide you through the intricate process of creating a robust object model that allows for efficient data organization and manipulation. Additionally, I dive into the intricacies of the type system, demonstrating how to define and enforce data types to ensure code correctness and maintainability.

  • Colony #12 - Design and Implementation

    I guide you through the intricacies of syntax design, providing clear explanations and practical examples for declaring and defining variables in Colony. Additionally, I dive into the impressive array of builtin types and functions available, showcasing their versatility and how they can simplify programming tasks.

  • OpenBSD/amd64 7.0 Install

    I walk you through the process of installing OpenBSD 7.0 on an AMD Ryzen 5 1600x with an AMD VEGA 64. I guide you step-by-step, from setting up the BIOS to boot from a USB, to installing the operating system on a dedicated hard drive. I also demonstrate how to set up a graphical interface using xenodm and xfce4, and how to configure the PulseAudio sound system. Additionally, I show you how to set up a webcam for video conferencing in Firefox. This video is perfect for anyone interested in exploring the world of OpenBSD.

  • QuickJS - qjs-env, qjs-cffi, fltk, libuv

    I showcase how to set up a QuickJS environment and package manager. I demonstrate how to create automatic bindings for shared libraries like FLTK and libuv using QuickJS and Python. I also introduce qjs-env and qjs-cffi, tools that make the process of creating new QuickJS-based projects and installing requirements a breeze. Additionally, I show you how to use libuv to implement setTimeout and setInterval functions, which are not native to QuickJS.

  • Colony #11 - syntax, grammar, object model

    I explore the captivating world of the Colony programming language, delving into the intricate aspects of syntax, grammar, and object model design. Additionally, I delve into the fascinating world of the Colony object model, showcasing how it enables effective data organization and manipulation.

  • FreeBSD 13.0 - Virtualization #2 - bhyve - AMD Ryzen 9 3950X, Nvidia RTX 2060

    Focusing on bhyve virtualization and GPU PCI passthrough, I couldn’t wait to showcase the potential of FreeBSD in harnessing the capabilities of my AMD Ryzen 9 3950X processor and Nvidia RTX 2060 graphics card.

  • Colony #10 - Programming language, new syntax, grammar, object model

    Throughout the video, I provide a comprehensive overview of the Colony language, showcasing its design choices and implementation techniques. From discussing the syntax and grammar to demonstrating key features, I offer valuable insights for both novice and experienced programmers looking to explore new languages.

  • FreeBSD 13.0 Virtualization #1 - vm-bhyve, ubuntu

    I explore the exciting features of FreeBSD 13.0 RELEASE. I dive into the world of virtualization, showcasing bhyve and vm-bhyve, as well as the impressive GPU PCI Passthrough capability. Powered by the AMD Ryzen 9 3950X and Nvidia RTX 2060 hardware.

  • FreeBSD 13.0 Installation #1 - XFCE, LightDM, OBS

    I take you through the process of a fresh install of FreeBSD 13.0 on my actual hardware, complete with live troubleshooting and exploration. The ultimate goal is to achieve a fully functioning operating system that boots to the GUI, enabling us to continue live streaming directly from FreeBSD once it’s installed. I navigate the installation process on my AMD Ryzen 9 3950X and Nvidia RTX 2060 hardware, providing valuable insights and tips along the way.

  • My YouTube Channel

    I started YouTube channel in 2020 during COVID-19 pandemics. It was perfect timing for me to finally align my thoughts. After years of thinking, I just started recording and publishing videos. My friends and colleagues asked me for years to record my talks and publish it for others to see. All opinions and advices are my own, and take them with grain of salt, I am just a regular guy doing interesting things online.

    I cover broad topics from computer science and engineering. Including BSD, Linux, data structures, algorithms, machine learning, programming languages design and implementation, etc. Please check my YouTube channel and subscribe if you like topics that I cover. Feel free to leave comments and suggestions.

    I am also active on Twitter, so you can get in touch with me over there as well.

  • Language Virtual Machine

    Hi there,

    I will start here series about language virtual machines. I will first show native examples in C and in few other dynamic languages such as Python, Ruby and Lua. Their speeds will be compared.

    After we have insight into what kind of speeds we expect from which programming language implementation, we will try to explore approaches in VM design and implementation.

    Our main goal is to show speed of the simplest but functional possible VM’s and some basic optimizations.

    VM’s will be written in C, C99 and in some cases C11 standard.

    System (my home desktop computer) on which benchmarks will be run is following:

    $ lscpu 
    Architecture:          x86_64
    CPU op-mode(s):        32-bit, 64-bit
    Byte Order:            Little Endian
    CPU(s):                4
    On-line CPU(s) list:   0-3
    Thread(s) per core:    1
    Core(s) per socket:    4
    Socket(s):             1
    NUMA node(s):          1
    Vendor ID:             AuthenticAMD
    CPU family:            18
    Model:                 1
    Model name:            AMD A8-3850 APU with Radeon(tm) HD Graphics
    Stepping:              0
    CPU MHz:               2900.000
    CPU max MHz:           2900.0000
    CPU min MHz:           800.0000
    BogoMIPS:              5792.15
    Virtualization:        AMD-V
    L1d cache:             64K
    L1i cache:             64K
    L2 cache:              1024K
    NUMA node0 CPU(s):     0-3
    
    $ uname -nsrm
    Linux arch 4.1.4-1-ARCH x86_64
    
    $ cat /proc/meminfo | grep MemTotal
    MemTotal:        8170204 kB
  • Loops

    In this post, I will show simple loop, its alternative implementation with imaginary JIT compiler that “optimizes” its internals. I will also show speed benchmark.

    Loops are core building blocks in every program. In Python, they iterate over sequence. However in C, they keep looping while some condition is meet.

    Take for example:

    // loop1.c
    // gcc -c loop1.c && gcc -o loop1 loop1.o && time ./loop1
    // clang -c loop1.c && clang -o loop1 loop1.o && time ./loop1
    #include <stdio.h>
    #include <stdlib.h>
    
    int f() {
        int i;
        int r = 0;
        int l = 100000000;
    
        for (i = 0; i < l; i++) {
            r += i;
        }
    
        return r;
    }
    
    int main(int argc, char ** argv) {
        int x = f();
        printf("%d\n", x);
        return 0;
    }

    Tracing JIT would recognize loop and try to optimize it. If code above is in C, there is really no need to do such a thing. However, if your code is in Python, JIT will dramatically improve speed over loops which “captured” variables stay with same type.

    Anyway, we will keep C example, and try to work on it. Code above would be JIT compiled to look like following:

    // loop2.c
    // gcc -c loop2.c && gcc -o loop2 loop2.o && time ./loop2
    // clang -c loop2.c && clang -o loop2 loop2.o && time ./loop2
    #include <stdio.h>
    #include <stdlib.h>
    
    void _loop(int i, int l, int * r) {
        for (; i < l; i++) {
            *r = *r + i;
        }
    }
    
    int f() {
        int i;
        int r = 0;
        int l = 100000000;
        int _count = 0;
    
        for (i = 0; i < l; i++) {
            r += i;
            _count++;
    
            if (_count > 10000) {
                _loop(i, l, &r);
                break;
            }
        }
    
        return r;
    }
    
    int main(int argc, char ** argv) {
        int x = f();
        printf("%d\n", x);
        return 0;
    }

    Speed benchmark:

    compiler loop1 loop2
    gcc 0.293s 0.261s
    clang 0.284s 0.284s
  • Welcome!

    I’ve decided to start writing about things that I think about daily. For almost 10 years, I’ve been thinking about successfully implementing VM for Lua or Python.

    Lua has more educational purpose in my life. I have learned a lot from its simple implementation.

    Python is language of choice for me. I like its elegance and simplicity, but I hate its internal ecosystem. It is huge. I wish we could install subprocess or re modules using pip instead of they coming included inside python implementations.

    This blog will be mainly about implementing Virtual Machines. Practices might not be the best, but idea is to implement cool stuff, so other can learn from it.

    I will text with intermediate level of knowledge. I expect that you understand compilation, basic VM principles, JIT compilation, etc.