Thursday, December 19, 2013

Should I Learn Google Dart As A First Language?: Swallowing The JavaScript Pill

Let’s get this out of the way. I’m an indecisive person. I’m the guy that’ll be in store looking at 2-10 different bottles of sunblock for an hour while one of my best friends is standing there with his hand freezing because he got a gallon of milk (thanks Kyle for always putting up with me!!!). All the while thinking this would have been much easier if I had only done the 2-4 weeks of research I usually do before buying a product (not joking).

Knowing the above, the world of programming is my own little level of Dante’s Inferno. So many choices from languages to frameworks. I went to a coding bootcamp and I took a very shallow dive into several languages, now it’s time to take a deep dive into a stack (frontend and backend). This came down to JavaScript, JavaScript/Python, or Google’s new language Dart.

It has been utter turmoil for me the past few weeks as I took a shallow look at these languages. The real decision was between JavaScript and its new competitor Dart. I’m a calculated risk type of guy and Dart is definitely a high risk / high reward scenario for Google, but what about the common man? This is where practicality wins out. I’m going to be learning JavaScript, for how long? Until I make something presentable for a project!! So months at least.

There are a lot of reasons to pick JavaScript over Dart, but the main reason for me, legacy code (ewww). Like it or not most of the web has some sort of JavaScript in it and it’s still worth learning now even as Ecmascript 6 is soon to be released, and all the frameworks that came out in the past few years are gaining traction. While learning Dart is something I still plan to do it isn’t worth being the first language I take a deep dive into because when I look for a position as a programmer I will most likely still need to deal with JavaScript code and it will be expected that I know it.

So for all the new programmers out there trying to make this decision I hope you found this helpful. I only stated one reason to learn JavaScript, but I think it’s the most important one when picking a first language. A language you will have to deal with anyways. Right now choosing to not learn JavaScript is like choosing to not learn HTML/CSS.

What Is Eloquent Code?

This post explains what is eloquent code to me and why. Note that I am still within my first year of learning to code when writing this so take it with a mountain of salt.

Before learning how to program I kept hearing about the concept of eloquent code.The word eloquent by itself vague so understandably it will mean different things to different people. Most commonly, it can mean readability, maintainability, pretty (aka syntactic sugar), well commented, efficiency (code that executes a function the fastest),  or having the least lines possible to run a program.

During my bootcamp the class had algorithms to solve and we would present our answers. This gave us a chance to see how each person thinks, represented by their code. When comparing my answers to others I noticed mine was simple and straightforward, maybe that’s because I’m simple minded. I have a tendency to minimize the amount of methods already available within the language, didn’t include regex (regular expressions), and didn’t get fancy with manipulating attributes, though I understand these are needed to complete certain tasks more efficiently (time to code and runtime).

My concept of eloquent code derives from understandability. It is as follows understandable->readable->well structured->maintainable.

  • Understandable code is:
    • Readable: A person should be able to look at the code and understand what is trying to be accomplished. Preferably, this is by reading the actual code instead of just the comments.
      • Well Structured: To obtain readability overtime the code base must be well organized. This means a person can find what they are looking for within a code base.
        • Maintainable: Because the code base is readable and well structured it is going to be more maintainable (updating/editing current code base).

Well, that wasn’t vague at all (/sarcasm). This is my general concept of eloquent code. What it means to be understandable and its derivatives will be up to each person and company to define. Just make sure to document so people don’t forget.

There are definite limitations to this concept. For instance, maintaining legacy code millions of lines long. This concept will only work when starting out or if the person/company have the ability to re-write the entire code base.

A friend once told me great code will look like only one person has written it, no matter how many people collaborated. There’s a lot of information in that one statement, and hopefully I unpacked it well in this post.