Hello world/Graphical: Difference between revisions

From Rosetta Code
Content added Content deleted
m (Remove extra whitespace)
(Added Frege example for Hello world/Graphical)
Line 878: Line 878:
sleep
sleep
End</lang>
End</lang>

=={{header|Frege}}==

<lang frege>package HelloWorldGraphical where

import Java.Swing

main _ = do
frame <- JFrame.new "Goodbye, world!"
frame.setDefaultCloseOperation(JFrame.dispose_on_close)
label <- JLabel.new "Goodbye, world!"
cp <- frame.getContentPane
cp.add label
frame.pack
frame.setVisible true</lang>


=={{header|Frink}}==
=={{header|Frink}}==

Revision as of 12:50, 19 December 2015


Task
Hello world/Graphical
You are encouraged to solve this task according to the task description, using any language you may know.

In this User Output task, the goal is to display the string "Goodbye, World!" on a GUI object (alert box, plain window, text area, etc.).

See also: Hello world/Text

ActionScript

<lang actionscript> var textField:TextField = new TextField(); stage.addChild(textField); textField.text = "Goodbye, World!" </lang>

Ada

Library: GTK version GtkAda
Library: GtkAda

<lang ada>with Gdk.Event; use Gdk.Event; with Gtk.Label; use Gtk.Label; with Gtk.Window; use Gtk.Window; with Gtk.Widget; use Gtk.Widget;

with Gtk.Handlers; with Gtk.Main;

procedure Windowed_Goodbye_World is

  Window : Gtk_Window;
  Label  : Gtk_Label;
  package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
  package Return_Handlers is
     new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);
  function Delete_Event (Widget : access Gtk_Widget_Record'Class)
     return Boolean is
  begin
     return False;
  end Delete_Event;
  procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
  begin
    Gtk.Main.Main_Quit;
  end Destroy;

begin

  Gtk.Main.Init;
  Gtk.Window.Gtk_New (Window);
  Gtk_New (Label, "Goodbye, World!");
  Add (Window, Label);
  Return_Handlers.Connect
  (  Window,
     "delete_event",
     Return_Handlers.To_Marshaller (Delete_Event'Access)
  );
  Handlers.Connect
  (  Window,
     "destroy",
     Handlers.To_Marshaller (Destroy'Access)
  );
  Show_All (Label);
  Show (Window);
  Gtk.Main.Main;

end Windowed_Goodbye_World;</lang>

ALGOL 68

The code below is a gentle re-write (including a bug fix) of that in the Algol 68 Genie documentation. <lang algol68> BEGIN

  FILE window;
  open (window, "Hello!", stand draw channel);
  draw device (window, "X", "600x400");
  draw erase (window);
  draw move (window, 0.25, 0.5);
  draw colour (window, 1, 0, 0);
  draw text (window, "c", "c", "Goodbye, world!");
  draw show (window);
  close (window)

END </lang>

App Inventor

No Blocks solution

This solution requires no code blocks as the text is entered directly into the Title properties TextBox of the Designer.
VIEW THE DESIGNER

Three blocks solution

This solution uses three blocks to assign the text to the Title bar:
Screen1.Initialize and
set Screen1.Title to "Goodbye World!"
VIEW THE BLOCKS AND ANDROID APP SCREEN

AppleScript

<lang applescript>display dialog "Goodbye, World!" buttons {"Bye"}</lang>

Applesoft BASIC

<lang Applesoft BASIC> 1 LET T$ = "GOODBYE, WORLD!"

 2 LET R = 5:GX = 3:GY = 2:O = 3:XC = R + GX:YC = R * 2 + GY
 3 TEXT : HOME : TEXT : HGR : HCOLOR= 7: HPLOT 0,0: CALL 62454: HCOLOR= 6
 4 LET L =  LEN (T$): FOR I = 1 TO L:K =  ASC ( MID$ (T$,I,1)):XO = XC:YO = YC: GOSUB 5:XC = XO + 1:YC = YO: GOSUB 7: NEXT : END 
 5 IF K > 64 THEN K = K + LC: GOSUB 20:LC = 32: RETURN 
 6 LET LC = 0: ON K >  = 32 GOTO 20: RETURN 
 7 GOSUB 20:XC = XC + R * 2 + GX: IF XC > 279 - R THEN XC = R + GX:YC = YC + GY + R * 5
 8 RETURN 
 9 LET XC = XC - R * 2: RETURN 
10 LET Y = R:D = 1 - R:X = 0
11 IF D >  = 0 THEN Y = Y - 1:D = D - Y * 2
12 LET D = D + X * 2 + 3
13 IF O = 1 OR O = 3 THEN  GOSUB 17
14 IF O = 2 OR O = 3 THEN  GOSUB 19
15 LET X = X + 1: IF X < Y THEN 11
16 LET O = 3:E = 0: RETURN 
17 HPLOT XC - X,YC + Y: HPLOT XC + X,YC + Y: HPLOT XC - Y,YC + X: IF  NOT E THEN  HPLOT XC + Y,YC + X
18 RETURN 
19 HPLOT XC - X,YC - Y: HPLOT XC + X,YC - Y: HPLOT XC - Y,YC - X: HPLOT XC + Y,YC - X: RETURN 
20 LET M = K - 31
21 ON M GOTO 32,33,34,35,36,37,38,39,40,41,42,43,44
22 LET M = M - 32
23 ON M GOTO 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87
24 LET M = M - 32
25 ON M GOTO 96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,10,112,113,114,115,116,117,118,119,120,121
32 RETURN 
33 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R - GY: HPLOT XC - R,YC + R: GOTO 9: REM !
44 HPLOT XC - R,YC + R + R / 2 TO XC - R,YC + R: GOTO 9: REM ,
71 LET O = 2:YC = YC - R: GOSUB 10:YC = YC + R: HPLOT XC - R,YC TO XC - R,YC - R: HPLOT XC + R / 2,YC TO XC + R,YC TO XC + R,YC + R:O = 1: GOTO 10: REM G
87 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R TO XC,YC TO XC + R,YC + R TO XC + R,YC - R * 2: RETURN : REM W
98 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R: GOTO 10: RETURN : REM B

100 HPLOT XC + R,YC - R * 2 TO XC + R,YC + R: GOTO 10: REM D 101 HPLOT XC - R,YC TO XC + R,YC:E = 1: GOTO 10: REM E 108 HPLOT XC - R,YC - R * 2 TO XC - R,YC + R: GOTO 9: REM L 114 HPLOT XC - R,YC - R TO XC - R,YC + R:O = 2: GOTO 10: REM R 121 HPLOT XC - R,YC - R TO XC,YC + R: HPLOT XC + R,YC - R TO XC - R,YC + R * 3: RETURN : REM Y</lang>

Arendelle

// title

   "Hello, World!"

// first spacings

   [ 5 , rd ]

// body

   /* H */ [7,pd][4,u][3,pr][3,d][7,pu]drr
   /* E */ [6,pd][4,pr]l[3,u][2,lp][3,u][3,pr]r
   /* L */ [7,pd]u[3,rp][6,u]rr
   /* L */ [7,pd]u[3,rp][6,u]rr
   /* O */ [7,pd]u[2,rp]r[6,pu][3,pl][5,r]
   /* , */ [5,d]prpd[3,pld][9,u][5,r]
   /*   */ rrr
   /* W */ [4,pd][2,prd][2,pru][5,pu][5,d][2,prd][2,pru][5,pu]rrd
   /* O */ [7,pd]u[2,rp]r[6,pu][3,pl][5,r]
   /* R */ [7,pd][7,u][3,rp][3,pd][3,pl]rrdpr[2,dp][6,u]rr
   /* L */ [7,pd]u[3,rp][6,u]rr
   /* D */ [6,pd][3,pr][5,up]u[2,lp]p[4,r]
   /* ! */ r[5,pd]dp[6,u]rr

// done

ATS

<lang ATS>//

  1. include

"share/atspre_define.hats"

  1. include

"share/atspre_staload.hats" // (* ****** ****** *)

staload UN = $UNSAFE

(* ****** ****** *)

staload "{$GLIB}/SATS/glib.sats"

(* ****** ****** *)

staload "{$GTK}/SATS/gdk.sats" staload "{$GTK}/SATS/gtk.sats" staload "{$GLIB}/SATS/glib-object.sats"

(* ****** ****** *)

%{^ typedef char **charpp ; %} ; abstype charpp = $extype"charpp"

(* ****** ****** *)

fun hello (

 widget: !GtkWidget1, _: gpointer

) : void = print ("Goodbye, world!\n")

fun on_delete_event (

 widget: !GtkWidget1

, event: &GdkEvent, udata: gpointer ) : gboolean = let

 val () = print ("delete event occurred\n")

in

 GTRUE // handling of delete-event is finished

end // end of [on_delete_event]

fun on_destroy

 (widget: !GtkWidget1, _: gpointer): void = gtk_main_quit ()

// end of [on_destroy]

(* ****** ****** *)

macdef nullp = the_null_ptr

(* ****** ****** *)

implement main0 (argc, argv) = { // var argc: int = argc var argv: charpp = $UN.castvwtp1{charpp}(argv) // val () = $extfcall (void, "gtk_init", addr@(argc), addr@(argv)) // val window =

 gtk_window_new (GTK_WINDOW_TOPLEVEL)

val () = assertloc (ptrcast(window) > 0) // val _(*id*) = g_signal_connect (

 window, (gsignal)"destroy", (G_CALLBACK)on_destroy, (gpointer)nullp

) (* end of [val] *) val _(*id*) = g_signal_connect (

 window, (gsignal)"delete_event", (G_CALLBACK)on_delete_event, (gpointer)nullp

) (* end of [val] *) // val () = gtk_container_set_border_width (window, (guint)10) val button = gtk_button_new_with_label (gstring("Goodbye, world!")) val () = assertloc (ptrcast(button) > 0) // val () = gtk_widget_show (button) val () = gtk_container_add (window, button) val () = gtk_widget_show (window) // val _(*id*) = g_signal_connect (

 button, (gsignal)"clicked", (G_CALLBACK)hello, (gpointer)nullp

) val _(*id*) = g_signal_connect_swapped (

 button, (gsignal)"clicked", (G_CALLBACK)gtk_widget_destroy, window

) // val () = g_object_unref (button) val () = g_object_unref (window) // ref-count becomes 1! // val ((*void*)) = gtk_main () // } (* end of [main0] *)</lang>

AutoHotkey

<lang autohotkey>MsgBox, Goodbye`, World!</lang> <lang autohotkey>ToolTip, Goodbye`, World!</lang> <lang autohotkey>Gui, Add, Text, x4 y4, To be announced: Gui, Add, Edit, xp+90 yp-3, Goodbye, World! Gui, Add, Button, xp+98 yp-1, OK Gui, Show, w226 h22 , Rosetta Code Return</lang> <lang autohotkey>SplashTextOn, 100, 100, Rosetta Code, Goodbye, World!</lang>

AutoIt

<lang autoit>#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Hello World") ; Create the main GUI GUICtrlCreateLabel("Goodbye, World!", -1, -1) ; Create a label dispalying "Goodbye, World!"

GUISetState() ; Make the GUI visible

While 1 ; Infinite GUI loop $nMsg = GUIGetMsg() ; Get any messages from the GUI Switch $nMsg ; Switch for a certain event Case $GUI_EVENT_CLOSE ; When an user closes the windows Exit ; Exit

EndSwitch WEnd </lang>

<lang autoit>MsgBox(0, "Goodbye", "Goodbye, World!")</lang>

<lang autoit>ToolTip("Goodbye, World!")</lang>

AWK

Awk has no GUI, but can execute system-commands.

E.g. the Windows-commandline provides a command for a messagebox,
see below at Batch_File and UNIX_Shell.

<lang awk># Usage: awk -f hi_win.awk BEGIN { system("msg * Goodbye, Msgbox !") } </lang>

Axe

This example is almost identical to the TI-83 BASIC version. <lang axe>ClrHome Text(0,0,"Goodbye, world!") Pause 5000</lang>

BASIC

Works with: FreeBASIC

<lang freebasic>' Demonstrate a simple Windows application using FreeBasic

  1. include once "windows.bi"

Declare Function WinMain(ByVal hInst As HINSTANCE, _

     ByVal hPrev As HINSTANCE, _
     ByVal szCmdLine as String, _
     ByVal iCmdShow As Integer) As Integer

End WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )

Function WinMain (ByVal hInst As HINSTANCE, _

                 ByVal hPrev As HINSTANCE, _
                 ByVal szCmdLine As String, _
                 ByVal iCmdShow As Integer) As Integer
   MessageBox(NULL, "Goodbye World", "Goodbye World", MB_ICONINFORMATION)
   function = 0

End Function</lang>

<lang freebasic>' Demonstrate a simple Windows/Linux application using GTK/FreeBasic

  1. INCLUDE "gtk/gtk.bi"

gtk_init(@__FB_ARGC__, @__FB_ARGV__)

VAR win = gtk_window_new (GTK_WINDOW_TOPLEVEL) gtk_window_set_title (gtk_window (win), "Goodbye, World") g_signal_connect(G_OBJECT (win), "delete-event", @gtk_main_quit, 0) gtk_widget_show_all (win)

gtk_main()

END 0</lang>

BASIC256

<lang BASIC256>clg font "times new roman", 20,100 color orange rect 10,10, 140,30 color red text 10,10, "Hello World"</lang>

Batch File

From Window 7 and later, pure Batch File does not completely provide GUI. However, MSHTA.EXE provides command-line JavaScript/VBScript access. <lang dos>@echo off

Output to message box [Does not work in Window 7 and later]

msg * "Goodbye, World!" 2>nul

Using MSHTA.EXE Hack::

@mshta javascript:alert("Goodbye, World!");code(close()); @mshta vbscript:Execute("msgbox(""Goodbye, World!""):code close") pause</lang>

BBC BASIC

<lang bbcbasic> SYS "MessageBox", @hwnd%, "Goodbye, World!", "", 0</lang>

BML

<lang bml>msgbox Goodbye, World!</lang>

C

Library: GTK

<lang c>#include <gtk/gtk.h>

int main (int argc, char **argv) {

 GtkWidget *window;
 gtk_init(&argc, &argv);
 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title (GTK_WINDOW (window), "Goodbye, World");
 g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
 gtk_widget_show_all (window);
 gtk_main();
 return 0;

}</lang>

Library: Win32

Where hWnd is a valid window handle corresponding to a control in the application <lang c>#include "windows.h" void SayGoodbyeWorld(HWND hWnd) {

 SetWindowText(hWnd, _T("Goodbye, World!"));

}</lang>

C#

Library: Windows Forms

<lang csharp>using System; using System.Windows.Forms;

class Program {

   static void Main(string[] args) {
       Application.EnableVisualStyles(); //Optional.
       MessageBox.Show("Hello World!");
   }

}</lang>

Library: GTK

<lang csharp>using Gtk; using GtkSharp;

public class GoodbyeWorld {

 public static void Main(string[] args) {
   Gtk.Window window = new Gtk.Window();
   window.Title = "Goodbye, World";
   window.DeleteEvent += delegate { Application.Quit(); };
   window.ShowAll();
   Application.Run();
 }

}</lang>

C++

Works with: GCC version 3.3.5
Library: GTK

<lang cpp>#include <gtkmm.h> int main(int argc, char *argv[]) {

  Gtk::Main app(argc, argv);
  Gtk::MessageDialog msg("Goodbye, World!");
  msg.run();

}</lang>

Library: Win32

All Win32 APIs work in C++ the same way as they do in C. See the C example.

Library: MFC

Where pWnd is a pointer to a CWnd object corresponding to a valid window in the application. <lang cpp>#include "afx.h" void ShowGoodbyeWorld(CWnd* pWnd) {

   pWnd->SetWindowText(_T("Goodbye, World!"));

}</lang>

Library: FLTK

<lang cpp>

  1. include <FL/Fl.H>
  2. include <FL/Fl_Window.H>
  3. include <FL/Fl_Box.H>

int main(int argc, char **argv) {

 Fl_Window *window = new Fl_Window(300,180);
 Fl_Box *box = new Fl_Box(20,40,260,100,"Goodbye, World!");
 box->box(FL_UP_BOX);
 box->labelsize(36);
 box->labelfont(FL_BOLD+FL_ITALIC);
 box->labeltype(FL_SHADOW_LABEL);
 window->end();
 window->show(argc, argv);
 return Fl::run();

} </lang>

C++/CLI

<lang cpp> using namespace System::Windows::Forms;

int main(array<System::String^> ^args) {

 MessageBox::Show("Goodbye, World!", "Rosetta Code");
 return 0;

} </lang>

Clean

Library: Object I/O

<lang clean>import StdEnv, StdIO

Start :: *World -> *World Start world = startIO NDI Void (snd o openDialog undef hello) [] world where

   hello = Dialog "" (TextControl "Goodbye, World!" []) 
                                    [WindowClose (noLS closeProcess)]</lang>

Clojure

<lang lisp>(ns experimentation.core

 (:import (javax.swing JOptionPane JFrame JTextArea JButton)
    (java.awt FlowLayout)))

(JOptionPane/showMessageDialog nil "Goodbye, World!") (let [button (JButton. "Goodbye, World!")

     window (JFrame. "Goodbye, World!")
     text (JTextArea. "Goodbye, World!")]
 (doto window
   (.setLayout (FlowLayout.))
   (.add button)
   (.add text)
   (.pack)
   (.setDefaultCloseOperation (JFrame/EXIT_ON_CLOSE))
   (.setVisible true)))</lang>

COBOL

GUI

The following are in the Managed COBOL dialect.

Works with: Visual COBOL
Library: Windows Forms
Translation of: C#

<lang cobol> CLASS-ID ProgramClass.

      METHOD-ID Main STATIC.
      PROCEDURE DIVISION.
          INVOKE TYPE Application::EnableVisualStyles() *> Optional
          INVOKE TYPE MessageBox::Show("Goodbye, World!")
      END METHOD.
      END CLASS.</lang>

gui.xaml.cbl: <lang cobol> CLASS-ID GoodbyeWorldWPF.Window IS PARTIAL

                INHERITS TYPE System.Windows.Window.
      METHOD-ID NEW.
      PROCEDURE DIVISION.
          INVOKE self::InitializeComponent()
      END METHOD.
      END CLASS.</lang>

gui.xaml: <lang xaml><Window x:Class="COBOL_WPF.Window1"

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   Title="Hello world/Graphical">
   <TextBox>Hello, World!</TextBox>

</Window></lang>

TUI

Works with: OpenCOBOL version 1.1

The program gets the lines and columns of the screen and positions the text in the middle. Program waits for a return key.

<lang cobol> program-id. ghello.

 data division.
 working-storage section.
 01  var pic x(1).
 01  lynz  pic 9(3).
 01  colz  pic 9(3).
 01  msg pic x(15) value "Goodbye, world!".
 procedure division.
   accept lynz from lines end-accept
   divide lynz by 2 giving lynz.
   accept colz from columns end-accept
   divide colz by 2 giving colz.
   subtract 7 from colz giving colz.
   display msg
     at line number lynz 
     column number colz 
   end-display
   accept var end-accept
   stop run.</lang>

Cobra

Requires

Library: GTK#

GUI library.

<lang cobra> @args -pkg:gtk-sharp-2.0

use Gtk

class MainProgram

 def main
   Application.init
   dialog = MessageDialog(nil,
     DialogFlags.DestroyWithParent,
     MessageType.Info, 
     ButtonsType.Ok,
     "Goodbye, World!")
   dialog.run
   dialog.destroy

</lang>

CoffeeScript

<lang coffeescript>alert "Goodbye, World!"</lang>

Common Lisp

This can be done using the extension package ltk that provides an interface to the Tk library.

Library: Tk

<lang lisp>(use-package :ltk)

(defun show-message (text)

 "Show message in a label on a Tk window"
 (with-ltk ()
     (let* ((label (make-instance 'label :text text))
            (button (make-instance 'button :text "Done"
                                   :command (lambda () 
                                              (ltk::break-mainloop)
                                              (ltk::update)))))
             (pack label :side :top :expand t :fill :both)
             (pack button :side :right)
             (mainloop))))

(show-message "Goodbye World")</lang>

This can also be done using the CLIM 2.0 specification. The following code runs on both SBCL and the LispWorks IDE:

Library: CLIM

<lang lisp> ((in-package :clim-user)

(defclass hello-world-pane

   (clim-stream-pane) ())

(define-application-frame hello-world ()

 ((greeting :initform "Hello World"
            :accessor greeting))
 (:pane (make-pane 'hello-world-pane)))
Behaviour defined by the Handle Repaint Protocol

(defmethod handle-repaint ((pane hello-world-pane) region)

 (let ((w (bounding-rectangle-width pane))
       (h (bounding-rectangle-height pane)))
   ;; Blank the pane out
   (draw-rectangle* pane 0 0 w h
                    :filled t
                    :ink (pane-background pane))
   ;; Draw greeting in center of pane
   (draw-text* pane
               (greeting *application-frame*)
               (floor w 2) (floor h 2)
               :align-x :center
               :align-y :center)))

(run-frame-top-level

(make-application-frame 'hello-world
  :width 200 :height 200))</lang>

Creative Basic

<lang Creative Basic> DEF Win:WINDOW DEF Close:CHAR DEF ScreenSizeX,ScreenSizeY:INT

GETSCREENSIZE(ScreenSizeX,ScreenSizeY)

WINDOW Win,0,0,ScreenSizeX,ScreenSizeY,0,0,"Goodbye program",MainHandler

PRINT Win,"Goodbye, World!" 'Prints in the upper left corner of the window (position 0,0).

WAITUNTIL Close=1

CLOSEWINDOW Win

END

SUB MainHandler

   IF @CLASS=@IDCLOSEWINDOW THEN Close=1   

RETURN </lang>

D

Library: gtkD

<lang d>import gtk.MainWindow, gtk.Label, gtk.Main;

class GoodbyeWorld : MainWindow {

   this() {
       super("GtkD");
       add(new Label("Goodbye World"));
       showAll();
   }

}

void main(string[] args) {

   Main.init(args);
   new GoodbyeWorld();
   Main.run();

}</lang>

Delphi

<lang Delphi>program HelloWorldGraphical;

uses

 Dialogs;

begin

 ShowMessage('Goodbye, World!');

end.</lang>

Dylan

(This works entered into the interactive shell): <lang dylan>notify-user("hello world!", frame: make(<frame>));</lang>

E

Library: SWT

This is a complete application. If it were part of a larger application, the portions related to interp would be removed.

<lang e>def <widget> := <swt:widgets.*> def SWT := <swt:makeSWT>

def frame := <widget:makeShell>(currentDisplay)

 frame.setText("Rosetta Code")
 frame.setBounds(30, 30, 230, 60)
 frame.addDisposeListener(def _ { to widgetDisposed(event) {
   interp.continueAtTop()
 }})

def label := <widget:makeLabel>(frame, SWT.getLEFT())

 label.setText("Goodbye, World!")
 swtGrid`$frame: $label`

frame.open()

interp.blockAtTop()</lang>

eC

MessageBox:

<lang ec>import "ecere" MessageBox goodBye { contents = "Goodbye, World!" };</lang>

Label:

<lang ec>import "ecere" Label label { text = "Goodbye, World!", hasClose = true, opacity = 1, size = { 320, 200 } };</lang>

Titled Form + Surface Output:

<lang ec>import "ecere"

class GoodByeForm : Window {

  text = "Goodbye, World!";
  size = { 320, 200 };
  hasClose = true;
  void OnRedraw(Surface surface)
  {
     surface.WriteTextf(10, 10, "Goodbye, World!");
  }

}

GoodByeForm form {};</lang>

EchoLisp

<lang lisp> (alert "Good bye, world!") </lang>

Elena

<lang elena>

  1. import forms.
  2. import system.
  1. class Window :: SDIDialog

{

   #field goodByeWorldLabel.
   #field closeButton.

   #constructor new <= (new)
   [
       goodByeWorldLabel := Label new.
       closeButton       := Button new.

       theControls append:goodByeWorldLabel.
       theControls append:closeButton.

       $self set &x:250 &y:200.
       $self set &width:200 &height:110.

       goodByeWorldLabel set &x:40 &y:10.
       goodByeWorldLabel set &width:150 &height:30.
       goodByeWorldLabel set &caption:"Goodbye, World!".

       closeButton set &x:20 &y:40.
       closeButton set &width:150 &height:30.
       closeButton set &caption:"Close".

       closeButton set &onClick:args
           [ 'program stop. ].
   ]

} </lang>

Euphoria

Message box

<lang euphoria>include msgbox.e

integer response response = message_box("Goodbye, World!","Bye",MB_OK)</lang>

EGL

Works with: EDT

Allows entry of any name into a text field (using "World" as the default entry). Then, when the "Say Goodbye" button is pressed, sets a text label to the value "Goodbye, <name>!". <lang egl> import org.eclipse.edt.rui.widgets.*; import dojo.widgets.*;

handler HelloWorld type RUIhandler{initialUI =[ui]}

   ui Box {columns=1, children=[nameField, helloLabel, goButton]};
 
   nameField DojoTextField {placeHolder = "What's your name?", text = "World"};
   helloLabel TextLabel {};
   goButton DojoButton {text = "Say Goodbye", onClick ::= onClick_goButton};
 
   function onClick_goButton(e Event in) 
       helloLabel.text = "Goodbye, " + nameField.text + "!";
   end

end </lang>


F#

Just display the text in a message box. <lang fsharp>#light open System open System.Windows.Forms [<EntryPoint>] let main _ =

   MessageBox.Show("Hello World!") |> ignore
   0</lang>

Factor

To be pasted in the listener :

   USING: ui ui.gadgets.labels ;
   [ "Goodbye World" <label> "Rosetta Window" open-window ] with-ui

Fantom

<lang fantom> using fwt

class Hello {

 public static Void main ()
 {
   Dialog.openInfo (null, "Goodbye world")
 }

} </lang>

Forth

Works with: SwiftForth

<lang forth>HWND z" Goodbye, World!" z" (title)" MB_OK MessageBox</lang>

Alternative:

Works with: Win32Forth version 6.15.03

<lang forth> s" Goodbye, World!" MsgBox</lang>

FreeBASIC

<lang FreeBASIC>'FreeBASIC Hello-fb0.bas May 2015

Screen 0 'open text window Print "Hello world"

Print "Enter any key to go the graphics screen" sleep

screen 18 'Screen 18 Resolution 640x480 with at least 256 colors locate 10,10 Print "Hello world!"

locate 20,10 Print "Enter any key to exit" sleep End</lang>

Frege

<lang frege>package HelloWorldGraphical where

import Java.Swing

main _ = do

   frame <- JFrame.new "Goodbye, world!"
   frame.setDefaultCloseOperation(JFrame.dispose_on_close)
   label <- JLabel.new "Goodbye, world!"
   cp <- frame.getContentPane
   cp.add label
   frame.pack
   frame.setVisible true</lang>

Frink

This brings up an infinitely-rescalable graphic window containing "Goodbye, World" drawn graphically.

All Frink graphics can be written to arbitrary coordinates; Frink will automatically scale and center any drawn graphics to be visible in the window (greatly simplifying programming,) so the exact coordinates used below are rather arbitrary. (This means that if you wrote "Hello World" instead of "Goodbye, World", you could just change that string and everything would still center perfectly.)

The graphics are infinitely-scalable and can be rendered at full quality to any resolution. This program "shows off" by rotating the text by 10 degrees, and also rendering it to a printer (which can include tiling across multiple pages) and rendering to a graphics file. (Frink can automatically render the same graphics object to many image formats, including PNG, JPG, SVG, HTML5 canvas, animated GIF, bitmapped image in memory, and more.)

<lang frink> g = new graphics g.font["SansSerif", 10] g.text["Goodbye, World!", 0, 0, 10 degrees] g.show[]

g.print[] // Optional: render to printer g.write["GoodbyeWorld.png", 400, 300] // Optional: write to graphics file </lang>

FunL

<lang funl>native javax.swing.{SwingUtilities, JPanel, JLabel, JFrame} native java.awt.Font

def createAndShowGUI( msg ) =

 f = JFrame()
 f.setTitle( msg )
 f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE )
 p = JPanel()
 l = JLabel( msg )
 l.setFont( Font.decode(Font.SERIF + ' 150') )
 p.add( l )
 f.add( p )
 f.pack()
 f.setResizable( false )
 f.setVisible( true )

SwingUtilities.invokeLater( createAndShowGUI.runnable('Goodbye, World!') )</lang>

Gambas

<lang gambas>Message.Info("Goodbye, World!") ' Display a simple message box</lang>

GML

<lang gml>draw_text(0,0,"Goodbye World!");</lang>

Go

Library: go-gtk

<lang go>package main

import "github.com/mattn/go-gtk/gtk"

func main() {

  gtk.Init(nil)
  win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
  win.SetTitle("Goodbye, World!")
  win.SetSizeRequest(300, 200)
  win.Connect("destroy", gtk.MainQuit)
  button := gtk.NewButtonWithLabel("Goodbye, World!")
  win.Add(button)
  button.Connect("clicked", gtk.MainQuit)
  win.ShowAll()
  gtk.Main()

}</lang>

Groovy

Translation of: Java

<lang groovy>import groovy.swing.SwingBuilder import javax.swing.JFrame

new SwingBuilder().edt {

 optionPane().showMessageDialog(null, "Goodbye, World!")
 frame(title:'Goodbye, World!', defaultCloseOperation:JFrame.EXIT_ON_CLOSE, pack:true, show: true) {
   flowLayout()
   button(text:'Goodbye, World!')
   textArea(text:'Goodbye, World!')
 }

} </lang>

GUISS

Here we display the message on the system notepad:

<lang guiss>Start,Programs,Accessories,Notepad,Type:Goodbye[comma][space]World[pling]</lang>

Harbour

<lang visualfoxpro>PROCEDURE Main()

  RETURN wapi_MessageBox(,"Goodbye, World!","")

</lang>

Haskell

Using

Library: gtk

from HackageDB

<lang haskell>import Graphics.UI.Gtk import Control.Monad

messDialog = do

 initGUI
 dialog <- messageDialogNew Nothing [] MessageInfo ButtonsOk "Goodbye, World!"
 
 rs <- dialogRun dialog
 when (rs == ResponseOk || rs == ResponseDeleteEvent) $ widgetDestroy dialog
 dialog `onDestroy` mainQuit

 mainGUI</lang>

Run in GHCi interpreter: <lang haskell>*Main> messDialog</lang>

HicEst

<lang hicest>WRITE(Messagebox='!') 'Goodbye, World!'</lang>

Icon and Unicon

Icon

<lang Icon>link graphics procedure main()

  WOpen("size=100,20") | stop("No window")
  WWrites("Goodbye, World!")
  WDone()

end</lang>

graphics is required

Unicon

<lang unicon> import gui $include "guih.icn"

class WindowApp : Dialog ()

 # -- automatically called when the dialog is created
 method component_setup ()
   # add 'hello world' label
   label := Label("label=Hello world","pos=0,0")
   add (label)
   # make sure we respond to close event
   connect(self, "dispose", CLOSE_BUTTON_EVENT)
 end

end

  1. create and show the window

procedure main ()

 w := WindowApp ()
 w.show_modal ()

end </lang>

Integer BASIC

40×40 isn't great resolution, but it's enough!

<lang basic> 10 REM FONT DERIVED FROM 04B-09 BY YUJI OSHIMOTO 20 GR 30 COLOR = 12 40 REM G 50 HLIN 0,5 AT 0 : HLIN 0,5 AT 1 60 VLIN 2,9 AT 0 : VLIN 2,9 AT 1 70 HLIN 2,5 AT 9 : HLIN 2,5 AT 8 80 VLIN 4,7 AT 5 : VLIN 4,7 AT 4 90 VLIN 4,5 AT 3 100 REM O 110 HLIN 7,12 AT 2 : HLIN 7,12 AT 3 120 HLIN 7,12 AT 8 : HLIN 7,12 AT 9 130 VLIN 4,7 AT 7 : VLIN 4,7 AT 8 140 VLIN 4,7 AT 11 : VLIN 4,7 AT 12 150 REM O 160 HLIN 14,19 AT 2 : HLIN 14,19 AT 3 170 HLIN 14,19 AT 8 : HLIN 14,19 AT 9 180 VLIN 4,7 AT 14 : VLIN 4,7 AT 15 190 VLIN 4,7 AT 18 : VLIN 4,7 AT 19 200 REM D 210 HLIN 21,24 AT 2 : HLIN 21,24 AT 3 220 HLIN 21,26 AT 8 : HLIN 21,26 AT 9 230 VLIN 4,7 AT 21 : VLIN 4,7 AT 22 240 VLIN 0,7 AT 25 : VLIN 0,7 AT 26 250 REM - 260 HLIN 28,33 AT 4 : HLIN 28,33 AT 5 270 REM B 280 VLIN 11,20 AT 0 : VLIN 11,20 AT 1 290 HLIN 2,5 AT 20 : HLIN 2,5 AT 19 300 VLIN 15,18 AT 5 : VLIN 15,18 AT 4 310 HLIN 2,5 AT 14 : HLIN 2,5 AT 13 320 REM Y 330 VLIN 13,20 AT 7 : VLIN 13,20 AT 8 340 VLIN 19,20 AT 9 : VLIN 19,20 AT 10 350 VLIN 13,24 AT 11 : VLIN 13,24 AT 12 360 VLIN 23,24 AT 10 : VLIN 23,24 AT 9 370 REM E 380 VLIN 13,20 AT 14 : VLIN 13,20 AT 15 390 HLIN 16,19 AT 13 : HLIN 16,19 AT 14 400 HLIN 18,19 AT 15 : HLIN 18,19 AT 16 410 HLIN 16,17 AT 17 : HLIN 16,17 AT 18 420 HLIN 16,19 AT 19 : HLIN 16,19 AT 20 430 REM , 440 VLIN 17,22 AT 21 : VLIN 17,22 AT 22 450 REM W 460 VLIN 24,33 AT 0 : VLIN 24,33 AT 1 : VLIN 24,33 AT 3 470 VLIN 24,33 AT 4 : VLIN 24,33 AT 6 : VLIN 24,33 AT 7 480 HLIN 0,7 AT 33 : HLIN 0,7 AT 32 490 REM O 500 HLIN 9,14 AT 26 : HLIN 9,14 AT 27 510 HLIN 9,14 AT 32 : HLIN 9,14 AT 33 520 VLIN 28,31 AT 9 : VLIN 28,31 AT 10 530 VLIN 28,31 AT 13 : VLIN 28,31 AT 14 540 REM R 550 HLIN 16,21 AT 26 : HLIN 16,21 AT 27 560 VLIN 28,33 AT 16 : VLIN 28,33 AT 17 570 REM L 580 VLIN 24,33 AT 23 : VLIN 24,33 AT 24 590 REM D 600 HLIN 26,29 AT 26 : HLIN 26,29 AT 27 610 HLIN 26,29 AT 32 : HLIN 26,29 AT 33 620 VLIN 28,33 AT 26 : VLIN 28,33 AT 27 630 VLIN 24,33 AT 30 : VLIN 24,33 AT 31 640 REM ! 650 VLIN 24,29 AT 33 : VLIN 24,29 AT 34 660 VLIN 32,33 AT 33 : VLIN 32,33 AT 34 670 END </lang>

Ioke

Translation of: Java

<lang ioke>import(

 :javax:swing, :JOptionPane, :JFrame, :JTextArea, :JButton

) import java:awt:FlowLayout

JOptionPane showMessageDialog(nil, "Goodbye, World!") button = JButton new("Goodbye, World!") text = JTextArea new("Goodbye, World!") window = JFrame new("Goodbye, World!") do(

 layout = FlowLayout new
 add(button)
 add(text)
 pack
 setDefaultCloseOperation(JFrame field:EXIT_ON_CLOSE)
 visible = true

)</lang>

IWBASIC

<lang IWBASIC> DEF Win:WINDOW DEF Close:CHAR DEF ScreenSizeX,ScreenSizeY:UINT

GETSCREENSIZE(ScreenSizeX,ScreenSizeY)

OPENWINDOW Win,0,0,ScreenSizeX,ScreenSizeY,NULL,NULL,"Goodbye program",&MainHandler

PRINT Win,"Goodbye, World!" 'Prints in upper left corner of the window (position 0,0).

WAITUNTIL Close=1

CLOSEWINDOW Win

END

SUB MainHandler

   IF @MESSAGE=@IDCLOSEWINDOW THEN Close=1

RETURN ENDSUB </lang>

J

<lang j>wdinfo 'Goodbye, World!'</lang>

Java

Library: Swing

<lang java>import javax.swing.*; import java.awt.*;

public class OutputSwing {

   public static void main(String[] args) {
       SwingUtilities.invokeLater(new Runnable(){
           public void run() {
               JOptionPane.showMessageDialog (null, "Goodbye, World!"); // in alert box
               JFrame frame = new JFrame("Goodbye, World!");            // on title bar
               JTextArea text = new JTextArea("Goodbye, World!");       // in editable area
               JButton button = new JButton("Goodbye, World!");         // on button
               frame.setLayout(new FlowLayout());
               frame.add(button);
               frame.add(text);
               frame.pack();
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               frame.setVisible(true);
           }
       });
   }

}</lang>

Using Java 8 lambdas syntax:

<lang java>import javax.swing.*; import java.awt.*;

public class HelloWorld {

   public static void main(String[] args) {
       
       SwingUtilities.invokeLater(() -> {
           JOptionPane.showMessageDialog(null, "Goodbye, world!");
           JFrame frame = new JFrame("Goodbye, world!");
           JTextArea text = new JTextArea("Goodbye, world!");
           JButton button = new JButton("Goodbye, world!");
           frame.setLayout(new FlowLayout());
           frame.add(button);
           frame.add(text);
           frame.pack();
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
       });
   }

}</lang>

JavaScript

<lang javascript> alert("Goodbye, World!");</lang>

jq

Works with: jq version 1.4

In the following, which generates SVG in a way that can be readily viewed using a web browser, the "Goodbye, World!" text is shaded using a linear gradient.

The approach used here to generate SVG is based on these principles:

  • a JSON object is used to specify CSS styles
    • this makes it easy to combine default specifications with partial specifications, because in jq, for JSON objects, "+" is defined so that (default + partial) is the combination which gives precedence to the right-hand-side operand;
  • for other defaults, the jq "//" operator can be used; thus all SVG parameters can be easily given defaults.

Part 1: Generic SVG-related functions <lang jq># Convert a JSON object to a string suitable for use as a CSS style value

  1. e.g: "font-size: 40px; text-align: center;" (without the quotation marks)

def to_s:

 reduce to_entries[] as $pair (""; . + "\($pair.key): \($pair.value); ");
  1. Defaults: 100%, 100%

def svg(width; height):

 "<svg width='\(width // "100%")' height='\(height // "100%")'
          xmlns='http://www.w3.org/2000/svg'>";
  1. Defaults:
  2. id: "linearGradient"
  3. color1: rgb(0,0,0)
  4. color2: rgb(255,255,255)

def linearGradient(id; color1; color2):

 "<defs>
   <linearGradient id='\(id//"linearGradient")' x1='0%' y1='0%' x2='100%' y2='0%'>
     <stop offset='0%' style='stop-color:\(color1//"rgb(0,0,0)");stop-opacity:1' />
     <stop offset='100%' style='stop-color:\(color2//"rgb(255,255,255)");stop-opacity:1' />
   </linearGradient>
 </defs>";
  1. input: the text string
  2. "style" should be a JSON object (see for example the default ($dstyle));
  3. the style actually used is (default + style), i.e. whatever is specified in "style" wins.
  4. Defaults:
  5. x: 0
  6. y: 0

def text(x; y; style):

 . as $in
 | {"font-size": "40px", "text-align": "center", "text-anchor": "left", "fill": "black"} as $dstyle
 | (($dstyle + style) | to_s) as $style
 | "<text x='\(x//0)' y='\(y//0)' style='\($style)'>
      \(.)",
    "</text>";</lang>

Part 2: "Goodbye, World!" <lang jq>def task:

 svg(null;null),                                                   # use the defaults
 linearGradient("gradient"; "rgb(255,255,0)"; "rgb(255,0,0)"),     # define "gradient"
 ("Goodbye, World!" | text(10; 50; {"fill": "url(#gradient)"})),   # notice how the default for "fill" is overridden
 "</svg>";

task</lang>

Output:
jq -n -r -f Hello_word_Graphical.jq > Hello_word_Graphical.svg

Just Basic

<lang Just Basic> print "Goodbye, World!" 'Prints in the upper left corner of the default text window: mainwin, a window with scroll bars. </lang>

Julia

Library: Tk

<lang julia>using Tk

window = Toplevel("Hello World", 200, 100, false) pack_stop_propagate(window)

fr = Frame(window) pack(fr, expand=true, fill="both")

txt = Label(fr, "Hello World") pack(txt, expand=true)

set_visible(window, true)

  1. sleep(7)</lang>

KonsolScript

Popping a dialog-box. <lang KonsolScript>function main() {

 Konsol:Message("Goodbye, World!", "")

}</lang>

Displaying it in a Window. <lang KonsolScript>function main() {

 Screen:PrintString("Goodbye, World!")
 while (B1 == false) {
   Screen:Render()
 }

}</lang>

LabVIEW

This image is a VI Snippet, an executable image of LabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.

Lasso

On OS X machines: <lang lasso>sys_process('/usr/bin/osascript', (: '-e', 'display dialog "Goodbye, World!"'))->wait</lang>

Liberty BASIC

<lang lb>NOTICE "Goodbye, world!"</lang>

LiveCode

<lang LiveCode>answer "Goodbye, World!"</lang> A dialog box can be modified as appropriate for the context by setting a "iconType", button text and title <lang LiveCode>answer warning "Goodbye, World!" with "Goodbye, World!" titled "Goodbye, World!"</lang>

Lobster

<lang Lobster>gl_window("graphical hello world", 800, 600) gl_setfontname("data/fonts/Droid_Sans/DroidSans.ttf") gl_setfontsize(30)

while gl_frame():

   gl_clear([ 0.0, 0.0, 0.0, 1.0 ])
   gl_text("Goodbye, World!")</lang>

Works with: UCB Logo

Among the turtle commands are some commands for drawing text in the graphical area. Details and capabilities differ among Logo implementations. <lang logo>LABEL [Hello, World!] SETLABELHEIGHT 2 * last LABELSIZE LABEL [Goodbye, World!]</lang>

Lua

Library: IUPLua

<lang lua>require "iuplua"

dlg = iup.dialog{iup.label{title="Goodbye, World!"}; title="test"} dlg:show()

if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then

 iup.MainLoop()

end</lang>

Library: LÖVE

To actually run this LÖVE-program, the following code needs to be in a file main.lua, in its own folder.
This folder usually also contains other resources for a game, such as pictures, sound, music, other source-files, etc.

To run the program, on windows, drag that folder onto either love.exe or a shortcut to love.exe.

<lang lua> function love.draw()

   love.graphics.print("Goodbye, World!", 400, 300)

end </lang>

Maple

<lang Maple> Maplets:-Display( Maplets:-Elements:-Maplet( [ "Goodbye, World!" ] ) ); </lang>

Mathematica / Wolfram Language

<lang Mathematica>CreateDialog["Hello world"]</lang>

MATLAB

<lang matlab>msgbox('Goodbye, World!')</lang>

Add text to a graphical plot. <lang Matlab> text(0.2,0.2,'Hello World!') </lang>

MAXScript

<lang maxscript>messageBox "Goodbye world"</lang>

mIRC Scripting Language

<lang mirc>alias goodbyegui {

 dialog -m Goodbye Goodbye

}

dialog Goodbye {

 title "Goodbye, World!"
 size -1 -1 80 20
 option dbu
 text "Goodbye, World!", 1, 20 6 41 7

}</lang>

Modula-3

Library: Trestle

<lang modula3>MODULE GUIHello EXPORTS Main;

IMPORT TextVBT, Trestle;

<*FATAL ANY*>

VAR v := TextVBT.New("Goodbye, World!");

BEGIN

 Trestle.Install(v);
 Trestle.AwaitDelete(v);

END GUIHello.</lang> This code requires an m3makefile.

import ("ui")
implementation ("GUIHello")
program ("Hello")

This tells the compiler to link with the UI library, the file name of the implementation code, and to output a program named "Hello".

Nemerle

Compile with:

ncc -reference:System.Windows.Forms goodbye.n

<lang Nemerle>using System; using System.Windows.Forms;

MessageBox.Show("Goodbye, World!")</lang>

NetRexx

Using Java's Swing Foundation Classes.

Library: Swing

<lang NetRexx>/* NetRexx */ options replace format comments java crossref symbols binary

import javax.swing.

msgText = 'Goodbye, World!' JOptionPane.showMessageDialog(null, msgText) </lang>

An alternative version using other Swing classes.

Library: Swing

<lang NetRexx>/* NetRexx */ options replace format comments java crossref symbols binary

import javax.swing.

msgText = 'Goodbye, World!'

window = JFrame(msgText) text = JTextArea() minSize = Dimension(200, 100)

text.setText(msgText)

window.setLayout(FlowLayout()) window.add(text) window.setMinimumSize(minSize) window.pack window.setVisible(isTrue) window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

return

method isTrue() public static returns boolean

 return 1 == 1

method isFalse() public static returns boolean

 return \isTrue

</lang>

An example using Java's Abstract Window Toolkit (AWT)

Library: AWT

<lang NetRexx>/* NetRexx */ options replace format comments java crossref symbols binary

class RCHelloWorld_GraphicalAWT_01 extends Dialog implements ActionListener

 properties private constant
   msgText = 'Goodbye, World!'
 properties indirect
   ok = boolean
   can = boolean
   okButton = Button
   canButton = Button
   buttonPanel = Panel

method RCHelloWorld_GraphicalAWT_01(frame = Frame, msg = String, canaction = boolean) public

 super(frame, 'Default', isTrue)
 setLayout(BorderLayout())
 add(BorderLayout.CENTER, Label(msg))
 addOKCancelPanel(canaction)
 createFrame()
 pack()
 setVisible(isTrue)
 
 return

method RCHelloWorld_GraphicalAWT_01(frame = Frame, msg = String) public

 this(frame, msg, isFalse)
 return

method addOKCancelPanel(canaction = boolean)

 setButtonPanel(Panel())
 getButtonPanel.setLayout(FlowLayout())
 createOKButton()
 if canaction then do
   createCancelButton()
   end
 add(BorderLayout.SOUTH, getButtonPanel)
 return

method createOKButton()

 setOkButton(Button('OK'))
 getButtonPanel.add(getOkButton)
 getOkButton.addActionListener(this)
 return

method createCancelButton()

 setCanButton(Button('Cancel'))
 getButtonPanel.add(getCanButton)
 getCanButton.addActionListener(this)
 return

method createFrame()

 dim = getToolkit().getScreenSize
 setLocation(int(dim.width / 3), int(dim.height / 3))
 return

method actionPerformed(ae = ActionEvent) public

 if ae.getSource == getOkButton then do
   setOk(isTrue)
   setCan(isFalse)
   setVisible(isFalse)
   end
 else if ae.getSource == getCanButton then do
   setCan(isTrue)
   setOk(isFalse)
   setVisible(isFalse)
   end
 return

method main(args = String[]) public constant

 mainFrame = Frame()
 mainFrame.setSize(200, 200)
 mainFrame.setVisible(isTrue)
 message = RCHelloWorld_GraphicalAWT_01(mainFrame, msgText, isTrue)
 if message.isOk then
   say 'OK pressed'
 if message.isCan then
   say 'Cancel pressed'
 message.dispose
 mainFrame.dispose
 return

method isTrue() public static returns boolean

 return 1 == 1

method isFalse() public static returns boolean

 return \isTrue

</lang>

newLISP

NewLISP uses a lightweight Java GUI server that it communicates with over a pipe, similar how some languages use Tcl/Tk. This takes advantage of Java's cross platform GUI capability.

<lang NewLISP>; hello-gui.lsp

oofoe 2012-01-18
Initialize GUI server.

(load (append (env "NEWLISPDIR") "/guiserver.lsp")) (gs:init)

Create window frame.

(gs:frame 'Goodbye 100 100 300 200 "Goodbye!") (gs:set-resizable 'Goodbye nil) (gs:set-flow-layout 'Goodbye "center")

Add final message.

(gs:label 'Message "Goodbye, World!" "center") (gs:add-to 'Goodbye 'Message)

Show frame.

(gs:set-visible 'Goodbye true)

Start event loop.

(gs:listen)

(exit) ; NewLisp normally goes to listener after running script. </lang>

Nim

Library: GTK2

<lang nim>import dialogs, gtk2 gtk2.nim_init()

info(nil, "Hello World")</lang>

Library: IUP

<lang nim>import iup

discard iup.open(nil, nil) message("Hello", "Hello World") close()</lang>

Objective-C

To show a modal alert (Mac): <lang objc>NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:@"Goodbye, World!"]; [alert runModal];</lang>

To show a modal alert (iOS): <lang objc>UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Goodbye, World!" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show];</lang>

Objeck

Library: Qt

<lang objeck> use Qt;

bundle Default {

 class QtExample {
   function : Main(args : String[]) ~ Nil {
     app := QAppliction->New();
     win := QWidget->New();
     win->Resize(400, 300);
     win->SetWindowTitle("Goodbye, World!");
     win->Show();
     app->Exec();
     app->Delete();
   }
 }

} </lang>


OCaml

Library: GTK

<lang ocaml>let delete_event evt = false

let destroy () = GMain.Main.quit ()

let main () =

 let window = GWindow.window in
 let _ = window#set_title "Goodbye, World" in
 let _ = window#event#connect#delete ~callback:delete_event in
 let _ = window#connect#destroy ~callback:destroy in
 let _ = window#show () in
 GMain.Main.main ()

let _ = main () ;;</lang>

Library: OCaml-Xlib
Library: Tk
ocaml -I +labltk labltk.cma

Just output as a label in a window: <lang ocaml>let () =

 let main_widget = Tk.openTk () in
 let lbl = Label.create ~text:"Goodbye, World" main_widget in
 Tk.pack [lbl];
 Tk.mainLoop();;</lang>

Output as text on a button that exits the current application: <lang ocaml>let () =

 let action () = exit 0 in
 let main_widget = Tk.openTk () in
 let bouton_press =
   Button.create main_widget ~text:"Goodbye, World" ~command:action in
 Tk.pack [bouton_press];
 Tk.mainLoop();;</lang>

OxygenBasic

Windows MessageBox:


print "Hello World!"


Oxygene

Glade

HelloWorld
HelloWorld


Requires a Glade GUI description file. 'ere be one I produced earlier: <lang xml> <?xml version="1.0" standalone="no"?> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.24.dtd">

<glade-interface>

<widget class="GtkWindow" id="hworld">

 <property name="visible">True</property>
 <property name="title">Hello World</property>
 <property name="modal">False</property>
 <property name="resizable">True</property>
 <property name="default_width">200</property>
 <property name="default_height">100</property>
 <signal name="delete_event" handler="on_hworld_delete_event"/>
 <child>
   <widget class="GtkLabel" id="label1">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="label" translatable="yes">Farewell, cruel world.</property>
   </widget>
 </child>

</widget>

</glade-interface> </lang> And finally the Oxygene: <lang oxygene> // Display a Message in a GUI Window // // Nigel Galloway, April 18th., 2012. // namespace HelloWorldGUI;

interface

uses

 Glade, Gtk, System;

type

 Program = public static class
 public
   class method Main(args: array of String);
 end;
 MainForm = class(System.Object)
 private
   var
     [Widget] hworld: Gtk.Window;
 public
   constructor(args: array of String);
   method on_hworld_delete_event(aSender: Object; args: DeleteEventArgs);
 end;

implementation

class method Program.Main(args: array of String); begin

 new MainForm(args);

end;

constructor MainForm(args: array of String); begin

 inherited constructor;
 Application.Init();
 with myG := new Glade.XML(nil, 'HelloWorldGUI.Main.glade', 'hworld', nil) do myG.Autoconnect(self);
 Application.Run();

end;

method MainForm.on_hworld_delete_event(aSender: Object; args: DeleteEventArgs); begin

 Application.Quit();

end;

end. </lang>

.NET

HelloWorld
HelloWorld


<lang oxygene> namespace HelloWorldNET;

interface

type

 App = class
 public
   class method Main;
 end;
 

implementation

class method App.Main; begin

 System.Windows.MessageBox.Show("Farewell cruel world");

end;

end. </lang>

Oz

<lang oz>declare

 [QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
 Window = {QTk.build td(label(text:"Goodbye, World!"))}

in

 {Window show}</lang>

OpenEdge/Progress

<lang Progress (OpenEdge ABL)>MESSAGE "Goodbye, World!" VIEW-AS ALERT-BOX.</lang>

Panoramic

<lang Panoramic>print "Goodbye, World!" 'Prints in the upper left corner of the window. </lang>

Pascal

Works with: Free_Pascal
Library: Gtk2

Variant of the C example: <lang pascal>program HelloWorldGraphical;

uses

 glib2, gdk2, gtk2;

var

 window: PGtkWidget;

begin

 gtk_init(@argc, @argv);

 window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
 gtk_window_set_title (GTK_WINDOW (window), 'Goodbye, World');
 g_signal_connect (G_OBJECT (window), 
                   'delete-event',
       G_CALLBACK (@gtk_main_quit),
       NULL);
 gtk_widget_show_all (window);

 gtk_main();

end.</lang>

Perl

Works with: Perl version 5.8.8

Library: Perl/Tk

Just output as a label in a window:

<lang perl> use strict; use warnings; use Tk;

my $main = MainWindow->new; $main->Label(-text => 'Goodbye, World')->pack; MainLoop();</lang>

Output as text on a button that exits the current application:

<lang perl>use strict; use warnings; use Tk;

my $main = MainWindow->new; $main->Button(

 -text => 'Goodbye, World',
 -command => \&exit,

)->pack; MainLoop();</lang>

Library: Perl/Gtk2

<lang perl>use strict; use warnings; use Gtk2 '-init';

my $window = Gtk2::Window->new; $window->set_title('Goodbye world'); $window->signal_connect(

 destroy => sub { Gtk2->main_quit; }

);

my $label = Gtk2::Label->new('Goodbye, world'); $window->add($label);

$window->show_all; Gtk2->main;</lang>

Library: Perl/Qt

<lang perl>use strict; use warnings; use QtGui4;

my $app = Qt::Application(\@ARGV); my $label = Qt::Label('Goodbye, World'); $label->show; exit $app->exec;</lang>

Library: XUL::GuiGui

<lang perl>use strict; use warnings; use XUL::Gui;

display Label 'Goodbye, World!';</lang> <lang perl>use strict; use warnings; use XUL::Gui;

display Button

   label => 'Goodbye, World!',
   oncommand => sub {quit};</lang>

Perl 6

Library: GTK

<lang perl6>use GTK::Simple;

my GTK::Simple::App $app .= new; $app.border_width = 20; $app.set_content( GTK::Simple::Label.new(text => "Goodbye, World!") ); $app.run;</lang>

Library: Gtk#
Works with: niecza

<lang perl6># Translated from http://www.mono-project.com/GtkSharp:_Hello_World

constant $GTK = "gtk-sharp,Version=2.12.0.0,Culture=neutral,PublicKeyToken=35e10195dab3c99f";

constant Application = CLR::("Gtk.Application,$GTK"); constant Window = CLR::("Gtk.Window,$GTK"); constant Button = CLR::("Gtk.Button,$GTK");

Application.Init;

  1. Set up a button object.

my $btn = Button.new("Goodbye, World!"); $btn.add_Clicked: sub ($obj, $args) { #OK

   # runs when the button is clicked.
   say "Goodbye, World!";
   Application.Quit;

};

my $window = Window.new("goodbyeworld"); $window.add_DeleteEvent: sub ($obj, $args) { #OK

   # runs when the user deletes the window using the "close
   # window" widget in the window frame.
   Application.Quit;

};

  1. Add the button to the window and display everything

$window.Add($btn); $window.ShowAll;

Application.Run;</lang>

Phix

<lang Phix>{} = message_box("Goodbye, World!","Bye",MB_OK)</lang>

PHP

Library: PHP-GTK

<lang php>if (!class_exists('gtk')) {

   die("Please load the php-gtk2 module in your php.ini\r\n");

}

$wnd = new GtkWindow(); $wnd->set_title('Goodbye world'); $wnd->connect_simple('destroy', array('gtk', 'main_quit'));

$lblHello = new GtkLabel("Goodbye, World!"); $wnd->add($lblHello);

$wnd->show_all(); Gtk::main();</lang>

PicoLisp

<lang PicoLisp>(call 'dialog "--msgbox" "Goodbye, World!" 5 20)</lang>

PostScript

In the general Postscript context, the show command will render the string that is topmost on the stack at the currentpoint in the previously setfont. Thus a minimal PostScript file that will print on a PostScript printer or previewer might look like this:

<lang postscript>%!PS % render in Helvetica, 12pt: /Helvetica findfont 12 scalefont setfont % somewhere in the lower left-hand corner: 50 dup moveto % render text (Goodbye, World!) show % wrap up page display: showpage</lang>

PowerBASIC

Works with: PB/Win

<lang powerbasic>FUNCTION PBMAIN() AS LONG

   MSGBOX "Goodbye, World!"

END FUNCTION</lang>

PowerShell

Library: WPK


Works with: PowerShell version 2

<lang powershell>New-Label "Goodbye, World!" -FontSize 24 -Show</lang>

Library: Windows Forms

<lang powershell>$form = New-Object System.Windows.Forms.Form $label = New-Object System.Windows.Forms.Label

$label.Text = "Goodbye, World!" $form.AutoSize = $true $form.AutoSizeMode = [System.Windows.Forms.AutoSizeMode]::GrowAndShrink $form.Controls.Add($label)

$Form.ShowDialog() | Out-Null</lang> Alternatively, simply as a message box:

Library: Windows Forms

<lang powershell>[System.Windows.Forms.MessageBox]::Show("Goodbye, World!")</lang>

Processing

Uses default Processing methods and variables. <lang Processing> text("Goodbye, World!",0,height/2);</lang>

Prolog

Works with SWI-Prolog and XPCE.

A simple message box : <lang Prolog>send(@display, inform, 'Goodbye, World !').</lang> A more sophisticated window : <lang Prolog>goodbye :-

   new(D, window('Goodbye')),
   send(D, size, size(250, 100)),
   new(S, string("Goodbye, World !")),
   new(T, text(S)),
   get(@display, label_font, F),
   get(F, width(S), M),
   XT is (250 - M)/2,
   get(F, height, H),
   YT = (100-H)/2,
   send(D, display, T, point(XT, YT)),
   send(D, open).

</lang>

PureBasic

<lang PureBasic>MessageRequester("Hello","Goodbye, World!")</lang> Using the Windows API: <lang PureBasic>MessageBox_(#Null,"Goodbye, World!","Hello")</lang>

Pure Data

#N canvas 321 432 450 300 10;
#X obj 100 52 loadbang;
#X msg 100 74 Goodbye\, World!;
#X obj 100 96 print -n;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
  • While there is no easy (intuitive) way to print a comma (or semicolon) this pd script will do.
  • When writing messages to the terminal window, Pd prepends the name of the print object and a colon, or "print: " if no name is specified, which can be avoided by using "-n" instead of a name. This behaviour, however, has not been adopted by Pd-extended :-(

Python

Works with: Python version 2.x

Library: Tkinter

<lang python>import tkMessageBox

result = tkMessageBox.showinfo("Some Window Label", "Goodbye, World!")</lang>

Note: The result is a string of the button that was pressed.

Works with: Python version 3.x
Library: Tkinter

<lang python>from tkinter import messagebox

result = messagebox.showinfo("Some Window Label", "Goodbye, World!")</lang>


Library: PyQt

<lang python>import PyQt4.QtGui app = PyQt4.QtGui.QApplication([]) pb = PyQt4.QtGui.QPushButton('Hello World') pb.connect(pb,PyQt4.QtCore.SIGNAL("clicked()"),pb.close) pb.show() exit(app.exec_())</lang>

Library: PyGTK

<lang python>import pygtk pygtk.require('2.0') import gtk

window = gtk.Window() window.set_title('Goodbye, World') window.connect('delete-event', gtk.main_quit) window.show_all() gtk.main()</lang>

Library: VPython

Works with: Python version 2.7.5

<lang python>

  1. HelloWorld for VPython - HaJo Gurt - 2014-09-20

from visual import *

scene.title = "VPython Demo" scene.background = color.gray(0.2)

scene.width = 600 scene.height = 400 scene.range = 4

  1. scene.autocenter = True

S = sphere(pos=(0,0,0), radius=1, material=materials.earth) rot=0.005

txPos=(0, 1.2, 0)

from visual.text import *

  1. Old 3D text machinery (pre-Visual 5.3): numbers and uppercase letters only:

T1 = text(pos=txPos, string='HELLO', color=color.red, depth=0.3, justify='center')

import vis

  1. new text object, can render text from any font (default: "sans") :

T2 = vis.text(pos=txPos, text="Goodbye", color=color.green, depth=-0.3, align='center') T2.visible=False

Lbl_w = label(pos=(0,0,0), text='World', color=color.cyan,

             xoffset=80, yoffset=-40)     # in screen-pixels

L1 = label(pos=(0,-1.5,0), text='Drag with right mousebutton to rotate view', box=0) L2 = label(pos=(0,-1.9,0), text='Drag up+down with middle mousebutton to zoom', box=0) L3 = label(pos=(0,-2.3,0), text='Left-click to change', color=color.orange, box=0)

print "Hello World" # Console


cCount = 0 def change():

   global rot, cCount
   cCount=cCount+1
   print "change:", cCount
   rot=-rot
   if T1.visible:
       T1.visible=False
       T2.visible=True
   else:
       T1.visible=True
       T2.visible=False

scene.bind( 'click', change )

while True:

 rate(100)
 S.rotate( angle=rot, axis=(0,1,0) )

</lang>

Library: WxPython

<lang python>import wx

app = wx.App(False) frame = wx.Frame(None, wx.ID_ANY, "Hello, World") frame.Show(True) app.MainLoop()</lang>

RapidQ

<lang rapidq>MessageBox("Goodbye, World!", "RapidQ example", 0)</lang>

R

Library: GTK

Rather minimalist, but working... <lang R>library(RGtk2) # bindings to Gtk w <- gtkWindowNew() l <- gtkLabelNew("Goodbye, World!") w$add(l)</lang>

Racket

<lang Racket> #lang racket/gui (require racket/gui/base)

Make a frame by instantiating the frame% class

(define frame (new frame% [label "Goodbye, World!"]))

Make a static text message in the frame

(define msg (new message% [parent frame]

                         [label "No events so far..."]))

Make a button in the frame

(new button% [parent frame]

            [label "Click Me"]
            ; Callback procedure for a button click:
            (callback (lambda (button event)
                        (send msg set-label "Button click"))))

Show the frame by calling its show method

(send frame show #t)</lang>

Rascal

<lang rascal> import vis::Figure; import vis::Render;

public void GoodbyeWorld() =

 render(box(text("Goodbye World")));

</lang> Output:

REALbasic

<lang vb> MsgBox("Goodbye, World!") </lang>

REBOL

<lang REBOL>alert "Goodbye, World!"</lang>

REXX

version 1

This REXX example only works with:

  •   PC/REXX
  •   Personal REXX

<lang rexx>/*REXX (using PC/REXX) to display a message in a window (which is bordered). */ if fcnPkg('rxWindow') ¬== 1 then do

                                 say 'RXWINDOW function package not loaded.'
                                 exit 13
                                 end

if pcVideo()==3 then normal= 7

                else normal=13

window#=w_open(1, 1, 3, 80, normal) call w_border window# call w_put window#, 2, 2, center("Goodbye, World!", 80-2)

                                      /*stick a fork in it, all we're done. */</lang>

output

╔══════════════════════════════════════════════════════════════════════════════╗
║                               Goodbye, World!                                ║
╚══════════════════════════════════════════════════════════════════════════════╝

version 2

This REXX example only works with:

  •   PC/REXX
  •   Personal REXX


and it creates two windows, the first (main) window contains the   Goodbye, World!   text,
the other "help" window contains a message about how to close the windows. <lang rexx>/*REXX program shows a "hello world" window (and another to show how to close)*/ parse upper version !ver .; !pcrexx= !ver=='REXX/PERSONAL' | !ver=='REXX/PC' if ¬!pcrexx then call ser "This isn't PC/REXX" /*this isn't PC/REXX ? */ rxWin=fcnPkg('rxwindow') /*is the function around?*/

if rxWin¬==1 then do 1; 'RXWINDOW /q'

                  if fcnPkg('rxwindow')==1 then leave   /*the function is OK.*/
                  say 'error loading RXWINDOW !';     exit 13
                  end

top=1; normal=31; border=30; curpos=cursor() width=40; height=11; line.=; line.1= 'Goodbye, World!' w=w_open(2, 3, height+2, width, normal); call w_border w,,,,,border helpLine= 'press the ESC key to quit.' helpW=w_open(2, 50, 3, length(helpLine)+4, normal) call w_border helpw,,,,,border; call w_put helpW, 2, 3, helpLine call w_hide w, 'n'

                            do k=0  to height-1
                            _=top+k;      call w_put w, k+2, 3, line._, width-4
                            end   /*k*/

call w_unhide w

                            do forever;   if inKey()=='1b'x  then leave;  end
                                                  /*   ↑                     */

call w_close w /* └──◄ the ESCape key.*/ call w_close helpw if rxWin¬==1 then 'RXUNLOAD rxwindow' parse var curPos row col call cursor row, col

                                      /*stick a fork in it,  we're all done. */</lang>

Ruby

Library: GTK

<lang ruby>require 'gtk2'

window = Gtk::Window.new window.title = 'Goodbye, World' window.signal_connect(:delete-event) { Gtk.main_quit } window.show_all

Gtk.main</lang>

Library: Ruby/Tk

<lang ruby>require 'tk' root = TkRoot.new("title" => "User Output") TkLabel.new(root, "text"=>"CHUNKY BACON!").pack("side"=>'top') Tk.mainloop</lang>

Library: Shoes

<lang ruby>#_Note: this code MUST be executed through the Shoes GUI!!

Shoes.app do

 para "CHUNKY BACON!", :size => 72

end</lang>

Run BASIC

<lang runbasic>' do it with javascript html "<script>alert('Goodbye, World!');</script>"</lang>

Rust

Rust

Library: GTK

<lang rust>// cargo-deps: gtk extern crate gtk; use gtk::traits::*; use gtk::{Window, WindowType, WindowPosition}; use gtk::signal::Inhibit;

fn main() {

   gtk::init().unwrap();
   let window = Window::new(WindowType::Toplevel).unwrap();
   window.set_title("Hello World!");
   window.set_border_width(10);
   window.set_window_position(WindowPosition::Center);
   window.set_default_size(350, 70);
   window.connect_delete_event(|_,_| {
       gtk::main_quit();
       Inhibit(false)
   });
   window.show_all();
   gtk::main();

}</lang>

Scala

Library: scala.swing

Ad hoc REPL solution

Ad hoc solution as REPL script: <lang scala>swing.Dialog.showMessage(message = "Goodbye, World!")</lang>

JVM Application

Longer example, as an application: <lang scala>import swing._

object GoodbyeWorld extends SimpleSwingApplication {

 def top = new MainFrame {
   title = "Goodbye, World!"                     
   contents = new FlowPanel {
     contents += new Button  ("Goodbye, World!") 
     contents += new TextArea("Goodbye, World!")
   }
 }

}</lang>

.Net Framework

<lang Scala>import swing._

object HelloDotNetWorld {

 def main(args: Array[String]) {
   System.Windows.Forms.MessageBox.Show
                     ("Hello, .net world!")
 }

}</lang>

Scheme

Library: Scheme/PsTk

<lang ruby>

  1. !r6rs
PS-TK example
display frame + label

(import (rnrs)

       (lib pstk main) ; change this to refer to your PS/Tk installation
       )

(define tk (tk-start)) (tk/wm 'title tk "PS-Tk Example: Label")

(let ((label (tk 'create-widget 'label 'text: "Goodbye, world")))

 (tk/place label 'height: 20 'width: 50 'x: 10 'y: 20))

(tk-event-loop tk) </lang>

Scratch

Seed7

Seed7 does not work with an event handling function like gtk_main(). The progam stays in control and does not depend on callbacks. The graphic library manages redraw, keyboard and mouse events. The contents of a window are automatically restored when it is uncovered. It is possible to copy areas from a window even when the area is currently covered or off screen.

<lang seed7>$ include "seed7_05.s7i";

 include "draw.s7i";
 include "keybd.s7i";
 include "bitmapfont.s7i";
 include "stdfont24.s7i";
 include "pixmap_file.s7i";

const proc: main is func

 local
   var text: screen is STD_NULL;
 begin
   screen(400, 100);
   clear(curr_win, white);
   KEYBOARD := GRAPH_KEYBOARD;
   screen := openPixmapFontFile(curr_win);
   color(screen, black, white);
   setFont(screen, stdFont24);
   setPosXY(screen, 68,  60);
   write(screen, "Goodbye, World");
   ignore(getc(KEYBOARD));
 end func;</lang>

Sidef

Library: Tk

<lang ruby>var tk = require 'Tk'; var main = %s'MainWindow'.new; main.Button(

   '-text'    => 'Goodbye, World!',
   '-command' => 'exit',

).pack; tk.MainLoop;</lang>

Library: Gtk2

<lang ruby>var gtk2 = require('Gtk2') -> init;

var window = %s'Gtk2::Window'.new; var label = %s'Gtk2::Label'.new('Goodbye, World!');

window.set_title('Goodbye, World!'); window.signal_connect(destroy => func(*_){ gtk2.main_quit });

window.add(label); window.show_all;

gtk2.main;</lang>

Smalltalk

Works with: GNU Smalltalk

<lang smalltalk>MessageBox show: 'Goodbye, world.'</lang>

Works with: Smalltalk/X

<lang smalltalk>Dialog information: 'Goodbye, world.'</lang>

Supernova

<lang Supernova>I want window and the window title is "Goodbye, World".</lang>

Swift

Translation of: Objective-C

<lang Swift>import Cocoa

let alert = NSAlert() alert.messageText = "Hello, World!" alert.runModal()</lang>

Tcl

Library: Tk

Just output as a label in a window: <lang tcl>pack [label .l -text "Goodbye, World"]</lang>

Output as text on a button that exits the current application: <lang tcl>pack [button .b -text "Goodbye, World" -command exit]</lang>

Or as a message box: <lang tcl>tk_messageBox -message "Goodbye, World"</lang>

TI-83 BASIC

<lang ti83b>PROGRAM:GUIHELLO

Text(0,0,"GOODBYE, WORLD!")</lang>

TI-89 BASIC

<lang ti89b>Dialog

 Text "Goodbye, World!"

EndDlog</lang>


VBScript

<lang vbscript> MsgBox("Goodbye, World!") </lang>

Vedit macro language

Displaying the message on status line. The message remains visible until the next keystroke, but macro execution continues. <lang vedit>Statline_Message("Goodbye, World!")</lang>

Displaying a dialog box with the message and default OK button: <lang vedit>Dialog_Input_1(1,"`Vedit example`,`Goodbye, World!`")</lang>

UNIX Shell

In a virtual terminal

Using whiptail or dialog <lang bash> whiptail --title 'Farewell' --msgbox 'Goodbye, World!' 7 20 </lang> <lang bash> dialog --title 'Farewell' --msgbox 'Goodbye, World!' 7 20 </lang>

In a graphical environment

Using the simple dialog command xmessage, which uses the X11 Athena Widget library <lang bash> xmessage 'Goodbye, World!' </lang> Using the zenity modal dialogue command (wraps GTK library) available with many distributions of Linux <lang bash> zenity --info --text='Goodbye, World!' </lang> Using yad (a fork of zenity with many more advanced options) <lang bash> yad --title='Farewell' --text='Goodbye, World!' </lang>

Visual Basic

<lang vb>Sub Main()

   MsgBox "Goodbye, World!"

End Sub</lang>

Visual Basic .NET

Works with: Visual Basic version 2005

<lang vbnet>Module GoodbyeWorld

   Sub Main()
       Messagebox.Show("Goodbye, World!")
   End Sub

End Module</lang>

Visual FoxPro

<lang vfp>* Version 1: MESSAGEBOX("Goodbye, World!")

  • Version 2:

? "Goodbye, World!"</lang>

X86 Assembly

Works with: nasm

This example used the Windows MessageBox function to do the work for us. Windows uses the stdcall calling convention where the caller pushes function parameters onto the stack and the stack has been fixed up when the callee returns. <lang assembly>;;; hellowin.asm

nasm -fwin32 hellowin.asm
link -subsystem
console -out:hellowin.exe -nodefaultlib -entry:main \
hellowin.obj user32.lib kernel32.lib
       global _main
       extern _MessageBoxA@16
       extern _ExitProcess@4
       MessageBox equ _MessageBoxA@16
       ExitProcess equ _ExitProcess@4
       
       section .text

_main:

       push 0                  ; MB_OK
       push title              ;
       push message            ;
       push 0                  ;
       call MessageBox         ; eax = MessageBox(0,message,title,MB_OK);
       push eax                ; 
       call ExitProcess        ; ExitProcess(eax);

message:

       db 'Goodbye, World',0

title:

       db 'RosettaCode sample',0

</lang>

Works with: FASM on Windows

<lang assembly>

use win32ax for 32 bit
use win64ax for 64 bit

include 'win64ax.inc'

.code

  start:
     invoke MessageBox,HWND_DESKTOP,"Goodbye,World!","Goodbye",MB_OK
     invoke ExitProcess,0

.end start </lang>

Web 68

<lang web68>@1Introduction. Define the structure of the program.

@aPROGRAM goodbye world CONTEXT VOID USE standard BEGIN @<Included declarations@> @<Logic at the top level@> END FINISH

@ Include the graphical header file.

@iforms.w@>

@ Program code.

@<Logic...@>= open(LOC FILE,"",arg channel); fl initialize(argc,argv,NIL,0); fl show messages("Goodbye World!"); fl finish

@ Declare the necessary macros.

@<Include...@>= macro fl initialize; macro fl show messages; macro fl finish;

@ The end.</lang>

XSLT

The output is an SVG document. The idea is that it's straightforward to use XSLT to turn an existing SVG into an instantiable template.

<lang xml><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:template match="/*"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200"> <rect x="0" y="0" width="400" height="200" fill="cyan"/> <circle cx="200" cy="100" r="50" fill="yellow"/> <text x="200" y="115" style="font-size: 40px; text-align: center; text-anchor: middle; fill: black;"> <xsl:value-of select="."/> </text> </svg> </xsl:template> </xsl:stylesheet></lang>

Sample input:

<lang xml><message>Goodbye, World!</message></lang>

Sample output (with formatting non-destructively adjusted):

<lang xml><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200"> <rect x="0" y="0" width="400" height="200" fill="cyan"/> <circle cx="200" cy="100" r="50" fill="yellow"/> <text x="200" y="115" style="font-size: 40px; text-align: center; text-anchor: middle; fill: black;">Goodbye, World!</text> </svg></lang>

zkl

zkl doesn't have a decent GUI ffi but, on my Linux box, the following work: <lang zkl>System.cmd(0'|zenity --info --text="Goodbye, World!"|); // GTK+ pop up System.cmd(0'|notify-send "Goodbye, World!"|); // desktop notification System.cmd(0'|xmessage -buttons Ok:0,"Not sure":1,Cancel:2 -default Ok -nearmouse "Goodbye, World!" -timeout 10|); // X Windows dialog</lang> The quote quote syntax is 0'<char>text<char> or you can use \ (eg "\"Goodbye, World!\"")