Expanding Programming Horizons with JavaScript

18 Jan 2017

Learning JavaScript

The computer science curriculum starts a student off with a popular high level language, typically on the lines of Java and Python. Then, as that student continues down this academic road, they find themselves delving into lower level languages, even to the point of using something as low as DLX, with the direct manipulation of registers and memory.

I had used JavaScript before, but I had a very surface level understanding of how it worked in regard to its syntax. Now after learning JavaScript and having played around with it, it certainly is a language that is very easy to pick up, especially if you have prior experience in programming. All of the fundamental programming language characteristics are here, from variable declarations, flavors of loops, and object oriented features; all wrapped together in a simple and eloquent language. Essentially, on the surface, this language bears resemblance to its sibling language, Java, but perhaps even more cleaner looking.

One of the aspect of JavaScript that really caught my attention was the declaration of variables; namely the removal of seperate primative types in favor for a universal “primative”. If one were to take a coding tutorial for JavaScript, you would be working around with the single “var” primative keyword rather than the standard primatives and even data types such as arrays and lists. While “var” is a viable declaration keyword, it is good practice to use keywords “let” and “const”. Unlike “var”, these keywords incorporate scope into their declaration of the variable.

For example:

function varExample() {
  var thing = "this is a var!";
}

console.log(thing);// prints out correctly
function letExample() {
  let thing = "this is a let!";
}

console.log(thing); // will not work, thing is in different block

As one could see, the main difference between these two keywords is the accounting of scope. Using “let” is a much safer keyword to use in this regard, as scope will be retain and one will not accidentally tamper with a variable that they are not suppose to. The “const” keyword works in the same vein as “let” which is block scoped, but unlike “let”, variables declared using “const” are not changeable during the runtime of the code.

This characteristic of this language makes programming in it less about the syntax and more about what is actually being programmed. While it is too early to have an opinion on the runtime efficiency of the languange, I can say that programming in it should be a rather simple experience as one can write elegant readable code quickly in a web page or web application. However, considering that most if not all major web pages use JavaScript, runtime efficiency must at least be adequate.

Learning Like an Athelete

While I have been learning how to program for some time now in my academic career, I have never really been aware of the style of learning and practice that I have been using. Only recently had I been introduced to “Athletic Software Engineering”. In this style of learning one trains themself like an athlete, using “Workouts of the Day” or WODS as a means of practice. This is like how a runner takes laps or how a football player practices throws. For us programmers and computer scientists , its a matter of fingers on the keyboard.

WOD are Those?

WODS are small programming exercises that can be completed in a short amount of time. Depending on the time you completed, you will be given a different rating. The shorter the amount of time that you take on the problem, the better the rating will be. For example, the second WOD was to sum every even value in a fibbonacci sequence which has 1 and 2 as its first and second values respectfully. While this is not a problem that requires a large amount of code, it is one that requires some creativity and thinking. I was able to solve this problem on my first try at 7 minutes and 52 seconds which put me at the “Advanced” rating, which is not too shabby if I do say so myself. If one would find themselves disappointed in their rating, then they can try again from scratch to achieve a better timing. Though, one should not be too quick to go and look up solutions. The understanding the problem yourself is just as, if not more important that simply finishing quickly.

WODS and Athletic Software Engineering offer a very structured method of learning. The fact that these exercieses are times not only gives a quantifiable measure of one’s proficiency, but one feels under pressure when solving thiese problems. Something that most assignments don’t provide. I think of it as a way of pushing oneself to their limit, testing one’s nerves and critical thinking under a high pressure scenario. I am already impressed with this type of learning style and will continue to use this as a regiment. After all, practice does make perfect.