One World, One Language
“There sure are a lot of languages.” - Jenn Schiffer
It was September of 2003 when I began my undergraduate studies in Computer Science. Having chosen a liberal arts school, I was required to select a number of general education course requirements which lived outside the realm of my major. One of those requirements were two foreign language courses. When I had inquired about using Java to fulfill that sequence, my request was immediately shut down. “You have to pick a real foreign language, like Spanish or French,” my undergraduate advisor told me.
Perhaps I should have asked them about JavaScript.
To be multilingual, or a polyglot, has always been preached as superior to being able to speak one’s native language only. I have never understood why people believe this. Living under one roof, having one job for an extended amount of time, and being in a long-term monogamous relationship; these are seen as qualities of a stable life. Being an expert in a single subject, as opposed to knowing a little bit about a lot, is championed. So should be the case with programming.
JavaScript is a single, stable language which is powerful enough to build the World Wide Web, make robots move, and convince publishers to print entire books about it. If we were required to pick a single programming language, JavaScript seems like a no-brainer.
It is understandably controversial for one to say that a specific language is better than the rest and that it should, therefore, become the official language of programming. Who am I to decide which language every other programmer should learn and build with? In my favor, one of the greatest aspects of web development in the 21st century is the expression of opinions so strong they are worthy of becoming Web standards.
An Imperative, Dynamic Proposal
Imagine you are an academic advisor at a liberal arts college and tasked with defining the choices given to students for their foreign language requirement. A language called “JavaScript” comes up in a proposal and you need to study it and determine if it is a viable option. Naturally, you just so happen to be a fluent JavaScript expert, but yet you are not sure it would be more useful than, say, Java.
Java is notoriously simple to learn at the college freshman level, regardless of the student’s experience.
/**
* Hello World in Java
*/class Example {
public static void main(String[] args) {
System.out.println(“Hello World.”);
}
}
To run Java, the client must also be running the Java Virtual Machine (J.V.M.). It would be silly to ask students to carry multiple machines around to all of their classes, therefore a language that does not require a Java virtual machine would be a better option. You might be thinking “maybe this is a weird joke I just don’t get?” and perhaps the author, yours truly, is trying to make a joke and you feel like there are much better ones she could make. This is no joke; JavaScript does not require a Java virtual machine.
Neither does Haskell.
-- Hello World in Haskell
main = putStrLn “Hello World.”
The problem with Haskell is that, unlike JavaScript, it requires installation of a compiler. It is also a functional programming language which, like Latin, is considered “dead” and referenced only in historical texts. Yes, it is useful to learn Haskell in order to understand the context of programming today, but not for making useful products. It would be irresponsible to require students to learn something that would not help them build client-side web applications.
Ruby happens to be quite useful in building web applications.
# Hello World in Ruby
puts “Hello World.”
One of the features of Ruby is flexibility in the form of having dozens of different versions, the most popular of which is called Rails. Rails itself has many versions–dialects, if you will–which causes communication breakdowns between apps. Multiple versions works for operating system releases, but not for web development. JavaScript versions do not matter to the user or developer because it is not server-side, so that one less headache makes it a better option for teaching.
Cascading Style Sheets (C.S.S.) are also not server-side and do not require a compiler or virtual machine.
/* Hello World in "C.S.S." */
#example { content:’Hello World.’}
Much like hardware does not work without software, C.S.S. does not work without other languages. In the above example, the browser looks for an element on the page with the id “example.” If the developer did not use another language to create that element, the C.S.S. cannot do anything. The professor teaching the foreign language course would have to teach another language in addition to C.S.S., and that is asking a lot of the staff. JavaScript does not need other languages to work. It just works.
Hyper Text Markup Language (H.T.M.L.) works on its own and does not need a compiler installed.
<! — Hello World in H.T.M.L. →
<!DOCTYPE html>
<html ng-app>
<head>
<script src=”angular.js”></script>
</head>
<body ng-controller=”ExampleController”>
<script type=”text/javascript”>
function ExampleController($scope) {
$scope.printText = “Hello World”;
}
</script>
<h1>{{printText}}</h1>
</body>
</html>
Actually, H.T.M.L. does need another language to work, and it is JavaScript. Sure, in the past, H.T.M.L. used to be all you needed to create a web page. In the current state of the Semantic Web, though, the use of front-end JavaScript frameworks like Ember.js is required to bind text to a document.
JavaScript does not need a JavaScript framework to run. Because it is JavaScript already.
// Hello World in JavaScript
alert(‘Hello World’);
And there you have it. Simple, pure, vanilla, untouched, beautiful JavaScript. Short, effective, and simple to teach. You can rightfully count JavaScript among the options for teaching foreign languages to your college’s student body.
The Paradox of Choice
As hard as it is to choose the options of foreign language courses a student can take, it is all the more harder for the student to pick themselves. One of the hardest problems in computer science is choosing the right tool to use, and the same certainly goes for communication. It is an impossible question to ask, “German or JavaScript?” Why can a student not learn both?
This may seem like an np-complete problem. You cannot teach JavaScript in German, because JavaScript syntax is in American English.
// Hello World auf Deutsch
Benachrichtigung(‘Hello World’);
Although semantically, factually, and tactfully correct, the above code is syntactically incorrect.
>> ReferenceError: Benachrichtigung is not defined
It turns out, though, that you can teach German in JavaScript.
// Hallo Welt in JavaScript
alert(‘Hallo Welt’);
If one can learn a language within JavaScript, then it is clear that JavaScript can be the only foreign language course offered without preventing students from learning how to communicate in foreign countries.
Globalcommunicationscript
College is the basis of learning for all web developers, as is evident with the current education revolution within the software industry. As more programming jobs are created, educators grow more responsible for fostering the growth of new developers. To make this job easy, it only makes perfect sense to choose a language that everyone can communicate and learn with. As we discovered in our foreign language course narrative, that language is JavaScript.
Simple, pure, vanilla, untouched, beautiful JavaScript.
This is a chapter of an actual real book that O’Reilly is actually really selling called “Beautiful JavaScript” which has other chapters with actual real substance. All profits from the book go to EFF – who the author, Jenn “who’s to blame for that 2.5 star review” Schiffer, only learned today is *not* a subsidiary of the World Wrestling Federation.
And now that I’ve got your attention – that Paul Graham guy seems kind of out of touch, don’t you think? Anyway, happy new year, miss you pals.