Most active commenters
  • jameshart(3)

←back to thread

Type checking is a symptom, not a solution

(programmingsimplicity.substack.com)
67 points mpweiher | 11 comments | | HN request time: 0.401s | source | bottom
1. jameshart ◴[] No.45142572[source]
All programmers need to try assembly programming just once.

Just a program counter, a stack, a flat addressable block of memory, and some registers.

You’ll very quickly learn how hard it is to program when you have complete responsibility for making sure that the state of the system is exactly as expected before a routine is called, and that it’s restored on return.

Every language tool we’ve built on top of that is to help programmers keep track of what data they stored where, what state things should be in before particular bits of code are run, and making it harder to make dumb mistakes like running some code that will only work on data of one sort on data of a totally different structure.

Of course types are a solution. You just have no idea what the problem was.

replies(7): >>45142961 #>>45143148 #>>45143298 #>>45143430 #>>45143718 #>>45145214 #>>45145436 #
2. delta_p_delta_x ◴[] No.45142961[source]
When I was taking my compilers class at uni, I realised very quickly that the most irritating part was the sheer volume of book-keeping.

Things like the ABI itself, which includes register saving/restore, function call stack setup, to the linker and loader, ensuring the right sections go to the right places and are correctly sized, and then at load time ensuring relative addresses are correctly relocated, all branch target labels are resolved to these relocated addresses, it was such a pain.

All of this book-keeping was a genuinely the most time-consuming part of the assignments; the actual compiler ideas and implementation being relatively manageable.

Funnily enough the compiler implementation was done in OCaml.

3. ratelimitsteve ◴[] No.45143148[source]
https://computersystemsbook.com/

If anyone is interested in learning assembly, this was the book and simulator I used as an undergrad. It's not exactly bytecode that will run on an actual processor but it will help you understand the bare metal things a CPU has to do in order to actually operate upon data and it's kinda eye opening when compared to what modern coding is actually like nowadays.

replies(1): >>45143230 #
4. jameshart ◴[] No.45143230[source]
I’ll always recommend Ben Eater’s YouTube series - one where he constructs a CPU and then one where he builds a working system around a 6502. Full of amazing insights into the things that a computer has to do just to accomplish the simplest tasks. And if you work your way up from the very bottom you have such an appreciation for why 6502 assembly language is the way it is when it’s introduced.

https://eater.net/

5. wazdra ◴[] No.45143298[source]
Note that this is not incompatible with the author's view. The function abstraction does solve something: a problem we faced in the 20th century.

While I don't know whether I agree with their view, I do see that, once we've used the function abstraction to build a C compiler, and used this C compiler to build a proper OS, there is possibility for such an OS to provide entirely new abstractions, and to forego (almost) completely with functions.

6. actionfromafar ◴[] No.45143430[source]
A very weird counter point was when I learned how to do COM / OLE calls in assembler instead of C++.

It was easier to get right, there was no wizard behind the typed curtain, just a bunch of arguments.

replies(1): >>45147609 #
7. xlii ◴[] No.45143718[source]
And I'll recommend Turing Complete game on Steam if someone wants to have full journey.

It's a puzzle focused on creating electronic components (with the goal of creating a running computer). Since it's more educational than competitive it's rather smooth journey.

But in the end there's not only assembler but there are actual electrons in the system that take time to reach CPU. It took me 2-3 days to finish during Holiday period and it made me much more aware of what is happening under the hood.

8. TheCleric ◴[] No.45145214[source]
For anyone who just wants a taste of this I highly recommend the game Shenzen I/O. The game is your writing a subset of assembly for products at a manufacturing facility.
replies(1): >>45146119 #
9. mbb70 ◴[] No.45145436[source]
I implemented a casino in assembly for college. Started with a Mersenne Twister and added a few pure chance games like roulette and slots.

The PRNG was trivial. Managing the user's bank balance, switching between games, making the roulette wheel 'spin' by printing a loop of numbers slower and slower was painstaking, error ladden work.

State doesn't just contributing to complexity, it is complexity.

10. jameshart ◴[] No.45146119[source]
Great recommendation, although the limited assembly language doesn't give you access to memory or a stack. Zachtronics have a couple more assembly-language-like games - TIS-100 and ExaPunks - both of which are also excellent for exploring the kind of coding you can do in a very limited programming environment. ExaPunks offers the most programming freedom (including a fully emulated handheld video game device you can use to implement actual games); TIS-100 is probably most like real assembly programming.
11. ahartmetz ◴[] No.45147609[source]
It's similar for a few other aspects of programming. After doing a minimum of assembly, it is impossible to get confused about pointers.