‘Beacons are parts of a program that help a programmer understand what the code does. You can think of a beacon like a line of code, or even part of a line of code, that your eye falls on which makes you think, "Aha, now I see."
Beacons typically indicate that a piece of code contains certain data structures, algorithms, or approaches.’
Turns out that all that time I spend “making the code pretty” I was just making it understandable. The question is if what I consider pretty/understandable is the same as other programmers would call pretty/understandable
“after taking a course on design patterns, the time participants needed to maintain code was lower for the code with patterns but not for the code without patterns. The results of this study indicate that gaining knowledge about design patterns, which is likely going to improve your chunking ability, helps you process code faster. You can also see in the graphs that there is a difference in effect for different design patterns: the decrease in time is bigger for the observer pattern than for the decorator pattern.”
I have no idea what the decorator pattern is, but I’m a fan of the observer and i sprinkle it everywhere whenever I can.
A tangent: I think this the magic of functional programming: you have some well defined concepts that you can mix and match. It’s hard to learn them because they are unfamiliar, not because they are difficult, but once you do, it’s easier to reason about stuff that uses them
In the age of so called AI isn’t it weird I’m reading a book that teaches you how to use refactoring and state tables for the sole purpose of understanding?
Weird is good though
The point of the chapter though is that readability and maintainability aren’t the same, and readability depends on the experience of who is reading.
So, for example, I tend to dislike loops now, I think they add too much noise to what usually can be just a map + a filter call, or reduce or whatever. But before I started to learn Haskell any code using higher order functions was overly confusing for me.
I been rejecting any attempt to make languages easier to learn or more familiar based on how my own experience. Learning is uncomfortable and takes time. There’s no shortcut. If you wanna help beginners don’t be an asshole when they ask stuff. That’s 100 better than adding braces to an ML language (yes I’m still mad at ReasonML)
This books is making me doubly down on the idea that programming sucks because programmers suck, not because programming languages sucks. We approach the discipline in a way that’s nothing rigorous at all. We call 100% coverage rigor, and that’s laughable.
If you think and LLM can write code that’s as good or better than yours, that’s on you
“The process of replacing a misconception based on a programming language you already know with the right mental model for the new language you are learning is called conceptual change. In this paradigm, an existing conception is fundamentally changed, replaced, or assimilated by the new know ledge.” Can’t stop thinking about “type classes are like interfaces”. No.
Edit: it proceeds to explain that learning Java after Python my lead to misconceptions and then you have haskellers swearing there’s nothing wrong with saying that type classes are interfaces. Truly Haskell is hard for the same reason that Nix is hard
“Use tests and documentation within a code-base to help prevent misconceptions.”
There’s nothing more to be said about how and when to comment and test code
No wonder this scale has been criticised, we need to come up with out own:
0. Very, very low mental effort
1. Very low mental effort
2. Low mental effort
3. Rather low mental effort
4. Neither high nor low mental effort
5. Rather high mental effort
6. High mental effort
7. Very high mental effort
8. Very, very high mental effort
(The numbers weren’t in the source)
This book pretty much confirmed what I’ve been suspected for a long long time: any idiot can be a programmer, which explains why I, a fucking idiot, am a programmer. It has nothing to do with intelligence, or not in the way people usually thinks about intelligence. You don’t have to be smarter than the average person, you just have to practice.
I’ve been fascinated by computers for a long time, so I’ve spent a huge amount of my time dealing with them, which is another way to say that I have practice.
I’m pretty dumb though, it takes me a long time to learn things, but when motivated that just gives me more practice
«If a codebase or programming language is very strict (for example, using types, assertions, and post conditions), it can be hard to use code to express a thought. We then say this tool has low provisionality. Provisionality is an essential factor in learnability because expressing vague ideas and incomplete code might be needed if you are a beginner in a certain system. Thinking of a plan for your code while also thinking about types and syntax can cause too much cognitive load in beginners.»
I consider this as a division we can’t surmount. Some languages will always be hard to learn and any attempt to make them easier (provisional) will remove some constraint that IMO helps with thinking
I should note that one's capacity for cognitive load decreases with age. Young children can withstand a ton of it. That's why we send them to school at such a young age. That's also why young kids learn programming relatively easily (provided, of course, that they're curious and nerdy enough to want to).
I do dearly miss having a young brain…
@argv_minus_one here I’m more sceptic. I experienced myself what you describe, as I’m mostly self-taught. But I think the difference was time. And I didn’t have to worry about buying and apartment or keep renting, or things like that.
Of course we see how the cognitive capacity decreases dramatically with age, but I believe it’s mostly because we don’t have the right to experience what kids do, for example few of us can study after we get one degree. But I’m pulling things out of my ass here. This is mostly a hope that something I’ve researched
You can kinda-sorta mitigate this problem with helpful compiler diagnostics. Rust, for example, tries really hard to tell you why your code is wrong and what you can do to fix it.
But that's only a kinda-sorta mitigation. Rust is very much not a provisional language. And the compiler's advice isn't always correct, either.
@RosaCtrl Same here.
I think that the problem is at the source tho, ie that we think that "intelligent" and "idiot" are good ways to describe people.
Being able to code, as you put it, just means that someone has put a lot of time into learning to "speak computer".
It's like being able to speak many human languages: it can take a lot of effort, but it's something all humans can do.
@RosaCtrl re type classes - i agree it’s maybe confusing if you think of interface as an oop thing. But type classes are collections of purely abstract functions for which you can demand or provide implementations. They’re contracts. They’re APIs. All these things are synonymous to interfaces.
It’s confusing if all you know is OOP interfaces, because this adds the subtyping constraint. And that’s a good example of how transfer learning can lead you astray.
Haskell goes one step further by requiring, by convention if not compilation, that there’s a single implementation of a type class for a given type. So - collections of purely abstract functions that you provide implementations for on a per-type basis. Without more context, i wouldn’t be able to tell you if you mean type classes or oop interfaces.
RE: https://social.vivaldi.net/@RosaCtrl/116311373431116257
@NicolasRinaudo the thing is that if you add protocols to the mix you can do better. Fun fat! I do remember some Haskellers complaining on Twitter that Apple called these protocols instead of type clases. But with protocols you get both, what a Haskeller is used to as well as what a Java programmer is used too! (Unless I’m missing out something about Java, to be fair I don’t know that much Java. Or C#)
@RosaCtrl but that’s an implementation detail!
Also, it does - it’s just immutable in Haskell. Like in Java, for some classes. Strings are immutable and implement the Comparable interface.
@NicolasRinaudo OK, I’m getting ready for the gym so I wasn’t clear 😅 When I said that most programmers don’t see implementation I meant that when you learn Haskell you don’t have to learn how type clases are implemented. And maybe other languages will implement them in a different way.
And then when I mentioned state I’m saying that when you learn interfaces in OOP you most likely learn about how to implement methods that touch the internal state of the objects that implement the interface.
What I’ve seen is that people, including me, gets super confused by type classes are interfaces, because in the sense of OOP, they are not. Things may be similar, but the differences are enough to make us confused for years.
Unless I’m wrong and actually only some people gets confused, which I highly doubt, but I could accept if confronted with the right evidence
@RosaCtrl i think if the explanation went:
- this is what an interface is.
- do you see how oop interfaces are actual interfaces? (This removes the confusion with subtyping and state which are not part of the concept)
- here’s another way of doing interfaces
But people skip the first point, and so you try to bring in unrelated concepts and can’t find them, hence the confusion.
@RosaCtrl understanding the similarity means knowing both has allowed you to create a more abstract mental model and to see how each is a specialisation of that model. And THEN the third time you encounter them with different implementation details, maybe transfer learning will help.
If you think about it it’s really just category theory :)