Bjarne Stroustrups and More Problems With Programming
Phoe6 writes "As a follow up to the first part of his interview, Technology Review Magazine has another article running titled 'More Trouble with Programming'. Bjarne Stroustrup shares his point of view on good software, bad software design and aspect oriented programming." From the article: "Technology Review: Name the coolest and lamest programs ever written in C++, and say what worked and didn't work. Bjarne Stroustrup: Google! Can you even remember the world before Google? (It was only five years ago, after all.) What I like about Google is its performance under severe resource constraints. It possesses some really neat parallel and distributed algorithms. Also, the first Web browsers. Can you imagine the world without the Web? (It was only about 10 years ago.) Other programs that I find cool are examples of embedded-systems code: the scene-analysis and autonomous driving systems of the Mars Rovers, a fuel-injection control for a huge marine engine. There is also some really cool code in Photoshop's image processing and user interfaces."
This site is about new spam, not accuracy, so keep your hopes down. Gems like this hidden in the muck of Microsoft bug articles (which are needed to pay the bills) still make Slashdot useful.
Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
Can you find the bug in this C++ program?
---- begin bugdemo.h ----
template<class T> void doprint(T obj) { printf("The numbers are: %d %d\n",obj.num1,obj.num2);}
void foo(void);
void bar(void);
---- end bugdemo.h ----
---- begin bugdemo.cc ----
#include "bugdemo.h"
int main(int argc, char *argv[])
{
foo();
bar();
return 0;
}
---- end bugdemo.cc ----
---- begin foo.cc ----
#include <stdio.h>
#include "bugdemo.h"
struct A {
int num1,num2;
};
void foo(void)
{
A myobj;
myobj.num1=-5;
myobj.num2=6;
doprint(myobj);
}
---- end foo.cc ----
---- begin bar.cc----
#include <stdio.h>
#include "bugdemo.h"
struct A {
short num1,num2;
};
void bar(void)
{
A myobj;
myobj.num1=-5;
myobj.num2=6;
doprint(myobj);
}
---- end bar.cc ----
This program seems to be intended to generate:
The numbers are: -5 6
The numbers are: -5 6
But instead generates:
The numbers are: -5 -1
The numbers are: -5 6
or perhaps something different altogether.
The problem is portable across platforms and compilers (although the exact incorrect answers sometimes vary).
Hey, Guess what's cooler ...
program MyProg;
uses
CRT;
begin
Writeln('Hello World!');
end.
...Doesn't duck because he knows that any real pascal programmer could beat any C++ pussy down
P.S. - C++ isn't too bad, but Pascal is way cooler.
I am Spartacus