Web Dev – WhatDuh-Script?

WhatDuh-Script

WhatDuh-Script, sure I’m new, but I didn’t realize there were different levels of Javascript.

WhatDuh-Script PredatorIn a nutshell, Javscript is not alone. It is being hunted and the predator is WhatDuh-Script. Just like in the film, there was a lone predator hunting after the humans, (Javascript) but what the humans didn’t realize is that it was actually surrounded by many more invisible predators. All watching the battle. Waiting for the hunt to be killed. And in this case, waiting for Javascript to become obsolete. However, in these past few years, I do have to give it up for Javascript… it’s stayed strong and relevant and if anything, it’s starting to improve to the point where Javascript can be used not only for front end development, but also back end as well! For server-side web development, there is a multitude of languages and frameworks, but for client-side programming Javascript is really the only language that is supported by all of the common browsers. With the jQuery framework that works hand in hand with Javascript, it’s now gotten more broad and comprehensive, but that also means that there are a crap ton of “gotchas! I’m here now!” functionality.

Javascript Backend

CoffeeScript. Meant to be a play on word for “Java” which is the fancy term for coffee. And thinking that through, coffeescript is javascript in a simple way. It’s described as a “one-to-one” into javascript, so it does not need interpretation allowing it to run seamlessly, readable, and quick. Below is an image for a comparison between the two. CoffeeScript on the left, and normal Javascript on the right. Part of the WhatDuh-Script family, it’s a separate language that is just converted back into Javascript before being sent and read by the browser. Two of the most common options are CoffeeScript and TypeScript, however they both serve slightly different purposes. CoffeeScript, which is similar to Javascript is actually vastly different, and the reason it was so widely used then was because it offered simplistic and intuitive function and coding. There are some annoyances and features that I couldn’t really understand when I played around with it a little bit such as indentation/blank spaces as blocks. Semicolons are optional (which I don’t really like as much, harder to troubleshoot), function parentheses are optional, and operators are nicely compiled. Unfortunately, CoffeeScript syntax is pretty different so conversion can take some effort.

WhatDuh-Script WhatDuh-ScriptWhatDuh-Script WhatDuh-Script

Something in Javascript, as well as in Java is the idea of of using the “this” object, within another “self” object to indicate the current variable. I realize that was probably confused, but how “this” is used to refer to other variables within the local environment.

WhatDuh-Script Coffee

Truthfully, I researched into CoffeeScript and TypeScript… and I really don’t know if I would be using it much. It seems to have aged past its prime when it was widespreadly popular back in 2012, but has since helped to spur the current javascript ecosystem, which has been a fortunate side effect.  Now it seems that ECMAScript and Babel are the tools of the choice, but even then Javascript is just the basic choice, it’s commonly taught and easy to learn because of its C-Style syntax.

https://babeljs.io/

On the other hand, TypeScript! Another transpiler has been gaining ground these past few years as CoffeeScript has been slowing down in popularity now that Javascript has been making up for lost ground in functionality and ease of use. A newer transpiler in the javascrip/web dev world, it is actually written by Microsoft meant to be used with Visual Studio and help with on-the-fly compiler errors.

TypeScript is super set of JavaScript. You can take valid JavaScript code and use it as TypeScript without any change. You can think of TypeScript as JavaScript 2.0 that supports JavaScript 1.0. That makes transition and converting existing JavaScript code TypeScript very easy.

CoffeeScript is entirely different language than JavaScript. Converting existing JavaScript code to CoffeeScript is not straightforward, but CoffeeScript brings far more advanced language features in to the table.

Source

In a sense, TypeScript is similar to Sass in that it is still Javascript syntax, but all you’re really doing is adding additional TypeScript functionality and features. There’s a very easy conversion step, because it’s already mostly TypeScript <-> Javascript! Overall, TypeScript provides a way to generate better JavaScript such as the same syntax with additional features. The compiler is a program that takes it in, and can output the necessary .js file! And you can choose an ES5 or ES6 output!

Overall, although CoffeeScript has seen its prime and is a bit more aged with slowed updates (found out recently that it’s been kind of neglected), they could both be used for a project. However, similar to any preprocessors it’s only as useful if the group, or the user, or the client has the ability to render and utilize the transpiler. They provide developers an easier way to write more readable and manageable code (depending on the transpiler). CoffeeScript comes from the Ruby/Python syntactical background, while TypeScript, part of Microsoft is much more similar to C# in style. TypeScript does provide more “sweeteners” but takes away some of the dynamism. In addition, it also supports ECMA Script 6 which is the leading Javascript standard. In the end, there are many options that just make you go all “whatduh-script” do I use? It’s up to you! But there’s nothing wrong with just plain Javascript anymore! However, if you just want to be basic and stick to a language with a large population base, as opposed to a subset, ES6/Javascript is an amazing way to go! Although ES6 isn’t fully supported yet by older browsers, Babel can be used to translate the ES6 file into ES5!

 

whatduh-script

Use TypeScript if: Better support, and more similar syntax with JavaScript. If you want a short learning curve, or there is a need to migrate legacy code, however since the syntax is basically the same, there’s no problem. More robust and allows flexibility to maintain and write client side code, in the same form as server side code. If you’re familiar with OO Programming, this will be your thing due to being part of the Microsoft Visual Studio program, though it is a separate compiler and program. Type based, so if you don’t like it, go with Coffee. Supposed to lead to fewer bugs due to compile-time type checking.

Use CoffeeScript if: Better and more concise code with syntactic sugar. Because of the blank space delineation, it might be a better fit if you’re coming from Ruby or even Python. Due to brevity, supposed to reveal bugs more easily.

Article by Sir. Lappleton III

I'm a happy-go-lucky college student that started a blog as a way to not only document my education and my experiences, but also to share it with whoever stumbles upon my site! Hopefully I can keep you guys entertained as well as learn about a few things from IT as well as from my time and experiences as I plunge deeper and deeper into healthcare! A couple of my areas of focus is data management, system security (cyber security), as well as information technology policy.