116 points · by todsacerdoti · 3y ago · 84 comments
The “You could have invented monads, and maybe you already did” approach: monads do solve a problem, but if you’re presented with the solution before being exposed to the problem, you’d be like “This is magical, complicated, unnecessary. Why would I ever want the problem that this solves?”
This frustrates me a lot when I see our current education system, from the kindergarten to post-grad.
For instance my 6th grader son's book introduces LCM/HCF out of the blue, something like "this is LCM and here's how you calculate it". Not a single motivating example.
Or take design-patterns. I learnt about two dozen of them in college and promptly forgot them within a week. I finally begin to appreciate them after encountering problems at work.
Imagine if carpentry is taught by asking pupils to cram about 150 tools over 3 years. Or they start out by saying "Let's build a chair" and discover the need for one tool at a time and mastering them as they go along. They will also learn that they should look for a tool should they encounter a new kind of task.
I think this is also why I didn't see the point of the design patterns book.
If you don't already have all the problems that Kubernetes solves and the complexity that goes with those problems, adding Kubernetes prematurely gives you problems you didn't have by introducing complexity you weren't (yet) subscribed to.
A: "What the hell is a PersistentVolumeClaim? Why can't I just write to disk?"
B: "But what if you don't have a disk at the edge? How does this scale?"
A: "What edge?! What scale?! I have a disk!"/rant
The ones that have experience with devops tend to appreciate Kubernetes
Why study long-obsolete tech?
Because it helps you better understand why the current tech is what it is, and it even makes one think about possible alternatives, which in turn foster innovation much more than merely religiously learning current technology.
> When teaching programming, we should let people make these mistakes, and then show them the tools to correct them.
This was one of my pain points when I was in college studying CS. It was killing me to have the teacher just dictate that programming lecture without showing what problems it solves and/or how difficult our lives would be if we don’t get it right. I still recall that interfaces lecture where the teacher keep telling us to declare some sort of class with some methods but without implementation!! Any class could then benefit from this! How/Why?! I wasn’t able to get this interface thing until I graduated and worked on a personal C# project with WPF where I designed it with a basic architecture of plugins/addons that got loaded at runtime, those plugins should all have some common functions that can be called by the host app, only and only then, I fully understood interfaces and how/why/when to use them. At that point, I wished I can go back to college, explain this concept to students and get back!
I believe the reason why college teachers struggle to explain such concepts in a better way is their lack of experience in the field.
It was only when I picked up a couple of online courses like CS50 from Harvard and CS106 from Stanford (quite outtdated now) that things started to make more sense. Sometimes those things take time and looking at them from different perspectives, and even different programming languages/paradigms.
E.g. I started to appreciate the use of interfaces more when I started using Go, going from Java, where they're implemented implicitly, that I realised they're actually really useful and not just a nuisance.
This happens to ... a friend of mine.
Now, granted, too many people / organisations / whole fucking countries aren't even learning from their own experiences, but you should really strive to learn from others too.
-- Douglas Adams, Last Chance to See
:-)
But I take your point.
However, responding here since you did, I think you missed the whole point of that sub-thread. People aren't telling you that Bjarne's terrible I/O streams functionality is great so you should use that. They're praising the much more normal looking std::format and related features which have been adopted from fmt.
As a result assessing Bjarne's I/O streams and discovering that they're terrible is not a meaningful reaction to that praise. We know Bjarne's feature is bad, we're talking about a different, much better, feature.
I had many collegues in unversity that had to shoot themselves into the foot. A normal part of learning. But as we were always working together everybody had the chance to see the others doing so.
Now there were some people who saw others shoot themselves in the foot in a particular way, only to go and do the same thing on their own project. Don't be that type of person. Be the person who observes others shoot themselves into their foot and wonder how you could prevent yourself from doing that in the future (and accept that for some things you can't).
Software engineering is very similar. Sure maybe you are the type of person who can't grok a footgun unless they got shot by it. But you can try not to be that type of person. Making mistakes is important. But make them at home or in toy projects, don't make them in a decade long effort by a ten people team with the data of million people. And if you are in such a project it is part of your job to learn from other similar projects and the ways they shot themselves into the foot.
I would add one thought here - it's not just about seeing others make mistakes, or about making the mistakes yourself. It's also about seeing how mistakes can be made across bigger teams or time-frames. Well-intended innocent creative choices at one point in the process can cause serious trouble later. Or two independent choices can create unforeseen problems. That's the sort of experience that's least visible, and that's what experienced mentors can provide.
So, I would argue that it's best to have a healthy mix - you want to see others fail, you want to fail yourself, but then you also want to have mentorship by others who have made these failures themselves. Seeing someone else make a mistake and then making that same mistake yourself can be a very valuable and humbling experience.
I do agree with you that the profession doesn’t lack its fair share of big egos and self taught arrogant geniuses.
But there is a difficult equilibrium to find between this and the other side of the coin which is the cargo cult of inherited best practices and over engineering.
Most programmers (including sometimes myself) have a hard time choosing the right tool for the right job. But learning to pick the right tool is hard.
Even learning this from others is hard : I’ve happily learned from a lot of specialists how to use a specific tool in depth, but I can count on one hand the number of people who suggested me a better tool for the task.
However I also think that most people need to experience the pain and frustration of hitting themselves with their own decisions a number of times, until they develop enough humbleness to see the benefits of using other's experience instead.
I’m also pretty sure that students in civil engineering are making virtual bridges collapse every single day.
It’s also true in other engineering branches : we have barely the same planes design since decades and that’s for good reason.
It’s not really something you can do when rules and best practices are going left and right every couple of months.
And don’t get me wrong I’m convinced that the peak of program engineering is in the past. But the industry keep forcing new things to developers.
By three methods we may learn wisdom: First, by reflection, which is noblest;
Second, by imitation, which is easiest; and third by experience, which is the
bitterest.And honest reflection on failure is punished in hierarchies.
It’s the job (and value) of a teacher to help you understand not only how but why we do like this.
Since we are more or less thrown is this beautiful "life-long learning" career without professional teachers, it’s way harder to understand the why without exceptionally great mentors. And that’s my pet theory that this is at the roots of cargo cults.
Before civil engineering became a profession all kinds of people would build bridges and all kind of bridges would collapse. The solution wasn't to accept that bridges collapse, the solution was to not allow just anybody to build a bridge and to create standards that bridges had to adhere to.
Also, as a self thought programmer that is regularily shocked of what he finds in the field, done by supposed professionals: Being self thought has nothing to do with it. Because I can also read on someone's experiences and mind set. Every self thought programmer will read books on programming made by people who program. Even self thought programmers will avoid goto atatements like the pest even if they don't know the original reason for that rule.
The problem in software engineering is one of culture. We program shit and move on. If it breaks it is not our fault. Very few people feel ownership and/or responsibility for the code. Granted: Very few companies are willing to pay the money needed to allow for such a process, except if they are in a field where it is required by law (automotive, aviation, ...)
What we need is a clearer liability structure for software errors. If a companies software is investigated after privacy leaks and they are on the hook for each individuals data that they mistreated if the software is not up to standard companies will think twice to cheap out on software engineering. If software engineers are on the hook if a company gave them everything needed to make a safe product and they didn't, they are on the hook.
I don't say everything needs to follow that level/standard, but as of now a software error is treated like a unavoidable act of gods will that nobody could have foreseen or prevented.
Learning C before Rust so you better understand Rust isn't "foolish action" nor does it "impede one's own plans".
I grow tired of authors twisting and abusing the meaning of common English idioms so the author can say "well actually some times you want to shoot yourself in the foot"
But i want to attach something on your "some opinion" title's
> You should learn Zig (or C) before you learn Rust
part.
I had learned C before Rust but, vectors are not used in C. It belongs to C++. And although I know C, Rust is still very confusing to me. In my opinion, it would be better learn C++ before Rust.
Example: (Destructive) Move assignment is the correct thing, if you introduce that to begin with, showing Copy as an optimization, I think that makes more sense than the way it's often taught knowing people are familiar with languages that default to (or only have) copy assignment.
Another example: Rust doesn't have boolean coercion, the boolean coercion is so rife that you find it in otherwise seemingly principled languages, but the consequences are quite awful - in Rust you can cheerfully teach the entire language without this concern, because Rust doesn't have this coercion. "false" is neither true nor false, it's a string, 0 is neither false nor true, it's an integer. Many modern languages avoid C's extreme coercions - you can't write "Ten" + 5 or 'a' + 1 in such languages, (in a few of them it's a concatenate operation, which I don't love either, but at least it's not some weird coercion) - but they still insist "false" is true because it seemed easier and C did it. Rust does not.
You mean by default?
std::vector is famously the only C++ standard library container which isn't crap, but, the fun thing is that it's still a bit crap anyway. Like a lot of C++ standard library features it could be better, but that'd be an ABI break, so too bad either use somebody's custom replacement which is better or put up with the good-but-not-great std::vector
Unfortunately learning the fundamentals requires a lot of reading and practicing and most literature and content out there isn't great.
The OP would have known why holding a reference to an item in a list sometimes is not a good idea by knowing the fundamentals of memory allocation, which can be found on many books and articles totally unrelated to Rust.
One of my favorite books for learning fundamentals is Effective Java, even when I wrote very little code in Java during my career I found some of the concepts and ideas in that book to be language agnostic.
... which can be learned by shooting yourself in the foot with C.
My opinion is, it's best to have done a little low level programming because it will nag you subsconsciously when you go accidentally quadratic or worse in a high level language.
"Men say that a stitch in time saves nine, and so they take a thousand stitches today to save nine tomorrow." - Henry David Thoreau, Walden.
It's good to not shoot yourself in the foot. Really. But, depending on what you're working on, it may not always be worth the effort to prevent.
For some things, of course it is. If you're working on something either safety-critical or enterprise-critical, you almost certainly want to use whatever tools you can to prevent shooting yourself in the foot.
But sometimes the price of the safety costs more than it's worth. At the extreme other end, if I'm writing an experimental one-off for my own curiosity, I'm not going to worry about satisfying the borrow checker (unless the point of the one-off is to learn Rust). If I'm writing an experimental one-off for work, that's likely to be still true - I'll write it in whatever gets me there fastest, because the point is learning what the results are, not producing production-level code.
Use the level of protection that's appropriate for what you're working on - no less, but also no more.
Note that all this is somewhat orthogonal to the question of whether one needs to shoot oneself in the foot before learning how not to. This is more like, once you've shot yourself in the foot, learn when to leave yourself exposed yourself to the possibility of shooting yourself in the foot again.
It is sad that newcomers are told to learn this tool and that tool while they never get to know the problem those tools are solving.
Another experience that triggered an A-ha moment for me, was reading the OAuth2 RFC (6749). I had previously read multiple docs of libraries implementing the protocol and had integrated with such libraries in the past, but it was only when I read RFC and the problems the different flows try solve that it finally clicked.
That is how my university professor made whole semesters hate programming.
An IDE makes the entry into programming much easier and fun.
then they shouldn't have picked java as an intro language.
It is more than possible, but for anything non-trivial, it just sucks.
It's very gratifying when you're a Unity dev in a room of Unity devs and you're the only person who can diagnose and fix a build problem involving raw OpenGL ES and Objective-C++.
From another angle, these baser systems like C and vanilla JS are _simpler_ and you just have a lot less to learn at once. It's a good waypoint.
Interestingly not my experience.
I usually start something uselessly complex, with more passion than reason, to learn or brag, then halfway I indeed shoot shoot myself in the foot trying to be clever or lazy.
I would not recommend to look for footguns, they are already looking at you :)