Introduction to Javascript

JS, ie. JavaScript, is in a lot of ways quite similar to Processing…

…But not quite.

JS is a general-purpose web programming language with dynamic “duck” typing, leaning heavily towards object-oriented paradigm, with a C-like syntax.

This is going to get a bit jargon-heavy, no matter which way we slice the cake here, sorry about that. We’ll talk about all this, so no need to try to absorb everything from here.

1) General-purpose, meaning that the language is suited for pretty much any kind of programs, ranging from simple interactions on a web page, to 2D and 3D games and desktop programs.

2) Web programming, in the sense that most of the JS still runs in the browser, on a web page. These days, you can use JS to build desktop applications, too.

3) Dynamic typing, meaning that the types of variables are not bound to what they were originally. You can declare a variable as an integer, and later on use that exact same variable as a, say, string, without converting it manually. This is both a burden and a joy, depending on how you think. The “duck” part comes from the expression: “If it walks like a duck and it quacks like a duck, then it must be a duck” – basically, when it comes to variables, this means that if we can use a shoe to hammer in a nail, to JS that shoe is a hammer.

4) Programming language, in the sense that it is a language we use to program computers.

5) Object-oriented, meaning that the language has built-in capabilities for *objects*. We’ll talk about that a bit later on this course, but for now it suffice to say that OOP – object-oriented programming – tends to be the most common way of conceptualizing software development these days. An *object* in OOP is just an aggregation of data and functionality. Don’t worry, it’s going to make more sense soon.

6) C-like syntax means just that the conventions with respect to delineating things like control flow, code blocks, et cetera, resemble the C language. This means we’ll be using a lot of curly braces and semicolons.

The practical implications here are, then, respectively:
1) We need to be a bit more careful about which parts of the whole language to use. As a rather complicated general-purpose language, there are some parts that are outright scary.
2) Development of JS is a bit different: Instead of some sort of JS environment (compare: Processing IDE), we’ll be using a text editor and a web browser.
3) We don’t need to (and can’t!) declare variable types. This will inflict all sorts of horrible suffering upon you at some point, if you’re not careful. When you get used to it, though, it’s actually pretty nice.
4) We gon’ learn to program computers.
5) Processing is even more object-oriented than JS. A lot of the stuff you’ll learn here about objects is relevant also in Processing, as well as languages like Java, C++, C# (used in Unity), and openFrameworks.
6) It’s almost like writing two dialects of the same language. Once you get used to the semicolons, they’re equally useful here as in Processing or any other C-family languages.

Apart from the language differences, there’s also cultural differences, especially with respect to things like libraries. JS developers tend to rely heavily on libraries: No matter what you want to do, somebody has usually done something quite similar to that, and it’s often quick and easy to use some already existing code. Furthermore, the libraries themselves are often updated on a very fast pace. This is a good thing, in the sense that you get the newest developments almost immediately, but the drawback is that larger projects are a pain to manage.

This entry was posted in JS. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *