
How to improve your programming skills - antoarts
http://www.antoarts.com/10-ways-to-improve-your-programming-skills/
======
edw519
11\. Rewrite something that desperately needs to be rewritten.

So many times I've encountered something and thought, "I can't believe that
people are actually expected to use this software."

It was bad from a user perspective: difficult to use, slow, tedious to do what
you actually needed to do, unable to "get there from here".

Then once I looked under the hood, it was often worse: built upon a horribly
designed data structure, inflexible with constants where there should have
been parameters, no apparent thought put into its use, too many violations of
acceptable practice to mention, looking as if it evolved haphazardly (which it
probably did).

It's easy to bitch about stuff like this, but you often have to go to the next
level to _do something about it_. It's amazing how much rethinking you have to
do and how many tools you have to build to turn horrible software into what
should have "obviously" been done in the first place.

Easier said than done. And often, some of my best learning experiences.

~~~
rickmb
Rewriting something is most definitely a good way to learn that a) rewrites
are easy to underestimate, and often not such a good idea as they seem, and b)
the previous programmer may not be such an idiot as you first thought.

Understanding the thinking behind other peoples code (yes, even crap code) is
one of the hardest programming skills to acquire.

~~~
steve-howard
This is something that took a lot of mistakes to learn for me. Replace only
the code that's definitely wrong, and resist the urge to start over. Whenever
I see a project announce that they're going to rewrite the next version, I
know I'll never see it.

------
DavidMcLaughlin
"Learn a new programming language"

I would rephrase this to learn a new programming _paradigm_. There are
fundamental differences between static typing and dynamic typing, object
orientation and functional, manual memory management and garbage collection.
There are also "pure" single-paradigm languages and multi-paradigm languages.
If you learn the same type of language multiple times, you're really just
learning new syntax and probably a couple of extra idiosyncrasies, so it's
important that you pick languages with fundamental differences.

Compare going through this learning path:

Perl -> PHP -> JavaScript -> Python -> Ruby -> Node.js

To going through this:

Java -> C -> Scheme -> JavaScript -> Erlang

For example.

~~~
Deestan
Counting _proper_ languages I actually wrote something _useful_ in, my path
looks like:

C64 BASIC -> C64 raw machine code -> QBasic -> x86 raw machine code -> Turbo
Pascal -> C -> Visual Basic -> Java -> O'Caml -> Delphi7 -> Python -> C++ ->
Erlang -> C# -> Haskell -> F# -> JavaScript

To keep learning very different languages is also what guarantees you will be
able to get a good job when your bread-and-butter language falls out of
fashion. Try to imagine being a 60-year old Cobol-only programmer in the job
market today. In addition to getting some experience with the actual
languages, you will also get a good grip of the underlying patterns and ideas,
which will make it a breeze to pick up any new language.

Another mostly overlooked skill that you gain from working in radically
different languages, is to be able to work with different _priorities_. Java
and C++ are designed for serious work. In these, you take types, error
checking and exceptions seriously, you keep the code clean and robust, and you
_R_ the _FM_ thoroughly for every single external function you call. Visual
Basic, on the other hand, is designed for slapping together something that
gets a small job done. Errors can be ignored, text encoding can be fucked up,
functions can run into 500 lines, and that's simply something you should be
comfortable with when in VB - it's copy/paste/hack/throw away all the way. C#
is again very much like Java, but without the documentation attitude. Critical
bits of the standard library are woefully undocumented, and you are expected
to just try some code and see if it works. When in C#, just accept that and be
comfortable with it.

But, most importantly when learning a new language: _Adopt the mindset_. Don't
try for type-safe Python. Don't write slapdash C++ code. Don't try for time-
critical optimized VB. Don't box/unbox everything in F# to get dynamic typing.

~~~
jrockway
_Java and C++ are designed for serious work. In these, you take types, error
checking and exceptions seriously, you keep the code clean and robust, and you
R the FM thoroughly for every single external function you call._

What type is "null" in Java? What type is the stack in C++?

Java and C++ have very little typing. You have to type a lot of types into
your source code, but they don't get you anything. For every Java or C++
program, there is some set of input that results in a NullPointerException or
a segmentation fault. Guess what: if you had a type system, that wouldn't
happen.

Java and C++ are designed for certifications, long-lasting career, and
compiling [1].

[1] <http://xkcd.com/303/>

~~~
Deestan
Completely agree with the types part. I did not try to say that Java or C++
are strictly typed, but that the types (ie. classes) that _are_ used in
programs are taken seriously. By this I mean that if you are looked down by
serious C++ developers upon if you send your references via void pointers or
typecast by guessing.

------
peteretep
Learning Javascript changed my Perl for the ... more fun to write. Possibly
better, too. I've started passing around coderefs as arguments to functions a
lot more recently, and allowing people who use my APIs to do just that...

I've been writing code that allows you to describe a website in data and at a
high level recently, and builds you up all the methods you need to interact
with it. In general, when people need to provide parameters, I also let them
pass in coderefs that can be executed to provide those eg:

    
    
                my $name = ref($args{'form_name'}) eq 'CODE' ?
                    $args{'form_name'}->( $self, @user_options ) :
                    $args{'form_name'};
                my $form = $self->mech->form_name( $name );

~~~
wnight
Not to golf your code or anything, but that's around the point where I
switched to Ruby. It's almost a drop-in replacement, you can be coding in
minutes with all the handy shortcuts non-PERL coders don't know they're
missing.

 _name = args[:form_name].respond_to?(:call) ?
args[:form_name].call(user_options) : args[:form_name]_

Fewer sigils, no array/scalar access nonsense, real and convenient objects,
etc.

~~~
chromatic
_Fewer sigils_

As with PHP, reusing the same sigil for everything misses the point of sigils
rather badly. I count _five_ instances of _two_ sigils in your example and
each sigil character has another syntactic meaning within the same line.

~~~
wnight
If sigil means non-ascii character, there are six. If you use it to mean name-
modifier (changes what the following string means) there is one, the colon.
What did you mean?

And yes, colon is also the _or_ in the ternary operator.

But there are still less than Perl, for the same length of code, and the code
is simpler - _.call()_ the thing if _it.respond_to?(:call)_

~~~
chromatic
_What did you mean?_

A punctuation character considered as part of an identifier by way of a parser
rule. The _?_ in _respond_to?_ , in this case.

------
peteretep
Also, randomly: I started putting bug bounties on my code on CPAN:

[http://search.cpan.org/~sargie/Data-Google-Visualization-
Dat...](http://search.cpan.org/~sargie/Data-Google-Visualization-
DataTable-0.08/lib/Data/Google/Visualization/DataTable.pm#BUG_BOUNTY)

This made me more conscientious about what I release ;-)

~~~
perlgeek
I found a doc bug :-) "This module is attempts to hide the gory details". The
"is" isn't English grammar.

(No, doesn't count as a bug, really)

------
JesseAldridge
> 10\. Don’t rush to StackOverflow. Think!

Disagree with this one. My rule is, "If you get stuck for more than 10
minutes, post to StackOverflow." I'll post my question then continue trying to
solve it myself. Sometimes someone will post a good answer right away, saving
me lots of time. Other times I'll end up solving my problem on my own, but
I'll still learn something valuable from a comment or answer somebody posts to
my question. Here's a good example of what I'm talking about:

[http://stackoverflow.com/questions/6327396/set-time-part-
of-...](http://stackoverflow.com/questions/6327396/set-time-part-of-datetime-
in-ruby)

~~~
roundsquare
It sounds like you value "getting things done" over "improving your skills."
That's not a bad thing, but its not what the article was about.

~~~
JesseAldridge
I don't know about that. My point was that by posting to StackOverflow you can
do both more efficiently. I don't see much of a point in trying to trial-and-
error a problem, hunt through documentation, etc, when somebody more
experienced can just tell you what to do in a few seconds. The same lesson is
learned either way.

~~~
roundsquare
"The same lesson is learned either way."

Not at all. Learning how to find the solutions to a problem is very different
from learning the solution to your specific issue. I'm not saying its always
worth your time, but there is a different lesson learned when you find the
solution yourself.

------
synnik
11\. Learn how the entire stack works. I see way too many people coding around
problems that could be solved at the server level, the network layer, etc.

------
stephen_dryden
Really good article, I agree with every point.

If I were to add to it I stress the importance of reading books by different
authors and publishers, even if they're about the same subject. This helps you
get a much wider, well-rounded view and it often improves the learning
experience.

~~~
vibrunazo
I agree, reading books of different perspectives is great.

I would also like to bring up the importance of reading "good practices" books
and articles. Learning not only how to write good code for yourself, but good
code for your colleagues to work with is an important skill to have. Writing
maintainable code is often not trivial. I recommend reading Effective Java by
Joshua Bloch.

------
Androsynth
-Build something that is bigger/more complex than your current skill level.

This will not only improve your skills in general, but learning from the
mistakes you make is probably the best way to grow as a programmer.

~~~
Androsynth
By the way, I can't recommend going out and reading massive textbooks. That
might be useful in a vacuum, but in reality you only have so much time.
Programming should always be number one on this list; followed by: -building
something completely different than your used to (either in scope, by
features, or by language) -looking at code from open source projects

The main thing: always challenge yourself. When your at the inflection point
of your learning curve, do something different. Expanding your boundaries will
not only help you learn different technologies, but it will give you a better
perspective on your actual specialties.

~~~
spacemanaki
Some things are better found in books though. I've been reading Lisp in Small
Pieces for a while now, and there's some great stuff buried in there. I don't
think I would have stumbled upon it just hacking away on toy Lisps on my own.

There might be other places to find some of these things, like other compiler
texts or the actual source of some Lisp compilers and runtimes, but books are
often laid out in a nice pedagogical way. Reading the SBCL or Racket source
would be a steep way to get to some of these ideas.

I would amend your recommendation to say, pick the massive textbooks you read
carefully. Don't suffer through big, poorly written books.

~~~
Androsynth
thats a good point.

------
highace
+1 for don't rush to StackOverflow!

You don't get better if you don't tax your brain a little, much like how you
don't get stronger if you use a winch or wheelbarrow to carry a load instead
of carrying it yourself.

~~~
Tashtego
I've been trying to get better at this myself. Although, you do feel foolish
when you bang your head against something for six hours, and then you get your
first (correct) answer on stack overflow five minutes after you post.

Still, if you're not feeling foolish often, you're not learning. Competence is
deadly that way.

~~~
wccrawford
Learning to find the answer yourself is -way- more helpful than having it
provided to you. Don't regret those 6 hours. It's a process.

~~~
highace
Agreed. Plus next time you won't have to go looking for it on Stack again
because it'll be ingrained, painfully, in your brain. And you'll probably
learn a whole lot of other things along the way too.

StackOverflow isn't a total no-no, just don't make it priority 1.

~~~
minikomi
Or, if it's important, go to stack but make a record of what it was... Then
try to do the same thing without looking a weekend down the line .. sometimes
things can't wait!

------
kenjackson
While people recommend reading code, like the Linux sources, I also find more
code focused sites like Code Project (www.codeproject.com) very useful. These
aren't blogs like Coding Horror, which are more "philosophy". These articles
on Code Project typically are explaining code in detail.

------
zwentz
I find that trying to ask my question at StackOverflow is the best way to
improve. Because I have to think about how best to word my problem, and really
make it clear and concise. And usually when I do that, I end up just solving
the problem on my own.

Of course, I see a lot of give me teh codez there, so I can see where the
author is coming from. Nevertheless, I find it to be a useful tool in helping
me become a better programmer.

~~~
antoarts
Good catch. This is similar to "rubber-duck debugging"
(<http://en.wikipedia.org/wiki/Rubber_duck_debugging>).

------
phereford
I got a "Database Connection Error" (I am sure your server got hit hard with
being top 5 on HN). :) The irony makes me giddy.

~~~
vimalg2
Obligatory Google Cache link:
[http://webcache.googleusercontent.com/search?rls=en&q=ca...](http://webcache.googleusercontent.com/search?rls=en&q=cache:http://www.antoarts.com/10-ways-
to-improve-your-programming-skills/)

------
joecasper
Really good article. Another way to improve your programming skills would be
to teach someone else. I find this to be one of the best ways to solidify your
understanding of something.

------
bajsejohannes
The article suggest reading code, which I agree is a good way to improve
programming skills. But I'm a bit unsure what to do with the advice to read
the linux source code. Where would you start? I find the only way to actually
get to reading code, is if you have a need to understand some part of it (e.g.
to fix a bug or add a feature).

So perhaps a more actionable proposal is to try to fix a bug, preferably one
you care about, in some open source project.

~~~
llimllib
I often go read code to figure out how somebody else does something I want to
do. Usually, somebody has solved your problem better than you have.

------
antoarts
For those of you who get a database error, I think it is the huge amount of
traffic I'm getting at the moment which causes this (>1000 visits last hour).
I'm using shared hosting, which might have problems with this, so in one way,
you are DDOSing my site ;-). I don't know if it is safe to tell you to just
wait and reload the page, but do that, BUT NOT TOO FAST!

~~~
tszming
Are you using any caching module, e.g. Hyper Cache for WP? If not, you should
give it a try.

~~~
antoarts
I started using one just recently. I'm not a web developer and I just
installed WordPress less than a month ago. Apparently, PHP scripts are heavy
to execute :S

It seems to work better now.

------
nu2ycombinator
What I observe so far is people who learn all kind of programming languages
will become very good programmers. And one who see language as a tool to solve
problem and applies it smartly will become millionaire providing food for
remaining good programmers.

------
blaaah
But how does one get ideas for a project? I started learning programming using
C++ about 5 months ago. I've been making good progress on learning the
concepts but I just can't think of anything useful to create.

~~~
chc
Do you do anything? Like, anything at all besides learn C++? Do you know
anyone else who does things? Think about what parts of those things are
suboptimal and create something to make it better.

For example, where I work, we get a lot of user-submitted content, but we
can't use all of it. So we need to filter. The lady who is primarily
responsible for this simply doesn't have the time to vet the massive number of
images she runs across to make sure they meet some basic criteria for size and
quality, so I wrote a program that mostly automates it.

~~~
blaaah
Well, I'm a college student, so no I don't do much else aside from learning
how to do stuff.

~~~
chc
I'm sure you study, research, write, socialize, etc. in addition to learning
C++. If not, I recommend starting. Those are all way more important than C++.

And like I said, it doesn't need to be _your_ pain that you're relieving. Look
at the people around you — even if you yourself are chained into your bed with
no hope of escape, I bet you know people who do things. You can help them do
those things.

For example, take a look at patio11 on this site. He's built a whole business
out of a simple tool he wrote in a few hours to help a teacher make bingo
cards for her students, because making bingo cards is such a soul-sucking
waste of time when humans do it. (To be clear, he's put a lot more time than
that into building the program and the business over the years. But it only
took a few hours of coding to solve the problem.)

~~~
blaaah
Ah, alright, I see what mean. So the general idea is to create something that
will help make other people's lives easier?

~~~
chc
Yeah. It's a good way to come up with a concrete idea, and it has the benefit
of, y'know, actually helping people. (And helping people sometimes has the
benefit of turning into paying work in the future.)

~~~
blaaah
Awesome. Thanks for all the insight! I appreciate it.

------
isomorph
I like how "Program" is all the way down at number 5

------
lhnz
1\. Learn paradigms, kinds of problems and computer science fundamentals.

2\. Work on poorly-run large projects with (a) performance problems or (b)
code organisation problems.

3\. Work on other projects with developers that use (1) to solve the problems
of (2). You'll be surprised how quickly you learn when you've seen the
benefits to be had by doing things better... ;)

------
shii
Reading and trying to work with the Linux kernel source is hardly a good way
to get better programming skills. It's really large and hard to understand.
Something like Minix, MenuetOS, or LoseThos is a much better alternative to
hack on. LoseThos particularly reminds me of old school hackable boxes like
the Commodore64.

------
pmr_
All of the advice given here is good and none of the tips here are going to
hurt you.

It's just another less abstract reiteration of a few truths that encompass
much more than programming.

Work with different tools. Think. Talk about what you do with other people. Do
all of it a lot.

~~~
secoif
i.e communicate, keep an open mind and challenge yourself

------
antoarts
I hope that I fixed the problem now by installing a plugin (QuickCache) which
caches pages and serves a normal, static HTML page when possible instead of
generating a new dynamically from the PHP scripts each time. I _hope_.

------
kvgr
8\. is very important. Once you decide to write article, you got to have solid
knowledge about the topic. You just can't write the code and see if it works
:) you got to know why and how!

------
Morendil
This is severely biased toward things that require no in-person interaction.

So I'll add two:

0\. talk to other programmers 11\. attend a Coding Dojo

------
jrockway
One way to improve your programming skills: stop reading programming blogs and
start programming.

~~~
secoif
Worst part of this is that you can end up sounding and feeling like you
are/could be a far better programmer than you actually are; you know all of
the ideals, philosophy and lingo about how to create clean, amazing code but
actually turning this into real programs that solve real problems in real
budget & time constraints is a very, very different thing.

------
coreyhaines
Also, spend time doing focused practices. Attend a coderetreat
(www.coderetreat.com)

------
ataranto
1\. Find something that you can't do. 2\. Do it. 3\. Repeat.

------
known
Debug other people's code.

