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 

.zshrc from scratch

My zsh shell files are at over 1500 lines of code, not including many plugins of various complexity. It’s a bit of a mess, but it’s all things that I wrote (or copied) for a reason.

But easily 90% of what I love about this shell is doable in less than 100 lines of code.

So let’s build a Zsh config from scratch!

[Read More]
zsh  config  linux 

Zsh Plumber - 0

What is it?

all posts in this series

There is a very cool and useful tool out there called Ultimate Plumber. You call it with some-command | up, and then it opens a simple TUI where you write a pipeline at the top of the screen and see results of some-command piped through that pipeline beneath it.

It is such a wonderful tool for working with pipes, but there is one problem I have: it doesn’t use the Zsh line editor.

[Read More]

What makes a shell?

I recently (re)discovered the Oil shell. The last time I saw it, it was trying to write a language to subsume Bash, Awk, and Make.

However, I came back to it doing nearly accomplishing two smaller goals:

  • Writing a fast, statically-parsed shell (osh) as close to Bash-compatible as possible.
  • Developing a stricter subset of Bash from which to build a new language (oil).

And I really like it.

[Read More]

Using Zparseopts

tl;dr: Always use the flags -D and -E (and -F if available). Add a colon to indicate an argument is required (similar to getopt)

[Read More]

100 Days of Code: Day 15

After a busy weekend of visiting siblings, car troubles (snow’s no joke) and getting back to school, I had a chance to sit down to work on my #100DaysOfCode project.

I saw the Geometry zsh theme hit 2.0! It looks like a more modular Pure, which is fantastic for me!

With that, I figured it was as good of a time as ever to rename and rebrand my prompt segment to be more prompt-agnostic. I now have instructions for enabling it with Geometry, P10k, and Bullet Train.

The project is now moved to zsh-prompt-dir-glob

100 Days of Code: Day 13

Wrote more of the zparseopts post, I think I have everything explained. Waiting until I look over it more tomorrow, see if I worded anything poorly.