Ranieri Teixeira wrote:
I've downloaded the sources of Ruby 1.8.7-p22 and compiled it with MS CL
compiler.
What a pain! Next time, get CygWin, and compile with GNU C.
> Ok, very well. But, the code is in structured C, not in object
oriented C++. Why? C++ doesn't provides the sabe low level facilities as C
and the powerful abstractions, and good practices from the OOP paradigm?
All system-level engines are written in C, not C++. C has been a Standard for much longer, and has more compliant compilers. So any engine that wants to run on the widest number of platforms must use C. It compiles for everything from wristwatches to Mars Rovers.
It may well compile for them, but there are systems where even diet libc would be too heavy a runtime requirement which is why many embedded applications still use assembly language.
The point of OOP is rapid code changes. That contradicts the goal of
super-widespread portability. No matter what your language, you must
chose one or the other, not both.
The point of OOP is that it cleanly encapsulates code and data to form discrete black boxes. This makes it easier to design complex systems and ideally reduces the volume of code which has to be remembered. This can have the added benefit of enabling rapid code changes, but it's by no means the main advantage.
The slow uptake of C++ for system-level coding owes much to the historic poor performance of compilers in optimising virtual function calls and the memory footprint of the runtime. In recent years both considerations have become less important, but in the embedded sector there is still a preference for assembly language and imperative languages such as C or BASIC.
However even in the mid-90's people were demonstrating that C++ could be every bit as speedy as C in real-world applications where memory footprint was of lesser importance. Go play with a copy of BeOS which was written in C++ and you'll see what I mean: it was running rings around both the MacOS and Windows of its day. It was also portable, being compilable with the Metrowerks compiler on PowerPC and GCC 2.95 on x86.
Ellie
Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
···
On 11 Jul 2008, at 02:31, phlip wrote:
----
raise ArgumentError unless @reality.responds_to? :reason