Tech Talk

Share |
E-Mail ArticleE-Mail Article Printer-FriendlyPrinter-Friendly

Living in the JS World

Columnist: Mike E. Duffy
August, 2018 Issue
Columnist

Mike E. Duffy
All articles by columnist

chat18.webcam

It’s August, and there’s nothing new in tech. Lots of concern over privacy and security: not new. Facebook and Google know too much about us: not new. Smartphones are the dominant lifeform in the universe: not new. Small businesses (for good reasons) are reluctant to embrace new technology: not new. Life may seem boring for a tech columnist.

But I have a new job. I’m working as a senior software developer for KIXEYE, a maker of mobile games like War Commander and Battle Pirates. These games are designed to play on your phone or tablet for five to 15 minutes at a time. They’re also free, which means that KIXEYE makes its money by enticing players to purchase extra features which speed up gameplay (like reducing the time to build things) or customize their experience (like one-of-a-kind items).

Since smartphones are ubiquitous, it seemed like a good idea to jump on the bandwagon, career-wise. I’m also getting to learn some new technology, which is key to remaining relevant as a software developer.

You may have heard of JavaScript (JS)—a programming language, which was originally developed to make it possible to program the Netscape browser (Netscape was the first commercially-available web browser). That was in 1995. Before that, web pages were limited to displaying just text and images. The only interactivity was clicking on a link to display a new page with different text and images. Making the browser capable of running programs written in JS was a big step forward and eventually led to the vibrant web applications we use today.

As you might also know, web applications—from Amazon’s online store to Google Mail—exist both in your browser and on a server somewhere in a data center, talking back and forth over your Internet connection. In the old days, the server side of a web app was written in a traditional programming language like C, PHP, or Perl. That meant companies needed both JS programmers and non-JS programmers, which means hiring and supporting the needs of two different kinds of developers. Netscape realized this early on, and offered JS-based programming on their web servers. But the open-source web server Apache became the dominant web server, and writing Apache server programs meant using Perl or PHP.

There were a number of attempts to bring JavaScript to the server side, and one finally caught hold. It’s known as node.js, and was originally released in 2009. But web servers using node are still a tiny fraction of all web servers (less than one percent). Still, it’s a popular choice for new web services.

JS and node.js are the environment I work in at KIXEYE, helping to build the server-side part of our games. While I’ve done some basic browser-side JS programming over the past two decades, I’m now fully immersed in the JS world. Fortunately, I have 40 years of programming experience, during which time I’ve worked extensively in C, Perl, Python, and C++ (along with that smidgen of JS), so learning another programming language isn’t bothersome. It’s mostly a matter of learning how to express familiar concepts with a new vocabulary.

One of the goals with any computer program, regardless of language, is reliability. When the server side of a web application doesn’t work right, lots of people are affected. Writing reliable code of any type is easier when you work in a language that helps you avoid mistakes. One of the ways a programming language does that is by making sure you have the right number of things to work with, and that each thing is of the expected type. This is called “strong typing.”

For example, if you write code to add two numbers and return the result, using a language, which makes sure that you have exactly two things to work with (not one, not three) and that they’re both numbers (not text or some other type of object) means it will catch errors. It also makes sure that, if you said you were going to return a result, that there is a result, and that it’s a number. In a large program with many various functions (like our hypothetical addition function), these cross-checks are a huge help to a fallible human programmer.

Unfortunately, JS (like Python, but unlike C) does not have these checks: JS is “weakly-typed.” It causes problems for programmers when writing large programs in JS such as our KIXEYE game server code. Fortunately, Microsoft wrote a program called TypeScript, which allows adding “type” specifications to your JavaScript code. It adds extra time to development, but it greatly lessens the chance of making a type-related mistake. For me, it’s just another part of the learning process.

So these days, I’m becoming a JavaScript expert and a TypeScript expert. It’s fun, and it’s anything but boring.



 

In this Issue

First Street Napa

A number of new businesses opened in First Street Napa this fall, boosting pedestrian traffic downtown and tax revenue for the City of Napa. The recent arrivals included lululemon, Maker’s Marke...

Business As Usual

One year after the Wine Country wildfires, both Sonoma and Napa are still suffering afterburn when it comes to tourism. The old adage is that “perception is reality,” and that is keeping ...

Age Friendly Cities

Marin and Sonoma counties have official Age-Friendly status, and Live Healthy, an initiative of Napa County’s Livable Communities, is incorporating the same elements to develop new strategies fo...

See all...