MIC102G » Lecture 1

Update: January 8th, 2009

Introductions

Why programming?

  • Prevent manual duplication and tediousness (HTML lists)
    • Creating 1000 files
    • Emailing everyone in a list, one at a time
    • Parsing content (filtering/reformatting)
  • Create interactivity (flash movies, events)
    • Games
    • Visual Effects
  • Dynamic population (database driven content)
    • Creating a navigation list (like in WordPress)
    • User Directory
  • Cryptography/Security
    • rot13
    • https, public key crypto, etc...

It's just math, like algebra, right?

  • Functions (similarities and differences)
    • Algebra: f(x) = x2
    • JavaScript: square(x) = { return x*x; }
  • Syntax (different between languages)
    • string concatenation
    • data types
    • strong vs. loose types
  • Logic! (conditionals)
    • PHI 106 (intro to logic)
    • If, else, elseif
  • Human readable vs. Machine readable
    • Binary
    • Hexadecimal

Popular Modern Languages

Programming Language Timeline

Here are some popular modern languages:

  • JavaScript
  • A web based scripting language. JavaScript has historically been a lightweight and simple language with limited capabilities. In recent years, it has grown massively and become nearly a full Object-Oriented language. It is security sandboxed by the web browser, which is where the code is interpreted. This sandbox prevents JavaScript from being able to access the client Operating System and File System. However, because JavaScript can be run by a client, data from JavaScript cannot be implicitly trusted by the server of a web application. Different web browsers have different built in JavaScript methods and rules--but standards are much clearer than they were only a few years ago. JavaScript is not related in any way to Java. Although JavaScript is run primarily on the Client-Side, there are a few tools to use JavaScript as a Server-Side language.

  • Java
  • "Java is to JavaScript what car is to carpet" - unknown scholar
    Java is a full-blown Object-Oriented Programming language. Java is compiled to run inside of the Java Virtual Machine. This allows it to run on multiple operating systems without needing separate compiled binaries for each OS type.

  • C++
  • C++, like Java, is fully Object-Oriented and it is a compiled language. However, C++ is not written to run inside of a universal Virtual Machine. A C++ program that is intended to be run on both Windows, Linux and Mac OSX will require separate code compilations for each operating system. C++ is a popular language for writing Operating Systems and desktop applications.

  • C#
  • C# is popular as both a desktop application programming language and as a server-side web programming language to support ASP .NET driven web sites.

  • Objective-C
  • This is the language used to program iPhone applications and desktop applications on Mac OSX.

  • Ruby
  • A popular Object-Oriented, Server-Side language.

  • Python
  • Python is used primarily as an embedded scripting language and as a Server-Side web language.

  • PHP
  • PHP is a very popular Server-Side scripting language. It has a large open-source community of extension developers

  • Perl
  • Perl is primarily used for server side batch processing, system administration scripts and as a Server-Side language for creating web CGI applications.

  • ActionScript
  • ActionScript is used to create Adobe Flash movies or Adobe AIR applications. It is run inside of the Flash Player Virtual Machine. ActionScript in Flash movies is similar to JavaScript, in that it is interpreted and security sandboxed by the Flash Player and does not have access to the client filesystem. However, when used to create an Adobe AIR application, ActionScript becomes more like Java, with full access to the users operating system environment.

Scripted vs. Compiled

Scripted languages are interpreted line by line, executing the next line of code only after the current line has finished running. Scripted languages ship the source code as executable code. For this reason, code written in scripted languages are more likely to be treated as Open Source software. However, many code obfuscation techniques can hide or mask source code to a non-human readable state.

Compiled languages are written in human readable code and then run through a compiler, which extracts the human readable code into machine readable code. The running operating system doesn't know how to read a set of functions the way a human can so the code needs to be compiled in a way that the machine can understand it. After being compiled, the code can be executed on whatever platform it was compiled for. If the language is written to run inside of a virtual machine, the virtual machine acts as a guest operating system for that application.

Scripted languages can be thought of as running inside of a virtual machine. This is either a web browser or an appication like Zend (the environment that serves PHP pages) or an embedded system.

Client-Side Vs. Server-Side

Client code is anything that is downloaded and run on the user's machine. Server code is code that runs on the server. The output of that code's execution may end up in the user's hands but the code itself is never run on the user's machine. Server code is the only code that you can trust hasn't been modified (with a few minor obscure and complex exceptions).

Client-Side Code Security

  • Client code cannot be trusted
  • It's run by the user, in their environment.
  • They don't have to run it at all
  • Validation of all input data must be done on the server.
No comments yet.
You must be logged in to post a comment.
TOP