Computer Programming: Difference between revisions

From Wikibooks, open books for an open world
Jump to navigation Jump to search
[unreviewed revision][unreviewed revision]
Content deleted Content added
No edit summary
m Reverted edit of 140.198.76.135, changed back to last version by 122.164.95.232
Line 41: Line 41:
* [[/Agent Oriented Programming/]] {{stage|25%|16. Dec 2005}}
* [[/Agent Oriented Programming/]] {{stage|25%|16. Dec 2005}}
* [[/Ars based programming/]]
* [[/Ars based programming/]]
* [[/Aspect oriented programming/]]
*
* [[/Component based software development/]]
* [[/Concurrent programming/]]
* [[/Constraint-based programming/]]
* [[/Design by Contract/]]
* [[/Distributed programming/]]
* [[/Embedded Programming/]]
* [[/Event driven programming/]]
* [[/Generic programming/]]
* [[/Post object programming/]]
* [[/Relational programming/]]
* [[/Symbolic programming/]]
* [[/System Programming/]]


=== Programming for applications ===
=== Programming for applications ===
* [[/Application development/]]
* [[/Application development/]]
* [[/AI|Artificial Intelligence (AI)]]

* [[/Database Programming|Databases]]
* [[/Drivers/]]
* [[/Games/]]
* [[/Networks|Internet & Networking]]
* [[/Multimedia/]]
* [[/Operating system creation/]]
* [[/Physics/]]


=== Programming for platforms ===
=== Programming for platforms ===
* [[/OS Programming/]]
* [[/OS Programming/]]
** [[/DOS Programming|DOS]]
** [[/DOS Programming|DOS]]
** [[/Linux Programming|Linux]]
**
** [[/MacOS Programming|MacOS]]
** [[/Windows Programming|Windows]]
** [[/CL (Control Language|IBM Midrange Systems]]
** [[/JCL (Job Control Language|IBM Main Frame Systems]]
** [[/AROS Programming|AROS]]


== History of programming ==
== History of programming ==
Line 75: Line 99:


; [[Learning the vi editor/Vim|Vim]] {{stage|100%|Feb 7, 2005}}: An abbreviation of <b>Vi</b> I<b>m</b>proved, this editor is modelled on the classic Unix editor vi. However, Vim is a much more modern editor with an optional graphical interface and quite a few features vi doesn't have, making it the editor of choice for someone experienced with vi.
; [[Learning the vi editor/Vim|Vim]] {{stage|100%|Feb 7, 2005}}: An abbreviation of <b>Vi</b> I<b>m</b>proved, this editor is modelled on the classic Unix editor vi. However, Vim is a much more modern editor with an optional graphical interface and quite a few features vi doesn't have, making it the editor of choice for someone experienced with vi.

For more text editors, see Wikipedia's [[Wikipedia:Category:Text_editors|text editor category]].

=== Tools ===
* [[GNU Compiler Collection|gcc]], a free compiler collection <small>(Ada, C, C++, Fortran, Java, Objective-C, Objective-C++)</small>.
* [[Apache Ant]], an XML-based build scripting language similar to Make.

=== Popular libraries ===
Unix native
* [[Programming:Cocoa|Cocoa/OPENSTEP framework]]
* [[FreeType Library|FreeType2]]
* [[IJG JPEG Library]]
* [[X Windows Programming/OpenGL|Mesa3D]]
* [[Gtk|GTK+]]
* [[PNG Library|LibPng]]

Windows "native"
* [[Windows Programming/DirectX|DirectX]]
* [[Windows Programming/Managed_DirectX|Managed DirectX]]

Cross platform
* [[Programming:Allegro|Allegro]]
* [[wxWidgets|wxWidgets]]
* [[OpenGL|OpenGL]]
* [[w:Qt|Qt]] - Popular object oriented C++ GUI framework. [[w:KDE|KDE]] is based on it. Bindings for various languages are available.
* [[w:XUL|XUL]] XML based GUI.
* [[w:Simple DirectMedia Layer|Simple DirectMedia Layer]] (SDL)

=== Format Reference ===
* [[/PTF|Poor Text Format]]

== Misc ==
*[[/Debugging/]]
*[[C Programming/Networking in UNIX|C Networking in UNIX]]
*[http://www.landofcode.com/view/introprogramming/ An introduction to computer programming]

=== Bibliography ===
* [http://www.htdp.org How to Design Programs]
* [http://mitpress.mit.edu/sicp/ Structure and Interpretation of Computer Programs] ([http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/ Videos])
* [[/How to Think Like a Computer Scientist/]]
* [http://www.swebok.org Software Engineering Body of Knowledge (SWEBOK)]

----
* [[/current|What's New?]]
* [[/Authors|Authors]]
* [[/Tools|Authoring Tools]]
* [[/Guidelines|Authoring Guidelines]]

{{alphabetical|C}}
{{DDC|000|005}}
{{LOC|QA75.5|QA75.5}}
[[Category:Programming|Computer Programming]]
[[Category:Computer Programming| ]]

[[de:Programmieren: Inhaltsverzeichnis]]
[[es:Fundamentos de programación]]
[[fr:Programmation]]
[[gl:Introdución á programación]]
[[it:Programmazione e Sviluppo]]

Revision as of 21:11, 25 October 2007

The Scope

Computer programming is the craft of writing useful, maintainable, and extensible instructions which can be interpreted by a computing system to perform a meaningful task. Programming a computer can be performed in one of numerous languages, ranging from a higher-level language to writing directly in low-level machine code (that is, code that more directly controls the specifics of the computer's hardware).

Using programming languages and markup languages (such as XHTML and XForms) require some of the same skills, but using markup languages is generally not considered "programming." Nevertheless, many markup languages allow inclusion of scripts, e.g. many HTML documents contain JavaScript.

Computer programming is one part of a much larger discipline known as software engineering, which includes several different aspects of making software including design, construction and quality control. The subject of this book is software construction, that is, programming. Computer programming is also a useful skill (though not always necessary) for people who are interested in computer science. Whereas software engineering is interested specifically in making software, computer science tends to be oriented towards more theoretical or mathematical problems.

Getting started

Many people think they must choose a specific programming language in order to become a programmer, believing that they can only do that language. They ask themselves, "should I be a C programmer or a Java programmer?" That's completely the wrong question. The right question is "How can I become a good programmer?".

There are a few points one can make about this. First - many languages are based on the same fundamental building blocks. Learning a language should be seen more as a way of acquiring those concepts than anything else. Second - good programmers are probably competent in more than one language. It might not be necessary to master them all -- a programmer could excel in one language and have only a working idea how to program in another -- but it is useful to have a strong programming culture, one which includes knowing several languages. Since programming languages have so many things in common, it is generally easy to learn a new programming language once you have mastered another.

So how do you get started? One reasonable technique would be to just pick a language and run with it. Unfortunately, we cannot suggest what the right language might be. Ask ten programmers what language you should learn and you will get ten different responses. Given the collaborative nature of this wikibook, you'll probably get as many responses as there are programming language books on the site. For more information, see the Wikibooks:Programming languages bookshelf which not only lists and categorizes all the languages known to wikibooks, but provides a small description on the side.

Families of languages

There is a common misconception held by programmers that all programming languages are essentially the same. While it is true that mainstream languages tend to be very similar (hence the popularity of this misconception), some languages fall into different paradigms which provide for a radically different programming experience. Programming in Haskell is nothing like programming in Java, which in turn is nothing like programming in Prolog. In the American Scientist article The Semicolon Wars, Brian Hayes classifies languages into four categories: imperative, object-oriented, functional, and declarative. Imperative and object-oriented languages tend to be used in the mainstream, whereas functional and declarative languages tend to be used in academic settings. Functional and declarative programming enthusiasts might argue that the paradigms are 20 years ahead of the mainstream and superior in many respects; however, mainstream language advocates would probably counter that such paradigms are hard to learn, or not very practical for their own unpopularity, among other things. We do not make any claims about who is right on this matter, but at the very least, we will suggest that building familiarity with the four major paradigms is an extremely valuable exercise.

Common concepts

Programming languages tend to have many general concepts in common. One can examine the recurring concepts and how they are expressed in various languages in the following table.

Table of language concepts and how they are expressed in various languages.

Available pages for "Key concepts in programming"
Wikicode Ada C C++ Java C# Perl Delphi PHP Python VB VBNet J2ME
Statements page here page here page here page here page here page here page here page here page here page here page here page here
Control Statements page here page here page here page here page here page here page here page here page here page here page here
Variables page here page here page here page here page here page here page here page here page here page here page here
Types page here page here page here page here page here page here page here page here page here
Type conversion page here page here
Mathematical calculations page here page here page here page here page here page here page here page here
Procedures and Functions page here page here page here page here page here page here page here page here
Function overloading page here page here page here page here
Structure and Style page here page here page here page here page here page here page here page here
String manipulation page here page here page here page here page here page here page here
Input and Output page here page here page here page here page here page here
Memory Management page here page here page here page here
Error handling page here page here page here page here page here page here page here
Object Oriented Programming page here page here page here page here page here page here page here page here
Generic Programming page here page here page here
Concurrent Programming page here page here page here
Packages and Modules page here page here page here page here
Libraries page here page here page here
Combining Languages page here page here

To see a comparison of syntax in various programming languages, see these "Hello World" examples. For a list including various computer languages arranged together by syntax terms and patterns, see Wikipedia's lists of computer syntax patterns.

Programming skills

Computer programming is really just about solving problems. It turns out that a large number of the problems you encounter in the real world are really just special cases of a more general problem. Luckily for you, many of these problems have been studied by computer scientists for a very long time, sometimes leading to provably unbeatable solutions, or sometimes solutions which are "good enough" for every day needs. In short, learning a language gives you skills, but learning data structures and algorithms shows you how to use these skills wisely.

Data Structures and algorithms

Programming for applications

Programming for platforms

History of programming

Specific languages

The following languages deserve special mention, being significant languages in the development of structured programming languages and object-oriented programming. They are worth understanding for the concepts they introduced.

ALGOL
was the first structured programming language and as such is the basis for all modern imperative languages. It was built around the notion of a block, delimited by BEGIN and END containing declarations and statements. ALGOL is a recursive general-purpose language, including recursive calls at a time when this was thought too difficult in languages like FORTRAN and COBOL. ALGOL is a stack language, so as blocks are entered, the declared variables are pushed on the stack and when a block exits, the stack is reduced. A block without declarations is not actually a block, but a compound statement, causing no stack building overhead. ALGOL was first developed as ALGOL 58, based on the formal BNF (Backus-Naur Form) language design notation. ALGOL-60 was a revision and this formed the basis of many other languages such as ALGOL-68, ALGOL-W, Pascal, Modula-2, Oberon, C, C++, Java, Simula, Ada, and Eiffel. ALGOL-60 was the first language used for systems programming in the Burroughs B5000 stack machines operating system in the early 1960s (when all else was programmed in assembler and where ALGOL is still used in 2006 Current ALGOL manual ). Learning ALGOL will teach you the basis of block-structured languages and structured programming concepts.
Simula
was the first object-oriented language developed in 1967 using ALGOL-60 as a basis (much as C++ used C). It was originally conceived as a simulation language (hence the name) to model real world systems. As ALGOL had been a block-structured language with blocks entered on the stack as they were called and deleted from the stack when exited, Simula liberated programs from this restriction. Thus a block could be entered but when the code exited, the block persisted on the heap, rather than on the stack – thus the object was born. However, unlike records and structures (structs) of other languages, procedures were associated with this saved block so a programmer could define an entire algebra to manipulate entities. Thus variables declared as part of the outer block (class) persisted beyond the original invocation of the block code (which would now be considered a constructor or creation routine). Local variables and arguments to the procedures in the class would be pushed on the stack when called and popped when exited, but would manipulate the object’s persistent state. Class facilities could be abstracted by use of inheritance. Simula also included a sophisticated concurrency paradigm. Learning Simula will teach you object-oriented and simulation concepts along with concurrency concepts and the use of coroutines and cooperating processes.
Smalltalk
was developed by Adele Goldberg, Alan Kay (the real inventor of Windows) and others at Xerox PARC. It is an object-oriented language with a natural language syntax. It is a typeless language and thus very flexible and dynamic, resulting in quick turn around of code, but can result in exceptions at run time that would have been caught at compile time by a typed language. Its concepts were the basis of Objective-C. Learning Smalltalk will teach you object-oriented programming in a typeless language with a very different syntax.

Additional Information

Editors

It is said that a programmer's best friend is his editor. A good editor is lightweight, has only essential tools and should support syntax highlighting for your language.

Examples of good editors for which we have teaching books are (alphabetically):

Vim 100% developed  as of Feb 7, 2005 (Feb 7, 2005)
An abbreviation of Vi Improved, this editor is modelled on the classic Unix editor vi. However, Vim is a much more modern editor with an optional graphical interface and quite a few features vi doesn't have, making it the editor of choice for someone experienced with vi.

For more text editors, see Wikipedia's text editor category.

Tools

  • gcc, a free compiler collection (Ada, C, C++, Fortran, Java, Objective-C, Objective-C++).
  • Apache Ant, an XML-based build scripting language similar to Make.

Unix native

Windows "native"

Cross platform

Format Reference

Misc

Bibliography