Rust + Gtk = Wow

As I’ve been experimenting with writing Rust apps, I attempted to create a small little GUI application. At first I attempted to setup everything with Qt, but C++/Qt interoperability with Rust is painful. Very, very painful. I experimented with some more radical UI frameworks such as Azul and Conrad. These have a lot of promise going forward. However for the here and now, I recommend looking at gtk-rs, Rust binding for Gtk.

With a bit of experimentation, looking through gtk-rs examples, some other projects using gtk-rs, and lots and lots of searching, I was able to create this:

This is a code viewer that lets you open Rust code, and view it. Yes, you are looking at a portion of the code that runs that code viewer. Getting the GtkSourceView working took some coaxing. Also I had to learn how to use the Glade UI editor for Gtk. Overall it took me about 2 to 3 hours to pull this off. I am very impressed with the results, and it opens up new possibilities for me.

Embedded Rust Library Experiment for Python and Web Assembly

With my ever growing list of things that I need to catch up (like wiring my home network and managing Rookeries), I needed a small fun project that I can work on. Ever since I learned enough Rust to be able to convert Rookeries, I wanted to play around with being able to speed up my code with a Rust library. I am especially interested in figuring how to call Rust code from Python or from JS with Web Assembly.

As a test bed (and a reason) for me to learn this, I created a small little library for getting the uptime of a local server (Linux only): embedded-uptime converting between different measurement units like Celsius and Fahrenheit: embedded-unit-converter. If you’d like to follow along, feel free to check it out. I will be posting updates on the blog, and on the Rookeries mailing list.

Updated on 2019 February 4: When I setup the project, I forgot that server uptimes that rely on accessing a server’s /proc/uptime can not possibly work in Web Assembly in browser environment. After some consideration I decided to go with something simple that accessible from any platform, namely conversion between different units of measure.

Self-Experiment: Fast Personal Context Switching

Time for a self-experiment, where I get to play the part of the guinea pig. And you get to observe the final results. Speaking of time, this university semester I felt rushed and busy like never before. I found myself with six assignments/exercises a week, and in a constant lack of time. In response I started going to time management counselling. Armed with calendars, todo lists, activity logs, my trusty PDA and advice from Mindtools.com, I felt I could do no wrong.

I discovered a problem that kept holding me back from achieving more. At home, with all things going on, my time become extremely fragmented. The fragmentation frustrated my attempts at coming up with a coherent schedule and sticking to it. And getting into the mood and mindset of performing school work – assignments that I tried to avoid – felt like climbing Mount Everest again and again. However when I interrupted and continued games between chores, I did so without missing a moment. Why could I do one well but not the other?

When you look at my situation, it resembles the life of a CPU. Why a CPU? Take a look at your computer. Your computer with one CPU can multitask well. The CPU seems to work on many things at the same thing. In reality, one CPU can only do one thing at a time, but the operating system switches the tasks for the CPU. Under Linux – the OS I use and understand best – every program (process and thread) becomes a task. The OS allocates a certain amount of time for executing a task, and then switches between them. Whenever the OS switches, it stores a record of what task it was working on, how far did it go into the task, and any extra information it needs to restart the task later. The OS then starts or continues another task. Eventually, the OS gets back to the stored task, retrieves it, figures out what to do, and executes the task until the next switch. So what?

Well, I often have to drop one thing and pick up another. Just like an OS, I switch from one task to another. Yet when I re-start my previous work, I sit trying to get into the work again. Being the distractible type, I get fed up and wander off to game instead of homework. And I need continuous blocks of time to do work in. So what to do?

Remember how the OS stores some information of its work in one task, before it switches? Well this week’s experiment is do the same. Before I go off on another task, I will write down the following:

Task: (what was I working on)
Working on: (which part or section I was working on)
Self-Progress: (how I am progressing through this section – well, badly, struggling, etc.)
Next work: (what I need to do next)
Notes: (any important things I need to jot so I don’t forget them)

Well this work or is useful? I have a pad of paper and pen ready, and we will see. Next week, I will post any interesting developments and results of this self-experiment.