-
Programming Basics
last modified April 3 by cdwinslow
Recap (talk given 3/5/2008):
Procedural code (which includes pretty much all of the code produced by TOPP right now) consists of describing a process as a sequence of steps. Other models for writing code include functional languages (where the process is described as a composition of functions applied to some input) and declarative languages (where the process is described as a set of constraints that the output must meet).
Functions are a means of organizing behavior within code by sectioning it off and giving it a name.
Objects are a means of organizing data within code by grouping less complex objects together. Objects can also contain functions. The type of an object is called a class.
Polymorphism is the quality of different pieces of code that behave differently, but provide the same interface to the code that uses them. The interface that a piece of software provides to code that uses it is called an API (application programming interface).
A server differs from a desktop application only in the mechanism by which users interact with it; in the case of a server users connect by using a client program to make requests over a network, whereas for desktop applications users interact 'directly' by using a keyboard, mouse, gamepad, etc.
Python is a programming language, as is Java. Most of the OpenCore stack is Python code; most of Geoserver is Java code. The two differ in a number of ways:
- Java code requires an intermediate step (called compilation) between writing code and seeing its effects, while Python allows source code to be run directly (in other words, it is interpreted).
- Java code requires that all code be contained within a class; a Java program is started by specifying a class as the 'entry point'. In python, code that does not belong to a class is simply run.
- In general, Java code requires that more structure is explicitly described in the code, whereas Python infers more about it.
When php code is embedded in a webpage, that code is run before the webpage arrives at the browser. Javascript, on the other hand, is run after the page is loaded in the browser, which allows it to do neat things like alter elements of the page interactively.
The reason some applications (ie, Google Earth) need to be downloaded and installed rather than simply opened in a browser (ie, Google Maps) is that those applications use APIs that are not available in a web browser (these API restrictions are intentional; for security concerns, it would not be wise to give full system access to scripts that are downloaded and run automatically over the web). For example, Google Earth uses the OpenGL or DirectX API to create hardware-accelerated 3D graphics.