Page 5 of 30 FirstFirst ... 3456715 ... LastLast
Results 41 to 50 of 297

Thread: "Hello Ubuntu" in every programming language

  1. #41
    Join Date
    Apr 2007
    Beans
    14,781

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by samjh View Post
    41 languages and variations so far. Keep rolling them out!
    Don't count Whitespace, I really didn't type it.

  2. #42
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by LaRoza View Post
    Don't count Whitespace, I really didn't type it.
    Bugger. 40 then.

  3. #43
    Join Date
    Apr 2006
    Location
    @home
    Beans
    2

    Re: "Hello Ubuntu" in every programming language

    LOLcode

    Code:
    HAI
    CAN HAS STDIO?
    I HAS A VAR
    VISIBLE "what is yr name?"
    GIMMEH VAR
    VISIBLE "HAI " N VAR N "! Welcome to Ubuntu
    KTHXBYE

  4. #44
    Join Date
    Jan 2007
    Location
    the third world
    Beans
    Hidden!

    Re: "Hello Ubuntu" in every programming language

    GTK+
    Code:
    /* compile with: gcc <filename> `pkg-config --cflags --libs gtk+-2.0` */
    
    #include <gtk/gtk.h>
    #include <string.h>
    
    GtkWidget *window, *vbox, *label, *entry, *button;
    
    static void close(GtkWidget *widget, gpointer data)
    {
    	gtk_main_quit();
    }
    
    static void okay_click(GtkWidget *widget, gpointer data)
    {
    	char msg[256];
    	memset(&msg[0], '\0', 256);
    	snprintf(&msg[0], 256, "Hello, %s! Welcome to Ubuntu!", \
    		gtk_entry_get_text(GTK_ENTRY(entry)));
    	
    	gtk_label_set_text(GTK_LABEL(label), msg);
    }
    
    void init_widgets()
    {
    	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    	vbox = gtk_vbox_new(TRUE, 0);
    	
    	label = gtk_label_new("Hi, What's your name?");
    	entry = gtk_entry_new();
    	button = gtk_button_new_with_label("Okay");
    		
    	g_signal_connect(G_OBJECT(button), "clicked", \
    		G_CALLBACK(okay_click), NULL);
    	g_signal_connect(G_OBJECT(window), "destroy", \
    		G_CALLBACK(close), NULL);
    	
    	gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
    	gtk_box_pack_start(GTK_BOX(vbox), entry, TRUE, TRUE, 0);
    	gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
    	
    	gtk_container_add(GTK_CONTAINER(window), vbox);
    	
    	gtk_widget_show(label);
    	gtk_widget_show(entry);
    	gtk_widget_show(button);
    	gtk_widget_show(vbox);
    	gtk_widget_show(window);
    }
    
    int main(int argc, char **argv)
    {
    	gtk_init(&argc, &argv);
    	init_widgets();
    	gtk_main();
    	
    	return 0;
    }
    PyGTK
    Code:
    #!/usr/bin/env python
    
    import pygtk
    pygtk.require('2.0')
    import gtk
    
    class HelloWorld:
    	def close(self, widget, event, data=None):
    		gtk.main_quit()
    	
    	def okay_click(self, widget, data=None):
    		self.label.set_text("Hello, " + self.entry.get_text() + "! Welcome to Ubuntu!")
    	
    	def __init__(self):
    		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    		self.vbox = gtk.VBox(False, 0)
    		self.label = gtk.Label("Hi, What's your name?")
    		self.entry = gtk.Entry(20)
    		self.button = gtk.Button("Okay")
    		self.button.connect("clicked", self.okay_click)
    		self.window.connect("delete_event", self.close)
    		self.vbox.pack_start(self.label, True, True, 0)
    		self.vbox.pack_start(self.entry, True, True, 0)
    		self.vbox.pack_start(self.button, True, True, 0)
    		self.window.add(self.vbox)
    		self.label.show()
    		self.entry.show()
    		self.button.show()
    		self.vbox.show()
    		self.window.show()
    
    if __name__ == "__main__":
    	HelloWorld()
    	gtk.main()
    Ruby/GTK2
    Code:
    #!/usr/bin/env ruby
    
    require('gtk2')
    
    class HelloWorld
    	def initialize
    		@window = Gtk::Window.new
    		@vbox = Gtk::VBox.new
    		@label = Gtk::Label.new("Hi, What's your name?")
    		@entry = Gtk::Entry.new
    		@button = Gtk::Button.new("Okay")
    		@button.signal_connect("clicked") {
    			@label.set_text("Hello, #{@entry.text}! Welcome to Ubuntu!")
    		}
    		@window.signal_connect("delete_event") { Gtk.main_quit }
    		@vbox.pack_start(@label, true, true, 0)
    		@vbox.pack_start(@entry, true, true, 0)
    		@vbox.pack_start(@button, true, true, 0)
    		@window.add(@vbox)
    		@label.show
    		@entry.show
    		@button.show
    		@vbox.show
    		@window.show
    	end
    end
    
    HelloWorld.new
    Gtk.main
    Last edited by runningwithscissors; July 16th, 2007 at 05:12 AM.
    IESVS FELLAT IN INFERNVM

  5. #45
    Join Date
    Dec 2005
    Beans
    527
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: "Hello Ubuntu" in every programming language

    did we get a C Sharp one yet (not my best language but I can manage it).

  6. #46
    Join Date
    Jan 2006
    Location
    Leuven, Belgium
    Beans
    3,414

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by Note360 View Post
    did we get a C Sharp one yet (not my best language but I can manage it).
    Post 17.

    I'm amazed no one used lisp yet...

  7. #47
    Join Date
    Apr 2006
    Location
    @home
    Beans
    2

    Re: "Hello Ubuntu" in every programming language

    sorry lisp is not my strongest point but i can use clips (some rule based programming language

    Code:
    (defrule welcome
    (name ?name)
    =>
    (printout t crlf "Hello " ?name "Welcome to ubuntu" crlf)
    )
    
    (defrule ask_name
    (initial-fact)
    =>
    (printout t crlf "what is your name? ")
    (bind ?inp (read t)
    (assert (name ?inp))
    )

  8. #48

    Re: "Hello Ubuntu" in every programming language

    Befunge
    Code:
    >0"!utnubU ot emocleW !?eman ruoy s'tahw ,iH"v
    v    ,,,,,,,,,,,,,,,,,,,,,                   <
    >~:48*`#v_$25*," ,olleH">:47*`#v_25*,@
    ^       <               ^  ,   <

  9. #49
    Join Date
    Jun 2006
    Location
    ~wfarr
    Beans
    409

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by runningwithscissors View Post
    GTK+
    Code:
    /* compile with: gcc <filename> `pkg-config --cflags --libs gtk+-2.0` */
    
    #include <gtk/gtk.h>
    #include <string.h>
    
    GtkWidget *window, *vbox, *label, *entry, *button;
    
    static void close(GtkWidget *widget, gpointer data)
    {
    	gtk_main_quit();
    }
    
    static void okay_click(GtkWidget *widget, gpointer data)
    {
    	char msg[256];
    	memset(msg, '\0', 256);
    	snprintf(&msg[0], 256, "Hello, %s! Welcome to Ubuntu!", \
    		gtk_entry_get_text(GTK_ENTRY(entry)));
    	
    	gtk_label_set_text(GTK_LABEL(label), msg);
    }
    
    void init_widgets()
    {
    	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    	vbox = gtk_vbox_new(TRUE, 0);
    	
    	label = gtk_label_new("Hi, What's your name?");
    	entry = gtk_entry_new();
    	button = gtk_button_new_with_label("Okay");
    		
    	g_signal_connect(G_OBJECT(button), "clicked", \
    		G_CALLBACK(okay_click), NULL);
    	g_signal_connect(G_OBJECT(window), "destroy", \
    		G_CALLBACK(close), NULL);
    	
    	gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
    	gtk_box_pack_start(GTK_BOX(vbox), entry, TRUE, TRUE, 0);
    	gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0);
    	
    	gtk_container_add(GTK_CONTAINER(window), vbox);
    	
    	gtk_widget_show(label);
    	gtk_widget_show(entry);
    	gtk_widget_show(button);
    	gtk_widget_show(vbox);
    	gtk_widget_show(window);
    }
    
    int main(int argc, char **argv)
    {
    	gtk_init(&argc, &argv);
    	init_widgets();
    	gtk_main();
    	
    	return 0;
    }
    PyGTK
    Code:
    #!/usr/bin/env python
    
    import pygtk
    pygtk.require('2.0')
    import gtk
    
    class HelloWorld:
    	def close(self, widget, event, data=None):
    		gtk.main_quit()
    	
    	def okay_click(self, widget, data=None):
    		self.label.set_text("Hello, " + self.entry.get_text() + "! Welcome to Ubuntu!")
    	
    	def __init__(self):
    		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    		self.vbox = gtk.VBox(False, 0)
    		self.label = gtk.Label("Hi, What's your name?")
    		self.entry = gtk.Entry(20)
    		self.button = gtk.Button("Okay")
    		self.button.connect("clicked", self.okay_click)
    		self.window.connect("delete_event", self.close)
    		self.vbox.pack_start(self.label, True, True, 0)
    		self.vbox.pack_start(self.entry, True, True, 0)
    		self.vbox.pack_start(self.button, True, True, 0)
    		self.window.add(self.vbox)
    		self.label.show()
    		self.entry.show()
    		self.button.show()
    		self.vbox.show()
    		self.window.show()
    
    if __name__ == "__main__":
    	HelloWorld()
    	gtk.main()
    Ruby/GTK2
    Code:
    #!/usr/bin/env ruby
    
    require('gtk2')
    
    class HelloWorld
    	def initialize
    		@window = Gtk::Window.new
    		@vbox = Gtk::VBox.new
    		@label = Gtk::Label.new("Hi, What's your name?")
    		@entry = Gtk::Entry.new
    		@button = Gtk::Button.new("Okay")
    		@button.signal_connect("clicked") {
    			@label.set_text("Hello, #{@entry.text}! Welcome to Ubuntu!")
    		}
    		@window.signal_connect("delete_event") { Gtk.main_quit }
    		@vbox.pack_start(@label, true, true, 0)
    		@vbox.pack_start(@entry, true, true, 0)
    		@vbox.pack_start(@button, true, true, 0)
    		@window.add(@vbox)
    		@label.show
    		@entry.show
    		@button.show
    		@vbox.show
    		@window.show
    	end
    end
    
    HelloWorld.new
    Gtk.main
    You shall be obligatorily lynched for using hard tabs in the Ruby and Python code instead of 2 and 4 spaces respectively.

  10. #50
    Join Date
    May 2007
    Beans
    11

    Re: "Hello Ubuntu" in every programming language

    in ASM:
    Code:
    %define BUFSIZE 2048
    
    section .data
    hellostr db 'Hello, '
    welcomestr db 'Welcome to Ubuntu!'
    
    section .bss
    ibuffer resb    BUFSIZE
    obuffer resb    BUFSIZE
    
    section .text
    global  _start
    _start:
        sub eax, eax
        sub ebx, ebx
        sub ecx, ecx
        mov edi, obuffer
    
    .readloop:
        ; read a byte from stdin
        call    getchar
    
    .put:
        call    putchar
        out    eax
        jmp short .readloop
    
    getchar:
        or  ebx, ebx
        jne .fetch
    
        call    read
    
    .fetch:
        lodsb
        dec ebx
        ret
    
    read:
        push    dword BUFSIZE
        mov esi, ibuffer
        push    esi
        push    dword stdin
        sys.read
        add esp, byte 12
        mov ebx, eax
        or  eax, eax
        je  .done
        sub eax, eax
        ret
    
    .done:
        call    write       ; flush output buffer
        push    dword 0
        call	print
    
    putchar:
        stosb
        inc ecx
        cmp ecx, BUFSIZE
        je  write
        ret
    
    write:
        sub edi, ecx    ; start of buffer
        push    ecx
        push    edi
        push    dword stdout
        sys.write
        add esp, byte 12
        sub eax, eax
        sub ecx, ecx    ; buffer is empty now
        ret
    
    printloop:
        mov     ecx, #hellostr & 0FFh 
        add	    ecx, eax
        add      ecx, #welcomestr & 0FFh
        mov     a, ecx                ; get pointer
        movp    a,@a                ; get char
        mov     edi,a                ; into to right register
        inc       ecx                  ; advance pointer
        call    putchar
        djnz    eax, printloop
        call    terminate
    
    terminate:
    sys.exit

Page 5 of 30 FirstFirst ... 3456715 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •