Help - Search - Member List - Calendar
Full Version: Et Vous De Quelle Catégorie êtes-vous ?
OpenSpace > Zone Ordinateurs > Programmation
chon
Sans le faire vraiment exprès, je suis tombé sur un petit truc bien débile au boulot aujourd'hui.

En gros cela présente les différentes manières d'afficher (le célèbre) Hello World, suivant votre rang dans une hiérarchie.

Bon c'est bien débile, cela doit être connu de certains, mais bon je le mets pour les autres.

(Note : il faut quand même si connaître un peu en prog :])

L'évolution d'un programmeur, ou comment afficher "Hello World" à l'écran

/****************************************************/

Terminale
10 PRINT "HELLO WORLD"
20 END

DUT 1ère année
program HELLO(input, output)
begin
writeln('HELLO WORLD')
end.

DUT 2ème année
(defun HELLO
(print
(cons HELLO (list 'WORLD))))

Fraîchement sorti de l'école
#include [stdio.h]
void main(void)
{
char *message[] = {"HELLO ", "WORLD"};
int i;
for(i = 0; i [ 2; ++i)
Printf("%s", message[i]);
printf("\n");
}

Professionnel très expérimenté
#include [iostream.h]
#include [string.h]
class string
{
private:
int size;
char *ptr;
public:
string() : size(0), ptr(new char('<!--POST BOX-->')) {}
string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}
~string()
{
delete [] ptr;
}
friend ostream &operator [[(ostream &, const string &);
string &operator=(const char *);
};
ostream &operator[[(ostream &stream, const string &s)
{
return(stream [[ s.ptr);
}
string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}
int main()
{
string str;
str = "HELLO WORLD";
cout [[ str [[ endl;
return(0);
}

Administrateur Système
#include (stdio.h)
main()
{
char *tmp;
int i=0;
/* on y va bourrin */
tmp=(char *)malloc(1024*sizeof(char));
while (tmp[i]="HELLO WORLD"[i++]);
/* Ooopps y'a une infusion ! */
i=(int)tmp[8];
tmp[8]=tmp[9];
tmp[9]=(char)i;
printf("%s\n",tmp);
}

Apprenti Hacker
#!/usr/local/bin/perl
$msg="HELLO, WORLD.\n";
if ($#ARGV = 0) {
while(defined($arg=shift(@ARGV))) {
$outfilename = $arg;
open(FILE, "" . $outfilename) || die "Can't write $arg: $!\n";
print (FILE $msg);
close(FILE) || die "Can't close $arg: $!\n";
}
}
else {
print ($msg);
}
1;

Hacker expérimenté
#include [stdio.h]
#define S "HELLO, WORLD\n"
main(){exit(printf(S) == strlen(S) ? 0 : 1);}

Hacker très expérimenté
% cc -o a.out ~/src/misc/bv/bv.c
% a.out

Gourou des Hackers
% cat
HELLO, WORLD.
^D

Directeur junior
10 PRINT "HELLO WORLD"
20 END

Directeur
mail -s "HELLO, WORLD." bob@b12
Henri, pourrais-tu m'écrire un programme qui écrit "HELLO,
WORLD." À l'écran?
J'en ai besoin pour demain.
^D

Directeur sénior
% zmail Jean
J'ai besoin d'un programme "HELLO, WORLD." Pour cette après-midi.

Président Directeur Général
% letter
letter: Command not found.
% mail
To: ^X ^F ^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized
% logout


/****************************************************/

Pour ma part, j'avoue me sentir très proche de Administrateur Système et/ou de Hacker expérimenté (tout dépend de ma finesse d'ésprit pour coder tongue.gif).

Ryle
Ben moi ce serait plutôt fraîchement sorti de l'école. Mais ouh là là ça fait un petit bout de temps que j'ai pas fait de C. Faudrait que je m'y remette un peu car sinon je vais oublier.
Guepi
ouais pareil que Ryle ... fraîchement sorti de l'école ... quoi que parfois, ça pourrait être Directeur ... smile.gif
PoP
J'aime pas le C.
Arsenik_
Moi ca serai plutot :

QUOTE
Terminale
10 PRINT "HELLO WORLD"
20 END



car je suis faignante de nature, donc moins j'en fais , mieux je me porte happy.gif
chon
Le truc le plus rigolo, c'est que certaines choses ne sont pas que de la science fiction. Par exemple, notre Directeur sénior nous a fait récemment le coup dans ma boîte (un programme tout simple, qu'il demande à quelqu'un d'autre de faire).

Quand la réalité rejoint la fiction happy.gif

Pop > mais qui a dit que j'aimais le C ? tongue.gif Et d'ailleurs il n'y a pas que du C (du Lisp aussi, du Java) dans mon premier message.



Sha
Hue moi disons que je suis un amateur évolué happy.gif
Gfx
En ce moment je serais plutôt dans le tyle "Développeur Corporate", qui ressemble en gros au développeur expérimenté. En gros :
CODE

   Call call = new Call();

   //This service uses standard SOAP encoding
   String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
   call.setEncodingStyleURI(encodingStyleURI);

   //Set the target URI
   call.setTargetObjectURI("urn:hello-world");

   //Set the method name to invoke
   call.setMethodName("helloWorld");

   //Create the parameter objects
   Vector params = new Vector();
   //params.addElement(new Parameter("fr", String.class, item, null));

   //Set the parameters
   call.setParams (params);

   //Invoke the service
   Response resp = call.invoke(new java.net.URL(m_hostURL), "");

   //Check the response
   if (resp != null)
   {
     if (resp.generatedFault())
     {
       Fault fault = resp.getFault();
       System.out.println ("Call failed due to a SOAP Fault: ");
       System.out.println ("  Fault Code   = " + fault.getFaultCode ());
       System.out.println ("  Fault String = " + fault.getFaultString ());
     } else {
       Parameter result = resp.getReturnValue();
       System.out.println(result.getValue());
     }
   }


Vous l'aurez compris, ce Hello World utilise un Web Service en SOAP-RPC et son utilisation ne nécessite qu'un simple serveur de 70 Mo pour fonctionner :-) Mais bon, au moins y'a du Web, du Service et du XML, donc c'est corporate et ça se vendra. Plus que les vôtres en tout cas tongue.gif

:-)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
Gfx
Ah et voilà le Web Service en question (notez qu'il est évidemment localisé :-)) :
CODE

//////////////////////////////////////////////////////////////////////////////////////////
// IMPORTS
//////////////////////////////////////////////////////////////////////////////////////////
import java.io.*;           // I/O
import java.util.*;         // utilitaires Java divers

import javax.xml.parsers.*; // support XML
import org.w3c.dom.*;       // support XML

import org.apache.soap.*;   // bibliothèque SOAP de la fondation Apache

//////////////////////////////////////////////////////////////////////////////////////////
// IMPLEMENTATION
//////////////////////////////////////////////////////////////////////////////////////////

public class HelloWorld
{
 public String helloWorld(String lang) throws SOAPException
 {
   ResourceBundle bundle = ResourceBundle.getBundle("resources/HelloWorld", new Locale(lang));
   try
   {
     return bundle.getString("hello.world");
   } catch (MissingResourceException mre) {
     throw new SOAPException(Constants.FAULT_CODE_SERVER, "Could not find the resource for lang: " + lang);
   }
 }
}




Gfx
Qui serait totalement inutile sans son descripteur de déploiement SOAP-RPC :
CODE

<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
            id="urn:hello-world">

 <isd:provider type="java" scope="Application"
               methods="helloWorld">
   <isd:java class="HelloWorld" />
 </isd:provider>

 <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>

</isd:service>


Et pour les clients le WSDL indispensable :

CODE

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:hello-world" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:hello-world" xmlns:intf="urn:hello-world" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://soap.apache.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
 <schema targetNamespace="http://soap.apache.org" xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
  <complexType name="SOAPException">
   <sequence>
    <element name="faultCode" nillable="true" type="xsd:string"/>
    <element name="message" nillable="true" type="xsd:string"/>
    <element name="rootException" nillable="true" type="xsd:anyType"/>
    <element name="targetException" nillable="true" type="xsd:anyType"/>
   </sequence>
  </complexType>
  <element name="SOAPException" nillable="true" type="tns1:SOAPException"/>
 </schema>
</wsdl:types>

  <wsdl:message name="helloWorldResponse">

     <wsdl:part name="helloWorldReturn" type="xsd:string"/>

  </wsdl:message>

  <wsdl:message name="SOAPException">

     <wsdl:part name="fault" type="tns1:SOAPException"/>

  </wsdl:message>

  <wsdl:message name="helloWorldRequest">

     <wsdl:part name="in0" type="xsd:string"/>

  </wsdl:message>

  <wsdl:portType name="HelloWorld">

     <wsdl:operation name="helloWorld" parameterOrder="in0">

        <wsdl:input message="intf:helloWorldRequest" name="helloWorldRequest"/>

        <wsdl:output message="intf:helloWorldResponse" name="helloWorldResponse"/>

        <wsdl:fault message="intf:SOAPException" name="SOAPException"/>

     </wsdl:operation>

  </wsdl:portType>

  <wsdl:binding name="rpcrouterSoapBinding" type="intf:HelloWorld">

     <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

     <wsdl:operation name="helloWorld">

        <wsdlsoap:operation soapAction=""/>

        <wsdl:input name="helloWorldRequest">

           <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:hello-world" use="encoded"/>

        </wsdl:input>

        <wsdl:output name="helloWorldResponse">

           <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:hello-world" use="encoded"/>

        </wsdl:output>

     </wsdl:operation>

  </wsdl:binding>

  <wsdl:service name="HelloWorldService">

     <wsdl:port binding="intf:rpcrouterSoapBinding" name="rpcrouter">

        <wsdlsoap:address location="http://localhost:8080/soap/rpcrouter"/>

     </wsdl:port>

  </wsdl:service>

</wsdl:definitions>


Voilà, c'est tout smile.gif)
chon
Gfx > Looool laugh.gif J'aurais dû rajouter une catégorie (Gfx-like) dans mon premier message happy.gif
Sha
MDR wahaha.gif
Ryle
laugh.gif laugh.gif
Darhf
Tin en fait je suis pire que je le croyais, le webservice à Gfx là, eh ben je le trouve censé blink.gif
PoP
MMMMMMMMMMMMMMMMMMMMMMMMDR!
Punaize Gfx, t'as un grain de sable dans les neurones toi! smile.gif
Gfx
Meuh non, comme je l'ai dit, j'ai juste le style "entreprise" :-))))
Poischack
au temps de l'amstrad:
CODE
? "Hello World"
IOEN
moi j'ouvre le bloc note et je tape "hello world" dedans...... QUI CAI L'MOINS CON HEIN ? biggrin.gif biggrin.gif
Gragt le Cruel
CODE

[ Main;
print "Hello world^";
];


Ca, c'est en Inform ^__^



yaka94
ROFL !!
genial !
Ghost Line
Clair C fort smile.gif

Par contre y'a un truc que je voudrais qu'on m'explique :

QUOTE

#include (stdio.h)
main()
{
char *tmp;
int i=0;
/* on y va bourrin */
>>> tmp=(char *)malloc(1024*sizeof(char));
while (tmp[i]="HELLO WORLD"[i++]);
/* Ooopps y'a une infusion ! */
i=(int)tmp[8];
tmp[8]=tmp[9];
tmp[9]=(char)i;
printf("%s\n",tmp);
}


Le truc avec le >>> ca sers à quoi ? il passe toutes les combinaisons une par une jusqu'à trouver la chaine exact ou j'ai rien calculé (<- plausible) ?
Gfx
Je vous le fais en J2ME MIDP ?
Peter Pan
user posted image
irion_d_alcor
malheur , dire que des gens comme ca existent et que je cotoie le forum ou ils postent.... tongue.gif





Sha
Un clic est l'entrée du texte dans VB.Net provoque ça : biggrin.gif

QUOTE

Public Class Form1
   Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

   Public Sub New()
       MyBase.New()

       'This call is required by the Windows Form Designer.
       InitializeComponent()

       'Add any initialization after the InitializeComponent() call

   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing Then
           If Not (components Is Nothing) Then
               components.Dispose()
           End If
       End If
       MyBase.Dispose(disposing)
   End Sub

   'Required by the Windows Form Designer
   Private components As System.ComponentModel.IContainer

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   Friend WithEvents Label1 As System.Windows.Forms.Label
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       Me.Label1 = New System.Windows.Forms.Label()
       Me.SuspendLayout()
       '
       'Label1
       '
       Me.Label1.Location = New System.Drawing.Point(8, 16)
       Me.Label1.Name = "Label1"
       Me.Label1.Size = New System.Drawing.Size(88, 16)
       Me.Label1.TabIndex = 0
       Me.Label1.Text = "HELLO WORLD"
       '
       'Form1
       '
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.ClientSize = New System.Drawing.Size(292, 273)
       Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1})
       Me.Name = "Form1"
       Me.Text = "Form1"
       Me.ResumeLayout(False)

   End Sub

#End Region

End Class
Peter Pan
Sha > tu devrais ajouter le Framework avec happy.gif
PoP
Gfx>ouais, pourquoi pas!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.