Sunday, July 12, 2015

3 ways to write code, which one should a "noob" pick?

There are basically in my opinion 3 ways to write code:

  • Bare Metal programming
  • Traditional programming
  • Easy-Lazy programming

Talk to an old programmer with a beard using Linux and he will talk about why all young coders really can't code and are really just "script kiddies".  

These programmers typically tell coding "noobs" to learn how to program using only “bare metal” programming.  "bare metal" coding is basically never using built in methods of the programming language.  A strict "bare metal" coder typically will try and only use if statements and loops to solve any and all coding challenges.  They prefer to write all of their own methods, and scoff at people who use built in methods.  The upside of learning to code this way is that you really can code, and don’t need to rely on any language's built in methods, you simply do it all yourself.  

The downsides of writing code using the "bare metal" coding method are many.  Writing code will be far more complex and with a much higher chance for overall “bugginess”.  Learning to code this way will also take much longer for a beginner to learn.

The traditional programmer will use a combination of “built in” methods and some of the “bare metal” style of coding to write code that gets the job done.  There is nothing really wrong with writing code like this, in fact it's very popular and is a fairly good happy medium.  Use the tools of the language whenever possible, and only write your own methods when you can't find a built in method.

The “Easy Lazy programmer” NEVER writes their own methods unless they absolutely have to.  When confronted with a coding challenge they will ALWAYS FIRST look to see if the language has a built in method to use.  If they can’t find a built in method in the language, they will look at using a library.  For example if we use the Javascript programming language as an example, we would look through the 4 most popular Javascript Libraries starting with:

‘jQuery’ jQuery Library
‘Underscore’ Underscore Library
‘lodash’ lodash Library
‘Ramda’ Ramda Library

If after looking through those libraries there wasn’t a method you could use to solve the coding problem, then and only THEN would the Easy-Lazy programmer write their own method to solve the problem.  The cons of writing code this way are that some coders will say that you can’t really code because you rely on as many of the helper methods as possible, and don’t write all of your code from scratch.

The upsides of writing your code the Easy-Lazy way are many:  Employers love it, as they want a code base that is less complex so that any programmer coming in behind you will be able to easily understand what the code is doing.  The Easy-Lazy method of writing code is much faster, cleaner,  requires less code, which makes for less complexity and overall easier to understand what the code is doing.

I see the value in “bare metal” coding, lots of older senior coders write code this way, BUT as a beginner learning how to code and solve coding challenges, you shouldn’t try to invent the wheel.  Try to solve the coding problem in the easiest, most tried and true way first.  Once you get better at basic coding, do more "bare metal" programming in your free time.  

I will say that using a Library does make the code run a little slower, I think most companies are fine with this, but I'm sure that in some cases you would want to avoid using libraries do to slowness.  The above is what I recommend for absolute beginners learning how to code.  This is not a blanket statement for never improving your own personal coding abilities.

Keep coding peeps!