Beat Hagenlocher
2y ago
#1 The goal
So—there's really two ways in which one 'is able to program'.
One is to being able to use a programming language to achieve a certain result (a)
The other one is to understand the underlying concepts, and being able to use them in every programming language that has them (b).
And you clearly want (b).
#2 How To Learn
Learning to program is like learning any other skill.
You want to understand a concept, then continue with very simple worked examples of programs, and work your way towards coming up with practice tests for yourself as you slowly transition form beginner to expert (per topic).
#3 What To Learn
The concepts that exist in programming languages today mostly stem from two families. One of them view programming as the art of manipulating a Turing Machine, while the other one views progamming as the art of manipulation expressions in the lambda calculus.
Those are the two paths you want to pursue in parallel. Start with:
Learning C from the ground up: That teaches you how the machine works. Simple syscalls, pointers, memory allocation, and so on. There's a book. For exercises, have a look here.
Working through How to Design Programs: That teaches you how to write programs not only the machine, but also humans can understand.
That's for starters. Have fun!
Beat Hagenlocher
2y ago
We all know it already: It's important to stay hydrated throughout the day.
There may be something you don't know yet:
You can drink too much water, too.
For a long time, I did. I felt dizzy. Exhausted. Had Headaches. That should have been something for me to notice and do something against—right? The crazy thing is this: For me, the symptoms of drinking too much and too little water were so similar that I didn't notice.
People around did notice.
They mentioned it, and I wasn't convinced that I could be drinking too much water. I knew there had been times when I was dehydrated and felt very similar. But then, I learned that overhydration can feel very similar to dehydration: A good friend heard sent me an excerpt from a podcast featuring a story about overhydration and what it feels like.
I reduced my water intake, especially in the evening—and the symptoms almost instantly improved.
So, if you regularly feel dizzy, have headaches, need to go to the toilet often (especially during the night) and your urine is relatively light:
Chances are you're not dehydrated, but overhydrated.
Try to drink less for about three days, and you'll see whether you are.
I even found the episode again.
Beat Hagenlocher
2y ago
We (humans) have an astonishingly small working memory capacity.
As soon as need to tackle a thought-intensive task, it's likely we hit out working memory capacity. When we do, we either have to stop that task (bad), or drop things we needed to complete the task correctly (also bad). Under normal circumstances, that makes you feel bad, too.
Programmers are humans.
However, we (programmers) seem to enjoy working at out working memory capacity quite a lot—at least that's the only way I can come up with to explain a lot of the code we write. We juggle several dozen objects in our head at once, or write deeply nested function calls when most programming could be as simple as:
Utilities that do one thing, and do it right, chained by Pipes.
We even know how to do it, and how it works:
cat reply.json | jq '.hits[] | .from, .msg' | paste -d ':' - -
Haskell has it, Clojure has them, but I personally like Elixir's one the most:
iex> "Elixir" |> String.graphemes() |> Enum.frequencies()
%{"E" => 1, "i" => 2, "l" => 1, "r" => 1, "x" => 1}Beat Hagenlocher
2y ago
Again: What should setting up a new repo look like?
It should be something like this:
'Create this kind of project'
Initialize the git repo
Create the first commit
Create the repo upstream
originThen, push to
origin, and setoriginas upstream.
Okay. Let's say I want to create a new static website project. This is my workflow: (prior to this post, hehe ^^)
> md new-website
> nft my#pollen-template
> gi
> gam "Initial commit"
> ghi new-website
> gpo
Can't understand anything? Well, all of them are aliases/shell functions/abbreviations. This is what I typed:
> mkdir new-website && cd new-website
> nix flake init --template github:haglobah/flakes#pollen-template
> git init
> git add . && git commit --message "Initial commit"
> gh repo create new-website --private --source=. --remote=origin
> git push --set-upstream origin
And of course, it already brings its own devshell.
How do you set up a new project? And do you have any suggestions for a better workflow? Let me hear in the comments!
Beat Hagenlocher
2y ago
TL;DR: Establish a typing practice.
Chances are you've never practiced to type done that—so this is quite the low-hanging fruit.
Let's assume you spend a bit more than a quarter of your workday typing. That can be writing a document, coding, but also things like searching the web, filling out forms, and of course, prompting ChatGPT.
Let's also assume you type at average speed: 40 words per minute (wpm).
That would mean you spend at least two hours per day typing at your slow speed, at 40 wpm. Just raising your typing speed to 60 wpm would reduce that time to 1 hour and 20 minutes, shaving 40 typing minutes off your day.
But we can do more than that.
The typing practice website keybr has anecdotal evidence that if you type at 40 wpm, a speed improvement to 70 wpm in under 10 hours of practice is realistic.
So, so you want to tackle typing faster. You resolve that you practice typing first thing after starting your PC, for 10 minutes. It would take 12 weeks until you reach 70 wpm. But the real question is: How long does it take until you don't have to start earlier anymore?
You only need 44 wpm for that.
With linear progress (conservative guess), that's 8 days.
8 days you need to start to work 10 minutes earlier so that after 3 months, you save 30 minutes per day while continuing the habit.
Beat Hagenlocher
2y ago
Web Servers are surprisingly simple.
A Web Server is a program that takes in a string and returns a string. The incoming and the outgoing string both adhere to rules: They follow a protocol. The protocol defines how the Web Server has to react to the incoming string. The protocol Web Servers follow is called HTTP.
A Web Server is a program that reads HTTP requests and returns HTTP responses. There are a number of requests (e.g. GET, POST, PUT, DELETE), as well as possible responses (e.g. 200 Ok, 301 Moved permanently, 404 Not found). Those HTTP requests and responses get transmitted by another protocol, TCP.
A Web Server is a program that typically runs on a machine somewhere on the World Wide Web. (And yes, this machine is called Server, too.) The World Wide Web is not the same as the Internet—it's an application that runs on top of it. This machine has a lot of ports (65535, to be exact), and if it has a Web Server on it, at least one of these ports is open: Port 80.
You know what? We can write a HTTP request by hand. Launch a terminal and type:
> curl --verbose telnet://google.com:80 (Enter)
* Host google.com:80 was resolved (... rest of telnet answer)
GET / HTTP/1.1
Host: google.com (Hit Enter twice)
HTTP/1.1 301 Moved Permanently
(... rest of HTTP response)
In case it took under five minutes to read this once, you can read it again.
Beat Hagenlocher
2y ago
When starting a side project with friends, it takes at most two weeks until I crave to use tools like:
An issue tracker/To Do-list/kanban board thing
A wiki
A whiteboard
And every single time, have to be strong to resist the urge to search for something that looks just that bit cleaner, has this one feature more, and so on.
The last two times, that worked, but today I failed. Or did I succeed? I think I found tools that are just that little bit cleaner and have this one more feature:
For the issue tracker/Kanban Board: Height. I used Github projects so far—but man, are those auto-drafts annoying.
For the wiki: For the last project I used Bookstack—now I'm going to go with Outline: It's open source and self-hostable like Bookstack, but looks way cleaner.
For the whiteboard: The last times I went with Miro, but that has been a pain performance-wise. Let's see how FigJam will do.
Happy collaborating!
Beat Hagenlocher
2y ago
Let's first ask ourselves: What should the Getting Started section of a project look like?
Abstractly, I think it should be something like this:
git clone <repo-name> && cd <repo-name>"Install the necessary dependencies"
"Run the app as intended"
And well, we all know what it can look like—I won't go into that here.
With a devShell from a Nix Flake, we can get to this:
(You probably need to install Nix first: )
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- installgit clone <repo-name> && cd <repo-name>nix develop"Run the app as intended"—if your
flake.nix-Person did it right,nix developshould make clear how to do that.
And the best part? One person can setup this flake, once—and the 'works on my machine'-days are gone.
That's all I've got for today. See you tomorrow! 🚢 👋
Beat Hagenlocher
2y ago
This is a piece for my self-from-2-years-ago.
I am automation obsessed. Over the last few years, I've accumulated nice level of tooling to speed things up: Almost all of the most-used commands in my shell history are aliases, I'm creating most of my projects via Nix Flake Templates, and my keyboard layout is full of Macros. But arguably, one of the very basic things has been still missing.
For the longest time in my life, I've been wasting countless keystrokes for switching between all the windows on my computer.
Enter gnome-magic-window—since 8 months, I've rarely been switching windows 'the normal way':
Want to open your terminal?
⌘+t(Hold super, press t, release both)Want to start to code?
⌘+cSwitch back to your terminal?
⌘+tLook something up on the internet?
⌘+f(firefox)Resume coding?
⌘+c
Yes, it's better, and yes, it's way faster.
But for me, the key difference is that it's simpler—there isn't the shortest moment when I'm tabbing through my open applications trying to select the one I want to switch to.
That's what I want to use automation for: Simplicity.
And in case anyone of you got something that's even more versatile/faster/better, please do let me know! (And yes, I do know about tiling window managers.)
