Ask HN: What's was the hardest part about starting to code?
I'm trying to understand what the hardest part is for people new to programming? Is is understanding what source code means? Syntax? Was it variables or functions? How to think more like a programmer?
41 comments
[ 0.24 ms ] story [ 176 ms ] threadI'm looking to craft a tutorial for the /absolute/ beginner. That's why I asked this question.
Thanks!
1. how to use the command line 2. how to `build from source` 3. how to integrate different technologies (such as the MEAN stack) 4. etc.
In addition to the above, certain parts of the web, like StackOverflow, can be uninviting to new people even though (in my experience) the vast majority of coders are inviting and encouraging both in person and online.
I'm looking to craft a tutorial for the /absolute/ beginner. That's why I asked this question. So more feedback the better!
When humans interact with each other there is a lot of subtlety and nuance that is embedded in that communication. I can say something to you but you can infer that I really mean the opposite by the tone of my communication.
All that is lost with computers, when communicating with a computer you need to be especially precise in what you want the computer to do and when you want the computer to do it. I'd argue that most bugs are a result of improper communication between the programmer and the computer. Either the actual intent was not communicated properly or there is context lacking in the communication (server status, load, etc.) that is not being accounted for.
Half of all documentation is meant to be read literally. "Follow these exact steps for this exact reason and this exact thing will happen."
Then the other half is written as if you're supposed to have some secret knowledge. "Just run this, do the usual thing people do, and then you'll probably end up with something like this."
Those halves aren't mutually exclusive by document, and it took me a long time to get a feel for what the documentation author's intended.
If I was learning today, I think that I would be completely overwhelmed by the amount of information that we have at our disposal. It would be harder to dive into one thing while being bombarded by the other 300 things you are supposed to learn because everyone is talking about them.
When I mentor young programmers, I advise them to focus on a single language/framework for a really long time, until they achieve real proficiency, and actively filter out everything else.
The amount of information available now is overwhelming and, increasingly, not collected into paper books. As much has I love my e-reader for fiction, I don't absorb technical content on it as well.
However, I don't have a problem picking up new things now without a physical book. There are basic concepts of programming that don't have to be relearned for new languages and frameworks. I don't have to learn about loops again. I just need a quick example of the syntax in a new language.
Perhaps immersive experiences are best early on as you say.
TL/DR : for me programming is a way of thinking with a problem solving attitude, making sure to simplify the problem as much as possible.
Syntax comes pretty quickly, but it's the precision that is hard. So, for example, even writing a simple loop. Are you going to start at zero? Are you going to start at one? Should your loop condition be at the top of the loop, or at the bottom? Do you know what each of those implies about how many times the body of the loop will be executed? Do you check the termination condition with less than, equal to, or both? Are you sure the loop will terminate? Really sure? Do you know at what point any variables declared inside the loop are initialized, or re-initialized? Are you adjusting the loop variable inside the loop body in a way that is going to mess with the loop termination?
Programmers think of things like loop pre-conditions, post-conditions, and loop invariants to help them keep track of what they are doing, but beginners don't usually have tools like this that help them run the code in their heads while writing it to help ensure it will do what they intended.
As an example of just how easy this is to screw up, consider examples of unintended infinite loops:
https://en.wikipedia.org/wiki/Infinite_loop#Examples_of_unin...
Sometimes you get bugs that just are real headscratchers. This happens at the beginning of your career, at the end, and all the way through. There's some subtle thing keeping your code from working, even though you've gone through all the guides, stack overflow, and code review you can handle. Examples of issues like this are bugs in other people's code, library incompatibilities, timing issues, and generally trying to do anything.
You really need a lot of patience and a good problem solving attitude to solve these problems and keep going. Some people are lucky and look more productive because they don't run into these problems as often (though they do run into them). But you learn a lot more by solving these issues and understanding random parts of the stack.
To do this you really need to understand the entire system and use your tools. You need to understand things like how the OS might be doing things, how memory works, how threads work, how drivers work, etc.
If you just sit there and get frustrated, you can put in all the time in the world and not come up with the solution. You need an engineering/builder mentality right from the start, IMHO.
Anything with security, encryption, passwords, certificates is extra hard, because a lot of times the error messages are just too cryptic (ha!) to get to the root cause. They are trying to not give away anything if possible, which can make even the most trivial errors hard to spot.
* Learning tools (they get in the way of solving the problem at the beginning imo)
* Incomplete/inaccurate documentation
* Not knowing what things are possible (both in code a la standard libraries or language features and working with tools like debuggers)
* Not knowing simple best practices until you're bit by something and find them out through a slow, painful discovery process
These auxiliary abstractions were the hardest for me. Where "is" my the data in my database? Isn't it all files at the end of the day? Why can't I just use files? What does "stateless" mean in the context of HTTP, when clearly something is remembered when I log in? Circa 2009, why not do everything in JavaScript? (Ha!)
Which probably comes down to one thing really:
When you look at an existing codebase, you have no idea about the logic behind any of its design decisions. You think it's all a confusing mess or that a smarter person would 'just get it', without realising that most of the complexity comes down to:
1. Bug fixes that cropped up along the way. Usually extreme edge cases.
2. Code being refactored piece by piece, since throwing out the whole codebase and starting over is often not economically viable.
3. Backwards compatibility in general
4. Multiple people working on it, often without much of a style guide (or a non enforced one)
5. Or one or more people having no idea what they're doing, getting help from other people who have no idea what they're doing, and using code from donkeys years ago also by people who may or may not have known what they were doing that sort of fixes the issue if you hammer at it a bit.
There's often a huge jump between 'what the average tutorial teaches you' and the source for a major project/commercial product, and for some guy going from say, learning basic PHP to reading the Magento source code, it can just feel completely overwhelming.
Relatedly, the whole jump from 'intermediate' to 'expert' is probably one of the hardest parts too. As people said before, there are loads of tutorials for absolute beginners, a fair few for experts, and a lot less for people in between.
The difference between good and great is being able to refactor when you hit a wall, and avoiding the wall entirely by designing things well up front.
A tiny example might be something that uses a symlink or, worse, is hard-linked from multiple places. A newbie might not even know that such things are possible; and if you don't point it out or use the terms, they can end up be horribly confused.
Anyone here who ever taught a course to beginners where each person brought their own computer? I bet you've got stories about the hundred million ways that setting up a dev environment can go wrong. And it's even worse if that beginner doesn't even have an actual teacher guiding them.
The second hardest part was that edlin is a dreadful editor.
The programming comes naturally if you have documentation and tools.
These days my biggest gripe is probably the state of the JavaScript world. I'm mostly a Python person, but having to deal with JS leaves me frustrated more often than not: new frameworks, tools crop up every year, old tools stop working, breaking changes are introduced at such pace that someone not fully dedicated to frontend has a hard time keeping up. If any JS framework had the same stability, level of documentation, and clear roadmap as Django, the frontend world would be a much better place.
I think the most valuable skill for a "real world" programmer is the ability to find and read the documentation. Also, curiosity to do that even without an immediate need. Read it like sci-fi. The more you read, the more you have the right mindset, and those "building blocks" that would come later when you're thinking about implementation.
There is too much stuff coming at you all at once - it's like trying to drink from a fire hose.