WebFund 2015W Lecture 3

From Soma-notes
Revision as of 19:54, 13 January 2015 by Soma (talk | contribs)

Audio and video from the lecture given on January 12, 2015 are now available. The video has a partial audio track due to corruption; for full audio listen to the mp3.

Notes

Web applications versus web pages *Web page HTML + CSS + JAVASCRIPT

HTML(Hyper Text Mark Up Language) defines structure of page (define HTML) CSS is responsible for the styling of the webpages JavaScript is the code of the webpage

Web Applications:Set of webpages + Server side logic

when you a loading a webpage the serves does two things: 1)browser sends HTTP GET 2) Server returns HTML document * The document has references to other resources _ The browser does GETs for those

What does the server side logic do?

1) It changes what is returned in response to GETs, (and POST)

Static Web Servers serve files, while on the other hand Dynamic web servers implement logic.

Early web server used CGI to do dynamic web pages

CGI: Common Gateway interface An Example of a CGI would be a program, for example a perl script

the web started with static web pages

The problem with using CGI for everything is that: 1) You have to run seperate process for each web request, which is rather expensive and not a great architecture

One solution is to keep dynamic program running -this is usually used with PHP (does not pay overhead of executing)

With node we eliminate the static web server .

What is node? Node is a javascript execution environemnt with networking and disk Input and Ouput(I/O) support

Javascript is limited in what it can do

On the other hand, node by itself does not have much functionality, we need to add *modules* to make it better

NPM = node package manager

The node package manager lets us load the code that node depends upon

FrameWork: All a framework is a scaffolding for an application

Also a framework helps you to gennerate a simple application that runs but doesnt does much, then you have the functionality you want.

app.js: contains the code Public folder : anything you put in here, static web server i.e images, style sheets etc

packages.js: contains dependencies bin: contains the file you run

with node,all the code you will need will live in a node_module directory we type cat package.json on the terminal to view the dependencies

we also type "npm install" on terminal to install the NPM after the instalation is complete a node module directory will be downnloaded/installed

now we can run the web server.

localhost:3000? what does this mean

localhost is the machine you are operating on. In 2406 we will do everything off localhost. local host can be replace with your ip i.e 134.117.222.90:3000 3000 is the default

3000 is the standard development port we will be using.

usually to connect to port 80 you have to priviledges, and we do not want that, because no one knows how your code will react.

favicon is the little icon that shows on the corner of your browser while it is running.

JavaScript -it is loosely type -Weird globals -null is an object etc

JavaScript can also be said that it can be said that it is a first draft of a great language.

First rule of the web is Compatibility , and which is one of the reasons why JavaScript has not "fixed"

Properties of JavaScript -C like syntax -loosely typed : what does this mean? It means you do not specify types for variables, that doesn't mean there are no types -identifiers can refer to data of any type -numbers are ALL DOUBLES i.e Double Precision Floats(floating point i.e no integers) -Object Oriented -NO CLASSES - only prototypes -lexical scoped: meaning the range of which a variable can be seen or range of functionality of a variable, so that it can only be called from the scope/ the block of code where the variable was defined

Prototypes have no compile phase.