Introduction to Programming
When you program, you are programming the instruction set of the CPU (machine language). Intel 8080 CPU
Machine Language / Assembly Language The only programming language a CPU can directly execute is machine language (or machine code). Since machine language instructions are in binary, Assembly Language is created to allow a programmer to code the instructions in a familiar language, then compile these instructions into machine language. With Assembly Language, you are still programming using the instruction set of the CPU.
The Hierarchy of Programming Languages End-User Database, Worksheet, Document Access, Excel, Word C++, Java, C# Assembly Language Machine Language Hardware - CPU Lower Level - Higher Level #include main() { int Total,Kiwi,Bananas; Kiwi = 5; Bananas = 6; Total = Kiwi + Bananas; cout << Total << endl; }
Compiled versus Interpreted A compiler translates an entire program (source code) into machine language for execution by the CPU. The result is an executable (.exe) file that can be run on a computer. A = 5program.exe B = A Print B An interpreter translates or compiles a program one line at a time while it is executing. An older example of an interpreted language is Basic. A newer example is JavaScript.
Enter temperature in Fahrenheit: 75 It is degrees Celsius. #include float Convert(float); main() { float F,C; cout << "Enter temperature in Fahrenheit: "; cin >> F; C = Convert(F); cout << "It is " << C << " degrees Celsius.\n"; } float Convert (float F) { float C = (5.0/9.0) * (F ); return C; } Structured Programming Program Source Code Program Output Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures and for and while loops—in contrast to using simple tests and jumps such as the goto statement which could lead to "spaghetti code" which is difficult both to follow and to maintain.
DeckofCards Lucky; // define object Lucky to be a deck of cards Player Kirk; // define object Kirk to be a player Lucky.Shuffle; // shuffle the deck of cards Lucky.Cut; // cut the deck or cards Kirk.Cards = Lucky.Deal(5); // deal 5 cards to Kirk Kirk.ShowCards; // display the cards Kirk.PokerHand; // display poker hand Object Oriented Programming (OOP) Full House Program Source Code Program Output Object-oriented programming (OOP) is a newer approach to program design. It focuses on creating objects. Objects have both properties (data) and methods (functions). For example, an object might be a deck of cards. It’s properties are the number and order of the cards. Its methods/functions are shuffling, cutting, dealing, etc.
Software Development Life Cycle PhaseComments Problem AnalysisSystem analysts study the problem and define the specifications for the software. Program DesignThe specifications are used to develop an algorithm for the program Program CodingProgrammers produce the code for the program. Alpha versions of the program are created. Program Debugging and TestingProgram testing may be done in-house, or a Beta version may be produced to allow end-users test the program. Program Implementation and Maintenance After the program is put into production, the maintenance phase begins. New versions will be released to fix bugs and add requested functionality.
Programming Languages LanguageDescription Machine LanguageThe native programming language of the computer's CPU. This low-level language is tedious – CPUs come with a specified set of very basic instructions and operations. For example, a load instruction will move each piece of data from memory to a register on the CPU for processing. Machine language is written in binary – all 1's and 0's. Assembly LanguageA more efficient way to write machine language. This low-level language allows instructions to be written in a more understandable format (instead of binary), then converted to machine language. CA high-level structured, procedural programming language that is widely used for programming applications as well as operating systems. It was developed on a UNIX system and later used to reprogram UNIX. C++A high-level object oriented programming language that is a superset of C. Originally designed by Bjarne Stroustrup of AT&T's Bell Labs in It adds better type checking, data abstraction, and object oriented programming to C. C#Pronounced C-Sharp, this programming language was developed by Microsoft for its.NET Framework. In many ways, it is an upgrade to C++ and was made to compete with the Java language. BASICAn early high-level programming language that is simple to use and widely popular. Many of the first home computers in the 1970's and 1980's included this programming language. COBOLCOBOL (Common Business Oriented Language) was the first widely used high-level language for business applications such as payroll and accounting. This older programming language has been updated and is still used today, mostly on mainframe computers. FORTRANFORTRAN (Formula Translation) is an older high-level language that was designed for scientific applications. Objective-CA programming language similar to C that is used by Apple in programming iOS apps. In 2014, Apple created a new language called Swift that will operate within Objective-C. PascalPascal is an older high-level language that was also designed for math and science applications. It was popular as a teaching tool for structured programming before C became popular. Visual Basic (VB)Microsoft's Visual Basic adds object-oriented features and a graphical user interface to the standard BASIC language. JavaA high-level object-oriented programming language developed by Sun Microsystems for creating programs that are platform independent. Java programs are.class files and will execute on any operating system that has the Java run-time console installed. Java is now the programming language used for Android apps. JavaScriptA scripting language used in web pages that enhances the limited capabilities of HTML. JavaScript adds many functions to HTML including event handlers, cookies, and pop-up windows.