language comparision

Fitting all this information into a single table, on a single screen is very hard work indeed! Feel free to submit comments.
Over all, I see php as being the best language for web applications, it doesn't eat a whole trunk load of memory and has most of the features that one wishes from a webplatform. For system application development c and perl are my choice, one offers brilliant speed and the other offers source builds.

Every effort to keep this table correct has been taken, although no doubt there are some code -> web conversion errors, if you find any, please notify ed (at) s5h (dot) net, who shall correct the error.

Due to the obvious lack of space, things like colour highlighting and tabulation are long forgotten.

Errors? Suggestsions? Requests? Mail me, ed (at) s5h (dot) net, I promise to make requested additions, I've got nothing but time.

language
 perlc#cphpjsp/javapython
Learn-abilityModerately easy to learn, but there are many ways to skin a cat. Not /that/ similar to C languages due to peculiarities in syntax.The syntax and libraries are mostly like Java's, so anyone with a bit of C experience can get coding in C# in a matter of minutes.C is the grandfather of Java and c# and Perl. The syntax is strict and requires depth knowledge of the OS and hardware, in particular memory pointers.PHP is very fast, very simple and a lot like other c-style languages. This is ideal for anyone wishing to produce enterprise applications.C# has a lot of Java's style, but it's less open. JSP provides a good means of building web pages in a OOP environment. Java is a popular teaching language.Python is perhaps the best RAD solution, the language similarities with C end at printf syntax - even that strays with the % character!
PortabilityVery portable, nearly every Unix installation has a Perl interpreterC# is limited to platforms with .NET installed. MS platform programmers often reference proprietary DLLs and thus limit portability.Highly portable when programmed correctly. Is not portable for system administration.Very portable where PHP is installed, this includes compatibility with the worlds most popular web server!Very portable, most Java applications are written from scratch (unlike VS concoctions), and thus retain their portability to all targets that have JRE and JSP.Python is very portable, but can rely on third party modules to perform system level operations which could otherwise be done with wrappers written in c.
Speed of executionReasonably fast if the Perl binaries are cached in memory, otherwise the binary has to be copied to memory (roughly 5megabytes) before the program can run. Perl has a compiler, but it is not often used. Apache modules exist to help the execution of scripts, such as mod-perl and FastCGI.C# on Unix runs via the mono runtime. This too must be copied to memory before the program can run. However, the code is already in a interpreted state, so much parsing is done at compile time.C code is very close to machine assembler so execution is hard to optimize without doing serious benchmarks.PHP code is often run via mod_php, which handles DB connections and often reduces much of the overhead in PHP pages.Java 'beans' are classes held in memory of the webserver and can often reduce the execution time by far.Python at the webserver often runs via a shell execution of `python`, this causes an over head for the webserver, but modules do exist much like the PHP ones to handle many overheads. There are extensions such as FastCGI and mod-python to improve performance.
Requirements/Debian packagesPart of the base install.The C# compiler is part of the pnetc package. Mono is also available in testing.The GNU compiler is included in the gcc and g++ packages, projects may require the make packageThe php4 and php-cli packages enable most uses of phpThe Java binaries on the Sun site are among the best, in addition, for JSP pages you require the libapache-mod-jk and libservlet2.3-java packagesPython binaries are included in the default install under the package 'python'
Comments# comment// comment
/* comment */
/* comment */// comment
/* comment */
// comment
/* comment */
# comment
TypesScalar, Hash and meta typebool
byte sbyte
char
short ushort int uint long ulong
float double decimal
char
int
pointer
float
long
bool
boolean
array
meta type
boolean
byte
char
short int long
float double
str
int
list
bool
dict
float
Print textprint( "text", $my_var );Console.WriteLine( "text" + my_var );printf( "text%s", my_var );echo( "text", $my_var );System.out.println( "text" + my_var );print( "text %s" % my_var )
File readopen( F, 'file' );
my @lines = <F>;
close( F );
StreamReader sr = File.Open( "file" );FILE *fp = fopen( "file", "r+" );
fgets( char *s, fp, 100 );
$fp = fopen( "file", "r" );
$line = fgets( $fp, 100 )
BufferedReader br = new BufferedReader( new FileReader( "file" ) );
br.readLine();
file = open( "file" )
line = file.readline()
String bufferavailable from cpan as additional moduleusing System.Text.StringBuilder
StringBuilder sb = new StringBuilder();
sb.Append( "Text" );
Console.WriteLine( sb.ToString() );
char *s=(char *)malloc( 1000 )
strncpy( s, "text", 1000 ); // use realloc when nearing ceiling of *s, and free(s) when finished
StringBufer is available by third partyStringBuffer sb = new StringBuffer()
sb.append( "Text" );
System.out.println( sb.toString() );
import StringIO
sb = StringIO.StringIO()
sb.write( "Text" )
print sb.getvalue()
Arraysmy @array;
$array[0] = 1;
$array[1] = 2;
foreach my $a ( @array )
{
print( "$a\n" );
}
int array[] = new int[10];
array[0] = 1;
array[1] = 2;
for( int i=0 ; i<sizeof(array); i++ ) {
Console.WriteLine( array[i] );
}
int array[10];
array[0]=1;
array[1]=2;
for( int i=0;i<sizeof(array);i++){
printf( "%d\n", array[i] );
}
$array[0]=1;
$array[1]=2;
for( $i=0;$i<sizeof($array);$i++ ) {
echo( $array[$i] );
}
int array[] = new int[2];
array[0] = 1;
array[1] = 2;
for( int i=0 ; i<sizeof(array); i++ ) {
out.println(array[i] );
}
l = [1,2,3]
l = l+[4]
for i in l:
     print( "%d" %i )
Threadsuse Thread;
sub thread {
while( 1==1 ) {
print( "Thread running" );
sleep(1); } }

my @ar;
for( my $i=0; $i<5; $i++ ) $ar[$i] = Thread->new( \&thproc );


Also:
my i = fork();
fork returns 0 to the child, and the child pid to the parent process, and undef on error
public class threadtest {
public static int i=0;
public static void test() {
int j;
lock(j) {
j = i++;
}
while(true) {
Console.WriteLine( "thread " + j );
System.Threading.Thread.Sleep(1000);
}
}
public static void Main() {
for( int k=0 ; k<5 ; k++ ) {
Thread t = new Thread( new ThreadStart( test ) );
t.Start();
} } }
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>

pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int global_counter = 0;
void *allocations[4000];
void *thread_function() {
int somevar = 0;
pthread_mutex_lock( &mutex1 );
global_counter++;
somevar = global_counter;
pthread_mutex_unlock( &mutex1 );
while( 1 ) {
sleep(1);
fprintf( stdout, "thread %d ", somevar );
}
}
int main( int argc, char *argv[] ) {
int t[5], c;
pthread_t thread[5];
for( c=0 ; c<5; c++ ) {
if( ( t[c] = pthread_create( &thread[c], NULL, &thread_function, NULL ) ) ) {
fprintf( stderr, "could not create the thread: \
%d ", t[c] );
return( EXIT_FAILURE );
}
}
pthread_join( thread[0], NULL );
return( EXIT_SUCCESS );
}


Also:
int i = fork();
fork returns 0 to the child, and the child pid to the parent process.
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
echo( "parent" ); }
} else { echo( "child" );
}
public class ThreadTest implements Runnable {
static int i;
synchronized public int geti() {
return(++i);
} public ThreadTest() {
}
public void run() {
int k = geti();
while(1==1) {
System.out.println( "thread " + k );
try {
Thread.sleep(1000);
}
catch( java.lang.InterruptedException ie ) {
}
}
}
public static void main( String []args ) {
for( int i=0 ; i<5 ; i++ ) {
new Thread(new ThreadTest()).start();
}
}
}
#!/usr/bin/pythin
import threading,thread,time
c = 0
l = thread.allocate_lock()
def myth():
     global c
     l.acquire(0)
     c += 1
     i = c
     l.release()
     while 1:
         print( "thread %d " % i )
         time.sleep(1)
threads = []
for i in range( 0, 5 ):
     threads.append(threading.Thread(None, myth, None))
     threads[i].start()
while 1:
     pass
Regular expressionsmy $var;
if( $var =~ /string/ ) {
...
}
public static void Main() {
string s = "Text";
Match m = Regex.Match( s, "(.)+ext" ); if( m.Success ) {
Console.WriteLine( "Match" );
} }
No stdlib supportpreg_match( '/(Text)/', $var, $matches );
print_r( $matches );
import java.io.*;
import java.util.regex.*;
public class RegexTest {
public static void main( String []args ) {
Pattern p = Pattern.compile( "^(Te)(st)$" );
Matcher m = p.matcher( "Test" );
if( m.matches() ) {
for( int i=0 ; i System.out.println( m.group(i) );
}
}
}
}
import re
str = "Text"
lst = re.findall( r'(Te)(xt)', str )
print lst