Skip to main content

JavaScript Rocks

Here's a bold statement... (so I made the font bold)
JavaScript is the best programming language


Here's why...

  1. The language is extremely powerful.  Let's imagine that we are inventing a new programming language.  The most important thing we will focus on is "power."  That means... write more elegant, more flexible, more readable programs... and write them even faster.
    1. Closures.  A completely awesome, overlooked feature of JavaScript that we all (hopefully) take for granted.  Closures allow you to create a new instance of a function which retains access to the context in which it was created.  Examples are here: http://en.wikipedia.org/wiki/Closure_(computer_science).
    2. Dynamic data types.  JavaScript variables aren't restricted to any particular datatype.  Store a String, store a number, or store an Object.  JavaScript automatically casts datatypes back and forth as needed.
    3. Objects are basically associative arrays, and vice-versa.  Everyone loves associative arrays.  The end.
    4. First-class and higher-order functions.  Variables can store functions.  You can pass functions as arguments to another function.  A function can return another function.  Functions in JavaScript can have an unlimited number of arguments.  Anonymous functions?  No problem.  Functions in JavaScript are just awesome!
    5. OOP is easy.  Objects are made up of properties.  There is no distinction between properties and methods because functions are handled the same way as other datatypes.  JavaScript supports inheritance.  Constructors are just functions that are invoked using the new operator.
    6. JavaScript is prototype-based.  Object oriented code is awesome (reduce coupling, encourage encapsulation, code re-use, etc).  But, classes aren't the answer.  Classes are too strict, resulting in strictly defined Objects, each with fixed properties and methods.  With prototype-based OOP, you design Object prototypes (i.e classes) that can evolve throughout the lifetime of the program.  Adding a new method to all instances of an Object can be done very efficiently at run-time with one line of code.
    7. JSON is a subset of the object literal notation of JavaScript.  Use eval() on a JSON string and you successfully implemented Object deserialization - although in practice you would actually use JSON.parse().  Still... awesome!
    8. No concurrency headaches!  That's right -- JavaScript is single-threaded.  There is an event loop (hidden from view) and there are events and event handlers.  Start an I/O operation with function call.  When the I/O operation completes, an event handler function is called.  Piece of cake!  You don't need concurrency -- a single-core CPU only has a single thread anyway.  If you want to utilize multiple CPU cores or build a computer cluster with Node.JS, just run multiple instances of your application and allow them to communicate via Sockets.  Threads are slow and waste a lot of memory anyway.
    9. Other dynamic programming features.  Eval(), func.call(), func.apply() are all features that should be used sparingly, yet they are still available when their use is appropriate.
      http://www.w3schools.com/jsref/jsref_eval.asp
      http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways-to-call-a-function.aspx
  2. JavaScript is widely adopted.  Almost every operating system has a web browser with JavaScript support.  PCs, Macs, Cell phones, handhelds, tablets, & netbooks all have browsers that support JavaScript.  While it is mostly used as a language for client-side browser applications, it is being increasingly used as a general programming language (even compiled)... Node.js is a good example.  Also, due to JavaScript's wide adoption, JavaScript has a very large development community.  There are a ton of JavaScript tutorials all over the Internet.
  3. A simple library backed by a ton of 3rd party libraries.  JavaScript on the browser has an extremely simple API.  The DOM is relatively straight-forward, as well.  jQuery is just one example of a library that makes JavaScript much easier to use and much more readable.  Node.js is also relatively simple.
  4. JavaScript is fast.  JavaScript is among the fastest interpreted languages thanks to many recent advancements.  (thank you, Google Chrome, et. al.).  On some platforms, you can compile JavaScript.  From what I've read, it's pretty fast, too.
  5. I forgot to mention the obvious.  Developing in JavaScript is free.
JavaScript will soon become a common server-side programming language (perhaps running like CGI or NodeJS will take over).  Web servers will be used for serving static pages.  Technologies like JavaScript client-side and NodeJS will run the bulk of a "Web 3.0" application.  Cutting-edge database back-ends like Redis will lead developers to lightning fast real-time applications.

If you don't know JavaScript learn it.  If you hate JavaScript (which I did for many years), look again.

JavaScript ROCKS!  The end!

Comments

Popular posts from this blog

Wedding Prediction - October, 2013

Carla and I are planning on getting married sometime in October next year.  We need to pick a date, and that decision may  involve some science and mathematics.  :) For example, we want the weather to be nice.  To be more precise, we'd like the high temperature for the wedding day to be between 60 and 80 degrees Fahrenheit.  Obviously, we have both lived in Ohio our entire lives, and we have a pretty good idea of what the weather will be like.  We both hypothesised that October was a "hit or miss" sort of month; it could be cold, or it could be nice. But, for me, a simple hypothesis was not enough; I really wanted to know the probabilities of decent weather based on historical weather data.  Many websites on the Internet (i.e. almanac.com) charge you to review historical weather data, but Carla and I discovered a cool page on cleveland.com that provided exactly what we wanted.  I loaded the historical temperature data from 1903 to 2011 f...

Web Browsers You Should Support

As a web developer, generally speaking, you should consider supporting the following browsers (at the time of this writing): Chrome (latest) - the browser that sets the bar for the others; you should be using it and supporting it Internet Explorer 9+ - the browser that finally caught up with the times a bit; basically, a Chrome wannabe.  I still say that IE sucks... even if it really doesn't anymore.  Yes... I'm sour about IE8 and below. Internet Explorer 8 - the old, sad browser that we sadly still have to support for a while.  CSS 3 is not well-supported here, so we use projects like CSS3 PIE or whatever.  By the way... IE8 sucks.  I can't wait until this comes off of the list. Firefox (latest) - the browser that was once awesome and has sadly suffered recently because it's slower than Chrome... but hey, lots of people still use it. Safari (latest) - Watch out for Safari as more iPhones, iPads, Macs, and more overly-priced Apple products flood the ...

BallWorld Screen Saver

Overview: My last Java programming assignment for my class at the University of Akron was called "BallWorld."  Its details can be found here .  I will not post any source code here, but I will post an executative JAR file that will run the screen saver.  Anyways, the final project of the BallWorld project was kind of cool, so I modified it a little bit to make a pretty neato screen saver.  You can download the project here:  BallWorld.zip .   The zip file contains a .JAR, an .EXE, and a .JOB.  The JAR file should execute the screen saver on any operating system.  The EXE file works only on Windows.  The JOB (Windows Task Scheduler) file can be used to automatically run the EXE file after a specified amount of computer idle time. Details: The EXE file was created using a program called Launch4j .  Launch4j simply takes a JAR file and converts it into a Win32 EXE.  Obviously, this destroys platform-inde...