JavaScript What? Why? Where? David Madden IT Services - - PowerPoint PPT Presentation

javascript
SMART_READER_LITE
LIVE PREVIEW

JavaScript What? Why? Where? David Madden IT Services - - PowerPoint PPT Presentation

JavaScript What? Why? Where? David Madden IT Services d.d.madden@bham.ac.uk Java is to JavaScript as car is to carpet So what is it? Created by Brendan Eich in 1995. JavaScript often abbreviated as JS, is a high-level, interpreted


slide-1
SLIDE 1

JavaScript

What? Why? Where?

David Madden IT Services d.d.madden@bham.ac.uk

slide-2
SLIDE 2

“Java is to JavaScript as car is to carpet”

slide-3
SLIDE 3

So what is it?

Created by Brendan Eich in 1995. “JavaScript often abbreviated as JS, is a high-level, interpreted programming language. It is a language which is also characterised as dynamic, weakly typed, prototype-based and multi-paradigm.” (https://en.wikipedia.org/wiki/JavaScript)

slide-4
SLIDE 4

General language features

Should look familiar:

  • Types

○ Boolean ○ Null ○ Undefined ○ Number ○ String ○ Symbol ○ Object

  • if, for, while, switch, break, continue etc.
  • Classes…(functions)

Not so familiar:

  • Variable and function hoisting
  • Function level scope
  • Global scope
  • Closures
slide-5
SLIDE 5

So why does it exist?

The web browser

  • Needed a scripting language
  • Wanted it to be Java “like”

(marketing !?!)

  • Built in 10 days
slide-6
SLIDE 6

What it’s good at (kind of...)

  • Moot point, it’s all you’ve got.

○ What about Java applets (dead) ○ What about Flash (dead)

  • If you want to anything “dynamic” in a web page you will have to write JavaScript
  • Asynchronous - non blocking
slide-7
SLIDE 7

What it’s not so good at (quite a bit…)

slide-8
SLIDE 8

What it’s not so good at (quite a bit…)

Know the limits of the language

  • Don’t write spacecraft control systems in JavaScript
  • Don’t write complex financial processing systems in JavaScript
  • Don’t write 3D animation engines in JavaScript
slide-9
SLIDE 9

So it’s just web pages?

Turns out one part of JavaScript is really powerful:

  • Asynchronous - non blocking

Not any more

slide-10
SLIDE 10

Beyond the niche

Node.js

(https://nodejs.org) Created by Ryan Dahl in 2009

Run JavaScript outside the browser (Thanks in part to Google Chrome and the V8 JavaScript engine)

slide-11
SLIDE 11

It’s still JavaScript though...

slide-12
SLIDE 12

What can you use it for?

  • Web applications - in the browser
  • Websites - with Node.js
  • REST APIs - with Node.js
  • Command line scripts - with Node.js
  • Desktop apps with Node.js e.g. Visual Studio Code, GitHub Desktop, Postman,

Slack, loads more.

slide-13
SLIDE 13

What’s next?

Increased competition

WebAssembly (https://webassembly.org)

  • Compile other languages to run

in the browser

slide-14
SLIDE 14

Questions?