Continuing to Learn JavaScript (Programming Language)

» It has been only two months since I set my sights on learning Javascript .. shortly after I discovered that HTML5 is coming, and that HTML5 is all about » Javascript. I continue to make progress (.. reading Flanagan's 1100-page Definitive Guide) .. tho not nearly as rapidly as I'd like.

Learn Javascript with Flanagan's Definitive GuideI get bogged down, particularly, whenever sections discuss OOP (.. Object-Oriented Programming) cuz I never learned OOP when studying PHP. (OOP was covered in the next video tutorial, titled » Beyond the Basics.)

Reading the sections on OOP makes me feel like my feet are tramping thru mud. Muck. Slow-going. Tho even there I'm now starting to make progress.

At first, the impression I got about programming .. was that » it was very much about » SYNTAX (.. how to use periods, capitalization, semi-colons, spaces, curly braces, comments, key-words, etc). And certainly, that's where all programmers start.

Programming is About » Building Things

But now the idea I get .. is that programming is about » BUILDING THINGS. All these things I'm learning are for the purpose of building programs. (Hopefully cool ones.) It was a distinct shift in my thinking.

A cool shift, I might add. Cuz syntax suks. Nothing much creative about syntax. But programs let you do nothing without proper syntax.

if I omit a period or capitalization here using english, or mispel something, you'll still know what I mean But not so with a programming language. No sense of humor do they have when it comes to getting creative with syntax. ERROR is their only response.

But getting back to the notion of building things .. programming is very much about » methods to control complexity. No problem to code up a simple 'hello world' function. The problem, rather, comes as the program grows in size and scope. Anybody can build a doghouse. Skyscrapers are another story.

••• today's entry continues here below •••

HTML5 logoSurprises & Confusing Parts

The most surprising thing I learned recently was that .. strings (of text) are considered » immutable. Unchangeable (.. in Javascript, anyway). Hmm. That torqued my cranium nicely.

It you want to change the contents of a variable that contains a string, you will REPLACE the old string with a new one. Not (as I'd imagined) modify the original string. [ Immutable .. cool word, no? =) "Not subject to change or variation." ]

One of the more confusing parts came when I learned that » Javascript (unlike many other programming languages) makes no distinction between integers (whole numbers) and floating-point values (those that contain a decimal point).

This is confusing because .. as you go along, it seems like the language *does* make a distinction. Take, for example, the global function » parseFloat() [.. which converts a string to a floating point number] .. and also » parseInt() [.. which converts a string to an integer].

Why the different function()s if Javascript "makes no distinction" between integers and floating point numbers? See my 'point'? Maybe the reason will become clear as my studies continue.

I also learned that JavaScript represents numbers in 64-bit format according to the IEEE-754 standard. But what if your computer only supports 32-bit processing?

Learn Javascript with Flanagan's Definitive GuideNumbers: Very Big & Very Small

As a little aside, do you happen to know the next largest set of numbers that come after 'trillion'? I didnt. Had to look that up. You can find the answer » here.

Javascript supports 9 of them. I'm talking whole-number integers, both positive & negative values. Exact numbers. (You can go larger, but may loose precision in the trailing digits.)

Heck that number is even larger than our national freakin' unbelievable debt (.. nearly 15 trillion now), which uh, shows no signs of slowing anytime soon. If I was in charge of promoting Javascript, I'd pimp it out as » So powerful it can even handle the U.S. debt. =)

The book delves quite deeply into the notion of the biggest and smallest numbers that the language supports (.. ±1.8 x 10308 and ±5 x 10-324). Then it spends some time discussing how infinity (& negative infinity) is handled .. which makes me think, btw, of the video » Dangerous Knowledge (.. and how Cantor lost it over the concept of infinity).

For example, dividing-by-zero (.. a mathematical no-no) does NOT generate an error. The language has devised clever ways for dealing with most any mathematical operation you might throw at it.

Learn Javascript with Flanagan's Definitive GuideOOP & Objects in Javascript

Regarding the difference between OOP and non-OOP (procedural) programming (.. a contrast that interests me) .. the sharpest distinction that I've read yet came in the following paragraph. See here:

Javascript is an object-oriented language. Loosely, this means that rather than having globally defined functions to operate on values of various types, the types themselves define methods for working with values.

To sort the elements of an array a, for example, we dont pass a to a sort() function. Instead, we invoke the sort() method of a » a.sort()

The question, of course, is » how 'loosely'?

Another frustrating thing that gave me trouble (before I read more and learned better) is that » both ARRAYS and FUNCTIONS are also considered OBJECTS (.. members of the OBJECT type). Meanwhile » NUMBERS, STRINGS & BOOLEAN (truth values) are not OBJECTS. They are considered "primitive" data types.

A related source of confusion was this quote:

Technically, it is only Javascript OBJECTS that have methods. But numbers, strings and booleans behave AS IF they had methods.

Note that a method is simply a function in OOP. [ See » a.sort() mentioned above. ]

The following terms seem to be used interchangeably » object, class, function, method, property. You eventually see into the nuances, but it can be confusing until you discern their shades of difference. Yes, I've pulled hair.

I spent extra time familiarizing myself with the reserved keywords (36 of them) and global functions & variables (30) .. cuz those will come into play when I start writing programs.

Learn Javascript with Flanagan's Definitive Guide Javascript + HTML5 = the Future of the Web

Final note » a second edition to Bruce & Remy's HTML5 book is scheduled to be released next month (Sept 25th). That should be a good title .. if it's anything like the original.

With HTML5 coming (.. seeing that HTML5 is very much about » Javascript) .. I can clearly feel the power of the technology .. even from my limited vantage point (of Programming n00b) .. especially with Web 3.0 coming.

HTML 5 + Javascript 5 + CSS 3 = the future of the Web.

Have you noticed how well the Java Rhinos go with my color scheme on the home page? And with the HTML5 logo? Think it means anything? =)

On a totally unrelated note, I was surprised to find one of my entries sitting near the top of the second page for the Google query » nietzsche+insanity. Not sure why that tickles me .. as if I am some kind of expert on the topic. =) I think the page title is what's causing it to rank so prominently. ■

For more along these lines, here's a Google search preconfigured for the query » learn javascript object-oriented programming language oop for html5

Radified home

About this Entry

This page contains a single entry by Rad published on August 23, 2011 8:23 AM.

Nostalgic Trip Leads to » Bitchin' Summer Day at Inspiration Point was the previous entry in this blog.

New 17-inch Lenovo Laptop with 2nd-Generation Intel Core i5 Processor is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.