Le 2012-02-22 à 20:47:00, Krnk Ktz a écrit :
Sorry, I'm no professional programmer (I don't think i'm even good at it!) but it seems like you are describing a Turing Machine, which includes every programming language.
Well... no. I'm talking about Imperative languages, which is a very broad category of languages that includes almost all languages in common use. That category includes executables, ASM, C, C++, Perl/Python/Ruby/Lua, Tcl, shell scripts, Java/C#, and even PureData.
Turing Machines are also in Imperative languages, but nearly all other Imperative languages are based on the idea of Von Neumann machine instead (in which the tape memory is replaced by the concept of RAM). This idea is refined differently by each language to structure the manner in which RAM is used and thought of. Almost no languages are based directly on the idea of Turing Machine.
Turing Equivalence doesn't mean every programming language is a Turing Machine, it means that every sufficiently complete programming language is able to express the same computations as every other sufficiently complete programming language. It doesn't say how fast it can possibly run, nor how short the programme is, nor how hard it was to write it. Turing-completeness is really just concerned with whether it's possible to compute a given thing at all with a given language.
What matters is how you organise your code, how you think your program. In the end, it will actually be the same - both C and C++ build to ASM. However, C++ forces you to think of objects while C doesn't: that's another way of thinking and therefore another paradigm.
C++ does not actually force you to do anything with objects. It's designed for seamless transition from C (unlike Java, for example, which does enforce objects). Therefore you can compile C programmes almost as-is, with occasional search-and-replace for minor details.
C++ introductory books might teach you to do everything with objects and with <fstream> and teachers might forbid you from using printf() so that you use <fstream>, but that's all ideology. The compiler has little opinion about the shape of your programmes apart from whether it compiles and detecting some gotchas that are actual bugs. For mistakes that aren't clearly mistakes, the compiler will just let you learn.
That's how I have always seen languages: they try to help you to write programs like you think them. Every language brings you new ways of thinking programs. It seems also illogical to me to try thinking in a way which is not the one your tool does.
The language is quite bad at preventing you from thinking in different ways, and sometimes it's quite bad at preventing you from writing in different ways. Structuring programmes in an OOP way is sometimes simply the best way of writing a C programme using C techniques. There is no hard barrier between the two, hardly a paradigm shift at all. C++ was created as a preprocessor for writing code that would have otherwise been OOP in C already, for use by people who expanded on the concept of Structured Programming in the same manner that people nowadays expand on the concept of OOP.
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC