Wednesday, October 7, 2015

How to start learning computer programming

People often ask me, "How should I start learning computer programming?" Specifically, what programming language should one start with?

Many programming languages are difficult to learn. C++ is a powerful and widely-used programming language, but I would seldom suggest that someone learn C++ first. Some do, and some do it well, but there are easier languages. Java is similarly difficult. Objective-C is a nightmare; I'm glad Apple replaced it with Swift, but don't let the name fool you ... you won't learn even Swift quickly unless you already know another programming language.


Also, people want to know whether they ought to take a formal class, try to learn from online tutorials, or just learn on their own. It depends a lot on the individual, but since we're talking about learning a first programming language never having learned about computers before, I'd always suggest taking the formal class, in person, with assignments and guidance, if possible. Don't try to learn from an online tutorial unless you already have a good grasp of your own computer, logic, and math. Even a little bit of database use or using Excel functions is great preparation for learning to program.

You might be interested in knowing what programming languages pay the best. While this is an interesting question, it doesn't really help you figure out what is the best way to start in the field. If programming in Objective-C or Ruby on Rails were easier, maybe the pay would not be so high. So learn an easier language first.

You may be interested in knowing which programming languages are used the most. Again, this may be a red herring. Some of these languages are used a lot because they hold monopolies over certain segments, not because they are easy to learn.

One thing people don't take into account when thinking about learning a programming language is that they will have to set up an environment in which to run the programs. If you want to learn Java, you'll need to set up Eclipse. If you want to learn PHP, you'll need to set up xAMP. If you want to learn C#, you'll need to install Visual Studio (Windows only). If you want to learn Swift, you'll need to install Xcode (Mac only). If you want to learn Ruby, you'll need to set up so much stuff I can't even begin to describe it.

So, when I give this advice, I think about how easy it is to install the tools, how easy it is to learn the language, what kind of college classes and/or online tutorials are available, and what kinds of interesting things you can do with the language from the very start. With those things in mind, there are only two languages that I suggest learning. After you have learned one of these two languages, learning another language will be easy.

1. JavaScript

The first thing one must always say about JavaScript is that it is not Java and has absolutely nothing to do with Java except an unfortunate similarity of names. JavaScript is an excellent language to start with because:

a. There is minimal setup. You need only two things to learn JavaScript: a text editor and a browser. Every modern computer comes with both of these things already installed. You may want to augment what came on your computer, however.

You'll want to use a real programmer's text editor. For Windows, we usually suggest NotePad++. For Mac, we suggest TextWrangler or TextMate. Brackets is another text editor available for most computers.

All computers come with a browser already installed. We usually try to steer Windows users away from Internet Explorer toward Firefox or Chrome for compatibility reasons. Internet Explorer does not comply with JavaScript standards as well as the other browsers. Mac users will be fine with Safari, but make sure to activate its developer mode in the preferences. It's a good idea to double-check your work on one of the other browsers too.

b. JavaScript uses standard syntax and is object-oriented, but not in an obtrusive way. JavaScript uses "curly brackets" like many other languages such as Java, PHP, C#, C++, and many others. The language has many object-oriented features, but it does not force you to use them all from the beginning.

c. You can do interesting things with JavaScript. In one day, I taught my high school students to make a web page, add color wells, and change colors throughout the page in response to clicking in the color wells.

2. Python

Python is an excellent language to start with because:

a. The setup is easy. You can install the Python compiler and it comes with a second program called IDLE, where you can type your code and interact with it.

b. The syntax is easy. Python does not use "curly bracket" syntax like many other languages do, but instead it relies on indenting to show the structure of your program. For many of us, indenting (like making an outline) is a natural way for us to visualize our programs anyway.

c. You can do fun things with Python. It comes with a graphics library that lets you draw shapes by moving a pen around the screen using x and y coordinates. So you can start using Python like an etch-a-sketch from the very first day of programming.

Well, that's my two cents regarding starting out. Let me know what you think.



No comments:

Post a Comment