Transcript L15

Comparing JavaScript
to Other Languages
Topics





Why did we study JavaScript?
Does programming language choice matter?
Differences with other languages
Some Really Exotic languages
How do I decide what language to use?
2
Why Did We Study JavaScript?


Effective language for teaching all the basic
computing concepts
Extremely useful for designing interactive
web pages


Practical for you to apply even if not a CS major
Syntactically similar to several other
languages

E.g.: C, C++, Java, PHP
3
Hello, World!


Typically, in any programming language, the
first example you learn displays “Hello,
World!”
Let’s use that as our Rosetta Stone for
examining programming languages...
4
Does Programming Language
Choice Matter?

Short answer: “Yes, but…”

Javascript:



Hello, world.
main( ) {
printf("hello, world");
}

Spanish:

Hola mundo
Fortran77:


document.write(“hello, world”);
English:
C:



PROGRAM HELLO
PRINT*, ‘hello, world‘
END
Lisp:

(defun helloworld ()
(print “hello, world") )

French:


Salut le Monde
Greek:
 Γεια σου κόσμε
5
Differences with other
Languages

JavaScript borrows many elements from
several, commonly-used languages, such as:





C
C++
Java
PHP
It shares many syntactic ideas with each
language (and they, with each other)
6
Differences with other
Languages


The differences are worth noting (and we will
come across them in the exercise), but there
is enough similarity that you can cross the
boundary easily
Some main differences:




Client-side vs. Server-side
Memory management
Type-handling
Type of object-oriented features (not covered)
7
(apply (quote (lambda (my_array)
(for i from 0 to 4 do
(setf (aref my_array i) i)
(setq
(a 1)
(b 2)
(cond (lt a b)
(format nil “a < b”))
…
8