Stupid things I used to say

03. April 2014 Uncategorized 0

Back in the day (roughly 4 years ago) I was doing Windows development. That was all I had done for about a decade of my professional career. If you add in my coding back before I turned pro, it was all I had ever done for about 15-20 years. I knew, more or less, how to write software for a Windows machine, or at the very least, a desktop.  My languages of choice were C++ and C#. Both of those are compiled, static languages.

At the time I was working on an IT team with 3 other developers. They were all web developers doing ColdFusion. I knew next to nothing about ColdFusion (not much less than I know now.)  I was the only Windows developer so a lot of times I was an outsider looking in. I didn’t really get to participate in too many conversations, after all, my medium had built in state that they didn’t get to play with.

However, every once in a while, one of the developers would get desperate and ask me a question, or have me look at their code. Usually this was either really early in the morning or really late in the evening when I was the only other developer at the office and they were stuck.

I knew literally zero JavaScript. I’d heard of JavaScript, but that was about it. I kind of had an idea about what it did, or why you’d use it, but that was about it.  One of the times I looked at someone’s code it wasn’t working because of a simple typo. After that was fixed, the code took off and worked perfectly. I remember going back to my desk and thinking, possibly even muttering to myself, “Why would anyone write using a language that doesn’t even catch simple things like typos until you go hit the page?” The concept was just baffling to me. I knew that compiling my code was no guarantee of accurate development, and that even after compiling I still needed to test it. But it was nice to know that it at least passed the “compile” test.

Fast forward 4 years and I’m neck deep in JavaScript. I spend my entire day for the past 5 months doing nothing but writing JavaScript, and I’m really enjoying it. What I didn’t realize back then was you can’t judge a language purely by how you see it being used.  There are a lot of ways to make sure things like typos don’t mess up your code, even when you’re using a dynamic, and/or interpreted language. For example, we have tools like JSHint which allow you to define rules to verify that your code is written correctly. For example, you can define a rule that states if a variable isn’t defined then it should return an error. In this case, defining a variable and then typoing it when you go to use it, would trigger this error.

But JSHint wasn’t around back when this code was being written. However, other static analysis tools were (according to Wikipedia JSLint, ClosureCompiler were both around back then.)  But you don’t have to rely on a static analysis tool. Writing tests would also detect these issues much faster.  Without writing tests, you wind up spinning up your server, launching your browser and navigating to the page that has the error, and then doing any actions on that page as setup conditions to hit your code. With a test you can write a few lines of code that will execute the exact lines you need to. These tests can then detect errors, like typos, or bad assignments etc.

At my job this week I’ve written quite a bit of JavaScript, but I haven’t worried at all about missing a reference, or a typo or calling a function on a null object. We use a lot of tools to make sure the code is correctly written, and it’s not any slower than a compiler.

My ignorance of other languages and paradigms has made me say some things that looking back now were down right foolish. Sometimes a large group of people are misguided or stupid. However, that doesn’t mean it’s always the case. In my situation, it had more to do with the approach to coding (more like wild west, everything goes) than it was the language. I want to think that I’ve matured since then and would ask more questions when I don’t understand something, like why someone would choose a particular language.