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

Beware the Ides of March...in 9 days

Stupid heading for this blog, but whatever.  I was amused.   So, a lot has happened since my last entry, which I believe was sometime in January.  I have officially started a new business -- OnlineFixShop, LLC.  The web address is http://www.onlinefixshop.com/ .  Check it out!  For the next few months, my business will be focusing on home PC repair.     I am offering services that can help you:   Rid your computer of spyware and viruses Retrieve lost information and data Gain access to the Internet Increase your computer's performance and speed Learn your way around various types of software Setup a secure wireless or wired network Back-up personal and valuable data Secure your computer(s) and protect your data Eventually, I am planning to focus on repairing computers over the Internet using remote administration technology, which I have yet to design.   Right now, I am working to setup an onlin...

JavaScript Sticky Footer and Scroll Effect

This post talks about two different HTML/JavaScript effects: How to keep a page footer stuck at the bottom of the browser window. How to create a scrolling <div> without using a scroll bar OK. So... you have a website. You want a header stuck at the top of your page and the footer stuck at the bottom of your page. The stuff in the middle, you want to be able to scrollable. But, you don't want those ugly scrollbars to the right of your scrollable text. Maybe, instead, you'll have up arrows and down arrows above and below your <div>. When you mouseover the arrows, the text in the <div> will move up or down and create a scrolling effect. Suppose your page looks like this... <html> <head> <title>Test</title> </head> <body> <div style="position: relative; width: 700px; margin-left: auto; margin-right: auto;"> <div id="header">Header</div> <div id="scrollUp...

Today's Quote

This is simply a brain dump.  I'm sleepy, and I want to type out some of the thoughts currently in my head. "Luck is where preparation and opportunity meet."  This is so remarkably true, and today I'm making it a mantra.  I believe that luck is merely an illusion that we perceive, but it truly when we have prepared ourselves for the right opportunity... and then a great opportunity comes along.  Many great opportunities pass us by every day.  Once we begin to recognize them and prepare for them, then we start to experience the thrill of luck. Interestingly, as described in "Good to Great", Mr. James Collins talks about how "Level 5" leaders often attribute their great success to luck .  That's a humble way of saying, "I planned on taking advantage of every opportunity ."   Hmmm...