ACCUEIL CONTACT BANNIERES LIENS PLAN
francais anglais
MUSIQUE
CREATION 2D/3D
INFORMATIQUE
TELECHARGEMENTS




PC-INFOGAME.COM : Tableau comparatif de la syntaxe de différents langages

Java VB.Net Delphi
C PHP Javascript

Syntaxe sensible à la casse ?

Java Oui
VB.Net Non
C Oui
Delphi Non
PHP Oui pour les noms de variables et fonctions utilisateurs
JS Oui


Programmation orientée objet possible ?

Java Oui
VB.Net Oui
C Non
Delphi Oui
PHP Oui
JS Non


Transtypage / Cast obligatoire ?

Java Oui
VB.Net Facultatif (sauf avec les options explicit et strict activées)
C Oui
Delphi Oui
PHP Facultatif
JS Facultatif


Présence des pointeurs ?

Java Non
VB.Net Non
C Oui
Delphi Oui
PHP Non
JS Non


Caractère de fin d'instruction

Java Point-virgule
VB.Net Aucun
C Point-virgule
Delphi Point-virgule
PHP Point-virgule
JS Point-virgule


Déclaration du programme / script

Java
VB.Net
C
Delphi
PHP <?php script ?>
JS <script language="javascript"> script </script>


Bloc d'instructions

Java {
 instructions 
}
VB.Net
C {
 instructions 
}
Delphi begin
 instructions 
end
PHP {
 instructions 
}
JS {
 instructions 
}


Ecrire une chaîne de caractère

Java ' texte' ou " texte"
VB.Net " texte"
C ' caractère' ou " texte"
Delphi ' caractère'
PHP ' texte' ou " texte"
JS ' texte' ou " texte"


Commentaire sur une ligne

Java // commentaire
VB.Net ' commentaire
C // commentaire
Delphi // commentaire
PHP // commentaire
JS // commentaire


Commentaire sur plusieurs lignes

Java /*
commentaire
*/
VB.Net
C /*
commentaire
*/
Delphi {
commentaire
}
PHP /*
commentaire
*/
JS /*
commentaire
*/


Caractères spéciaux

Java \n, \t, \r, \b, \f, \ (échappement)
VB.Net vbCr (=Chr(13)), vbLf (=chr(10)), vbCrLf (=Chr(13) + Chr(10) ), vbTab (=Chr(9) ), vbBack (=Chr(8))
C \n, \t, \r, \b, \f, \ (échappement)
Delphi #13#10 (retour à la ligne)
PHP \n, \t, \r, \b, \f, \ (échappement)
JS \n, \t, \r, \b, \f, \ (échappement)


Chaîne de caractères

Java string
VB.Net string
C Tableau de caractères : char[ ]
Delphi string
PHP string
JS string


Entier

Java byte, char, short, int, long
VB.Net byte, char, short, integer, long, decimal
C char, short, int, long
Delphi byte, char, short, integer, long
PHP integer
JS number


Flottant

Java float, double
VB.Net single, double
C float, double
Delphi single, double
PHP float
JS number


Booléen

Java boolean
VB.Net boolean
C bool (ANSI C99)
Delphi boolean
PHP boolean
JS boolean


Tableau

Java array
VB.Net array
C nomType [ ]
Delphi array
PHP array
JS array


Vide

Java void
VB.Net
C void
Delphi
PHP
JS Undefined, void


Nul

Java null
VB.Net nothing
C NULL
Delphi nil
PHP null
JS NULL


Définir une variable globale

Java Attribut de classe (voir notions objets)
VB.Net Attribut de classe (voir notions objets) ou création d'un module
C static
Delphi A déclarer dans la section Interface
PHP global. Appartiennent au tableau associatif : $GLOBALS
JS Variable déclarée sans le mot-clé var


Promotion entière vers le type

Java int
VB.Net
C int
Delphi
PHP
JS


Promotion flottante vers le type

Java double
VB.Net
C
Delphi
PHP
JS


Indice de départ d'un tableau

Java 0
VB.Net 0
C 0
Delphi 0
PHP 0
JS 0


Valeur de TRUE

Java 1
VB.Net 1
C Différent de 0
Delphi 1
PHP 1
JS 1


Valeur de FALSE

Java 0
VB.Net 0
C 0
Delphi 0
PHP 0
JS 0


Déclaration d'une variable

Java typeVariable nomVariable
VB.Net Dim nomVariable as typeVariable
C typeVariable nomVariable
Delphi nomVariable : typeVariable
PHP $nomVariable
settype($nomVariable, typeVariable)
JS var typeVariable nomVariable


Déclaration d'une constante

Java final typeConstante nomConstante
VB.Net Const nomConstante as typeConstante
C const typeConstante nomConstante
Delphi const typeConstante nomConstante
PHP define(nomConstante, valeurConstante) (pas de $)
JS const typeConstante nomConstante


Déclaration d'une fonction

Java typeRetour nomFonction (type var1, type var2, ...)
VB.Net Function nomFonction (var1 as type, var2 as type, ...) as typeRetour
C typeRetour nomFonction (type var1, type var2, ...)
Delphi nomFonction(var1 : type ; var2 : type; ...) : typeRetour
var
//Variables

begin
//Code
end;
PHP function nomFonction (var1, var2, ...)
function nomFonction (nomClasse objet1, nomClasse objet2, ...)
Le typage est possible (mais facultatif) pour les objets uniquement.
JS function nomFonction (var1, var2, ...)


Retour de valeur d'une fonction

Java return valeur
VB.Net return valeur
C return valeur
Delphi return valeur
PHP return valeur
JS return valeur


Déclarer une procédure

Java void nomProcedure (type var1, type var2, ...)
VB.Net Sub nomProcedure (var1 as type, var2 as type, ...)
C void nomProcedure (type var1, type var2, ...)
Delphi nomFonction(var1 : type ; var2 : type; ...)
var
//Variables

begin
//Code
end;
PHP function nomFonction (var1, var2, ...)
function nomFonction (nomClasse objet1, nomClasse objet2, ...)
Le typage est possible (mais facultatif) pour les objets uniquement.
JS function nomFonction (var1, var2, ...)


Appel d'une méthode

Java nomMethode(param1, param2)
VB.Net nomMethode(param1, param2)
C nomMethode(param1, param2)
Delphi nomMethode; (si aucun paramètre)
nomMethode(param1, param2)
PHP nomMethode(param1, param2)
JS nomMethode(param1, param2)


Déclarer une structure

Java
VB.Net Structure
 Dim nomVariable As typeVariable 
Dim nomVariable As typeVariable
End Structure
C struct nomStructure{
 type nomChamp; 
type nomChamp;
} [nomStructure];
Delphi type nomStructure=Record
 nomVariable : typeVariable; 
nomVariable : typeVariable;
end;
PHP
JS


Accès à un champ d'une structure

Java
VB.Net nomStructure.nomChamp
C nomStructure.nomChamp
nomStructurePointee->nomChamp
Delphi nomStructure.nomChamp
PHP
JS


Point d'entrée du programme

Java public static void main(String[] args)
VB.Net Public Shared Sub Main(args As String( ) )
C int main(int argc, char **argv)
Delphi
PHP
JS


Passage par valeur

Java Par défaut pour les types primitifs.
VB.Net Par défaut pour les types primitifs (mention de ByVal).
C Par défaut pour les types primitifs.
Delphi Par défaut pour les types primitifs.
PHP Par défaut pour les types primitifs.
JS Par défaut pour les types primitifs.


Passage par adresse

Java Par défaut pour les objets.
VB.Net Par défaut pour les objets. Mention de ByRef pour les types primitifs.
C Par défaut pour les tableaux, stuctures. Utilisation des pointeurs pour les types primitifs.
Delphi Par défaut pour les objets. Utilisation des pointeurs ou de la mention var pour les types primitifs.
PHP Par défaut pour les objets.
JS Par défaut pour les objets.


Condition

Java if (condition) {

}
else {

}
VB.Net If condition Then

Else

End If
C if (condition) {

}
else {

}
Delphi if condition then
begin

end
                 else
begin

end;
PHP if (condition) {

}
else {

}
JS if (condition) {

}
else {

}


Condition multiple

Java switch (variable) {
 case valeur : instructions; break; 

default : instructions; break;
}
VB.Net Select variable
 Case valeur 
instructions
exit

Case else
instructions
exit
End Select
C switch (variable) {
 case valeur : instructions; break; 

default : instructions; break;
}
Delphi Case valeur of
 valeur : begin
instructions
end;
else : begin
instructions
end;
end;
PHP switch (variable) {
 case valeur : instructions; break; 

default : instructions; break;
}
JS switch (variable) {
 case valeur : instructions; break; 

default : instructions; break;
}


Boucle de (valeur depart) à (valeur arrivée)

Java for (initialisation ; condition ; incrémentation) {

}
VB.Net For variable = valeurDepart To valeurFin

Next
C for (initialisation ; condition ; incrémentation) {

}
Delphi for variable :=valeurDepart to valeurFin do
begin

end;
PHP for (initialisation ; condition ; incrémentation) {

}
JS for (initialisation ; condition ; incrémentation) {

}


Tant que / Jusqu'à ce que (condition) Faire

Java while (condition) {

}
VB.Net While condition

End While


Do While / Until condition

Loop
C while (condition) {

}
Delphi while condition do
begin

end;
PHP while (condition) {

}
JS while (condition) {

}


Faire tant que/ Jusqu'à ce que (condition)

Java do {

}
while (condition)
VB.Net Do

While / Until condition
C do {

}
while (condition)
Delphi repeat

until condition ;
PHP do {

}
while (condition)
JS do {

}
while (condition)


Pour chaque (élément) dans (liste)

Java for (typeElement variableElement : variableListe) {

}
VB.Net For Each variableElement [As typeElement] In variableListe

Next
C
Delphi
PHP foreach($variableListe as $variableElement) {

}
JS for (variableElement in variableListe) {

}


Avec (objet) Faire

Java
VB.Net With variableObjet

End With
C
Delphi with variableObjet do
begin

end;
PHP
JS with (variableObjet) {

}


Stopper une boucle

Java break
VB.Net exit
C break
Delphi
PHP break
JS break


Poursuivre une boucle

Java continue
VB.Net continue
C continue
Delphi
PHP continue
JS continue


Affectation

Java =
VB.Net =
C =
Delphi :=
PHP =
JS =


Arithmétique

Java +, -, *, /, %
VB.Net +, -, /, \, *, %, ^
C +, -, *, /, %
Delphi +, -, /, *, mod, div
PHP +, -, *, /, %
JS +, -, *, /, %


Composés

Java +=, -=, *=, /=
VB.Net +=, -=, /=, \=, *=, %=, ^=, &=
C +=, -=, *=, /=, &=, |=, <<=, >>=
Delphi
PHP +=, -=, *=, /=, %=, .=
JS +=, -=, *=, /=, %=


Incrémentation et décrémentation

Java ++, --
VB.Net
C ++, --
Delphi
PHP ++, --
JS ++, --


Comparaison

Java ==, !=, !, <, >, <=, >=
VB.Net =, <>, <, >, <=, >=
C ==, !=, !, <, >, <=, >=
Delphi =, <>, <, >, <=, >=
PHP ==, !=, !, <>, <, >, <=, >=, ===, !== (types)
JS ==, ===, !=, !==, !, <, >, <=, >=


Ternaire

Java (condition) ? code si vrai : code si faux
VB.Net
C (condition) ? code si vrai : code si faux
Delphi
PHP (condition) ? code si vrai : code si faux
JS (condition) ? code si vrai : code si faux


Bit à bit

Java &, |, ^, >>, <<, >>>
VB.Net <<, >>
C &, |, ^, ~, <<, >>
Delphi and, nor, or, xor, shl, shr
PHP &, |, ^, >>, <<, ~
JS &, |, ^, ~, >>, <<, >>>


Logique

Java &&, ||, !
VB.Net and, or, xor, not
C &&, ||, !
Delphi and, nor, or, xor
PHP and, or, xor, !, &&, ||
JS &&, ||, !


Concaténation

Java +
VB.Net &
C
Delphi +
PHP .
JS +


Ensemble

Java
VB.Net in
C
Delphi in
PHP
JS in


Tableau

Java [ ]
VB.Net ( )
C [ ]
Delphi [ ]
PHP [ ]
JS [ ]


Transtypage / Cast

Java (type) variable
VB.Net CType(nomVariable, typeVariable)
DirectCast(nomVariable, typeVariable) (variable par référence)
Val / String
Classe Convert
C (type) variable
Delphi (type) variable
PHP (type) variable
JS


Contrôle d'erreur

Java
VB.Net
C
Delphi
PHP @
JS


Adresse (pointeur)

Java
VB.Net
C &nomVariable
Delphi @nomVariable
PHP &nomVariable
JS


Contenu (pointeur)

Java
VB.Net
C *nomVariable
Delphi ^nomVariable
PHP
JS


Héritage multiple ?

Java Non
VB.Net Non
C
Delphi Non
PHP Non
JS


Classe

Java class NomClasse {

}
VB.Net Class NomClasse

End Class
C
Delphi type NomClasse = class

end.
PHP class NomClasse{

}
JS


Interface

Java interface NomInterface
VB.Net interface NomInterface
C
Delphi type NomInterface = interface
PHP interface NomInterface
JS


Classe abstraite

Java abstract NomClasseAbstraite
VB.Net MustInherit NomClasseAbstraite
C
Delphi
PHP abstract NomClasseAbstraite
JS


Classe non dérivable

Java final NomClasse
VB.Net NotInheritable NomClasse
C
Delphi
PHP final NomClasse
JS


Héritage d'une classe

Java ClasseFille extends ClasseMere
VB.Net ClasseFille Inherits ClasseMere
C
Delphi type ClasseFille = class(ClasseMere)
PHP ClasseFille extends ClasseMere
JS


Implémentation d'une interface

Java NomClasse implements NomInterface
VB.Net NomClasse Implements NomInterface
C
Delphi type NomClasse = class(NomInterface)
PHP NomClasse implements NomInterface
JS


Attribut

Java typeAttribut nomAttribut
VB.Net nomAttribut As typeAttribut
C
Delphi nomAttribut : typeAttribut
PHP $nomAttribut
JS


Constante

Java final typeConstante nomConstante
VB.Net Const nomConstante As typeConstante
C
Delphi
PHP const nomConstante (pas de $ car définie à la compilation)
Accès par nomClasse : : nomConstante
JS


Variable statique

Java static typeVariable nomVariable
Accès : NomClasse.nomVariable
VB.Net Shared nomVariable As typeVariable
Accès : NomClasse.nomVariable
C
Delphi
PHP static $nomVariable
Accès : NomClasse : : nomVariable
JS


Accès aux attribut de l'objet

Java nomObjet.nomAttribut
VB.Net nomObjet.nomAttribut
C
Delphi nomObjet.nomAttribut
PHP nomObjet->nomAttribut (pas de $)
JS nomObjet.nomAttribut


Méthode abstraite

Java abstract nomMethode
VB.Net MustOverride nomMethode
C
Delphi abstract nomMethode
PHP abstract nomMethode
JS


Méthode statique

Java static nomMethode
VB.Net Shared nomMethode
C
Delphi
PHP static nomMethode
JS


Rédéfinition possible d'une méthode

Java
VB.Net Overridable nomMethode
C
Delphi virtual nomMethode
PHP
JS


Rédéfinition impossible d'une méthode

Java final nomMethode
VB.Net NotOverridable nomMethode
C
Delphi
PHP final nomMethode
JS


Rédéfinition d'une méthode

Java
VB.Net Overrides nomMethode
C
Delphi override nomMethode
PHP
JS


Surchage d'une méthode

Java
VB.Net Overloads nomMethode
C
Delphi overload nomMethode
PHP
JS


Synchronisation

Java synchronized nomMethode
VB.Net synclock nomMethode
C
Delphi
PHP
JS


Appel d'une méthode héritée

Java nomObjet.nomMethode(param1, param2 ...)
VB.Net nomObjet.nomMethode(param1, param2 ...)
C
Delphi inherited [nomMethode] (méthode spécifiée sinon c'est celle en cours)
PHP nomObjet->nomMethode(param1, param2 ...)
JS


Accèx méthodes d'un objet

Java nomObjet.nomMethode(param1, param2 ...)
VB.Net nomObjet.nomMethode(param1, param2 ...)
C
Delphi nomObjet.nomMethode(param1, param2 ...)
PHP nomObjet->nomMethode(param1, param2 ...)
JS nomObjet.nomMethode(param1, param2 ...)


Définition du constructeur

Java public NomClasse(type param1, type param2 ...)
VB.Net public Sub New(param1 As type, param2 As type ...)
C
Delphi constructor nomConstructeur (param1 : type, param2 : type ...)
PHP public function __construct (param1, param2 ...)
JS


Définition du destructeur

Java public finalize()
VB.Net Public Overloads Sub Dispose()
C
Delphi destructor nomDestructeur( )
PHP public function __destruct( )
JS


Accesseurs : get / set

Java Pas de méthodes propres au langage.

Récupérer un attribut :

public getNomAttribut() {
 return nomAttribut; 
}

Renseigner un attribut :

public setNomAttribut(typeAttribut valeurAttribut) {
    nomAttribut=valeurAttribut;
}
VB.Net Public Property nomPropriete() As typePropriete
    Get
        Return valeurAttribut
    End Get
Set(ByVal valeurAttribut As typeAttribut) nomAttribut = valeurAttribut End Set
End Property
C
Delphi property nomPropriete : typePropriete
   read nomChamp;      //Lecture
   write nomMethode;   //Ecriture
PHP Pas de méthodes propres au langage.

Récupérer un attribut :

public getNomAttribut() {
 return $this->nomAttribut; 
}

Renseigner un attribut :

public setNomAttribut(typeAttribut valeurAttribut) {
    $this->nomAttribut=valeurAttribut;
}
JS


Classe de l'objet racine

Java Object
VB.Net Object
C
Delphi TObject
PHP
JS


Instanciation d'un objet

Java ClasseObjet nomObjet = new ClasseObjet(parametres)
VB.Net Dim nomObjet As New ClasseObjet(parametres)
C
Delphi nomObjet : ClasseObjet
nomObjet.create(parametres)
PHP $nomObjet=new ClasseObjet(parametres)
JS


Destruction d'u objet

Java nomObjet.finalize()
VB.Net nomObjet.Finalize() (libération différée de la mémoire par le garbage collector)

nomObjet.Dispose() (libération immédiate de la mémoire)
C
Delphi nomObjet.free
PHP nomObjet.destruct()
unset(nomVariable)
JS


Objet courant

Java this
VB.Net Me
C
Delphi self
PHP $this
JS this


Classe mère

Java super
VB.Net MyBase
C
Delphi
PHP parent :: nomMethode
JS


Objet instance de (classe) ?

Java nomObjet instanceof nomClasse
VB.Net TypeOf nomObjet Is nomClasse
C
Delphi nomObjet is nomClasse
PHP nomObjet instanceof nomClasse
is_[type] pour les types primitifs
JS nomObjet instanceof nomClasse


Public

Java public
VB.Net public
C
Delphi public
PHP public
JS


Privé

Java private
VB.Net private
C
Delphi private
PHP private
JS


Protégé

Java protected
VB.Net Protected
C
Delphi protected
PHP protected
JS


Package

Java (par défaut)
VB.Net Friend
C
Delphi published (?)
PHP
JS


Classe des exceptions

Java Exceptions
VB.Net Exception
C
Delphi Exception
PHP Exceptions
JS


Capturer une exception

Java try {

}
catch (Exception e) {

}
finally {

}
VB.Net Try

Catch ex As Exception

Finally

End Try
C
Delphi Try

Except
  On e : Exception Do 
End;
PHP try {

}
catch (Exception $e) {

}
JS try {

}
catch (Exception e) {

}
finally {

}


Lancer une exception

Java Propagation de l'exception
throws ClasseException

Lancer l'exception dans le code
throw new ClasseException( )
VB.Net throw New ClasseException( )
C
Delphi raise ClasseException.Create()
PHP throw new ClasseException( )
JS throw new ClasseException( )


Définir un paquetage / projet

Java package nomPackage
VB.Net Namespace nomProjet

End NameSpace
C
Delphi unit nomUnite
PHP
JS


Importer un paquetage / classe

Java imports nomPackage/classe
VB.Net Imports nomProjet/Classe
C #include <fichier.h> : librairie du C
#include "fichier.h" : fichier personnel
Delphi uses nomUnite
PHP include / include_once nomFichier.php
require / require_once nomFichier.php

require stoppe le script si le fichier est introuvable.
JS


Ecrire dans la console

Java System.out.println( )
VB.Net System.Console.WriteLine( )
System.Diagnostic.Debug.WriteLine( )
C printf( )
Delphi
PHP
JS


Résumé sur les classes

Java public class Infos {
   //Attributs
   private String libelle;

   //Constructeur
   public Infos(String _libelle ) {
       this.libelle=_libelle;
   }

   //Méthodes
   public void afficher( ) {
       System.out.println(libelle);
   }

   //Point d'entrée
   public static void main(String[] args) {
       objetInfos=new Infos("test");
       objetInfos.afficher( );
  }
}
VB.Net Public Class Infos
   'Attributs
   Private libelle As String

   'Constructeur
   Public Sub New(ByVal _libelle As String) 
       Me.libelle=_libelle
   End Sub

   'Méthodes
   Public Sub afficher( ) 
       MsgBox.Show(libelle)
   End Sub

   'Point d'entrée
   Public Shared Sub Main(args As String( ) ) 
       Dim objetInfos As New Infos("test")
       objetInfos.afficher( )
   End Sub
End Class
C
Delphi type
  TInfos = class

  //Attributs
  private
    libelle : string;    
  public
    constructor Create;
    procedure afficher();
  end;

  implementation

  //Constructeur
  constructor TMaClasse.Create(_libelle : String);
   begin
     libelle:=_libelle;
   end;

  //Méthode
  procedure TMaClasse.afficher();
   begin
     MessageBox.Show(libelle);
   end;
end.

//Test
TInfos : objetInfo.create("test");
objetInfo.afficher( );
PHP public class Infos {
   //Attributs
   private $libelle;

   //Constructeur
   public function __construct(String _libelle ) {
        $this->libelle=_libelle;
   }

   //Méthodes
   public function afficher( ) {
       echo libelle;
   }
}

//Test
$objetInfos=new Infos("test");
$objetInfos->afficher( );
JS

- COPYRIGHT 2008-2011 - ALL RIGHTS RESERVED - WEBMASTER : UDUN (GIRARD CYRIL) - DESIGN PAR : ANTYOZ