Page 3 of 30 FirstFirst 1234513 ... LastLast
Results 21 to 30 of 297

Thread: "Hello Ubuntu" in every programming language

  1. #21
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: "Hello Ubuntu" in every programming language

    Great job folks! Keep them coming.

    I'll modify the rules so that you don't have to write stuff to terminal. That should make it easier for markup languages and for any implementations that use a simple GUI.

  2. #22
    Join Date
    Oct 2006
    Location
    Austin, Texas
    Beans
    2,715

    Re: "Hello Ubuntu" in every programming language

    NASM Assembly (i386)... Revised for size!

    This one is an alternative to my original assembly entry, but I hacked if down from about 1000 bytes to about 200 bytes. No linking required here since the ELF header is in the source.

    Once again, the assembler usage command is at the top of the file.

    Code:
    ; nasm hello.asm -f bin -o hello && chmod +x hello
    
    BITS 32
      
    org 0x08048000
    
    ehdr: db 0x7F, "ELF", 1, 1, 1, 0
    console_out: db 0xB0, 0x04, 0x31, 0xDB, 0x43, 0xCD, 0x80, 0xC3
       db 2, 0, 3, 0
       dd 1, _start, phdr-$$
    console_in: db 0xB0, 0x03, 0x31, 0xDB, 0xCD, 0x80, 0xC3, 0
       dw ehdrsz, phdrsz
    ehdrsz equ $-ehdr
    phdr: dd 1, 0, $$, $$, filesz, filesz, 5
    get_len: db 0x31, 0xD2, 0x42, 0x80
    phdrsz equ $-phdr
       db 0x3C, 0x11, 0x0A, 0x75, 0xF9, 0xC3
    
    _start:
        sub esp, 128
    
        mov ecx, intro
        mov dl, 22
        call console_out
    
        mov ecx, esp
        mov dl, 128
        call console_in
    
        mov ecx, outro1
        mov dl, 6
        call console_out
    
        mov ecx, esp
        call get_len
        call console_out
    
        mov ecx, outro2
        mov dl, 21
        call console_out
    
        xor eax, eax
        inc eax
        int 0x80
    
        intro  db "Hi! What's your name? "
        outro1 db "Hello "
        outro2 db "! Welcome to Ubuntu!", 10
    
    filesz equ $-$$
    Ugly, isn't it?

  3. #23
    Join Date
    Mar 2007
    Beans
    464

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by Wybiral View Post
    Ugly, isn't it?
    No way! Ugly is the 500 line Java Servlet "Hello World" program I was going to submit!

  4. #24
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: "Hello Ubuntu" in every programming language

    Java (AWT GUI version)

    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class helloubuntu extends Frame {
    
    	public helloubuntu() {
    		initComponents();
    	}
    
    	private void initComponents() {
    
    		inputField = new TextField();
    		greetButton = new Button();
    		greetMsg = new Label();
    
    		setMinimumSize(new Dimension(300, 100));
    		setTitle("Hello Ubuntu");
    		
    		addWindowListener(new WindowAdapter() {
    			public void windowClosing(WindowEvent evt) {
    				exitForm(evt);
    			}
    		});
    		
    		setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    		add(inputField);
    
    		greetButton.setLabel("Hi!  What's your name?");
    		
    		greetButton.addMouseListener(new MouseAdapter() {
    			public void mouseClicked(MouseEvent evt) {
    				greetButtonMouseClicked(evt);
    			}
    		});
    		
    		add(greetButton);
    		add(greetMsg);
    
    		pack();
    	}
    
    	private void greetButtonMouseClicked(MouseEvent evt) {
    		String userName;
    		userName = inputField.getText();
    		greetMsg.setText("Hello " + userName + "!  Welcome to Ubuntu");
    	}
    
    	private void exitForm(WindowEvent evt) {
    		System.exit(0);
    	}
    
    	public static void main(String args[]) {
    		java.awt.EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				new helloubuntu().setVisible(true);
    			}
    		});
    	}
    
    	private Button greetButton;
    	private Label greetMsg;
    	private TextField inputField;
    
    }

  5. #25
    Join Date
    Jan 2007
    Location
    the third world
    Beans
    Hidden!

    Re: "Hello Ubuntu" in every programming language

    Hello World with Xt!
    Code:
    /* Compile with gcc <filename> -lXaw */
    /* Please do not ask me where to get the headers as I don't know where on Debian */
    
    #include <stdio.h>
    #include <X11/Intrinsic.h>
    #include <X11/StringDefs.h>
    #include <X11/Xaw/Command.h>
    #include <X11/Xaw/Form.h>
    #include <X11/Xaw/Box.h>
    #include <X11/Xaw/AsciiText.h>
    
    Arg args[1];
    Widget window, box, label, form, button, text;
    
    static void button_handler(Widget w, XtPointer call_data, XtPointer client_data)
    {
    	String string;
    	char msg[256];
    	
    	XtSetArg(args[0], XtNstring, &string);
    	XtGetValues(text, args, 1);
    	memset(&msg, '\0', 256);
    	memcpy(&msg, "Hello, ", strlen("Hello, "));
    	memcpy((&msg[0] + strlen(&msg[0])), string, strlen(string));
    	memcpy((&msg[0] + strlen(&msg[0])), "! Where is your GNOME now!?", \
    			strlen("! Where is your GNOME now!?"));
    	
    	XtVaSetValues(label, XtNlabel, &msg, NULL);
    }
    
    
    int main(int argc, char** argv)
    {
    	XtAppContext cx;
    
    	window = XtVaAppInitialize(&cx, "Hello World", NULL, 0, \
    				    &argc, argv, NULL, NULL);
    	
    	box = XtVaCreateManagedWidget("box", boxWidgetClass, window, NULL);
    
    	label = XtVaCreateManagedWidget("label", labelWidgetClass, box, \
    		XtNlabel, "Hi! What's your name?", XtNborderWidth, 0, NULL);
    
    	form = XtVaCreateManagedWidget("form", formWidgetClass, \
    		box, XtNsensitive, True, XtNborderWidth, 0, NULL);
    	
    	text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, \
    		form, XtNheight, 20, XtNwidth, 500, NULL, NULL, NULL, NULL, \
    		NULL);
    	
    	button = XtVaCreateManagedWidget("button", commandWidgetClass, form, \
    		XtNlabel, "Okay", XtNfromVert, text, NULL);
    
    	XtAddCallback(button, XtNcallback, button_handler, NULL);
    
    	XtVaSetValues(text, XtNeditType, XawtextEdit, XtNdisplayCaret, True, \
    		NULL);
    	
    	XtRealizeWidget(window);
    	XtAppMainLoop(cx);
    }
    Last edited by runningwithscissors; November 17th, 2007 at 06:50 PM.
    IESVS FELLAT IN INFERNVM

  6. #26
    Join Date
    May 2007
    Location
    Munich Germany
    Beans
    100
    Distro
    Ubuntu 15.10 Wily Werewolf

    Re: "Hello Ubuntu" in every programming language


    SQL (script to be run in SQL*Plus)


    Code:
    select 'Hi!  What''s your name?' from dual;
    select 'Hello, &1 !  Welcome to Ubuntu!' from dual;


    PL/SQL (procedure with parameter)


    Code:
    create or replace procedure helloUbuntu(in_name in varchar2) 
    is
    begin
       dbms_output.put_line('Hi!  What''s your name?');  
       dbms_output.put_line('Hello, '||in_name||' !  Welcome to Ubuntu!');
    end helloUbuntu;
    Intel i5 6500 | MSI z170a Gaming M5 | Corsair Vengence LPX 16Gb DDR4 @ 2400 | MSI GTX 970 gaming 4G | Ubuntu 15.10 Wily Werewolf / Windows 7

    http://ubuntutechnical.wordpress.com/

  7. #27
    Join Date
    Apr 2007
    Beans
    14,781

    Re: "Hello Ubuntu" in every programming language

    VBScript
    Code:
    dim name 
    name = inputbox("Hi! What is your name?","Hello Ubuntu!")
    msgbox "Hello, "& name &"! Welcome to Ubuntu!"
    All the cools languages where done, so I had to go over to the darkside.

    Please note, this will NOT work in Linux.

  8. #28
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: "Hello Ubuntu" in every programming language

    Javascript

    Code:
    var name = prompt( 'Hi! What is your name?', 'Please enter your name'  );
    alert( 'Hello, '+name+'! Welcome to Ubuntu!' );
    I think that should work, haven't coded Javascript for a long time =D
    Last edited by v8YKxgHe; July 11th, 2007 at 03:16 PM.

  9. #29
    Join Date
    Apr 2007
    Beans
    14,781

    Re: "Hello Ubuntu" in every programming language

    ...
    Last edited by LaRoza; July 11th, 2007 at 03:27 PM.

  10. #30
    Join Date
    Mar 2006
    Beans
    Hidden!

    Re: "Hello Ubuntu" in every programming language

    danke, fixed!

Page 3 of 30 FirstFirst 1234513 ... 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
  •