Why Learn JavaScript over Python

JavaScript Logo

JavaScript Logo By Chris Williams [Public domain], via Wikimedia Commons

Last week, I talked about why Python was a better first language for a GIS professional to learn. Today, I’d like to flip that, and explain why JavaScript is a better first programming language for those in the GIS field. Have I had a change of heart? Not really, but keep reading. Let’s look at why JavaScript should be your first language.

It’s a relatively simple language

First off, how hard could a language that was designed in ten days? The language has all the basic data types you would need (string, numbers, true/false). There are only four complex data types(and some would argue three or two): arrays, objects, regular expressions, and functions. Almost every complex object you need could be built off of these simple and complex data types. And with few key words to memorize, it’s relatively easy to follow the logic of well written JavaScript*.

Python has a lot more data types, spread across multiple libraries. Python has many of the same basic data types, but they get a little more complicated. Strings can be of type str or unicode, while numbers can be expressed as integers, floating points, longs, and even imaginary numbers.

Python also has more complicated data types. Besides lists (equivalent to the JavaScript array), and dicts (equivalent to the JavaScript object), Python also has sets, frozen sets, and tuples, each with their own rules of use. I can’t tell you how many times I’ve wanted add an number to a tuple, and resorted to converting it to a list, appending the number, then converting it back to a tuple for the next calculation. And if you want to use regular expressions, well, there’s a whole separate library for that.

EDIT: * Okay, so JavaScript does have a few quirks… okay a lot. But they’re like Tribbles, you eventually grow to love them.. or offload them onto someone else.

All the Cool Kids Are Doing It

JavaScript is one of the hottest programming trends right now. There’s JavaScript on the server (in regular and extra bold flavor), JavaScript in robots, and even a JavaScript-based GIS is in the works. JavaScript has also given rise to a popular data format called JSON, which is short for JavaScript Object Notation.

Python, on the other hand, is much older. According to Wikipedia, Python first appeared in 1991. That’s older than Java and C#. While it is older, it is still in active development, primarily in the fields of data science and machine learning. Python does have a web server platform called Django. But as for its popularity, well… it’s not so much.

Django Search Results

Everybody Wants to Teach You JavaScript

It seems like every time I check my email, I find out about another website that wants to teach you JavaScript. Some do it through videos by industry leaders. Others teach through guided exercises. Still others test your debugging skills through multiple choice questions where you pick the correct output. Many also have larger-scale projects to help you practice your JavaScript coding craft.

As for Python, some of the JavaScript teaching sites I linked to above either teach you Python as well, or will in the near future. If you want to dig further into Python, however, you’re stuck with blogs from five years ago. Of course, there is the Python Challenge, which has been up since 2005, and maybe all the links still work. I vaguely remember having trouble with a few of the puzzles because of that.

Besides the proliferation of websites that teach you JavaScript, there are also websites that let store and publish code samples. Sites like JSFiddle, JSBin , and CodePen give you a sandbox where you can write HTML, CSS, and JavaScript and see the results. These “fiddles”, “bins”, or “pens” can then be saved to your account, and made publicly available through a unique URL. ESRI also offers its own sandbox application to test custom code through the ArcGIS JavaScript API.

Sharing What You Learn

Some people find their motivation keep up their education through socializing with other people. They are encouraged by their friends and peers when they share their work. The web makes it so easy to share what you know, and helps explain to people what you actually do. You can post code on your website, or use Github Pages or Neocities to share your web application examples for free.

With Python, its a lot harder to share what you’ve learned. Sure, you can post your code in a discussion group, push it to Github, or paste it into an answer on Stackoverflow. But unless you’ve written some amazing reusable plugin or utility, you’re not going to get an “Oooh and Aaaah” response from anyone who peruses your code. It’s just not that interactive.

The Browser as a Tool

I’ve worked with some organizations with very strict security policies. You have to jump through hoops, make this request to your server admin and that request to your network admin, just to install some software to let it run. Sometimes, you even have to sweeten the deal with some candy bars or a giant container of pretzels.

Image: giant container of pretzels

With three more of these, I can bribe our network admin into opening up port 6080 to outbound traffic.

But in all of these computers, no matter how locked down and secure, I’ve seen a place where I can practice programming JavaScript. Also, in almost every internet-connectable laptop running in the world today, from the 32-core powerhouse to the old, out-of-date desktop still running Windows XP, there’s a JavaScript interpreter ready to run some code for you.

I’m talking about the browser console. Every modern browser has some sort of JavaScript console that can be used to debug websites. The console also offers you a place to practice your JavaScript coding skills for free, one line at a time. You can run code one line at a time, and get instantaneous feedback from the browser. With Python, you can do the same with IDLE, but you still have to download and install it.


Unlike Python, which was designed with simplicity and ease of reading in mind, JavaScript focuses on being shared. Code for each website isn’t hidden in some compiled library, but available for anyone to read. People and organizations make code libraries freely available through open source. By cobbling together some of these libraries, and adding our own touches, we can learn to create some pretty creative websites and web-based mapping applications.

And as for why I flip-flopped between supporting Python and supporting JavaScript, the answer is simple. You know what motivates you best. You know whether you need to write simple scripts to build your confidence, or if you need social feedback from friends and peers to keep you motivated. So, go find a project to conquer, a learning resource, and go out and code.

2 Responses to “Why Learn JavaScript over Python

  • I like the way you looked at both sides of the coin. i started with Ruby, but moved to JS just because of JSFiddle and Codepen. I hated the semicolons and syntax at first, but chose JS cos it’s everywhere.

  • Thanks. After a while, you get used to the semicolons, or you go to CoffeeScript. We’ll pick up more and more languages the longer we stay in this field.

Leave a Reply

Your email address will not be published.