Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/blog.mzubairsaleem.com/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the advanced-ads domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/blog.mzubairsaleem.com/wp-includes/functions.php on line 6114
Comparison: Node.js, PHP, C, Go, Python and Ruby - Blog | M. Zubair Saleem

Comparison: Node.js, PHP, C, Go, Python and Ruby

I had fun doing performance tests after reading an article which had performance tests for Python.

I wanted to only test web back-end tech, but I still added in a test with C in order to compare everythig else with a low-level language.

Here is the code:

Python

sum = 0
for i in range(100000000):
sum += i
print(sum)

Ruby

$sum = 0
for $i in 0..100000000
$sum += $i
end
puts($sum)

Node.js

#!/usr/bin/env

var sum = 0
for (var i = 0; i < 100000000; i++) {
sum +=i
}
console.log(sum);

PHP

#!/usr/bin/php
<?php
$sum = 0;
for ($i = 1; $i < 100000000; $i++) {$sum += $i;} echo $sum + ‘n’?>

Go

package main

import “fmt”

func main() {
sum := 0
for i := 0; i < 100000000; i++ {
sum += i
}
fmt.Println(sum)
}

C

#include <stdio.h>

int main ()
{
int a;
int sum = 0;
for( a = 0; a < 100000000; a++ )
{
sum += a;
}
printf(“sum: %dn”, sum);
return 0;
}

Results:

Result

And the winner is… GO !

PS : Go here is 9x better than than C, but with good optimisation flags, C is faster.

Source