Wednesday, February 27, 2013

Additional notes for Finals

note: you must be online to view the links below.

JUST CLICK THE LINKS BELOW. THESE LINKS WILL SERVE AS YOUR NOTES

Logic gates

VB INTERFACE

Visual Basic History WIKI

VB Toolbox

Adding and Subtracting binary numbers


Adding binary numbers

Adding binary numbers is very similar to adding decimal numbers, first an example:


 Let's look at the above example step by step:

1 + 1 = 0 (carry one)
1 + 1 (+ the carry) = 1 (carry one)
0 + 1 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)
0 + 1 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)

The last carry is placed at the left hand side of the result giving: 10000010

reference: helpwithpcs.com

Subtracting Binary Numbers

The most common way of subtracting binary numbers is done by first taking the second value (the number to be subtracted) and apply what is known as two's complement, this is done in two steps:
  1. complement each digit in turn (change 1 for 0 and 0 for 1).
  2. add 1 (one) to the result.
note: the first step by itself is known as one's complement.

By applying these steps you are effectively turning the value into a negative number, and as when dealing with decimal numbers, if you add a negative number to a positive number then you are effectively subtracting to the same value.

In other words 25 + (-8) = 17, which is the same as writing 25 - 8 = 17.

An example, let's do the following subtraction 11101011 - 01100110 (23510 - 10210)
spr
note: When subtracting binary values it is important to maintain the same amount of digits for each number, even if it means placing zeroes to the left of the value to make up the digits, for instance, in our example we have added a zero to the left of the value 1100110 to make the amount of numerals up to 8 (one byte) 01100110.
spr
First we apply two's complement to 01100110








which gives us 10011010.

Now we need to add 11101011 + 10011010, however when you do the addition you always disregard the last carry, so our example would be:









which gives us 10000101, now we can convert this value into decimal, which gives 13310

So the full calculation in decimal is 23510 - 10210 = 13310 (correct !!)

reference: helpwithpcs.com
 

Types of Programing Languages

Interpreted language
  is a programming language in which programs are 'indirectly' executed ("interpreted") by an interpreter program. This can be contrasted with a compiled language which is converted into machine code and then 'directly' executed by the host CPU.

Advantages of interpreting a language
Interpreting a language gives implementations some additional flexibility over compiled implementations. Features are often easier to implement in interpreters than in compilers include (but are not limited to):
   • platform independence (Java's byte code, for example)
   • reflection and reflective use of the evaluator (e.g. a first-order eval function)
   • dynamic typing
   • smaller executable program size (since implementations have flexibility to choose the instruction code)
   • dynamic scoping


Disadvantages of interpreted languages
The main disadvantage of interpreting is a much slower speed of program execution compared to direct machine code execution on the host CPU. A technique used to improve performance is just-in-time compilation which converts frequently executed sequences of interpreted instruction to host machine code.

APL (programming language)
  • (named after the book A Programming Language)[5] is an interactive array-oriented language and integrated development environment which is available from a number of commercial and non-commercial vendors[6] and for most computer platforms.
  • It is based on a mathematical notation developed by Kenneth E. Iverson and associates
  • is used in scientific,[10] actuarial,[9] statistical,[11] and financial applications where it is used by practitioners for their own work and by programmers to develop commercial applications. It was an important influence on the development of spreadsheets, functional programming,
BASIC
  • (an acronym which stands for Beginner's All-purpose Symbolic Instruction Code) is a family of high-level programming languages designed to be easy to use.
  • -    The original Dartmouth BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire, USA to provide computer access to non-science students.
  • The eight design principles of BASIC were:
    • Be easy for beginners to use.
    • Be a general-purpose programming language.
    • Allow advanced features to be added for experts (while keeping the language simple for beginners).
    • Be interactive.
    • Provide clear and friendly error messages.
    • Respond quickly for small programs.
    • Not to require an understanding of computer hardware.
    • Shield the user from the operating system.
COBOL
is one of the oldest programming languages. Its name is an acronym for COmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments.

Grace hopper – the mother of cobol language.
IBM – International Business Machines

Procedural Programming Language
derived from structured programming, based upon the concept of the procedure call.
  • Procedures, also known as routines, subroutines, methods, or functions  simply contain a series of computational steps to be carried out.
PASCAL
Pascal was designed in 1968/9 and published in 1970 by Mr. Niklaus Wirth.
Brief description

Wirth's intention was to create an efficient language (regarding both compilation speed and generated code) based on so-called structured programming, a concept which had recently become popular. Pascal has its roots in the ALGOL 60 language, but also introduced concepts and mechanisms which (on top of ALGOL's scalars and arrays) enabled programmers to define their own complex (structured) datatypes, and also made it easier to build dynamic and recursive data structures such as lists, trees and graphs. Important features included for this were records, enumerations, subranges, dynamically allocated variables with associated pointers, and sets. To make this possible and meaningful, Pascal has a strong typing on all objects, which means that one type of data cannot be converted or interpreted as another without explicit conversions. Similar mechanisms are standard in many programming languages today. Other languages that influenced Pascal's development were COBOL, Simula 67, and Wirth's own ALGOL W.

Pascal, like many programming languages of today (but unlike most languages in the C family), allows nested procedure definitions to any level of depth, and also allows most kinds of definitions and declarations inside procedures and functions. This enables a very simple and coherent syntax where a complete program is syntactically nearly identical to a single procedure or function (except for the keyword itself, of course.)

Java
•    Java is a programming language originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform
What is the function of the program?
•    It is intended to let application developers "write once, run anywhere". Java is currently one of the most popular programming languages in use, particularly for server-client web applications.

SCRIPTING PROGRAMMING LANGUGES
A scripting language, script language or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the end-user. Scripts are often interpreted from source code or bytecode, whereas the application is typically first compiled to native machine code.
Early script languages were often called batch languages or job control languages. Such early scripting languages were created to shorten the traditional edit-compile-link-run process.

PERL
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular amongst programmers.
    *CGI – Computer Graphic Interface

 Advantages:
* Portability: Perl code that doesn't use system specific features can be run on any platform, and these days almost every operating systems support it. So, for example, if you write an utility that renames files in a complete directory tree according to some rule, you will be able to run it on Windows and Unix (Linux, Solaris, AIX, BSD, etc), and probably Mac OS too. But if you write an utility that changes file permissions, you might run into problems, because file permission are implemented differently on different systems.

* String processing and especially Regular expression support: Perl is a winner in everything related to string processing. Its regular expression support is the most versatile in existence and seamlessly integrated into the language. (In fact, it is so good, that Perl has set a new standard for regular expression, which is now emulated in many other programs and languages).

* CPAN: has a huge collection of free and reusable Perl code for many purposes - Science, system administration, Mathematics, Biology, foreign languages, database access, networking, etc.

* It is a beautiful language that combines the best features from many other languages and is very easy to learn if you approach it properly. But that's also a matter of taste.

Disadvantages:
*You can't easily create a binary image ("exe") from a Perl file. It's not a serious problem on Unix, but it might be a problem on Windows. There are some utilities which can do it, but they are neither free nor portable.

*If you want to run your program on a different computer, you can't always be sure that Perl is installed everywhere. It is common enough on most modern Linux and Solaris installations, although some system administrators choose to not install it for various reasons. On Windows, though, it is not so common and you need to install it. The installation is easy to get and free, but it needs to be done before you can run anything.

*Moreover, if you write a script which uses modules from CPAN, and want to run it on another computer, you need to install all the modules on that other computer, which can be a drag.

PHP
 is a general-purpose scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document. It also has evolved to include a command-line interface capability and can be used in standalone graphical applications. PHP can be deployed on most web servers and as a standalone interpreter, on almost every operating system and platform free of charge. A competitor to Microsoft's Active Server Pages (ASP) server-side script engine and similar languages, PHP is installed on more than 20 million websites and 1 million web servers.
PHP was originally created by Rasmus Lerdorf in 1995. The main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification. PHP is free software released under the PHP License which is incompatible with the GNU General Public License (GPL) due to restrictions on the usage of the term PHP.

JavaScript
JavaScript is a prototype-based, object-oriented scripting language that is dynamic, weakly typed and has first-class functions. It is also considered a functional programming language like Scheme and OCaml because it has closures and supports higher-order functions.
JavaScript is an implementation of the ECMAScript language standard and is primarily used in the form of client-side JavaScript, implemented as part of a web browser in order to provide enhanced user interfaces and dynamic websites. This enables programmatic access to computational objects within a host environment.
JavaScript's use in applications outside web pages—for example in PDF documents, site-specific browsers, and desktop widgets—is also significant. Newer and faster JavaScript VMs and frameworks built upon them (notably Node.js) have also increased the popularity of JavaScript for server-side web apps.
JavaScript uses syntax influenced by that of C. JavaScript copies many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics. The key design principles within JavaScript are taken from the Self and Scheme programming languages.

AppleScrip
AppleScript is a scripting language created by Apple Inc. and built into Macintosh operating systems since System 7. The term "AppleScript" may refer to the scripting system itself, or to particular scripts that are written in the AppleScript language.
AppleScript is primarily an inter-application processing system, designed to exchange data between and control other applications in order to automate repetitive tasks. AppleScript has some limited processing abilities of its own – basic calculation abilities, and some more intricate text processing tools – and is extensible, allowing the addition of scripting additions which add new functions to the language itself. Mainly, however, AppleScript relies on the built-in functionality of other applications and processes to handle complex tasks.
AppleScript has some elements of object-oriented programming, particularly in the construction of script objects, and some Lisp-like natural language processing tendencies, but does not strictly conform to either category.

GML
Game Maker Language (GML) is a scripting language developed for use with a computer game creation application called Game Maker. It was originally created by Mark Overmars to supplement the drag-and-drop action system used in Game Maker. However, in the latest versions, all the drag-and-drop actions translate to GML rather than being separate from it.
GML is heavily integrated with the Game Maker environment. Usually, elements such as sprites and sounds are all organized within the Game Maker IDE (though they can also be loaded from external files). Game Maker's architecture is designed to handle such things as event detection, level design, and object configuration without the need to code them manually, minimizing code verbosity with intuitive interface features.

FrinkFrink, named after the fictional mad scientist Professor John Frink, is a calculating tool and programming language designed by Alan Eliasen. It is built on the Java Virtual Machine and incorporates features similar to Java, Perl, Ruby, Smalltalk, and various BASIC implementations. Its main focus is on the fields of science, engineering, physics, text processing, and education.
One of the distinguishing characteristics of Frink is that it tracks units of measure through all calculations. This allows all values to contain a quantity and its units of measure. Frink understands how different units of measure interrelate, such as a length cubed is a volume, or power multiplied by time is energy. Different units of measure can be mixed in calculations, and Frink automatically ensures that the calculations lead to a result with the expected dimensions.

Evolution and History of Programming Languages

To build programs, people use languages that are similar to human language.  The results are translated into machine code, which computers understand.
Programming languages fall into three broad categories:
         Machine languages
          Assembly languages
          Higher-level languages

The Evolution of Programming Languages -
Machine Languages
         Machine languages (first-generation languages) are the most basic type of computer languages, consisting of strings of numbers the computer's hardware can use.
         Different types of hardware use different machine code.  For example, IBM computers use different machine language than Apple computers.

The Evolution of Programming Languages - Assembly Languages
         Assembly languages (second-generation languages) are only somewhat easier to work with than machine languages.
         To create programs in assembly language, developers use cryptic English-like phrases to represent strings of numbers.
         The code is then translated into object code, using a translator called an assembler.

The Evolution of Programming Languages -
Higher-Level Languages
Higher-level languages are more powerful than assembly language and allow the programmer to work in a more English-like environment.
Higher-level programming languages are divided into three "generations," each more powerful than the      last:
         Third-generation languages
         Fourth-generation languages
         Fifth-generation languages

Higher-Level Languages -
Fourth-Generation Languages
         Fourth-generation languages (4GLs) are even easier to use than 3GLs.
         4GLs may use a text-based environment (like a 3GL) or may allow the programmer to work in a visual environment, using graphical tools.
         The following languages are 4GLs:
o   Visual Basic (VB)
o   VisualAge
o   Authoring environments                          

Higher-Level Languages -
Fifth-Generation Languages
         Fifth-generation languages (5GLs) are an issue of debate in the programming community – some programmers            cannot agree that they even exist.
         These high-level languages would use artificial intelligence to create software, making 5GLs extremely difficult to develop.
         Solve problems using constraints rather than algorithms, used in Artificial Intelligence


Programing Languages by category 


Interpreted Programing Language:
Interpreted languages are programming in which programs may be executed from source code form, by an interpreter.
  •      Ant
  •      APL
  •      J
  •      Lisp  
  •      Lush
  •      MUMPS (an ANSI standard general purpose language
  •      Python
  •      S-Lang
  •      VBScript
  •      Windows PowerShell (Microsoft .NET-based CLI)

Procedural Programing Languages
Procedural programming languages are based on the concept of the unit and scope (the data viewing range of an executable code.
  •      Alma-0
  •      BASIC (BASICs are innocent of most modularity in (especially) versions before about 1990)
  •      C
  •      C++
  •      C#
  •      COBOL
  •      Combined Programming Language (CPL)
  •      D
  •      DASL
  •      Eiffel
  •      Fortran  
  •      Java
  •      Pascal 
  •      RPG

Scripting Programing Languages
  •      AppleScript
  •      ColdFusion
  •      Javascript
  •      F-Script
  •      Frink
  •      Game Maker Language (GML)
  •      JASS
  •      MAXScript
  •      Perl
  •      PHP (intended for Web servers)
  •      R
  •      S-Lang

Wednesday, September 12, 2012

Basic Logic Gates


Basic Digital Design
NOT, AND, and OR Gates

NOT Gate -- Inverter


AND Gate


OR Gate



Sunday, June 24, 2012

History of Computer Programming

History of Programming Languages 

Punch cards
Jacquard looms
Analytical engine  (Charles Babbage and Ada Byron Lovelace)
US Census data (Herman Hollerith)
Hand-coded machine language programs
  10110000 01100001
Assembly language programs
  movl $3, %eax
Modern programming languages
Charles Babbage’s Analytic Engine 1834
Earliest known computer
Never fully built
Operations and variables on separate punch cards
Conditional jumps accomplished mechanically by physically jumping over a band of cards
Collaborator Lady Ada Byron, Countess of Lovelace.
Babbage first computer scientist.  Ada Byron first computer programmer.
Von Neumann architecture 1945
Mathematician John von Neumann. Part of design of ENIAC, one of first electronic computers.
Computer in his design consists of small CPU, larger main memory, bus
Single CPU architecture still referred to as von Neumann machines.
EDVAC report (Electronic Discrete Variable Arithmetic Computer) describes the first stored program computer.
 Programming Language Generations

First Generation (late 1940s):
Machine-level programming languages
- Fast and efficient, executed directly on the CPU
- Consists only of 0s and 1s
- Difficult for humans to read, write, and debug


Second Generation (early 1950s):
- Symbolic assemblers
- Interpreting routines
- Very early compilers
Assembly languages
- Simple mnemonic instructions <opcode> <operands>
- Assembler translates into machine code
- Handcoding in assembly only for low-level needs


Third Generation (mid 1950s - present):
  High level, general-purpose
- FORTRAN, LISP, COBOL, ALGOL
- (Ada, Basic, C, C++, Java, Pascal, Smalltalk, …)
- Easier for humans to read, write, debug
- Compiler translates into machine code before running
- Interpreter translates into machine code at runtime


Fourth Generation (1970s - ):
  Specification languages, query languages, report generators, systems engineering
- Maple, Mathematica, Postscript, SPSS, SQL
Fifth Generation (1980s - ):
  Solve problems using constraints rather than algorithms, used in Artificial Intelligence
- Prolog

Konrad Zuse’s Plankalkül 1945

- Language for expressing computations
- Not published until 1972
- Anticipated many developments of programming languages
-Arrays, records
-Assertions
-Algorithms for sorting, numerical computations, syntax analysis, and chess 

Evolution of third-generation Languages
- Begins with FORTRAN in 1954
- Generation of high-level programming languages
- Languages stress expressivity and machine independence
- Programming is procedural
- Includes imperative, functional, compiler languages

FORTRAN (1954)

- Designed at IBM to efficiently translate mathematical formulas into IBM 704 machine code.  Wanted code at least as efficient as hand-coded.
- 1954 Report for a proposed Formula Translating System
- 1957 FORTRAN language manual published
- Translator produced code that in some cases was more efficient than the equivalent hand-coded program.
LISP (1958)
Interactive functional language
Designed for IBM 704 by John
  McCarthy at Dartmouth 1956-1958
Implemented at MIT.  First reference
  manual published in 1960.
Language based on lambda calculus. (Mathematical notation for expressing functions.)
LISP was designed for symbolic formula manipulation.  Stands for LISt Processor.
Has become standard language of the AI community
 

ALGOL (1958)
  ALGOrithmic Language
Language description published in ALGOL60 report
First appearance of Backus-Naur Form for programming language definition
Widely used as a publication language for algorithms
 
 Cobol (1960)
US Dept of Defense wanted
  “common” PL for data processing
CODASYL committee (Conference on Data Systems Languages)
Result was COBOL in 1960 (COmmon Business-Oriented Language)
Grace Hopper was involved in development and wrote 1st compiler
Designed to be machine independent, unlike FORTRAN.
Influenced by Fortran, ALGOL58, and English.


APL ( early 1960s)

A Programming Language
Based on notation developed by Ken Iverson at Harvard 1957-1962.
Functional, interactive, science-oriented language that assumes the array as the default data structure.
Suitable for applications with a heavy use of numerical data in large multi-dimensional arrays.
Used special symbols requiring special keyboard / printer

 BASIC (1964)
Developed at Dartmouth in 1960’s by Tom Kurtz, John Kemeny, and a succession of undergraduates; first ran in 1964.
Beginner’s All-purpose Symbolic Instructional Code
Intended to introduce students in non-scientific disciplines to computing.
Influenced by FORTRAN and ALGOL.

PL/1 (1964) 
Planned and designed by IBM as an extension to FORTRAN
“Extension” departed from FORTRAN specs and was first released as NPL. Renamed PL/1 (Programming Language 1)
Of interest in academic community because it had every element of language design.  Too big and complicated.
Compiler sold separately from machine

Pascal (1970)
Designed by Niklaus Wirth
(member of ALGOL committee; he proposed
   a revision known as ALGOL-W in 1965)
Pascal first implemented in 1970.
In opposition to trend of PL/1 – ALGOL68 – Ada
Named after 17th century French philosopher and mathematician Blaise Pascal.
Simple and elegant
Widely used in academic community
Interesting features:
Case statement
Facility for user-defined data types
Record structure

C  (1972) 
Designed by Kenneth Thompson
  and Dennis Ritchie at Bell Labs in 1972.
Designed for coding the routines of the UNIX operating system.
“High level” systems programming language which created the notion of a portable operating system
Concise syntax – programs somewhat hard to read, understand, debug, maintain
No built-in operations for handling composite data types such as strings, sets, and lists.
Not strongly typed.  No run-time type checking.  Easily leads to programming errors.
Provides ability to code low-level operations in a high-level language.


Programming Language Paradigms
  Procedural: procedures, sequential execution of code are basic building blocks of program
-FORTRAN (FORmula TRANslating; John Backus, IBM, 1950s)
-ALGOL (ALGOrithmic Language, 1958)
-COBOL (COmmon Business Oriented Language, 1960)
-BASIC (Beginner's All-purpose Symbolic Instruction Code,
                John Kemeny and Thomas Kurtz, Dartmouth, 1963)
-Pascal (Niklaus Wirth, 1970)
-C (Dennis Ritchie, Bell Labs, 1972)


Object-Oriented: Program is designed around the objects required to solve the problem
-Smalltalk (Alan Kay, Xerox PARC, 1971)
-Ada (US Dept of Defense, 1975)
-C++ (Bjarne Stroustrup, Bell Labs, 1983)
-Java (James Gosling, Sun Microsystems, 1995)
-C# (Microsoft, 2000)


Functional: Program is designed around the evaluation of functions, rather than modifying state
-LISP (John McCarthy, MIT, 1958)
-Common Lisp
-Dylan
-Logo
-Scheme
-ML (Robin Milner et al, Edinburgh, 1970s)
-Haskell (purely functional language, 1990)


Logic: Program is declarative, based on mathematical logic
-Prolog (1972)
  A program lists facts and rules, program execution is controlled deduction to answer a query.

Scripting languages (used for text processing, shells, HTML, CGI)
-awk (Aho, Weinberger, Kerningham, Bell labs, 1978)
-Perl (Larry Wall, NASA, 1987)
-Tcl/Tk (John Ousterhout, 1988)
-Python (Guido van Rossum, CWI, 1991)
-PHP (Rasmus Lerdorf, 1995)
-Ruby (Yukihiro Matsumoto, 1996)