Programozási evolúció
Az alábbi példákon nyomon követhetjük a programozó szakmai fejlődésének állomásait. Lássuk tehát, hogyan készíti el a klasszikus "Hello World" programot, életének különböző szakaszaiban:
Gimnazista
10 PRINT "HELLO WORLD"
20 END
Elsős egyetemista
program Hello(input, output)
begin
writeln('Hello World')
end.
Utolsó éves egyetemista
(defun hello
(print
(cons 'Hello (list 'World))))
Kezdő profi
#include
void main(void)
{ char *message[] =3D {"Hello ", "World"};
int i;
for(i =3D 0; i< 2; ++i)
printf("%s", message);
printf("\n");
}
Rafinált profi
#include
#include
class string{
private:
int size;
char *ptr;
public:
string() : size(0), ptr(new char('\0')) {}
string(const string &s) : size(s.size)
ptr =3D new char[size + 1];
strcpy(ptr, s.ptr);
}
string()
delete [] ptr;
}
friend ostream &operator <<(ostream &, const string &);
string &operator=3D(const char *);
};
ostream &operator<<(ostream &stream, const string &s){
return(stream << s.ptr);
}
string &string:
perator=3D(const char *chrs){
if (this !=3D &chrs)
delete [] ptr;
size =3D strlen(chrs);
ptr =3D new char[size + 1];
strcpy(ptr, chrs);
return(*this);
}
}
int main(){
string str;
str =3D "Hello World";
cout << str << endl;
return(0);
}
Mesterprogramozó
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
library LHello
// bring in the master library
importlib("actimp.tlb");
importlib("actexp.tlb");
// bring in my interfaces
#include "pshlo.idl"
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
interface IHello;
interface IPersistFile;
};
};
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
// some code related header files
Kezdő buherátor
#!/usr/local/bin/perl=20
$msg=3D"Hello, world.\n";=20
if ($#ARGV =3D 0) {=20
while(defined($arg=3Dshift(@ARGV))) {=20
$outfilename =3D $arg;=20
open(FILE, "" . $outfilename) ll die "Can't write $arg: =
$!\n";=20
print (FILE $msg);=20
close(FILE) ll die "Can't close $arg: $!\n";=20
}=20
} else {=20
print ($msg);=20
}=20
1;=20
Tapasztalt buherátor
#include=20
Rafinált buherátor
cc -o a.out /src/misc/hw/hw.c=20 % a.out=20
Nagymester buherátor
cat Hello, world.
Újdonsült menedzser
10 PRINT "HELLO WORLD"
20 END
Középvezető menedzser
mail -s "Hello, world." bob@b12 Bob, tudnal
nekem holnapra irni egy programot, ami kiirja a
kepernyore, hogy "Hello world"? Koszi!
Vezető menedzser
zmail jim Delutanra szuksegem van egy "Hello
Word" programra.
Vezérigazgató
letter letter: Command not found.
mail To: ^X ^F ^C % help mail help: Command not found.
faszom! !: Event unrecognized
logout