Beat Hagenlocher

/haglobah

Beat Hagenlocher

Software Architect | Lifelong Learner | Workflow Person

About
User Avatar

Beat Hagenlocher

2y ago

How I Would Structure My First Physics Semesters If I Would Go To University Again
@haglobah

Some time ago, I taught a course on learning at a summer school.

Now, some of my students there are beginning their studies and one of them asked me how I would structure them if I were to go to university again. (He's just beginning his studies in physics.) So, I did. This is the advice I gave:

#0: Figure out what you want out of your life at university

There are probably three goals you have:

  1. Deeply understanding what you're doing

  2. Having good grades

  3. Enjoying your life

Try to find a mixture that has as much overlap between them as possible, but if they compete, know how to choose, choose, and don't agonize about your choice(s).

#1: Deeply understanding stuff

  • Find a good learning group, and learn with them. Do the task sheets together, and discuss stuff whenever things are unclear.

  • Don't just rely on one source of learning materials. We're not used to thinking that abstractly, and getting more than one perspective on a topic is immensely helpful. Book, Recorded Lectures, Lecture Notes. Everything that helps, counts.

#2 Having good grades

  • Practice. A lot. Get yourself a book with just practice tasks, especially for Analysis 1. Practice with them, from the beginning on. Try to get a hold on old exams, and practice with them, too.

  • Make this a habit: Install a habit of practice testing yourself. Find a time of your day, for every day where you get out your Anki cards and test yourself on things. In the beginning, this can be small definitions, later this might be whole proofs.

#3 Enjoying your life

  • Find some friends, both from your courses and outside of them. Try to have at least two people you can share your (emotional) struggles with (in a healthy way, ofc)

  • Find groups of people you feel belonging to: As soon as you could bring a tray of baked goods with you, and it isn't awkward, they count.

And now for the hard part: Sometimes, you have to choose between the three, and actually pick priorities. Which one do you (or did you) pick?

User Avatar

Beat Hagenlocher

2y ago

Want To Start With Functional Programming? This Is The Book You Should Read For A Smooth Entry, Clearer Design, And Better Code In General
@haglobah

I'm currently reading Grokking Simplicity by Eric Normand.

And I'm.. not blown away by how much I enjoy reading it.

For really capturing my attention, the book moves to slow.

But that is a good thing. I'm no beginner anymore: I've been thinking about Functional Programming ever since I learned Haskell in 2018, learned a bunch of functional programming languages, and worked in several larger codebases. So it's probably time I start to feel what it's like to be an expert. To be perfectly tuned for me, the book would have to move faster.

But it doesn't.


So far, Grokking Simplicity is just great.

It's well written and really avoids jargon. On top of that, Eric Normand decided to reimplement functional programming's features in JavaScript. This has two benefits: People know JS, or are at least used to its C-like syntax, and it enables Eric to build them from the ground up.

I In every chapter so far, it either changed my thinking or gave me new language/examples/mental models to talk and think about the issue(s) it describes.

That's what I like about a book. So recommended.

User Avatar

Beat Hagenlocher

2y ago

Want To Learn Programming? The 3 Pointers I Would Give To My 10-Years-Ago Self
@haglobah

#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:

  1. 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.

  2. 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!

User Avatar

Beat Hagenlocher

2y ago

How Much Is Too Much? The One Thing You Should Know About Drinking Water
@haglobah

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.

User Avatar

Beat Hagenlocher

2y ago

The 3 Strategies I Used To Remove Neck Pain From My Life
@haglobah

From 2018 to 2023, I really struggled with Neck Pain.

About every other week, I would wake up in the morning, turn my head a little, and immediately feel my muscles tighten. And then I didn't even need to bother anymore: Even just trying to turn my head would be really painful. The only two things that would help were: Blackrolling extensively (1), and sitting perfectly upright for long periods, with only observing my breath (2).

In the summer of 2021, everything changed.

I decided to consistently do something against it—and not only treat the symptoms. And as with most of the pain from strained muscles, it came down to three things:

  1. Reducing the stressors

  2. Relieving the muscles

  3. Strenghtening the muscles (and/or their antagonists)

I tackled my two biggest stressors (1): Since then, I've been sleeping on my back, and whenever I write by hand, I'm changing positions frequently.

That alone greatly reduced the effect my neck pain had on my life.

(2) is something I did troughout, via blackrolling—but what I still didn't do for a long time was actually strengthening them (3). That is something I've been doing for the last one and a half years only: And since about a year, I really feel the effect of it.

Now, I don't even remember when the last time was I woke up with a pain like that.

It's certainly been more than a few months—my 2021-self would be astonished.

User Avatar

Beat Hagenlocher

2y ago

Less Headaches And Simpler Programs Using Pipes
@haglobah

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}
User Avatar

Beat Hagenlocher

2y ago

Setting Up A New Repo In Under 5 Minutes As Software Engineers With Nix
@haglobah

Again: What should setting up a new repo look like?

It should be something like this:

  1. 'Create this kind of project'

  2. Initialize the git repo

  3. Create the first commit

  4. Create the repo upstream origin

  5. Then, push to origin, and set origin as 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!

User Avatar

Beat Hagenlocher

2y ago

Are You A Knowledge Worker? Establish This Habit To Constanly Become More Productive
@haglobah

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.

User Avatar

Beat Hagenlocher

2y ago

It Took Me Years Until I Understood Web Servers—You Can Do It In 10 Minutes
@haglobah

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.

User Avatar

Beat Hagenlocher

2y ago

How Programming Changes Your Thinking—And You Can't Even Explain
@haglobah

A few weeks ago, I realized something: Programming makes your thinking accurate.

I was showing friends of mine what Software Engineering in a larger project could look like. They were newbies—they knew little about bash, weren't used to Build Systems, and didn't have much Linux experience. I let them try to set things up with a guide. The guide didn't provide them with all the information, and they got errors.

But when I asked them about what they did so far, they surprised me.

They just casually answered what they 'tried to do'.

When pressing them about what exactly they did, they had a hard time grasping the question. I asked again what specific commands they typed in, and in which order—but they just stared back.

In their view, they'd already said what could be said.

And then I realized that I once felt that way, too.

I remember being confused that people wanted to understand what exactly I had typed in, and getting irritated when my answers weren't satisfactory to them.

I think this comes down to how we as humans interact with each other and with technology. Surprisingly often, we're able to get away with 'trying to do something', and the other side (be it tech or human) guessing our intention and doing the approximately correct thing.

Or at least it's not painful enough to change our behaviour.

Learning to program is just that: Many, many opportunities to make your thinking more accurate. With time, people that program just 'get it'. And then, someday, when they want to tell newbies to 'think more accurately', they have their own moment of realization:

I've been there, too.

User Avatar

Beat Hagenlocher

2y ago

The 2 Ways Merino T-Shirts Help You To Be More Minimalist
@haglobah

Not that long ago, I was dismissive towards Merino T-Shirts:

  • "Why would anybody spend 80€ plus for a T-Shirt?"

  • "It has to be an accessoire for people who need to spend money to get themselves to go hiking."

Then, I realized something: Merino T-Shirts are more versatile than cotton ones, are five T-Shirts in one, and with that, a real alternative to normal clothing.

Way #1: You can wear them in many more environments.

Ever feared riding up that hill and then being cold afterwards?
They keep you warm even when they're wet.

Ever feared you'd smell too much after that?
They smell way less.

And now the big one:

Way #2: They are five T-Shirts in one

  • They take up less space

  • They reduce your choices of what to wear

  • You don't need to wash that often, etc.

  • They are cheaper: Assuming a normal T-Shirt costs 20€, a T-Shirt you can wear for 5 days straight but costs 80€ suddenly sounds like a good deal, doesn't it?

(What do you think about Merino T-Shirts? Is there anything I've missed?)

User Avatar

Beat Hagenlocher

2y ago

This Is The Best Book I’ve Ever Read On Human Nature
@haglobah

There are a lot of books about Human Nature.

And I've read a lot of them.

But the best book on book on Human Nature I've read is Humankind by Rutger Bregman.

For a few reasons:

  • Reason #1: It profoundly changed how I view the world. I definitely didn't think that humans are inherently good before, but now I do.

  • Reason #2: It tells great stories—I regularly find myself referencing and retelling them when discussing human nature with people:

    • What does really happen when high school kids strand on a barren island?

    • How much panic is there onboard when a plane is about to crash, and everyone knows it?

  • Reason #3: It answers questions I didn't even consider before—for example:

    • Why do almost all domesticated animals look like adolescents when compared to their wild counterparts?

  • Reason #4: It is just plain fun to read.

If you are at all interested in understanding Human Nature, I can't recommend this book enough. I routinely tell people if there's only one book they should read, this is it. It is that good.

(Did you read it? If so, do you agree? Is there another book you would recommend? Besides Sapiens by Yuval Noah Harari, of course?)

User Avatar

Beat Hagenlocher

2y ago

I just got into the best-collaboration-tools rabbit hole again—here's my current conclusion
@haglobah

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:


Happy collaborating!

User Avatar

Beat Hagenlocher

2y ago

Does your repo's Getting Started section take more than 10 minutes? Just use Nix.
@haglobah

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:

  1. git clone <repo-name> && cd <repo-name>

  2. "Install the necessary dependencies"

  3. "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:

  1. (You probably need to install Nix first: )

    curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  2. git clone <repo-name> && cd <repo-name>

  3. nix develop

  4. "Run the app as intended"—if your flake.nix-Person did it right, nix develop should 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! 🚢 👋

User Avatar

Beat Hagenlocher

2y ago

Window switching made simple.
@haglobah

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? ⌘+c

  • Switch back to your terminal? ⌘+t

  • Look 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.)

User Avatar

Beat Hagenlocher

2y ago

Why write, and why in public?
@haglobah

Do you want to get better at:

  1. Thinking clearly

  2. Communicating your thoughts

  3. Improving your reasoning?

I want to, and I think Writing in Public might be the way to go.

Here's why:

  1. Writing forces me to think.

  2. Writing with an audience in mind forces me to make my thoughts concrete, explain context, and spot gaps.

  3. Writing in public invites discussions, enables people to point out flaws—giving me the opportunity to improve my reasoning.


I recently signed up for Dickie Bush & Nicolas Cole's cohort-based course, Ship 30 for 30.

Over the next 30 days, I plan on writing about (functional) programming, living a simple(r) life, and whatever comes to mind.

Join me on this adventure—and let me know if you have any questions along the way!
I'm excited to start sharing my thinking online.