D vs Java
Anders F Björklund
afb at algonet.se
Tue Mar 21 01:08:49 PST 2006
Georg Wrede wrote:
> Hmm. Compared with D "Hello World", I'm getting worried.
D programs are bigger than C and Java, but smaller than C++ ?
Here are some old Hello test results I had: (on Mac OS X 10.3)
31b hello.sh (script)
Hello, World!
0.01 real 0.00 user 0.00 sys
12K hello_c (executable)
Hello, World!
0.03 real 0.00 user 0.00 sys
368K hello_cpp (including libstdc++)
Hello, World!
0.09 real 0.00 user 0.02 sys
104K hello_d (including Phobos)
Hello, World!
0.04 real 0.01 user 0.01 sys
637b hello.jar (archive)
Hello, World!
0.66 real 0.38 user 0.19 sys
Results for C, C++, D, Java 1.4 and Bourne Shell respectively...
If the Java runtime comes with the system, Java's really small !
(then again, it's also the far slowest to start up and execute
which makes it less suitable for small programs like this one)
BTW:
Having a programming language that needs separate compilation
as a first language is pretty mean I think. But that's just me.
(better to go with a scripting language, such as Ruby or Python ?
and it avoids having to unlearn things picked up from Pascal...)
But I learned Pascal in school, and Ada in university. Hated both. :)
I think you need to learn at least three languages. Preferrably more.
--anders
PS.
#!/bin/sh
echo "Hello, World!"
-----------------------------------------
#include <stdio.h>
int main(int argc, char *argv[])
{
puts("Hello, World!");
return 0;
}
-----------------------------------------
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello, World!" << endl;
return 0;
}
-----------------------------------------
import std.stdio;
void main()
{
writeln("Hello, World!");
}
-----------------------------------------
public class hello
{
public static void main(String[] args)
{
System.out.println("Hello, World!");
}
}
More information about the Digitalmars-d
mailing list