After a while websites start to look the same:
Af
And most websites use the same server-side programming language:
And the other programming languages look the same.
PHP
PHP supports classes these days:
class Person {
public $firstName;
public $lastName;
public function __construct($firstName, $lastName = '') { //Optional param
$this->firstName = $firstName;
$this->lastName = $lastName;
}
public function greet() {
return "Hello, I’m " . $this->firstName . " " . $this->lastName . ".";
}
public static function staticGreet($firstName, $lastName) {
return "Hello, I’m " . $firstName . " " . $lastName . ".";
}
}
$he = new Person('John', 'Smith');
$she = new Person('Sally', 'Davis');
$other = new Person('iAmine');
C#
At a cursory glance besides the dollars C# classes are the same:
class Person
{
// Field
public string name;
// Constructor that takes no arguments.
public Person()
{
name = "unknown";
}
// Constructor that takes one argument.
public Person(string nm)
{
name = nm;
}
// Method
public void SetName(string newName)
{
name = newName;
}
}
class TestPerson
{
static void Main()
{
// Call the constructor that has no parameters.
Person person1 = new Person();
Console.WriteLine(person1.name);
person1.SetName("John Smith");
Console.WriteLine(person1.name);
// Call the constructor that has one parameter.
Person person2 = new Person("Sarah Jones");
Console.WriteLine(person2.name);
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
The differences between Microsoft’s C# and Sun’s Oracle’s Java are even smaller.
TypeScript
Microsoft’s TypeScript is yet another language to JavaScript compiler, this time from Anders Hejlsberg inventor of Java C#.
class Person {
private name: string;
private age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
toString(): string {
return this.name + " (" + this.age + ")";
}
}
TypeScript code looks like C# and PHP.
ActionScript
TypeScript also looks a lot like ActionScript 3:
package com.example
{
import flash.text.TextField;
import flash.display.Sprite;
public class Greeter extends Sprite
{
public function Greeter()
{
var txtHello:TextField = new TextField();
txtHello.text = "Hello World";
addChild(txtHello);
}
}
}
Class declarations and type annotations in TypeScript and ActionScript look almost identical. ActionScript can be compiled to JavaScript or native code for iOS and Android using PlayScript.
Language wars
Looks like web developers using PHP, ASP.Net or Flash have quite a lot in common.