Talk:Computer Programming/Archive2

Cleanup-clarity
Too many advocates for too many programming languages have made attemts to make their programming language choosen - and I won't exclude myself from that list.

As a result the text is now very confusing to a reader looking for advice on what language to learn -.

I have changed the Programming_Languages chapter to be a platform for language advocates to be heard. I suggest we allow only a short text per language on the sole subject of "Why learn this language".

All language advocacy from the chapter Choosing_a_programming_language should be removed and be replaced by a more neutral poins of view.

Fundamental decisions
I agree with the top bit. Basically, this book is suffering from too-many-cooks syndrome.

Now, what I will argue is that our job here is to teach beginners how to program, and that anything which does not teach beginners how to program should be swept away. I will also argue that complete neutrality is going to be very unhelpful. While we do not want to fall into petty advocacy (use this compiler! use that!) we must do some steering. Instead of complete NPOV, I think we should should establish a rough consensus on the fundamental vision of our book. I'll start with some ideas and hope you folks make other proposals as well. -- Kowey 10:23, 9 Feb 2005 (UTC)

Advocates Playground
For the steering I have changed the layout of the Programming Languages chapter from simple list to definition list. If it is feelt that the definition list is still to tight for describing the languages whe can change to chapter layout.

Suitable teaching languages can describe themself without interfering with the main text or the description of other languages. The reader becomes a - hopefully - clear description an can then make an informed desicion.

Removing any reference to any language in all the other chapters will discurage "shame-less-plugs" - if somebody feals to need to advocate a language he/she will need to do properly in chapter 4.

--Krischik 11:48, 9 Feb 2005 (UTC)

Kowey's proposal

 * Ditch the whole "What language should I learn thing"... or at least, make it one of the last chapters in the book. Now that you have one or two ideas about programming, why don't you learn some other languages?
 * Teach fundamental notions: recursion, etc
 * Select one teaching language. I argue that the criteria to focus on is not how "useful" the language is, but how clearly we can communicate the fundamental concepts with it. Now this doesn't mean we don't mention the other languages, or say that this language is better than others, just that we choose to teach in that language.
 * I say we go for Caml or Python because users can get going right away without lots of confusing syntactic cruft.
 * ... more later


 * So more I think about it so more I am in favour of 'ditch the whole "What language should I learn thing"'. Anybody unhappy if I actualy do it? --Krischik 15:00, 16 Feb 2005 (UTC)

Algorithm Book
Actualy Chapter "2." itself is cool - it's only the child chapters "2.x.x" which are problematic.

For clarity and ease of learning I would always go for an Algol type language. The explicit use of "begin" and "end" make learning easier. And if I had to name one I would name Pascal. Pascal has been designed for learning and it shows. (Note: I am an Ada advocate).

However: the Computer_Science:Algorithms have made a good job of using a pseudocode language (also Algol based). They allow only "real" languages in the Appendix. And now guess what - the pseudocode language was so sucessfull than no-one ever felt the need to contribute any "real" languages examples.

I think we should follow.

Off Topic: if you are a Python advocate then please fill in the reason to learn Python.

--Krischik 11:48, 9 Feb 2005 (UTC)


 * That's funny, you're a Ada advocate recommending Pascal, and I'm a Caml/Haskell advocate recommending Python :-D I think that pseudocode is great for an algorithms course, but then again, the algorithms course is either for people who know (a) how to program, or (b) don't really care about programming proper (hard core mathy cs people?), whereas an actual programming course would benefit from a real-world language with which the user can try stuff out. That being said, I'm glad you're with me on pushing a language for its pedagogical merit and not its merit as a language in and of itself -- Kowey 14:05, 9 Feb 2005 (UTC)

Templates
But there are all ready enough real-world language courses - like me pet Programming:Ada. ( well, just checked Programming:Pascal - not much there :- - so we don't realy need one here.

But I just had an idea. Could we write the basics descriptions - like recursion - as templates and then use those templates povide the real articles in Programming:Ada, Programming:C etc. pp.?

For example "Programming:Ada:Hello World" would look like:

with Ada.Text_IO; procedure Hello is begin Ada.Text_IO.Put_Line("Hello, world!"); end Hello;

In "Computer_programming:Hello World" we describe what "Hello Word" does.

For us as authors we only have to think up the lessons once and yet we get many nice "Programming:XXX" books all looking similar.

I have created a Demo on what this could like: Programming:Function_overloading


 * Hmm... I was a bit worried about how you would handle the code interleaving, but you seem to implement it pretty well, with the semi-anonymous templates (0,1,etc). So far so good, I think this is a good idea. -- Kowey 17:11, 11 Feb 2005 (UTC)

Closing chapter and counting votes
There had been no new arguments for a while and the votes are 2-1 for removing pointless advocacy in "Choosing a programming language".

So today they go. There are down here if you think you need a last look at them:

What should I learn?
One immediate consideration when deciding which language to learn is how useful the language would be in the real world. Java and C or C++ would be a good choice if you want to write applications for a PC. Java is a very good language for large projects, as it sports sophisticated object-orientation and a large API. But C/C++ may be bad choices for beginners, as they are quite low level languages (of course, this choice depends on the programmer - if one is already familiar with the principles of computer architecture design, C may be a very good choice). Python is a very good first language because it is powerful, has a clean syntax, is dynamically typed and Open Source. Languages like PHP and Javascript will introduce more concepts like variables and fuctions, and may be familiar to the web-developer. For server-side apps (web apps) however you can use any language you want.

There are however, other factors that you should consider.

How suitable is the language for beginners?
Many programming languages are geared specifically to be easy to learn, such as BASIC or Pascal. However, they are sometimes criticised for lacking in power as they have a limited range of language features. One should remember that the primary purpose of these teaching languages is to learn how to write structured programs. For more advanced applications, one may need a more specialised and complex language.

Some programming languages (such as Python or Scheme), while suitable for beginners in that the syntax is not difficult, still offer a full range of language features for even the most advanced programmers.

Is the language available or suitable on your computer system?
It probably will be. When you have chosen your language to start with, you should seek an implementation of it for your platform. A quick search on the internet, including both the language and your platform, should give you some commercial and free implementations.

Older legacy computer systems may have been written in an early computer language, such as COBOL. In order to maintain or update these systems you may need to learn the language to read the original source code.

Will it help you learn other languages in the future?
The C-family (C, ObjectiveC, C++, C#, and Java) all resemble each other, so learning one would make learning others easier in some ways. Then again, superficial similarities can at times be confusing, and learning radically different kinds of language will help you adapt more easily to new languages in general.

Will it help you be a better programmer?
Learning academic languages like Prolog might not seem worthwhile if you want to jump into the job market; however, the purity of these languages forces you to refine the way you think about programming and teaches you skills which can then be transferred to other languages. Some might even argue that programming in these languages is so much more efficient that you would not want to bother with the rest, but since programming can often involve working for/with other people you will likely have to learn a popular language anyway.

How practical is the language?
Now we return to our first concern in choosing a learning language: how useful will this language be in the real world? Here you should consider how popular the language is, because working with people is inevitable and how appropriate the language is for the work you want to do is important. Unless you are pressed for time, it is recommended to take things slowly and focus on choosing a good learning language and worry about the practicality of that language later on.

Learn them all!
There are several philosophies about how you should go about this. One is:
 * 1) If you just want to dabble, go straight for a higher level language or a dynamic language like Python.
 * 2) If you want to be good, learn a higher level language, but also get a good grip on C and assembly language.
 * 3) If you want to be great, postpone both until you get the hang of academic languages like ML or Haskell.

But if your priorities are different, you may agree more with:
 * 1) If you want to portray yourself as an academic, try a language like ML.
 * 2) If you want to have a lot of trouble learning without accomplishing as much as you could, try languages like C and assembly language.
 * 3) If you want to get something done, use a high level scripting language like Python.

What languages should I use?
If you only have a hammer, you tend to see every problem as a nail. -- Abraham Maslow

Effectiveness
One trade-off between programming languages is speed of execution versus ease of coding. Writing in assembly language can result in the creation of the fastest and most compact program possible. The trade-off is that you may donate years of your life to creating the program, assuming it will be a moderately complex program and you will not be calling code from other higher level languages (which you must do if you write a program using libraries). Assembly language has an exact syntax that does very little with each command, since each command generally corresponds to only one or two processor instructions. There are dialects called Macro Assembly languages that relax this restriction.

Modern compilers can generate optimized assembly code significantly faster and more efficiently than humans; however due to the variety of syntax compilers must interpret they are unable to generate the most optimized assembly code possible. Therefore, many desiring maximum optimization use either mid or higher level compiled languages and manually optimize the compiler's optimized assembly code.

Modern techonological advancements, particularly faster processors, have reduced the dependence on refining the optimizations of a particular code in favor of merely increasing the system requirements.

Cost
To begin programming the novice does not need to invest vast sums of money; acquiring the skill is dependent more on the time invested in learning to program rather than the amount of money spent. While many of the most powerful (highly optimized and developed) compilers and development suites are expensive, many other tools exist that are completely cost-free. Commercial products are mostly used by professional programmers who need highly optimised compiling and highly refined development suites to maximize their productivity. If you choose to pursue programming as a vocation, you may eventually want to invest in one of these development environments, but while you are learning to program, take advantage of the free tools available to you.

Go for the Ease (an opinion)
Unless you will be working with speed-critical applications (not likely the case if you are reading an introduction to programming), the preferred language is one that makes programming easier. For starters, it is probably more interesting as a programmer to write software that works 'correctly' instead of quickly. Programming in a higher level language lets you avoid a lot of syntax and hides many wonderful opportunities to introduce bugs into your code.

Even if you do turn out to be a flawless machine code hacker, you'll also find that software tends to be long-lived and needs to be maintained, either by you ten years down the road, some anonymous underling in the ladder of your megacorporation, or one of millions of eyeballs in the open source community. Somebody is going to have to read and fix that code, so you might as well choose a language which helps them do this.

Finally, the question of speed is actually trickier than we presented above. Working with higher level languages could simplify programming enough for you to concentrate on solving the problem in an efficient way instead of relying on minor tweaks and hacks which will simply be washed away when the (hypothetical) next generation computer rolls out two weeks later.

Abstractions Leak (a counter-opinion)
We have hopefully convinced you that programming in a higher level language is generally better for your health. Yet if you take a look at the real world, you'll find many examples of people blissfully ignoring this sage advice. For example, both the Linux kernel and most GNU software such as GNOME are written in good old fashioned C.

The popularity of C can be partly tied to historical reasons. Before the development of C in the early 70s, computer programs were largely written in assembly language. At the time, there was a greater diversity of platforms, so programs in assembly language would have to ported from one platform to another in a time-consuming process. C was a major step forward, because relative to assembly language, it was a high level language, such that people could write their software once in C and have it automatically compiled to whatever platforms C was supported on. C's popularity is largely self-propagating; people continue to use C because it is a popular language that is nearly universally supported.

Relative to most modern languages, C is a very low-level language; it does not provide nearly as many abstractions over the "bare metal" as languages like Java. This low-levelness can be seen to be particularly well-adapted for software like the Linux kernel whose job is precisely to manipulate the bare metal.

The popular programming languages
The most used programming languages are probably C and C++. They are both very similar because C is almost a subset of C++, and thus, you can use a C++ Compiler to compile most ANSI-conformal C code. So if you learn C++, you are automatically learning the syntax of C. C and C++ are highly portable. However, C++ hasn't been ported to small systems like microcontrollers and embedded engines. Some say that C code is faster than C++, but it depends on the programmer. There are C programs with ugly slow style and real fast C++ programs written in a clean reasoned object-oriented style. Some say the object-oriented stuff of C++ eases bug-cleaning leading to more secure programs. The two languages can be mixed on most compilers when the need arises.

Another commonly used language is Java. One advantage is that Java "executables" (more precisely, they are called "byte codes") can be run on many systems (almost always) completely unchanged. This is because byte codes are not executed directly by the processor, but by a piece of software known as a virtual machine, a computer within a computer so to speak. Initially, the added complexity of using a virtual machine slowed Java enough to provoke bitter complaints from users and developers, but several techniques have been used to improve its performance considerably. Java's structure and syntax is similar to C++ so if you know C++ you can easily learn Java; however, learning C++ after Java might require mastery of a few more concepts.

BASIC (e.g. Visual Basic or QBasic) is also commonly used. It is very easy to program with and Visual Basic is used for many things today in Windows programming just because it is easy.

Assembly is not as heavily used today as it once was, but learning it will greatly help you understand how a computer works, and how to better structure high level code. However, a knowledge of assembly language is vital if you wish to program low-level system routines for different hardware.

More code is written in COBOL than any other language (there are estimates that COBOL accounts for 70% of existing code), but few new programs are being written in COBOL. There is, however, constant demand for programmers who can maintain old COBOL programs.

Language is often a trivial factor in program speed, with the exception of CPU bound code written in languages that are usually interpreted (rather than compiled). If a bottleneck in your program is network speed, changing programming language won't help you out. If you must optimize, first make sure you actually know where the bottlenecks are, then look at things like algorithms. Other factors like checking if you're accessing the memory sequentially rather than randomly, may also be important at times. Re-writing in assembly is a last resort; at times it can yield excellent results, but a compiler beats a novice assembly programmer easily. Assembly sacrifices portability; while knowing it is a useful skill, using it in a large program should be a last resort. As assembly is so low-level, each processor architecture has to be specifically written for; a program written in assembly for a PC will need an extensive rewrite to be run on an ARM CPU. Higher-level languages are far more portable, as the compiler handles the translation of the language into the assembly code for the system's processor architecture.

Another distinction must be made between scripting languages and very-high-level languages and other languages. Scripting languages, like Perl are interpreted languages that have been designed for performing short tasks with speed and ease of coding, often offering elastic syntax and allowing you to shrink complex tasks into just a dozen lines of code. They have been successfully implemented to solve day-to-day problems and not to build up complex, monolithic applications, although there are exceptions (Python-based applications, like MayaVi or Zope, are a notable example). Because of this, most dynamic languages these days will compile the code on the fly, whenever possible just in time, so that they run as fast as C in most cases. For example, there is no real speed difference between C and Lisp any more.