Ask HN: how do you learn to code right?
6 comments
I think the problem is that the "right" way is completely subjective. Is Spring "bad" and Scala "good"? Depends on what you're building and for who.
Overall, the best way to be a great developer (not just a good coder) is to: 1) Build a strong theoretical foundation. The curriculum of any top tier CS program is a good starting point. Check out Intro to Algorithms http://www.amazon.com/Introduction-Algorithms-Thomas-H-Corme...
2) Stay on top of new technologies and models. Read Hacker News, Read Reddit, Follow notables on Twitter. Check out @lhazlewood
3) research, debate, practice, implement, review
Overall, the best way to be a great developer (not just a good coder) is to: 1) Build a strong theoretical foundation. The curriculum of any top tier CS program is a good starting point. Check out Intro to Algorithms http://www.amazon.com/Introduction-Algorithms-Thomas-H-Corme...
2) Stay on top of new technologies and models. Read Hacker News, Read Reddit, Follow notables on Twitter. Check out @lhazlewood
3) research, debate, practice, implement, review
Yep, that's the current way I do things, but you know how much reading hacker news can be confusing. And not always what is popular == what is good code examples.
I'm looking for a highly acclaimed open source project, or developer, that most people agree is a good example. Some sort of a "developers academy" that gives awards for "best design" "most elegant code" etc. like the Oscars. then people can follow the practices. Sadly, at the moment, these things are not taught in school, or anywhere. If I want to learn making movies, I know exactly what movies to analyse, for coding, I have no clue, there is no guarantee that a popular github project is also well written, it just might be doing its thing right. I hope I managed to point the problem, and I think as a community, we should build some standards that are cross language and framework, and maintained and evolve with time. e.g. the "good code principles, with examples, certified by top 1000 in stackoverflow, 20 YC CTOs, 10 professors from Stanford, 20 R&D managers from the enterprise world, and 1000 top hackers on hacker news. crazy, but this is exactly the film academy, isn't it?
I'm looking for a highly acclaimed open source project, or developer, that most people agree is a good example. Some sort of a "developers academy" that gives awards for "best design" "most elegant code" etc. like the Oscars. then people can follow the practices. Sadly, at the moment, these things are not taught in school, or anywhere. If I want to learn making movies, I know exactly what movies to analyse, for coding, I have no clue, there is no guarantee that a popular github project is also well written, it just might be doing its thing right. I hope I managed to point the problem, and I think as a community, we should build some standards that are cross language and framework, and maintained and evolve with time. e.g. the "good code principles, with examples, certified by top 1000 in stackoverflow, 20 YC CTOs, 10 professors from Stanford, 20 R&D managers from the enterprise world, and 1000 top hackers on hacker news. crazy, but this is exactly the film academy, isn't it?
I think that, especially once you start asking for cross-language, cross-framework standards, you're simply asking for the impossible. I know that feeling, wishing some kind of authority could help you determine the One True Way but there is almost certainly no such Way that is equally True and Singular across all possible languages & frameworks.
My suggestion would be to learn some C if you don't already know it and and then look through the following projects:
SQLite, Fossil, Nginx
The reason I suggest this is that C is so old that it has got relatively immune to fashion and that by reading good code in a low level language you can make a more informed choice about what a high level feature or idea brings to the table.how do you know the good from the bad? what is the consensus?
what is the best book, open source project, mentor, forum, blog, hackathon, tutorial, podcast, meetup or academic course that taught you the best principles that made you a good coder."
It's not any one of those things. It's not who tells you how to think, but learning to make the choices yourself based on how things work. Occasionally there are clear choices regarding what is better, but most of the time, there are trade-offs. It sounds like you need to be looking at those trade offs at a higher level.
You need to stop caring so much if something is criticized, and instead look at whether those criticisms are valid for your use case.
I'd also note that I think a lot of the time, people place certain trades, certain practices, even certain frameworks and languages on a pedestal, when in reality there isn't always a huge difference for the average programming use case.
That's not to say that trying to be a better coder is not a worthy goal. But don't think of it as coding right, or good from bad. People too often use value judgment terms (right, wrong, good, bad) when they should be discussing trade offs (better performance, easier to add to, easier to maintain, less memory, faster compile, less time spent writing etc).
So, expose yourself to different viewpoints. find Java user group, a Scala meetup, whatever, and meet people. Hell, try tutoring or mentoring people yourself, it sounds like you have a wealth of experience. Get many different viewpoints, and try to learn what is right for you.
Also, I've read some of your posts to HN and your blog, and several things you've written or linked to have been informative and interesting. Thank you.
what is the best book, open source project, mentor, forum, blog, hackathon, tutorial, podcast, meetup or academic course that taught you the best principles that made you a good coder."
It's not any one of those things. It's not who tells you how to think, but learning to make the choices yourself based on how things work. Occasionally there are clear choices regarding what is better, but most of the time, there are trade-offs. It sounds like you need to be looking at those trade offs at a higher level.
You need to stop caring so much if something is criticized, and instead look at whether those criticisms are valid for your use case.
I'd also note that I think a lot of the time, people place certain trades, certain practices, even certain frameworks and languages on a pedestal, when in reality there isn't always a huge difference for the average programming use case.
That's not to say that trying to be a better coder is not a worthy goal. But don't think of it as coding right, or good from bad. People too often use value judgment terms (right, wrong, good, bad) when they should be discussing trade offs (better performance, easier to add to, easier to maintain, less memory, faster compile, less time spent writing etc).
So, expose yourself to different viewpoints. find Java user group, a Scala meetup, whatever, and meet people. Hell, try tutoring or mentoring people yourself, it sounds like you have a wealth of experience. Get many different viewpoints, and try to learn what is right for you.
Also, I've read some of your posts to HN and your blog, and several things you've written or linked to have been informative and interesting. Thank you.
A great mentor would be helpful for a code review.
Also, any communities or sites that promotes best standards and practices for your languages of choice would be great.
Also, any communities or sites that promotes best standards and practices for your languages of choice would be great.
Right or not right is subjective as other have said already, so what is right for me, may not be right for you. For me coding right is the following:
1) If I return in a month, I can still quickly understand what the code does. 2) When I modify part of the code I can do it easily without modifying too much other parts of it. 3) Someone else reading my code, who has never seen it before can read and understand it easily.
One other thing to remember is that right code also depends on the project you are doing. What is right for a small quick app is not the same as what is right for a big entreprise application. If there are many people in a project then you may need to code in a more documented way, but the same thing will be overkill if you just test a simple feature.
A great place to learn is from open source projects. Some of them have lots of contributors and if they don't their code right, the project will become a mess. Learn from their practice and apply it.
My very last advice is no matter what you decide is right code, be consistent. Don't code one day in one way and the next day in another way.
1) If I return in a month, I can still quickly understand what the code does. 2) When I modify part of the code I can do it easily without modifying too much other parts of it. 3) Someone else reading my code, who has never seen it before can read and understand it easily.
One other thing to remember is that right code also depends on the project you are doing. What is right for a small quick app is not the same as what is right for a big entreprise application. If there are many people in a project then you may need to code in a more documented way, but the same thing will be overkill if you just test a simple feature.
A great place to learn is from open source projects. Some of them have lots of contributors and if they don't their code right, the project will become a mess. Learn from their practice and apply it.
My very last advice is no matter what you decide is right code, be consistent. Don't code one day in one way and the next day in another way.
You learn how to do it right by doing it wrong a few times, feeling the pain, and looking for a better way. Sometimes that comes from looking at other people's code, and sometimes it comes from your own inspiration. Either way, there's no magic formula aside from perseverance and working with other people (who won't always be right, but you'll get ideas from them.)
I might know Java the language in and out, might pass any test with the highest score, and my code might be readable, might have low bugs, might be well designed, but I have no clue.
I find it so hard to find places that can really tell me what is the "right" way to do it.
for example, I was raised to believe Java OOP has the answer to anything, so I used my share of AbstractBeanProxyFactoryClass and Spring framework and thought this is what I should learn from, then there was Seam which influenced JEE 6, and then I learned about RoR which changed my mind a "little", then Scala, Play, then I learned that all that I was taught is wrong (Singletons, OOP, BDUF, multithreading in Java) or right (depending who you ask)
There are so many places to teach you how to code, I know how to code, I can code anything, but how do I learn to code right? if learning from a successful framework like Spring is "bad" and JEE, an industry standard, is something I should "not" be using as an example, if so many smart, educated, and experienced people are doing it "wrong" how do I know how to do it right?
for example, even the most popular web technologies site w3schools got a lot of criticism, e.g. http://w3fools.com
how do you know the good from the bad? what is the consensus?
what is the best book, open source project, mentor, forum, blog, hackathon, tutorial, podcast, meetup or academic course that taught you the best principles that made you a good coder.
Where can I just look at some code for common tasks with a wide consensus of the "don't" version vs the "do" version?