# Hello World window

Create a window that says hello world inside and nothing else. You can not have any ok or cancel buttons inside. It must be just a plain window that says hello world. I do not care about the contents of the window frame or how the window looks, but inside it must say hello world only.

Example:

Shortest code wins.

EDIT: I am sorry Johannes Kuhn the window has to actually stay there, it may not close right away. I didn't think of this scenario and as such didn't account for this.

EDIT 2: We currently have 3 tied answers (20 characters). Any suggestions of who should be the winner is welcome.

• Does the window have to be large enough to display the text when it pops up, or is it okay to require the user to resize the window? – Iszi Nov 26 '13 at 19:55
• It doesn't have to be large enough to display the text, it just has to be a window, meaning just be this container looking thing that has text and does not close until it is told to. – Quillion Nov 26 '13 at 20:00
• I can make it as short as Sven's, but with OK and Cancel buttons :( – Teresa e Junior Nov 27 '13 at 8:27
• Looks like there's a Bash answer at 19 now. – Iszi Nov 27 '13 at 15:31
• Can I do a VB 6 solution with a label with "Hello World"? 0 code solution? – Cruncher Nov 27 '13 at 16:41

### bash 20 19 chars

Thanks @manatwork for the useless space after -p!

read -pHello\ World


In action:

echo 'read -pHello\ World' >/tmp/helloworld.sh
chmod +x /tmp/helloworld.sh


Than double click from file manager:

And see:

Having as default shell.

### 19 16

As question stand for only Hello World and Nothing else, the window have to stay but nothing like print text only once or so on, I think this match requirement too!

yes Hello\ World


There is only 16 chars.

echo >/tmp/helloworld.sh 'yes Hello\ World'


With same procedure this give:

• Seems like GNOME to me. – Pierre Arlaud Nov 27 '13 at 14:01
• I think the "choose run in terminal" part should count as, at the very least, 1 byte. Similar to the rules about options passed to interpreters when running some codegolf solution. – Bakuriu Nov 28 '13 at 16:31
• @Bakuriu Depending on personal usages, you could configure you window manager to not ask and run alway under some shell or terminal of your choice... (I think it's default under MS-Window) – F. Hauri Nov 28 '13 at 17:55
• @Bakuriu like installing HQ9+ interpreter, adding .hq9+ as mime capacity: running HQ9+ in a terminal windows. So the challenge could be dropped to 1 byte. This answer was based on previous answers, using batch or powershell and running an OS which use this kind of trick by default. – F. Hauri Nov 28 '13 at 19:26
• @JohannesKuhn Are you crazy! There is no more than 2°C outer! It's too cold!! – F. Hauri Dec 3 '13 at 21:48

## Windows Command Prompt, 26

echo Hello World>.hta&.hta


• This is awesome. Bonus points for spawning two windows? – Gusdor Nov 27 '13 at 11:44
• @Gusdor What do you mean? I only see one spawned window here. – Iszi Nov 27 '13 at 15:09
• @Iszi I made the assumption that the batch file was run from desktop, not typed. Whoops! – Gusdor Nov 27 '13 at 15:25
• @Gusdor I think that's why he called it "Windows Command Prompt" instead of "Batch". Otherwise, it'd lose to Johannes' answer anyway. – Iszi Nov 27 '13 at 15:31
• @Iszi: This opens a new window, so it doesn’t matter whether the command is echoed in a different one… – Ry- Nov 29 '13 at 0:39

# R, 23

plot(1,m="Hello World")


This opens a plot window.

• +1. You can shorten sub= into s= thanks to partial matching however. – plannapus Nov 26 '13 at 17:50
• @plannapus Thanks, good idea! I modified my code. – Sven Hohenstein Nov 26 '13 at 18:21
• Sven, this doesn't print "hello world inside and nothing else" :) I was participating in a similar challenge and it had to be done differently, see codegolf.stackexchange.com/a/19807/2800 – Tomas Feb 2 '14 at 17:56
• @Tomas This challenge is different. From the question: "I do not care about the contents of the window frame". – Sven Hohenstein Feb 2 '14 at 20:35
• Well, but this is not about the frame, but also the text - axis label "index", the numbers etc.. – Tomas Feb 2 '14 at 21:17

## Dyalog APL (20)

⎕SM←'Hello World'1 1


Picture:

• Special characters!?! HAXXX! – AJMansfield Nov 27 '13 at 0:11

## Powershell, 23

'Hello World'>.hta;.hta


• Nice! Beats my "real" solution, and is only 3 characters longer than the shortcut method. Though, it's arguable that this isn't really much better than just using Hello World alone and calling it HTML - since that's almost exactly what you've done. You've just used PowerShell to build and execute it. – Iszi Nov 27 '13 at 15:05

### HTML (kinda), 17

data:,Hello World


Paste that into your browser's address bar.

### Javascript, 25

open("data:,Hello World")


This uses your browser's window.open and a data uri.

A Data URIs's mime-type and charset default to text/plain;charset=US-ASCII when omitted.

eval($("s").text())  This one only works when this answer is the top (or accepted) answer and it is run on THIS stackoverflow page (via your JavaScript console). :-) open("data:,Hello World"); • Funny trick. But sadly it depends on the ordering of the posts, which may vary. – manatwork Nov 27 '13 at 15:21 • Well, it'll work as long as it is the accepted answer (and the Question doesn't have an "<s>") – David Murdoch Nov 27 '13 at 15:25 • Lol. I have to upvote for your optimism. – manatwork Nov 27 '13 at 15:27 • Can you explain how this will work please? I am using chrome and have tried running it on the console, but I get Unexpected token ILLEGAL. Do you have to be top answer for this to work? – Quillion Nov 27 '13 at 21:13 • Yes, it needs to be the top answer for it to work. OR I could just edit the question itself to include the required <s>open("data:,Hello World");</s> HTML, but that might be cheating a little bit too much. :-p – David Murdoch Nov 27 '13 at 21:36 # Matlab, 3027 20 title('Hello World')  Are plot windows allowed? It does not have any buttons inside. • Yeah plot window is fine :) as long as it is window, I do not care – Quillion Nov 26 '13 at 16:05 • figure('name','Hello World') is shorter – magu_ Nov 27 '13 at 7:31 • @magu_ Good idea. But I suppose it's against the rule "a window that says hello world inside". – Sven Hohenstein Nov 27 '13 at 8:10 • @SvenHohenstein Hm, maybe. To say at least something usefull: you don't need the (1) necessarly. Making the code 3 characters smaller. – magu_ Nov 27 '13 at 8:23 • You don't actually need figure; – Torbjørn T. Nov 27 '13 at 23:26 # Java, 117 chars import java.awt.*;class C{public static void main(String[]a){new Frame(){{add(new Label("Hello World"));show();}};}}  With formatting: import java.awt.*; class C { public static void main(String[] a) { new Frame() { { add(new Label("Hello World")); show(); } }; } }  We can avoid having to explicitly declare a variable by using initializer blocks inside an anonymous subclass of Frame. Interestingly, using awt, it's just as many characters to import java.awt.*; as it is to just fully qualify both classnames. • You can call args whatever you want; a is sufficient. – daniero Nov 26 '13 at 20:19 • @daniero thanks for the suggestion, pretty silly of me to miss that :) – swilliams Nov 28 '13 at 7:20 • s/class/enum/ – Thomas Eding Nov 28 '13 at 7:38 • like @ThomasEding hints replacing the class by enum shaves off one byte – masterX244 Mar 14 '14 at 9:48 • @masterX244 That won't be syntactically correct unless a semicolon is added before the public static... to end the list of enum constants... see stackoverflow.com/questions/7318011/…. In either case you end up with the same number of characters. – swilliams Mar 16 '14 at 20:27 # Mathematica 29 27 25 With 1 byte saved thanks to CatsAreFluffy. DialogInput@"hello world"  • CreateDialog is shorter. – alephalpha Nov 27 '13 at 3:10 • Thanks. I thought CreateDialog would insert an OK button. – DavidC Nov 27 '13 at 3:57 • DialogInput is 1 byte shorter – CalculatorFeline Feb 28 '16 at 5:57 • Yes, thanks, and the curly braces are also unnecessary. – DavidC Feb 28 '16 at 13:17 # Shell, 32 xmessage -buttons '' Hello World  • There is a 1 character shorter way: xterm -e 'read -p Hello\ World'. – manatwork Nov 26 '13 at 15:29 • Mine would have been way shorter if I didn't have to -buttons '' :( – Hasturkun Nov 26 '13 at 15:31 • @Hasturkun I agree, but I had to add get rid of the buttons requirement because javascript would win with their alert or some other shortcut like that, and I felt that it would be too unfair and too plain especially to some other languages. – Quillion Nov 26 '13 at 15:42 • @Hasturkun, without the no button restriction your xmessage Hello World solution counts only 20 characters, but then Windows cmd would beat you with msg * Hello World of just 17 characters. So be grateful for the restriction. :) – manatwork Nov 26 '13 at 15:52 # Ruby with Shoes, 28 Shoes.app{para'Hello World'}  Result: # Python 2/3, 54 characters Capitalize the t in tkinter to make it work on Python 2. __import__("tkinter").Label(text="Hello World").pack()  • when I try that i get: AttributeError: Label instance has no attribute 'show'. However __import__("Tkinter").Label(text="Hello World").pack() gives me the desired effect. – plannapus Nov 27 '13 at 8:03 • @plannapus Actually I had copied a previous version with that error, not the correct one. Thanks. – Ramchandra Apte Nov 27 '13 at 8:04 ## Windows Batch, 23 @pause|echo Hello World  • Opens a black window that shows Hello World, nothing else. • Now the windows stays open • There are no buttons in the window. • Requirement is: create a window not force window manager to create a window – F. Hauri Nov 26 '13 at 19:36 • @F.Hauri Ok, I'll look how to write a window manager. Until someone post that, consider all posts as violation of your requirement. – Johannes Kuhn Nov 26 '13 at 19:37 • As the op states, it doesn't matter how the window looks. If it is a plot window or a shell window, who cares? – Johannes Kuhn Nov 26 '13 at 20:04 • I absolutely agree :) now this is absolutely acceptable because it is a window and it does say hello world :) well done I love it – Quillion Nov 26 '13 at 20:05 • @JohannesKuhn PowerShell can still beat it. Edit coming up. – Iszi Nov 26 '13 at 22:08 # Rebol 2, 29 view layout[txt{Hello World}]  ### ExtJS (Javascript) 44 new Ext.Window({html:'Hello world',}).show()  new Ext.Window({html:'Hello world',}).show() <link rel="stylesheet" type="text/css" href="http://dev.sencha.com/deploy/dev/resources/css/ext-all.css"/> <script type='text/javascript' src="http://dev.sencha.com/deploy/dev/adapter/ext/ext-base.js"></script> <script type='text/javascript' src="http://dev.sencha.com/deploy/dev/ext-all.js"></script> ## Tcl/Tk, 34 pack [label .l -text Hello\ World]  # AutoHotkey, 26 GUI,Add,Text,,Hello World!  AutoIt v3, 32 ToolTip("Hello World") Sleep(9^9)  • Wouldn't MsgBox(0,"","Hello World") be shorter? It's 26 characters. – Mr. Llama Dec 3 '13 at 16:05 • The requirements are to have no Ok or Cancel buttons within the window. The code you suggest has an OK button. :( – Chris Dec 3 '13 at 18:18 • Ah balls, I missed that requirement. – Mr. Llama Dec 5 '13 at 17:16 # HTML, 11 Hello World  Screenshot: I guess this shouldn't count, but I think it would be interesting to see such an answer here. • I agree it shouldn't count. The same can be accomplished by loading a simple TXT file in the browser. – Iszi Nov 27 '13 at 5:12 • Your count is off, that's 20 characters. – jmoreno Nov 27 '13 at 5:18 • @Iszi without HTML tags, this is really just getting rendered as a plain text file. I would argue that you can't even call it an html submission without <html> </html> – Cruncher Nov 27 '13 at 13:54 • @Cruncher Google Chrome actually adds an HTML skeleton including a <pre> which contains the file's contents (you can use Chrome dev tools for verifying this behavior). – ComFreek Nov 27 '13 at 16:30 • @Cruncher Well, maybe if you're using IE6, but in any modern browser, you can omit the <html> tags, as well as the <body> and <head> tags, and the browser will automatically fill out the "skeleton". For example, try <div style="background:#ff0">Hello</div> in a modern browser, and it will universally render "hello" with a yellow background. – Braden Best Feb 11 '14 at 5:09 ## PowerShell: 162124 114 or 20 ## The Long Way Around ($t=($a='New-Object Windows.Forms')+".Label"|iex).Text='Hello World';($x=iex $a".Form").Controls.Add($t);$x.Show()  Since PowerShell really doesn't have any built-in GUI functionality, I'm having a hard time coming up with anything shorter than this which I feel really fits the original spirit of the challenge. (Or, at least, fits within the parameters several of us have assumed were implied.) Changes from original: • Removed window size definition. Apparently, it's optional and the default is plenty large enough. • Incorporated changes provided by SpellingD in comments. Note: The window which spawns will hang - you'll need to kill PowerShell via Task Manager. ## Alternative 20-Character Approach Removing some assumed-implied requirements, we can also meet this challenge a-la Johannes Kuhn with this: 'Hello World';for(){}  Save as a .ps1 file. Make sure the system's ExecutionPolicy allows unsigned scripts. Right-click and select "Run with PowerShell". • Show instead of ShowDialog should do it, right? – It'sNotALie. Nov 26 '13 at 21:05 • Show() does work, but doesn't let you close the window. Which isn't a requirement! – SpellingD Nov 26 '13 at 21:22 • My edit to golf this was rejected, and my code isn't sufficiently different enough to warrant making a new answer, so here's how you could golf this to 114, I guess. ($t=($a='New-Object Windows.Forms')+".Label"|iex).Text='Hello World';($x=iex $a".Form").Controls.Add($t);\$x.Show() – SpellingD Nov 26 '13 at 21:57
• @SpellingD Thanks. I've incorporated your changes to the "true" solution, and also added a "cheap method" which currently beats all contenders. (Except, arguably, HQ9+ of course.) – Iszi Nov 26 '13 at 22:17

# Factor, 36 code + 23 imports = 59

USING: ui ui.gadgets ; "Hello World" <label> "" open-window


When this is run inside the listener, the imports will be brought in automatically. You only need them to deploy a standalone executable.

## Processing, 23

Based on my answer here: Make a PNG image with "Hello World!" with programming APIs, in the shortest code possible

text("HeΠo World!",9,8);


24 char non-cheating solution:

text("Hello World!",9,9);


Do I get extra points for this being the 42nd answer?

## Groovy, 68 27

Using console.

print"Hello World";for(;;);


Using Frame.

new java.awt.Frame(){{add new java.awt.Label("Hello World")}}.show()


Inspired by @swilliams Java answer.

# Processing, 37 chars:

void draw(){text("Hello World",0,9);}


Various things used to reduce strokes:

• Sketch window is spawned by default; no need to manually create it
• Using draw is shorter than setup (although the text is then redrawn each frame)
• Uses default size, background, fill, font, and font size
• You don't actually need all 10 pixels height for the text

Bash (36 chars)

xmessage -buttons "" "Hello World!"

Looks like crap, but works as requested.

• The rule “inside it must say hello world only” was explicitly added to avoid so simple solutions. – manatwork Nov 27 '13 at 13:27
• ok, fixed this. – klingt.net Nov 27 '13 at 13:32
• Now it's correct, but there is another problem: it became duplicate of Hasturkun's answer. – manatwork Nov 27 '13 at 13:56
• Damn, at least i've a screenshot :) – klingt.net Nov 27 '13 at 14:09

# Ghostscript 50

0 0 moveto/Courier 20 selectfont(Hello World)show


Could make it 49 by using a 9-point font, but it's a little hard to read.

Can make a smaller window by invoking gs with a geometry argument for an additional 8 chars.

gs -g200x30 hello.ps


# C#, 72

class P{static int Main(){System.Console.Write("hello world");for(;;);}}


Based on the answer by @Noctis. I would have suggested it as a comment if I had enough Rep.

## Delphi - 73 62

uses Dialogs;begin MessageDlg('Hello World',mtCustom,[],0)end.


Edit after @manatwork and @Gareth 's suggestions. Which actually brings me to a character count of 62.

• How you get that character count? The code you posted has 77 characters and the minimum to which it can me reduced is 64: uses Dialogs;begin MessageDlg('Hello World',mtCustom,[],0)end. – manatwork Nov 29 '13 at 15:43
• You need to count newlines as part of your character count. That's why many answers on this site are all on one line. – Gareth Dec 2 '13 at 14:44
• Ah, I didn't know that. I'll edit my answer. – R-D Dec 2 '13 at 14:48

# Shell script: 56 character

convert -size 99x9 xc: -draw 'text 0,10 Hello\ World' x:


Sample output:

## Ti84-Basic, 25

ClrHome
Disp "HELLO WORLD


## Arduino, 27

Serial.print("Hello World")


Place this in void setup()

## Game Maker Language, 40

show_message_ext("Hello World","","","")


I'm pretty sure this is the shortest way without adding any extension packages.

• If you would accept an OK button, show_message("Hello World") is 27 characters. – Timtech Nov 27 '13 at 11:40
• Extremely necroing this one, but I have 2 (slight) remarks about your Ti84-Basic one. 1: couldn't you drop the final "? 2: Should you count it in bytes, we have a clear winner here ;) – ɐɔıʇǝɥʇuʎs Mar 30 '14 at 14:30
• @Synthetica Yeah. Forgot that :) – Timtech Mar 30 '14 at 15:24
• Your TI-BASIC answer does not open a window, and it outputs capital rather than lowercase letters. – lirtosiast Jun 7 '15 at 15:07