But enough about you…

a writer's blog

Archive for September, 2020

So you want to learn to program

without comments

So, you want to learn a programming language. Most likely, you want to know how to get a nice, solid tech job that isn’t going to just disappear in the next wave of industry changes. How do you get there?

It makes a big difference whether or not you already code in any other programming language. If you don’t program at all, I would recommend that you start by learning Javascript. There are a thousand online resources for learning it, and you can get the instant satisfaction of seeing how it works right there, using technology we all have, in any web browser. Javascript will teach you basic program structure and all the different flow-of-control mechanisms, like if/else/endif, different kinds of loops, case conditions, and all that stuff.

Javascript will also get you familiar with the fact that in today’s programming world, you rarely get to live entirely in your language of choice. Javascript is typically embedded in HTML, and very often is used to generate HTML, as well as dynamically creating stylesheets in CSS, or generating and running SQL statements against data sources. You’ll want to learn a language that plays well with other languages, and Javascript does that as well as or better than anything. On my last contract I wrote a Javascript system using NodeJS that read Cobol programs and translated them to Python. This is typical of anything you’d want to do that rises to the level of being more than a toy. So make note: learning one language is where you need to start, but that one language is not going to make your career.

Once you have a bit of Javascript under your belt you’ll have a sense of whether you want to dig deeper. You could then learn Node JS, which is an excellent, enterprise strength version of Javascript that runs on a server instead of in a client – a web browser is a ‘client’; a ‘server’ is something like your own machine, or a remote Linux box that hosts a database, and that ‘serves’ pages to your browser. The great thing about Javascript is that it will run on virtually any machine, will function as – or with- a server system, and will function as – or with – a client. Even a tiny bit of Javascript knowledge will let you do something useful, and if you find yourself ready for the deep end, there is almost no limit to what you can accomplish with Javascript, up to and including enterprise level product development.

Utility languages

Any professional programmer worth her salt will have the language they’re working in for their client, their employer or their product – it might be Swift, it might be Java, Cobol, C# – it might be any of a host of things. They will also have a “utility” language. This will typically be a language that they can execute on their own local machine at the command line, a language in which they can read files off the hard drive and write some translated version of the file back to a hard drive. Your utility language is your go-to language when you’re supposed to be a PHP programmer (for instance) but the client hits you with some old version of a spreadsheet that nobody can open – you need to read it as raw lines of text, parse out the interesting stuff and throw away the old formatting and give the client back something they can read. You turn to your utility language for these things. Popular utility languages are Perl, Python, Javascript, C, Linux scripting language, Windows scripting language… your utility language might well be the language you use to earn your daily baguette, but it might not be. The important thing about your utility language is that you need it to always be close at hand, so it should be something that you can run on your own machine but can also install easily on a client machine, so no matter where you are, you’re never without it. This is another factor in favor of Javascript: combined with NodeJS it makes an excellent utility language.

Bi-Lingual by default

So let’s say you’ve got one utility language under your belt; you can either start to pick up a second language, just to get a feel for how different some of them are – in which case I’d strongly recommend Python, because there’s an excellent job market for Python. But there are also excellent job markets for C#, Swift, PHP, Perl, R, Go, Java and hundreds of others. In the end it won’t matter which you choose because you can do interesting programming on anything: But I started this post as an answer to a question on a Swift / IOS forum, so everyone there buys into, to some extent, the Apple ecosystem. Swift is an excellent language, and it has the added benefit of being one of the many languages that is converging on roughly the same syntax – C# is so similar that if you know one language you pretty much know the other!.

If there’s a negative side to Swift it’s this: Apple doesn’t really give a rat’s asset about backward compatibility. As I write this paragraph, in the closing days of 2020, I have a pretty complex Swift project open in XCode. In the couple months I’ve been working on it, I’ve seen the language change twice to the extent that I needed to change how a closure is implemented, and I’ve seen the need to remove some ‘self.’ references that had been required just weeks earlier. For backward compatibility you might want to look at C or C# – Microsoft, because it’s the bastion of big, necessarily conservative development shops, was still supporting code that ran on operating systems at the dawn of the internet, back in the early 1990s. So, for stability, think Microsoft, IBM, C, C#, PHP, Perl. For cutting edge, functional programming and beyond, think Apple, Swift, Go, R, Python, etc.

As you progress in your learning, you will need to absorb the concepts of Object Oriented programming (OO) because it underpins so much of what’s out there in the world. OO tends to follow a programming model called Model-View-Controller (MVC). BUT, you should not dive too deep on OO programming but learn instead Functional Programming (FP) which tends to follow a model called Model-View-View-Model (MVVM). You’ll want to learn what these models are and what they each have to offer.

Functional programming lets you step over a lot of historical detritus and get right into the kind of programming that will probably dominate for the next decade or more. Swift is an excellent language to concentrate on once you have some basics under your belt, and the course you’ll want to take is CS193P at Stanford University. It is available for free on YouTube, and you can start watching online. Most other online resources for Swift are slightly or badly out of date, but the Stanford course is nearly up-to-the-minute (as I write this, in late 2020). Accept nothing less, but take this one: https://cs193p.sites.stanford.edu/

Moving beyond ‘mere’ programming languages and getting into the whole world of things that you’ll need to work in the profession, you should be aware of GIT, and other code-management tools, you should try a variety of integrated development environments, IDEs, which offer code-completion, debugging features, and more. Use XCode for Swift development, but check out Eclipse and Visual Studio Code. All these are free, and there’s not reason not to try them all. Investigate Jupyter Notebook (especially if you’re moving into Python, R, Go or Julia…) Jupyter provides not just an IDE, but a whole new paradigm of partial and shared program compilations and data analysis.

It’s a big, rich tech world out there, and the important thing when you’re starting out is to pick the place where you’re going to dive in, and to dive deep. Stay focused, while also being aware of the complexity that surrounds you. Learning to program is like planting a tree – the best time to do it was 6 or 8 years ago. The second best time to do it, is now.

Just read a related post on Medium, by Quncy Larson. Really well done and funnier than my article, and he also comes down on the side of Javascript. Definitely worth a read.

Written by Alan

September 10th, 2020 at 4:05 pm

Posted in Writing