Why Learn to Code?

By now, you have heard that you should learn to code. Politicians, celebrities and others are advising you to learn how to code. With coding bootcamps like Free Code Camp, coding schools and organizations like Girl Develop It and online tutorials, you can easily learn code.

Learn to Code

Why should you learn to code? There are good reasons and bad reasons for doing it.

Bad Reasons for learning to code

  • You’ll make lots of money as a software programmer. Software programmers with years of experience and skills that are in high demand can get a good salary. It also depends on the industry. Non-profits and schools don’t pay as much as a software company would. If you are starting out as a programmer, you will be paid a beginner’s salary.
  • You’ll become a millionaire. For every great idea that succeeds, there are many that fail. Not everyone will want or even need your software idea. Being able to code won’t guarantee that your idea is what people will pay for.
  • Someone told you to It isn’t always a good idea to do something because someone told you to.

Good Reasons to learn to code

  • You enjoy solving with problems. When you write code, you need to be able to break a problem apart, decide what steps are require to solve and write code that solves the problem. If you don’t enjoy solving problems or figuring out puzzles, coding won’t be interesting or even fun.
  • You enjoy building new things. Building or creating things is a messy process. Sometimes it takes several versions or attempts to get the end result that you want. To write code, you have to enjoy this process and be persistent.
  • You enjoy learning new things. As a coder, you have to be a learner. Every day, there is some new technology, technique or requirement that you need to learn about. If you don’t like learning or trying out new things, than you won’t like coding.

What kind of knowledge do you want to gain from learning to code?

You can approach coding in two ways: Theory and Practical Knowledge. What do I mean by Theory? Theory means learning the basics of coding. It includes that history of programming, what does a coder (programmer) does and how do they start with idea and end up with a finished product. You’ll better understand how technology works and why they work they way they do.

Practical Knowledge includes theory. You learn how to use code to solve problems, program and build software and apps. It is a deep dive into the theory, techniques, tools and chosen languages. You learn how computers work, why you need to write code a certain way and how to take an idea from design to finished product.

How can you tell the difference? Michelle, Marktime Media, has a great example of theory vs practical knowledge. In her article about Should I Learn to Code, she talks about the difference between car ownership and car enthusiast. Car owners need to know how to drive a car and minimal maintenance. A car enthusiast knows more about cars than the average car owner. They are interested in learning everything they can about cars. Some enthusiasts can even design or build a car from scratch. Most car owners don’t want to do that. They learn just enough to drive and maintain their car.

What does this mean for you?

You have to decide what you want to do with coding. Are you going to learn theory or practical knowledge? Learn enough about coding to understand how it is done, what is involved in coding and using that knowledge to better understand the technology that you use on a daily basis. Or become a coding enthusiast. Learn how to code, solve problems and build great things.

If you are still considering learning to code and haven’t decided. Jeff Atwood of Coding Horror explains why you shouldn’t learn to code.

How to Style Your Code Snippets

When you write a blog post and need to add code snippets, they should stand out. You have two choices: use a Syntax Highlighter or style the code yourself.

Syntax Highlighter

A Syntax Highlighter is a tool styles the code snippet for you. You can use one of the following tools to style the syntax.

  • Prettify, a Javascript solution the highlights source code syntax.
  • Snippet, a jQuery Syntax Highlighter.
  • SyntaxHighlighter another Javascript Syntax Highlighter tool.
  • Prism, lightweight syntax highlighter that works with HTML5.

Style Your Code Snippets Yourself

If you want to handle the styling yourself, you’ll need to use HTML and CSS. You need to useĀ  HTML tags like <pre> and <code>. For extra styling, you can place your code inside a div tag.

Write the HTML

  1. Wrap the code snippet in a div tag like <div id=”codeSnippet”>
  2. Add your code snippet between the <pre> and <code> tags. The pre tag displays the text exactly as type preserving spaces and tabs.

<div id="codeSnippet">
<pre><code><script type="text/javascript">
$(document).ready(function() {
fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...

Write the CSS

In your CSS, add styles for pre, code, div and anything else that you need. In the following example, I created a style that mimics an old DOS computer screen. I used pre, code, a div and a class to achieve that look. Here is the simple CSS:

/* Code Styles */
pre {
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;}

code {
font-family: Courier, 'New Courier', monospace;
font-size: 12px;}

#codeStyler {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
margin: 1em 0;}

.computerGreen {
background-color: #000000;
color: green;}

When you view at your results in a browser, you get a code snippet that looks like this:CSS Code SnippetLine numbers can help to make the snippet more readable. If you want to add additional style to your numbers, try Styling ordered list numbers.