DEV Community

Discussion on: Bad Programming Habits

Collapse
 
mylesftop profile image
Myles

While I agree over the longer term, when learning a particular language, it is important to focus on it and learn its idiosyncrasies (e.g. features and how they're implemented, coding conventions) before jumping to another language, especially if it's one of your first languages.

Collapse
 
erebos-manannan profile image
Erebos Manannán • Edited

What should be your #1 priority is always productivity. Figure out how to do things, get the thing you need to do done, then try and figure out how to do it better, prettier, etc. if you still have extra time.

For one, if you spend a lot of time figuring out how to do things in the most perfect way instead of just doing it in less perfect ways, you will lose motivation to do the thing and will instead just do something else.

Also there is nobody out there who can say they know everything about any language, you keep learning with experience, best practices evolve, languages evolve, so having your focus be on "fully understanding" any language is just plain wrong.

When working with others, you should focus on things like readability. Generally speaking you should understand things like avoiding premature optimization, but when you do notice a place where speed matters - then focus on figuring out how to make that bit of code as fast as necessary or easily possible.

Most languages contain a lot of things that most people will never need. When I started with the Commodore 64's BASIC, e.g. POKE and PEEK were there, and mostly unnecessary. There are still tons of functions I've never used nor seen any practical use for. And BASIC is pretty damn .. basic.

Generally I would wish people would stay away from their languages special shorthand syntaxes and other such things that make their code unreadable for people who are not deeply familiar with that language's specialties (especially since often the people using them don't understand what they do either, they just copy & pasted it). I'm looking at you JavaScript:

const h = ({name}) => `Hello ${name}`

Learn what is useful to accomplish your tasks, occasionally spend some time looking at best practices when you have time, try to at least occasionally google before trying to solve every problem yourself and learn more about the wonderful world of libraries that take care of things for you .. but occasionally also reinvent the wheel when you have time and motivation so you understand what is going on.

Thread Thread
 
erebos-manannan profile image
Erebos Manannán

Oh and e.g. I've been a heavy user of Python for many years, I'm still regularly surprised of features the Python standard library includes, but it's more like "oh, neat" (and then usually forgetting about it) instead of "oh damn I would've done my job so much better all these years if I had known about that".

Thread Thread
 
mylesftop profile image
Myles

I definitely agree with you on both these posts. I've seen it said that a good senior dev's code looks more obvious than a junior dev's, simply because they'll produce what is both readable and efficient - which includes not using some of the weirder syntax and obscure features. But by the same token, you can get people trying to learn who are hopping around so quickly between languages (whenever they get bored of the current one or find another one more interesting), that they don't give themselves a chance to get a solid foundation (or even a "SOLID" foundation). I'd rather solve a new problem in the same language than have to relearn how to solve it - but I'm also a newer developer, so I know that will be different once I have a couple more languages under my belt.