1 / 67

# WWWInternet - PowerPoint PPT Presentation

WWW / Internet Aaron Bloomfield CS 415 Fall 2005 Impact of Internet on Programming Languages Formatting Languages HTML Background HyperText Markup Language Tim Berners-Lee– 1989 Subset/Instance of SGML Developed to support WWW Developed as a document-layout language Markup Languages

Related searches for WWWInternet

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'WWWInternet' - johana

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Aaron Bloomfield

CS 415

Fall 2005

### Formatting Languages

• HyperText Markup Language

• Tim Berners-Lee– 1989

• Subset/Instance of SGML

• Developed to support WWW

• Developed as a document-layout language

• Used to encode formatting

• Markup tags embedded in text

• Output device interpreted tags

• Originally used in word processing

• Standard General Markup Language

• Rules for defining logical structure of a document

• Basis for creating markup languages

• Essential info easily transferred

• HTML file processed and displayed by Web Browser

• Passive language

• Program that displays the html code decides how to interpret the description

• Tell Web Browser how to format text on screen

• Always enclosed in angle brackets: <tag>

• Not case sensitive

• Whitespace does not matter

• Allow jumping to different spots

• HREF

<A HREF=http://www.virginia.edu>UVA</A>

• Name

• Allows a different spot in the document to be jumped to directly

<A NAME=“sec2”>Section 2</A>

• Only need image URL

• SRC tag

• Images can be placed anywhere

• Align

• W3C & IETF: HTML standards

• Internet Drafts: published, tested, commented on, and become Document Type Definitions

• Browser authors add to HTML

• Support it in their browsers

• Community accepts or abandons additions

• Portable Document Format

• The second generation of PostScript

• PDF files retain their formatting across different viewing environments

• Applications exist for converting documents to PDF

• Document preparation system

• Typesetting for math and technical material

• Very close control over document

• Tex file created with regular text editor

• Tex converts it into a DVI (DeVice Independent) file

• DVI file read by another program

• Creating DVI file allows for 1 file to produce the same output by different reading programs

• Macro package for Tex

• Used for document preparation

• Author does not format document

• Specify defaults for document classes

• You can create your own document classes

\documentclass{article}

\title{Latex Example}

\begin{document}

Body text goes here.

\end{document}

• Formatting languages are not PLs

• But their use employs:

• Parsing

• Generating output in a different form

• Nesting

• XML is a markup languge used to represent data in a structured, portable manner

• It allows programmers to use a standard parser for many different types of data without having to worry about small changes in document structure affecting their parsing code

• It allows for easy interchange of data between heterogenous systems

• Why do we care about XML? Its not a programming language.

• Without XML:Doe, John 80 75 60 92Doe, Jane 81 90 54 84

• For some applications the tags make up a significant fraction of a documents size

• In general, this doesn't matter

• XML by itself doesn't provide a whole lot of services

• Things like linking, templating, parsing, and defining schemas are provided by other languages

• It isn't really that revolutionary

• It is very similar to SGML and ASN1

<?xml version=”1.0”?>

<!ATTLIST student name #CDATA #REQUIRED>

<!ATTLIST student id #CDATA>

• They show an agreement between two groups on a specific way of expressing some data.

• There are tools that will verify a document to a DTD

• They don't let you enforce restrictions beyond the structure of the document

• Without another tool there isn't a way to require that a grade tag only encloses a number.

• Data exchange is great, but how is XML really used?

• FOAF

• SOAP/XMLRPC

• Content Management/Syndication

• Streaming Video (SML)

• Microsoft Word

• ... and much, much more

• Many businesses like to write content once, and format it for a variety of destinations

• We want to have a version for the web (HTML), cellphones (WML), and print (SGML).

• We don't want to have to make each version by hand

• Gererally it works like this:

• A story is written and marked up in XML

• CMS software uses stylesheets to create the different output from the same source

• Everybody is happy

• The most common style sheet language is XSLT: the eXensible StyLesheet and Templating language.

• It allows us to transform one XML document into another document.

• Unlike XML, XSLT is a programming language

• XSLT programs just are expressed in XML

• XSLT is interpreted

• XSLT is dynamically typed and type-safe, does dynamic type checking, and is statically scoped

<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match=”/”>

<xsl:apply-templates />

<xsl:template />

<xsl:template match=”student”>

<h1><xsl:value-of [email protected]></h1>

<table><xsl:applytemplates />

</table>

</xsl:template>

<tr>

<td><xsl:value-of [email protected]/></td>

<td><xsl:value-of select=”.”/></td>

</tr>

</xsl:template>

</xsl:stylesheet>

• We can also do conditional processing

• <xsl:variable name=”thisgrade” select=”.”/><xsl:if test=”$thisgrade < 60”><h2><xsl:value-of select=”.”/></h2><xsl:if/><xsl:if test=”not ($thisgrade < 60)”> <xsl:value-of select=”.”/><xsl:if/>

### Internet Applications and Multimedia

• People like to be able to use their senses

• However, the space that digital pictures, sounds, and video required was far more than a disk could hold

• ~1994 the Internet became more popular in the common household

• However, browsers were originally mostly text based and connections were too slow to support large files

• Macromedia created Flash which, in one simple program allowed people to develop multimedia content

• Flash uses vector graphics, which is very space efficient and incorporates other methods for compressing media types

• Also provides streaming content, extremely useful to an internet user

• ActionScript is Flash’s scripting language

• From a programmer’s point of view, makes Flash a lot easier to work with

• The programmer has complete control over what is going on in their application

• Enhances one’s ability to create an interactive application, be that a presentation, a game, or a movie

• ActionScript and Flash are primarily used today as a 2D graphics environment.

• However, people are also using ActionScript to create interactive forms on the web

• Another useful application is that a company could store something on it’s main server, and when they have to give a presentation out in Seattle, they could just access that and have real time stream and interactivity

• In ActionScript, we don’t need to specify what type the variable is.

ex. favColor = “pink”; sets the variable named ‘favColor’ to a string with the value “pink”.

• Also, favColor can later be changed to another type.

ex. (following first example) favColor = 1; sets the variable ‘favColor’ to the number 1.

• However, if you want a function to only take a certain type and only return a certain type, you can do something like this:

ex. Function doThis(myWord:String):Number { }

• Also, ActionScript (being part of Flash) was designed with interaction in mind.

ex.

on (release)

{clip2._visible = false; }

• There are currently other languages out there which are intended to achieve the same results as ActionScript.

• The popular ones include JavaScript and upcoming Avalon.

• Using ActionScript, a programmer can extremely enhance a presentation with sound, graphics, video, and their overall layout

• Both ActionScript and JavaScript are based on the ECMA-262 (The European Computers Manufacturers Association)

• One big difference is that ActionScript doesn’t support browser specific objects and commands.

• Microsoft’s future OS is planning on distributing Avalon as a feature with it. Will support 2D and 3D vector graphics.

### Internet Applications

(Applets)

• One common misconception is that an applet refers to Java applets, which isn’t necessarily the case

• Something to note about these applications is that they can use the computing power of the server or of the user

• Even though we have stated that applets do not necessarily have to be Java, this is a predominant form

• One crucial feature of Java and Java’s Virtual Machine is that it is machine-independent

• To do this, applets need to be able to access some information about the user’s machine, but Java Applets are not allowed/able to read or write files on/to the users machine

• Originally, the Java Applets for the Java Virtual Machine were intended to be Interpreted

• This has its weaknesses, so there are two other methods that the JVM can use

• One thing that the JVM can do is look at what part of the program that is being most heavily used and convert that into machine code

• The other option is the Just-in-Time (JIT) Compiler

• This takes the Java bytecode and converts it to instructions that can be directly performed by the processor (also using machine code)

• Users of ActionScript like to point out that whatever they create will look the same on any machine (though you do need to download the Flash viewer) whereas JavaScript can be interpreted differently in different (especially the less mainstream) browsers

• Along the same lines, Java applets (as previously stated) were designed to be machine independent and could potentially even work on someone’s cell phone

### PERL & CGI

Practical Extraction & Reporting Language (Pathologically Eclectic Rubbish Lister)

• Brief History

• Language Overview

• Benefits of using Perl (Efficiency, Portability)

• Common Gateway Interface (CGI)

• Developed by Larry Wall

• Perl 1.000 released in 1987

• Perl 3.000 released in 1988 under GNU Public License

• Current stable release: Perl 5.8.1

• Today, Perl comes standard on most operating systems (e.g. Solaris, Redhat, Mac OS X)

• 3rd party companies offer pre-built Perl distributions for other OSs (e.g. Windows)

• Interpreted language

• Wall originally intended Perl for:

• Scanning arbitrary text files

• Extracting information

• Printing reports from extracted info

• Expression syntax borrows heavily from other languages (C, sed, awk, sh)

• “Perl is a language for getting your job done.”

• “Perl is designed to make easy jobs easy, without making hard jobs impossible.”

sub PrintHello {

while(1) {

if ($str =~ m/o..w/) { print “$str\n”;

}

else {

print “NO MATCH\n”;

break;

}

}

}

&PrintHello;

• 3 primitive types: $scalars, @arrays, and %hashes (associative arrays) • A$scalar variable may be a number or a string

• Conversion between the two is automatic pending on your operator usage (e.g. “= =“ OR “eq”)

• @arrays and %hashes are dynamically sized

• A %hash consist of a set of key-data pairs

$helloStr = “Hello, world!”;$someNum = 415;

@myArray = ($helloStr,$someNum, 1, 2.2, “3”);

%myHash{“key”} = $data; • Conditional branching: • if (condition) { statement(s); } • else { statement(s); } • elsif (condition) { statement(s); } • unless (condition) { statement(s); } • Iteration: • while (condition) { statement(s); } • until (condition) { statement(s); } • for ( initialize; condition; re-initialize; ) { } • foreach$scalar (@list) { };

• Perl allows for recursion with proper scoping declarations

• Defining a subroutine:

sub subname {

statement(s);

}

• Calling a subroutine:

&subname;

subname()

• Scoping keywords: my, our, and local

• One of Perl’s primary purposes was to process text

• Perl has built-in pattern matching – useful for searching and manipulating strings

• Perl’s regular expressions are derived from established regular expressions found in popular tools like sed, awk, grep, and vi

• regex operators:

=~ matches, !~ doesn’t match

m/ PATTERN /

s/ PATTERN / PATTERN /

tr/ PATTERN / PATTERN /

• Perl programs are not platform dependant

• Comes standard on many different operating systems

• Avoid C’s #IFDEF statements

• Does not guarantee that a program uses platform dependant tools

• regex widely used (grep, sed, awk, ed, vi, emacs, etc)

• Perl is a semantic superset of the above

• any regex that can be described in the above can also be described in Perl (but maybe using different characters

• Use of hashes instead of linear searches through an array

• Use of foreach instead of for loops

• No need to have extra operation on counter

• regex for fast pattern matching for searching large amounts of data

• Defines functions the first time they’re called

• CGI script – a program on the web server which runs on demand to generate the content of a web page

• You can find CGI scripts everywhere on-line:

• Used to access and manipulate databases

• On-line shopping

• Popular CGI scripting languages:

• Perl, PHP, ASP, Python

• But really, anything that is executable on the server

• Why use Perl to create CGI scripts?

• Free software

• Fast and powerful string manipulation (imagine doing the same thing with C/C++)

• Built-in types and functions that are useful for handling records and information (arrays and hashes)

• Comes standard on almost all web servers

• Standard CGI module

#!/usr/bin/perl

use CGI ':standard';

print header, start_html('Hello World'), b('And hello to you too'), end_html;

Content-type: text/html

<STRONG>And hello to you too</STRONG>

</BODY></HTML>

### Perl/CGI forms

• Purpose was to allow computations of the form ne mod m

• In particular, where the numbers involved were 500 digit integers

• Used in RSA encryption

• Provided to my CS 202 class

• The script creates the HTML page

• I’ve provided the HTML page separately to show what the HTML code looks like

• Note that the script is synchronous

• It requires the page be re-loaded with the new data

• AJAX stands for Asynchronous Java And Xml

• Does not require the page be re-loaded to display new data

• Google Maps is an example of an AJAX script

• Two files involved

• ajax: the Perl script itself, it’s pretty simple

• Example 1

• Script can be run at http://www.cs.virginia.edu/cgi-bin/cgiwrap/cs415/modpow

• Script can be viewed at http://www.cs.virginia.edu/~cs415/cgi-bin/modpow

• Example 2

• ajax.html: http://www.cs.virginia.edu/~cs415/code/ajax.html

• ajax script: http://www.cs.virginia.edu/~cs415/cgi-bin/ajax