Page 28 of 30 FirstFirst ... 182627282930 LastLast
Results 271 to 280 of 297

Thread: "Hello Ubuntu" in every programming language

  1. #271
    Join Date
    Oct 2008
    Location
    $HOME
    Beans
    112
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: "Hello Ubuntu" in every programming language

    Common Lisp
    PHP Code:
    (format t "Hi! What's your name?~%")
    (
    defvar *name* (read-line))
    (
    format t "Hello, ~a! Welcome to Ubuntu!~%" *name*) 
    $(fortune)
    In a world without walls and fences, who needs windows and gates?

  2. #272
    Join Date
    Jun 2009
    Location
    Cartago, Costa Rica
    Beans
    13
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Thumbs down Re: "Hello Ubuntu" in every programming language

    Some more Linux Assembly code:

    GNU Assembly (GAS) - Linux x86
    Code:
    // Segment for initialized data (contents and size of all strings needed)
    .section .data
        question:
            .ascii "Hi! What's your name? "
            .equ question_length, . - question
        greeting:
            .ascii "Hello, "
            .equ greeting_length, . - greeting
        welcome:
            .ascii "! Welcome to Ubuntu!\n"
            .equ welcome_length, . - welcome
    
    // Segment for uninitialized data (the user's name, up to 256 characters)
    .section .bss
        .lcomm name, 256
    
    // A macro definition to output a string 'string' of size 'string_size' to console.
    .macro write string, string_size
        movl  $4, %eax                  // 'Write to buffer' kernel service in EAX
        movl  $1, %ebx                  // Standard output buffer handle in EBX
        movl  \string, %ecx             // String address in ECX
        movl  \string_size, %edx        // String size in EDX 
        int   $0x80                     // Linux kernel software interrupt
    .endm
    
    
    .section .text
    .globl _start
    
        _start:
            write $question, $question_length
            
            movl  $3, %eax              // 'Read from buffer' kernel service in EAX
            movl  $0, %ebx              // Standard input buffer handle in EBX
            movl  $name, %ecx           // Destination string address in ECX
            movl  $256, %edx            // String size in EDX
            int   $0x80                 // Linux kernel software interrupt
            pushl %eax                  // The amount of bytes actually read is returned in EAX.
                                        //   It has to be pushed in order to use it later.
            
            write $greeting, $greeting_length
                    
            popl %edx                   // The size of 'name' is retrieved in EDX.
            decl %edx                   // 'name' includes a newline character at its end.
                                        //   So, it has to be excluded from output.
            write $name, %edx           // The name is output to console, without the newline.
            
            write $welcome, $welcome_length
            
            movl $1, %eax               // 'Terminate program' kernel service in EAX
            xorl %ebx, %ebx             // Return code in EBX.
                                        //   0 usually means the program succesfully terminated.
            int $0x80                   // Linux kernel software interrupt

  3. #273
    Join Date
    Jun 2009
    Location
    Cartago, Costa Rica
    Beans
    13
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Re: "Hello Ubuntu" in every programming language

    Sample of a dialect of the seemingly forgotten LOGO...

    TurtleScript
    Code:
    $name = ask "Hi! What's your name?"
    message "Hello, " + $name + "! Welcome to Ubuntu!"
    Last edited by Ariel David Moya Sequeira; June 11th, 2009 at 02:42 AM.

  4. #274
    Join Date
    Jun 2008
    Location
    New York, USA
    Beans
    781

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by samjh View Post
    "Hello Ubuntu" in every programming language
    Motorola 68HC11 assembler:


    Code:
    regbs   equ     $1000           ;register base
    scsr    equ     regbs+$2e       ;sci status reg
    scdr    equ     regbs+$2f       ;sci data reg
    
    
            org     $2000           ;stick it in sram
    
    
    start   clrb                    ;b=0
            stab    curpos          ;init cursor position to 0
    
            ldx     #msg1           ;point to prompt
            jsr     outstrg         ;display it
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; this is the main user input loop
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    main    jsr     input           ;read serial term
            beq     main            ;wait for a key
    
            cmpa    #3              ;ctrl-c?
            beq     exit            ;yes, exit
            cmpa    #27             ;escape?
            bne     main2           ;no, run program
    
    exit    swi                     ;quit received, exit!
    
    main2   cmpa    #13             ;c/r?
            beq     finish          ;yes, finish up
    
            cmpa    #8              ;backspace?
            beq     do_bs           ;yes, do it
    
            ldx     #buffer         ;point to buffer
            ldab    curpos          ;get cursor position
            cmpb    #bufsiz         ;at end?
            bhs     chrout          ;at end, can't do anything
    
            abx                     ;x points to current char
            staa    0,x             ;write char to buffer
    
            incb                    ;move fwd 1 position
            stab    curpos          ;update cursor position
    
            jsr     output          ;echo char to term
    
    chrout  jmp     main            ;return to main loop
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; got the user string - print req'd stuff & exit
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    finish  clra                    ;a=0
            staa    1,x             ;null last char
    
            ldx     #msg2           ;"Hello..."
            jsr     outstrg         ;display it
    
            ldx     #buffer         ;point to input buffer
            jsr     outstrg         ;display it
    
            ldx     #msg3           ;"..welcome to ubuntu"
            jsr     outstrg         ;display it
    
            swi                     ;return to monitor
    
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; do backspace
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    do_bs   ldx     #buffer         ;point to buffer
            ldab    curpos          ;get cursor position
            beq     dobsout         ;at beginning, can't do anything
    
            decb                    ;backup 1 position
            stab    curpos          ;update cursor position
    
            abx                     ;x points -> current char in buffer
    
            ldaa    #$ff            ;a = $ff
            staa    0,x             ;erase char in buffer
    
            ldaa    #8              ;load backspace
            jsr     output          ;print backspace to term
    
            ldaa    #' '            ;load a space
            jsr     output          ;erase char on term
    
            ldaa    #8              ;load backspace
            jsr     output          ;backup cursor on term
    
    dobsout jmp     main            ;return to main loop
    
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; input (read) data from serial port
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    input   ldaa    scsr            ;read status reg
            anda    #%00100000      ;check rdrf flag
            beq     input2          ;exit w/a=0 if no data
    
            ldaa    scdr            ;read serial data
    
    input2  rts                     ;return
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; output (write) data to serial port
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    output  psha                    ;save a
            ldaa    scsr            ;read sci status register
            coma                    ;invert bits
            bita    #%11000000      ;test tdre & tc
            pula                    ;restore a
            bne     output          ;sci busy, check again
    
            staa    scdr            ;send character
            rts
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; out string (print) string to serial port
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    outstrg pshx                    ;save x
    
    outs2   ldaa    0,x             ;get a char
            beq     outs3           ;done
    
            bsr     output          ;send character out
            inx                     ;increment buffer ptr
            bra     outs2           ;send next
    
    outs3   pulx                    ;restore x
            rts                     ;return
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; text messages for terminal
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    msg1    dc.b    $0d,$0a
            dc.b    "Hi!  What's your name? "
            dc.b    0
    
    msg2    dc.b    $0d,$0a
            dc.b    "Hello, "
            dc.b    0
    
    msg3    dc.b    "! Welcome to Ubuntu!"
            dc.b    $0d,$0a,0
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; buffers & vars in 'hc11 sram
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
            org     $100            ;evbu ram
    
    buffer  ds.b    32              ;incoming data buffer
    bufsiz  equ     *-buffer        ;size of buffer
    curpos  ds.b    1               ;cursor position

    Program running under HC11 EVBU BUFFALO Monitor:

    Code:
    >load
    
    OK-2000 
    >g 2000
    
    Hi!  What's your name? Roger Ramjet
    Hello, Roger Ramjet! Welcome to Ubuntu!
    
    P-204C Y-FFFF X-20B9 A-00 B-0C C-D5 S-003F CC-nZvC
    >




    -- Roger
    Gentlemen may prefer Blondes, but Real Men prefer Redheads!

  5. #275
    Join Date
    Jun 2008
    Beans
    9
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: "Hello Ubuntu" in every programming language

    C++/Gtkmm

    Code:
    // compile with g++ helloubuntu.cpp -o helloubuntu `pkg-config gtkmm-2.4 --cflags --libs`
    
    #include <gtkmm/main.h>
    #include <gtkmm/window.h>
    #include <gtkmm/button.h>
    #include <gtkmm/label.h>
    #include <gtkmm/entry.h>
    #include <gtkmm/box.h>
    
    class HelloUbuntu : public Gtk::Window
    {
    	protected:
    	// signal handlers:
    	virtual void on_button_click();
    	// widgets:
    	Gtk::Button button;
    	Gtk::Entry entry;
    	Gtk::Label label;
    	Gtk::VBox box;
    	public:
    	HelloUbuntu();
    };
    
    HelloUbuntu::HelloUbuntu()
    {
    	set_title("Hello Ubuntu!");
    	set_border_width(10);
    	button.set_label("Okay");
    	label.set_text("Please enter your name.");
    	
    	button.signal_clicked().connect(sigc::mem_fun(*this, &HelloUbuntu::on_button_click));
    	
    	box.pack_start(label, Gtk::PACK_EXPAND_PADDING, 5);
    	box.pack_start(entry, Gtk::PACK_EXPAND_PADDING, 5);
    	box.pack_start(button, Gtk::PACK_EXPAND_PADDING, 5);
    	
    	add(box);
    	
    	show_all();
    }
    
    void HelloUbuntu::on_button_click()
    {
    	label.set_text("Hello, " + entry.get_text() + ", welcome to Ubuntu!");
    }
    
    int main(int argc, char *argv[])
    {
    	Gtk::Main kit(argc, argv);
    	HelloUbuntu helloubuntu;
    	Gtk::Main::run(helloubuntu);
    	return 0;
    }

  6. #276
    Join Date
    Aug 2007
    Location
    127.0.0.1
    Beans
    1,800
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: "Hello Ubuntu" in every programming language

    MIPS Assembly
    (emulated on SPIM)

    Code:
    .data
    .align 0
    	hwrld:	.asciiz  "Hello Ubuntu!\n"
    .text
    .globl main
    
    main:
    	li $v0, 4	# I/O instruction
    	la $a0, hwrld	# Copy memory address to argument registry.
    	syscall		# System Call
    	
    	j	quit	# Jump to quit
    
    quit:
    	li $v0, 10
    	syscall
    (Old post is old)
    Last edited by Can+~; August 9th, 2009 at 08:27 PM.
    "Just in terms of allocation of time resources, religion is not very efficient. There's a lot more I could be doing on a Sunday morning."
    -Bill Gates

  7. #277
    Join Date
    Aug 2009
    Location
    Tampa Fl
    Beans
    15
    Distro
    Ubuntu 6.10 Edgy

    Wink Re: "Hello Ubuntu" in every programming language

    #Hi Ubuntu
    def main():
    name = raw_input("enter your name, ")
    print ('Hello welcome to the Ubuntu forrum,'), name

    main()

    enter your name, drew
    Hello welcome to the Ubuntu forrum, drew
    >>>

    This one worked.

  8. #278
    Join Date
    Aug 2009
    Beans
    29

    Re: "Hello Ubuntu" in every programming language

    Code:
    import javax.swing.*;
    
    public class HelloUbuntu extends JFrame {
         JLabel Hello = new JLabel("Hello Ubuntu");
         
         public HelloUbuntu() {
               super("Hello Ubuntu!");
              setSize(250,50);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel pane = new JPanel();
              pane.add(Hello);
              add(pane);
              setVisible(true);
         }
         
         public static void main(String[] args) {
               HelloUbuntu hu = new HelloUbuntu();
         }
         
    }

    Java Swing Frame With "Hello Ubuntu!" Label

  9. #279
    Join Date
    Apr 2006
    Beans
    996
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: "Hello Ubuntu" in every programming language

    Zinc
    :
    Code:
    library HelloUbuntu
    {
        function onInit()
        {
            BJDebugMsg("Hello ubuntu");
        }
    }

    Code:
    /* Feature creep version */
    // shows Hello Ubuntu every 0.2 seconds
    //
    library HelloUbuntu requires TimerUtils
    {
        type stringFunc extends function(string);
        struct stringDoer
        {
            string s;
            stringFunc func;
            method do()
            {
                timer t = NewTimer();
                SetTimerData(t, this);
                TimerStart(t, 0.2, true, function(){
                   thistype this = GetTimerData(GetExpiredTimer());
                   func.evaluate(s);
                });
            }
        }
    
        function onInit()
        {
            stringDoer sd = stringDoer.create();
            sd.s = "Hello ubuntu";
            sd.func = function(string msg){
                BJDebugMsg(msg);
            };
            sd.do();
        }
    
    
    }
    Last edited by vexorian; October 18th, 2009 at 02:43 AM.
    Xye incredibly difficult puzzle game with minimal graphics. Also at playdeb
    Got a blog: Will Stay Free

  10. #280
    Join Date
    Dec 2007
    Beans
    14
    Distro
    Ubuntu Karmic Koala (testing)

    Re: "Hello Ubuntu" in every programming language

    LOLCODE 1.3

    http://www.icanhaslolcode.org/ I used that interpreter to write this gem

    Code:
    HAI 1.3
     VISIBLE "WELKUM 2 UBUNTU!, WHAT R YR NAEM?:)"
     I HAS A NAME ITZ A YARN
     GIMMEH NAME
     VISIBLE "HEY THERE :{NAME} WELKUM 2 UBUNTU"
    KTHXBYE

Page 28 of 30 FirstFirst ... 182627282930 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
  •