How to learn a new (programming) language

...by leveraging your existing knowledge to rebuild something you've already built. A Case study in Hare

(Cold open)

I watch a lot of “edutainment” on Youtube. And when a video on Portal 2 being turned into a webserver crossed my feed, I had to watch.

Combining that with this “webserver in 25 lines” from Computerphile I saw the previous year, I got inspired to write a webserver in Zsh.

Here’s the immediate result is what came out of that. Even though it’s single-threaded, it’s still reasonably scalable, since I’m poll()ing all open connections (using the Zsh builtin zselect).

And a toy webserver like this is a great project to take to a new language.

[Read More]
code  zsh  harelang  web 

Intermediate Sed Usage

If you’ve been using Linux for any small length of time, you’ve likely used sed before. Most of the time, you’ve seen it in the form of sed "s/find/replace/g", so you simply go to it whenever there’s a replacement you want to do.

But sed stands for stream editor, and as a tool it can do more than just find and replace.

[Read More]
sed  linux  code 

Creating an Asynchronous Zsh Theme

Pure bliss

I converted to Zsh a while back, when I first saw the Oh-My-Zsh framework. OMZ is really just a long chain of source calls with some logic to turn groups of features on or off. I’ve since changed to Zplugin (not to be confused with a similar framework, zplug), a wonderful framework which supports asynchronous plugin loading. This has better than halved the load time for Zsh on my Pi and phone (Termux).

However, my theme had not changed, it still has to wait until (relatively) expensive git calls have completed before redrawing the prompt. Now is the time to change this.

[Read More]
zsh  code 

C language, how I love it

Or at least how I love pthreads

I quite enjoy working with multiple threads to speed up a program. I recently wrote (what I considered) a high-performace timer which read commands in from a named pipe. This afforded the user the ability to script/program around my program as they please. I intend to put header files with all my #define statements so other programs can use it effectively.

[Read More]
code