Talk:"Hello, World!" program/Archive 1
New comments at the bottom please
"To run:" recipes unneccessary
Should all this "to run:" crap really be in the 'Hello world program' article? We don't seriously expect everybody to have a GNU/Linux system with complete development environment installed. --Jizzbug
- You mean posix environment? Well, it is the official standard. ;-) Kim Bruning 22:03, 17 Jul 2004 (UTC)
XHTML Warning
The following notice was attached to the XHTML example:
Please note that this document must also be sent with the appropriate HTTP Header, most preferably "application/xhtml+xml", but it MAY also be sent as "application/xml" or "text/xml"; however it MUST NOT be sent as "text/html"; see XHTML Media Types for further info.
I removed this, as on http://www.w3.org/TR/xhtml-media-types/#text-html (the section just above the one referenced), there is a backward compatibility clause that renders it unnecessary to make any relevant point here. This also matches my experience with 100's of XHTML documents on web servers and various browsers. --Nigelj 20:19, 15 Nov 2004 (UTC)
- Indeed, I would have to agree - while it is technically correct to use that doctype, it's going a bit far to impose it upon everyone when text/html is set so rigidly into some systems that it may never change... -[Unknown] 21:13, Nov 15, 2004 (UTC)
- That clause is applicable to XHTML 1.0, not 1.1. —Ævar Arnfjörð Bjarmason 15:19, 17 July 2005 (UTC)
Hello world tradition (BCPL)
The tradition of using "Hello world!" as the test message was probably started by its use as an example program in the book The C Programming Language, by Brian Kernighan and Dennis Ritchie.
- In 1997, Dennis Ritchie says: 'so far as Brian and I can remember, the Tutorial contains the first instance of a "Hello, world" program.' The Tutorial in question is (ext lk) http://cm.bell-labs.com/cm/cs/who/dmr/btut.html . It is for the B programming language, and was published internally at Bell Labs in January 1973. The program could be even older (the Unix people had switched to C for almost everything by then; the heyday of B on Unix was perhaps 1970-71). But January 1973 is the earliest surviving evidence. This is a few years before "The C Programming Language" book, and obviously a precursor to it, since the same people are involved.
- It would be interesting to hear more details of the BCPL claim. BCPL is the main inspiration for B, so it is possible someone doing B had seen the hello world in BCPL and "translated" it. Ritchie and Kernighan 24 years later would not necessarily remember this. On the other hand, it is possible some later reporter heard that hello world was invented in B and misreported this as BCPL. We need more details of the BCPL claim, preferably including a date.
Java Swing example
The Java Swing example is excessively long. It should only be a half-dozen lines longer than the console example. Ed Poor
- Good point. I'll put up a more reasonable one. The other option is to not have a GUI one at all, but I'll probabl lose that argument. --LDC
IMO i think it should be the most basic way of doing hello world, without any fancyness such as a gui, so yes, put the CLI one there. --Ævar Arnfjörð Bjarmason 23:43, 2004 May 5 (UTC)
"Evolution of a Programmer" joke
Would it be terribly off topic to include all the "Hello world!" examples from the old Evolution of a Programmer joke, possibly as a subpage? I don't want to go to the trouble of looking it up and copying it if it's just going to get deleted as off-topic.
- It's really not on topic, so someone will likely remove it. --Stephen Gilbert
Java GUI example
The "Java GUI" example seems excessively long. Did someone put that in there on purpose, to make the point that Java is a verbose language? I put in a 5-line Java applet example in rebuttal, if that was their purpose. -- User:Ed Poor
- I put that one in, and for the same reason: whoever put in the original "Java GUI" example put in one that was three times as long, made it look like Java GUI programming is a real mess. I shortened it down to the current version, which really is about as small as you can get a standalone Java GUI appication. Of course applets can be even smaller, because they aren't standalone--they depend on an enclosing application. --Lee Daniel Crocker
- The 6502 (comparably simple system) example too depends on an "enclosing application": the "KERNAL ROM" whose charoutput subroutine is called. Similarly a java applet with just a paint() function would establish a hello world GUI example. If one is very picky, the according .html file got to be listed because it defines the size of the display. But on the other hand, other examples to might need "make" (or such) files that the reader would need to really get the hello world sample running on the system in question, but are not listed. -26.9.2005
import java.applet.*; import java.awt.*; public class hello extends Applet { public void paint(Graphics g) { g.drawString("Hello World!",20,20); } }
- I took out the following, because it's not a Hello, world program. No one would use code as long and complex as this to test whether their compiler is working. Java always comes with the Appletviewer, which would run the 5-line program I supplied. Java program are rarely stanalone, in that they require the JVM to run. Likewise a VB program requires 6 MB or more of runtime DLLs and EXEs to run, and all Windows GUI programs require the Windows API to run. User:Ed Poor
- I'm putting it back, because your exlanation here is mostly wrong. Most JVMs /do not/ come with "appletviewer": Sun's do, but there are lots of others that don't (For example, I use GCJ, a Java native compiler, that doesn't). Also, "Hello world" programs are frequently used to test more than just basic compilers, but also libraries and APIs: it is quite common to test a communications library by sending a "Hello world" message, or test a GUI library by drawing a "Hello window". This program really is a good example of GUI programming in Java, and is far simpler than a GUI program would be using many C libraries. It might look better compared to something like a Windows GUI "Hello world", or a GNOME "Hello world". Maybe those could go into a separate section?
- And a lot of 6502 do not come with the "KERNAL ROM" but with something else. Similar argument with many of the examples. -26.9.2005
- Yes, thanks. Thus the selfish Java meme propagates itself. User:Ed Poor
- Hi, I've cut the GUI (non-applet) version to 6 lines. It doesn't rely on an applet window. Hope this is satisfactory? Ben Arnold 23:30, 25 Mar 2004 (UTC)
- I've cut it back now to 5 lines (one statement with the surrounding method and class definition). Apparently the System.exit(0) call was unnecessary. I'm sure I tried doing without it when I first submitted the program. It's possible that in an earlier JDK showMessageDialog wasn't disposing the dialog or that the JVM didn't use to terminate when all windows were disposed... but it's more likely I was just wrong the first time. Ben Arnold 13:26, 19 Feb 2005 (UTC)
Brainfuck example
I just replaced the brainfuck example with a more concise one written by Urban Müller, who made brainfuck. -Daniel.
C example mess-up
Jizzbug messed up the hello world C program about a month ago - he removed the return statement (required in classic ANSI C) and the return type of main (required in C99 / ANSI 2000). I have corrected this, but he also modified the programs for several other languages, and may well have damaged these too; it would be useful if people who know these languages could check that all is well. --Zundark 18:10 Feb 5, 2003 (UTC)
Shell script interpreter call
I wonder if it's a good think to keep the comment calling the interpreter (like #!/usr/local/bin/perl). It's specifically unix and there is a way to run the program without this comment. Ericd 23:54 Apr 25, 2003 (UTC)
- I think they should be removed. --Zundark 08:34 Apr 26, 2003 (UTC)
Hello world string tradition
From the Wiki article:
"the tradition of using "Hello, world!" as the test message was probably started by its use as an example program in the book The C Programming Language, by Brian Kernighan and Dennis Ritchie."
If you actually look at what that book published, you find not "Hello, world!" but "hello, world" . Why do we use the modified form in this Wiki article? - Bevo 12:33, 17 Aug 2003 (UTC)
SQL example
Is this not valid SQL?:
SELECT 'Hello, world!' AS Greeting;
It works at least in PostgreSQL and mySQL, and avoids the creation and destruction of an unnecessary table. --FOo 12:57, 5 Sep 2003 (UTC)
I don't think so, in Oracle you need something like:
SELECT 'Hello, world!' AS greeting FROM dual;
but I don't believe that's ANSI SQL either. OTOH there are various methods like temporary tables which may be "better". Lady Lysine Ikinsile 04:01, Jun 8, 2004 (UTC)
Yes, technically you should do this for ANSI SQL:
CREATE TEMPORARY TABLE helloworld ( example varchar(16) ); INSERT INTO helloworld VALUES ('Hello, world!'); SELECT example FROM helloworld; DROP TABLE helloworld;
It's a bit roundabout, but the SELECT xyz; extension, while nice, is proprietary.
Embedded literal strings
There is presently a long rant on this page about how all the example programs have embedded text and this is bad practice because such strings cannot be automatically replaced by translations into the user's native language. This is factually inaccurate (some environments allow translation of embedded strings, others do not) and non-NPOV (whether not string separation is good practice is controversial, but it's presented here as universally agreed).
I tried to rework the rant into a brief mention of the issue and a cross reference to Internationalization, where the topic chould be discussed more evenly and at length, but I cannot make it brief without making it unclear. And I'm wondering whether this is an appropriate place to mention this at all. The more I think about it, the more totally offtopic this seems. Thoughts?
- Zack 06:19, 10 Sep 2003 (UTC)
- Well said, Zack. It would be hard to work that other topic in appropriately with this topic.
- I killed it. Zack
GTK / Windows API examples
Is the GTK exemple serious ?
- Ericd 08:57, 13 Sep 2003 (UTC)
- It's not the canonical GUI "hello world" program in my book, but tastes may differ. (The way I learned it, a GUI "hello world" is supposed to pop up a window showing that text, and obey the standard quit commands for that GUI -- it may or may not have a quit pushbutton too.)
- Zack 04:16, 14 Sep 2003 (UTC)
- The standard "hello world" app for the Windows API that I've seen is similar also. According to Petzold (via [1]): "The original hello-world program in the Windows 1.0 SDK was a bit of a scandal. HELLO.C was about 150 lines long, and the HELLO.RC resource script had another 20 or so more lines... Veteran C programmers often curled up in horror or laughter when encountering the Windows hello-world program". I have a textbook with a Windows API hello-world spread over 3 source files plus a header file -- one for WinMain and the message loop, one for initialising the class and the window, and one for the paint procedure. The program creates a proper overlapped window, with "Hello world" in the client area. Using MessageBox() really is cheating. -- Tim Starling 04:42, Sep 14, 2003 (UTC)
- We should decide about appropriateness of using cheats (e.g. MessageBox()) at all. -- Xrgtn 14:46, 25 October 2005 (UTC)
- Is this good? After seeing your comment I was going to put it in, but I was afraid someone would change it right back...
#include <windows.h> LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); char szClassName[] = "MainWnd"; HINSTANCE hInstance; int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; WNDCLASSEX wincl; hInstance = hInst; wincl.cbSize = sizeof(WNDCLASSEX); wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.style = 0; wincl.hInstance = hInstance; wincl.lpszClassName = szClassName; wincl.lpszMenuName = NULL; //No menu wincl.lpfnWndProc = WindowProcedure; wincl.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); //Color of the window wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //EXE icon wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Small program icon wincl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor if (!RegisterClassEx(&wincl)) return 0; hwnd = CreateWindowEx(0, //No extended window styles szClassName, //Class name "", //Window caption WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, //Let Windows decide the left and top positions of the window 120, 60, //Width and height of the window, NULL, NULL, hInstance, NULL); //Make the window visible on the screen ShowWindow(hwnd, nCmdShow); //Run the message loop while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: CreateWindow("STATIC", "Hello, world!", WS_CHILD | SS_NOTIFY | SS_SIMPLE | \ WS_VISIBLE, 15, 10, 80, 20, hwnd, NULL, hInstance, NULL); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
- - Evil saltine 05:29, 14 Sep 2003 (UTC)
- Why does that create two windows? Or am I confused? I don't know Windows GUI programming at all. Would a programmer really write all that, or would they use a higher level "toolkit" library to do the grunt work?
- Anyhow, I wonder if there should be a separate page for GUI hello world programs. They do tend to be much longer than the simple "print text" variety, and are not really examples of programming in a given language. They are instead examples of programming to a given API (which may or may not imply a language; Tk for instance can be used from several different languages).
- Zack 17:32, 14 Sep 2003 (UTC)
- One "window" is the actual window, and the other is the text. That's the way it would probably be written... but I don't know for sure.
- Evil saltine 21:02, 14 Sep 2003 (UTC)
- In my experience, a toolkit is usually used (although they're not called toolkits). Microsoft's MFC is the most popular, although personally I'm more familiar with VCL. Both are basically wrappers, they don't provide significant functionality like GTK does. Yes, there are two windows: one overlapped parent window and a static text child window. MS Windows programmers have a different definition of the word "window" to ordinary people: controls such as buttons, text boxes, etc. are actually child windows. The hello world program I was referring to didn't create two windows like that, it just used TextOut in response to WM_PAINT. -- Tim Starling 07:51, Sep 15, 2003 (UTC)
More (sub)sections suggested
I suggest we create a (sub)section "Script languages", and perhaps others, to make the article a little more navigable. I'll work on this if no one else does and not too many strongly discourage it. --Wernher 06:22, 17 Dec 2003 (UTC)
- Hmmm, let me try to squeeze in another line in this heated discussion. :-) To tidy up the article I also suggest "Assembly languages" to be a section instead of it being a subsection under Line-oriented languages. No protests => 'do it'. --Wernher 21:38, 10 Feb 2004 (UTC)
PostScript example variant
Postscript: Hello world with shadow.
(Hello world) /Times-Roman findfont setfont 300 50 moveto [0 100 -100 0 0 0] concat /X {gsave .01 setlinewidth dup stringwidth pop .2 add dup neg exch 0 0 -1 4 -1 roll 0 0 1 rlineto rlineto rlineto rlineto stroke grestore .1 .2 rmoveto dup show} def gsave [1 0 2 -.8 0 0] concat .8 setgray X grestore X showpage
(forgot to sign)
I don't undertand why PostScript is under "File Formats" and not unter programming languages. This is clearly a programming language! Not at all at the same sige than HTML or even RTF! The same is true about LaTeX. — MFH: Talk 18:04, 24 Jun 2005 (UTC)
Romanian pseudocode esoteric?
I wonder if the Romanian pseudocode example should rather be placed in the Hello world program in esoteric languages article instead? "Romanian pseudocode" certainly sounds quite esoteric to me, but then again I'm not from Romania... --Wernher 21:44, 10 Feb 2004 (UTC)
MSDOS example too long
The MSDOS command could just be "@echo Hello, world!" There's no reason for turning echo off on a one line batch script.
- OK. Please, "be bold" and edit it. Bevo 21:03, 24 Feb 2004 (UTC)
YaBasic advocacy
"To whom it may concern": please take no offence, but there is absolutely no new information gained by including "Hello world" written in YaBasic as long as we already have a section on Structured BASIC; there's a whole lot of BASICs out there where the Hello world program would look exactly the same -- so we include only a sampling of the most well-known ones. --Wernher 09:54, 3 Apr 2004 (UTC)
- maybe list variations on languages where the things look the same under the earliest of the genre? e.g.,
... panadaCalc ...
growl 'helloWorld'
Also, HoarseFelineCalc, BearCalc, machoMaleCalc.
- Er -- I'm not quite sure what to make of this, lest it be some sort of humorous(?) comment? --Wernher 20:01, 3 Apr 2004 (UTC)
- Well… some sarcasm maybe, but Anonymous' point is valid. If the "hello world" program is identical in languages X and Y, don't include two programs. Instead include just the X program with the annotation "Also Y." Makes sense, don't you agree?
- —Herbee 21:12, 2004 Apr 3 (UTC)
- Ah, now I understand *blush*; thank you. Yes, the point is absolutely valid -- too bad I didn't see at first reading what Anon. was trying to say. For a language with many similar dialects, such as BASIC, a typical listing of variations might be a general reference to e.g. "Microsoft BASIC". --Wernher 21:58, 3 Apr 2004 (UTC)
HyperTalk Example
HyperTalk is the programming language behind HyperCard, the popular "stack" programming tool for the Macintosh during the '90s (and in limited use today).
on openStack answer "Hello, World!" end openStack
'open stack' could be any handler, but makes the most sense in a "Hello, World!" example since a stack is really an entire program in HyperCard.
(HyperCard will automatically format control blocks with each indent being, I believe, two spaces.)
Color-coding of hello world programs
User:Rrjanbiah who seems to be a large fan of the -s
option of php(1)
he has recently
color coded the Hello world program article to look something like this example of C and C++ and this example of Perl and PHP.
While i agree that readability of these code examples is of the essence i think something like this just crosses the line, first of all it is highly unportable so people would have to run around manually syntax highlighting everything that the php parser doesnt read, second of all the html code produced by said parser can only be horrendous, and third of all it does not follow the Wikipedia:Manual of Style,
In the meantime i have reverted the article to it's former state and notified User:Rrjanbiah, he can respond below this line if he disagrees/has anything to add, then we can hold a vote on this. --Ævar Arnfjörð Bjarmason 00:25, 2004 May 6 (UTC)
- I've checked the manual of style, and couldn't find a clear policy on this, so I started a discussion at http://en.wikipedia.org/wiki/Wikipeda_talk:Manual_of_Style#Syntax_highlighting_for_source_code.
Before thinking of voting, these days it's called a survey. See: http://en.wikipedia.org/wiki/Wikipedia:Survey_guidelines . But best if this were discussed on the talk for manual of style first. Kim Bruning 22:35, 17 Jul 2004 (UTC)
PHP Example
I corrected the
Hello World!
to
<?php echo "Hello World!"; ?>
The former just can't be right, because the text outside of <?php ?> tag-pairs is not interpreted by the PHP-engine and if you put the text "Hello World" inside the tags without echo or print, then you just get an error.
- It is, technically, correct. Text outside of <?php ?> is passed, through unmodified. For example:
15> cat >hello.php Hello, world ^D 16> php hello.php Hello, world 17>
- However, given that the idea is to demonstrate the basic structure of the language (IMHO), I think the more complex example is more useful. —Lady Lysiŋe Ikiŋsile | Talk 23:29, 2004 Jul 15 (UTC)
I changed primary PHP example back to
Hello, world!
and put
<?php echo "Hello, world!\n"; ?>
in as a secondary example, the reason for this is that each Hello world example should display the simplest way to print "Hello, world" using the language, and printing and ignoring everything outside <?php ?> tags is a feature of php, and thus the simplest way to print "Hello, world" is the first example above. —Ævar Arnfjörð Bjarmason 23:50, 21 July 2005 (UTC)
The title
Clicking on "Hello world" program leads to an appropriately named edit window for that page, so surely moving the article there (i hasten to add, using the Move link, not cutting and pasting into the window i provided by that link) will produce the desired result. The present title is contrary to the in-line-text usage of the article, & bad English syntax. (Why would anyone say hello to a world program, whatever that is?) Unless i've missed a prohibition in the WP:MOS, i intend to rename this page's article in that way. --Jerzy(t) 22:31, 2004 Jul 29 (UTC)
Uselessness of various alternates
There are certain various useless alternate examples that I'm removing. Python has two examples, one showing that you can use the sys object to produce output. Rexx demonstrates that you could use single or double quotes for the string. This is not useful. In the languages I'm more familiar with (Perl and Ruby) there are several ways of expressing strings, and there are several ways of getting data to STDOUT. I'm sure many other languages have their slight variations on these themes. If we were to apply the treatment Python and Rexx have received to every language on the list, the page would become three times as large and ten times as annoying. In the interest of consistency, I'm trimming off some of this stuff. --Yath 21:46, 14 Aug 2004 (UTC)
I agree! It seems quite silly that an article on the hello world program should now be approching the 32k range. I'd like to offer a suggestion, where we refactor the article in such a way that the one-liners don't have to take up so much real estate... Um, I was going to be bold, but I was fairly sure someone would just immediate revert, so I present it here on the talk page:
One Liners
- Here is a listing of those languages where "hello world" is a simple one-liner, that is, where a literal-notation for the string "hello world" is generally preceeded or followed by a single command to either send the string out to a console or to a graphical user interface, such as a dialog box:
WRITE "Hello, world!" ABC trace ("Hello, world!") ActionScript 'Hello, world!' APL display dialog "Hello, world!" AppleScript BEGIN { print "Hello, world!" } AWK ShowMessage("Hello, world!"); Delphi,Kylix puts(1, "Hello, world!") EUPHORIA -TYPE Hello, world! Focus ." Hello, world!" CR Forth println["Hello, world!"] Frink print,"Hello, world!" IDL "Hello, world!" print Io WriteLine "Hello, world!" Kogut alert( "Hello, world!" ); JavaScript print [Hello, world!] Logo print "Hello, world!" Lua W "Hello, world!" M (MUMPS) Print["Hello, world!"] Mathematica print "Hello, world!\n"; Perl echo "Hello, world!"; PHP 'Hello, world!' => POP-11 write('Hello, world!'),nl. Prolog print "Hello, world!" Python MsgBox "Hello, world!" REALbasic say "Hello, world!" REXX puts "Hello, world!" Ruby (display "Hello, world!") Scheme sed -ne '1s/.*/Hello, world!/p' sed 'Hello, world!' print. Self Transcript show: 'Hello, world!' Smalltalk print "Hello, world!\n"; SML #OUTPUT Hello, world! TACL puts "Hello, world!" Tcl put "Hello, world!" Turing echo 'Hello, world!' UNIX-style shell MsgBox "Hello, world!" Visual Basic WScript.Echo "Hello, world!" Windows Script Host
So, what does everyone think? func(talk) 04:54, 8 Sep 2004 (UTC)
- What about the shebangs? Won't someone think of the shebangs? (And preprocessor directives, if you must.) ... I'm not sure I like this. "That other junk" is pretty important. --Yath 06:33, 8 Sep 2004 (UTC)
My only concern is that such a simple notion as "hello world" doesn't need such a tediously long article. In terms of the assembly languages, the code is really interesting, but in terms of languages where it's more or less just a command and string, what exactly are we trying to show people? All of these examples don't teach us any more about:
- what hello world is
- why hello world is used
Nor does it really teach us anything about the differences between these languages. A better way to do that would be to provide a link to 99 Bottles of Beer. func(talk) 16:11, 8 Sep 2004 (UTC)
- (William M. Connolley 17:03, 8 Sep 2004 (UTC)) HW is a useful test. To *write* HW doesn't need a long article but to list it for various languages does. We are trying to show people the differences between various languages. Obviously not a full comparison but its useful from the quick-and-dirty POV.
Er, right, and that's what my example does. It shows a quick and dirty example of HW in dozens of languages, without taking up hundreds of lines. Note that I wasn't suggesting removing any language example whatsoever, I just thought that for those languages where it's a one-line affair, we could simplify. (My personal opinion is that HW is the silliest way one could choose to show language differences, but I wasn't advocating removing anything). func(talk) 17:11, 8 Sep 2004 (UTC)
- With a basic knowledge of a variety of programming languages, I actually find looking up a 'hello, world' program a simple refresher with regard to syntax of a particular language. so for me, this article is great... thanks to the various authors. --Mysteronald 19:16, 8 Sep 2004 (UTC)
- (William M. Connolley 18:47, 8 Sep 2004 (UTC)) Oh, sorry, I misunderstood you. You are proposing to condense the one-liners as above? Fine by me.
I believe that the list of programs does not belong in this article. It should be moved to List of hello world programs or something. I also believe that each entry in that list, as well as the examples retained here, should include all canonical preprocessor directives, shebang lines, etc. The environment in which a language normally operates is an important aspect of the language. In fact, the differences between C's #include <stdio.h> and Perl's #!/usr/bin/perl -w tell you a lot more about these languages than their respective print[f] statements. --Yath 04:46, 9 Sep 2004 (UTC)
We could also make lists :
- Languages in which print "Hello, world!" ; is valid.
- Languages in which echo "Hello, world!"; is valid.
- same with parentheses... — MFH: Talk 20:26, 23 Jun 2005 (UTC)
Page too large
The Wiki is giving a page warning. How do we split this thing? Aliter 19:21, 22 Sep 2004 (UTC)
- I suggest splitting it into "Hello world program (examples)" [Unknown] 19:33, Sep 22, 2004 (UTC)
- I heartily agree with this suggestion. This page has definitely become unwiedly, and it serves two primary purposes. It first, explains what a Hello World program is and its history/origins, then goes on to provide a ton of examples. I do not think that splitting the language examples into different articles between those that are current and 'esoteric' or based on their interfaces would be prudent. These categories may change over time or may become redundant.
- No matter what type of splitting occurs, this article will always be large, and that is partly the point. However, a description of Hello World programs in general, and a listing of various examples are two fundamentally different topics. --Inarius 08:59, 7 January 2006 (UTC)
You mean splitting the list of from the description? Though functionally a good think, it will not save us for very long, I expect. The programs take up the bulk of the article anyway. Aliter 19:43, 22 Sep 2004 (UTC)
Make a new page at List of hello world programs or something, move the bulk of them over, and leave a representative example of major programming languages on this page. People will disagree about which programs are major enough to warrant inclusion on this page, but so be it. I'd be bold if I had the time... I suggest you just go ahead. --Yath 21:01, 22 Sep 2004 (UTC)
Another possibility is to leave in this article only the text oriented examples, and move to new articles the 'GUI', 'Document formats', and 'Page Description languages' examples (to follow the same convention that made with the examples in esoteric languages. In fact, I've just deleted the Befunge and Brainfuck examples because they were in the article 'Hello world program in esoteric languages'). -- suruena 09:23, 2004 Dec 21 (UTC)
- I very much agree with this idea - Hello world program in document formats, etc. -[Unknown] 09:59, Dec 21, 2004 (UTC)
- If in one week nobody complains, I'll move 'GUI', 'Document formats', and 'Page Description languages' examples to three new articles (and to fix the internal references of other articles that links to this one). But please, I'm not a native english speaker so, could someone help me choosing good names for the new articles? Thanks -- suruena 09:32, 2004 Dec 28 (UTC)
- Hmm... well, I would suggest:
- Hello world program in page description languages
- Hello world program in document formats
- Hello world program using GUI
- But, I'm not sure. -[Unknown] 21:09, Dec 28, 2004 (UTC)
The right place to this is wikisource:Hello_world, let's keep the article small, descriptive and elegant. --EliasTorres 01:28, 10 Feb 2005 (UTC)
- I 'm sure you meant Hello world program using GUIs, Brackets? I think the splitting up is a good idea, but of course the remaining article is very huge anyway. Elias is perhaps on to something, but on the other hand it's nice to have the examples in WKP. Ah, decisions, decisions... The Tyranny of Choice! :( --Wernher 02:14, 10 Feb 2005 (UTC)
- I know, it's good to have examples, maybe the C hello world example and maybe five more, but the HUGE list perhaps belongs to wikisource:Hello_world (or to a separated list). We can use {{Wikisourcepar|Hello_world}} resulting:
- EliasTorres 08:41, 20 Feb 2005 (UTC)
Disagree, just because the wiki is giving a warning doesn't mean you have to split the page. —Ævar Arnfjörð Bjarmason 15:28, 17 July 2005 (UTC)
Newlines
Why do some examples use newlines (eg. Perl) while others do not? It seems to me that they should be consistent, and personally I would suggest no newlines... but some languages don't even allow that (well, I'm thinking of DOS batch files, but they hardly count anyway.) -[Unknown] 21:01, Sep 29, 2004 (UTC)
- The hello world program is supposed to output a newline. Some languages have print statements that automagically add a newline and some don't. Perl doesn't. Python and Ruby do. Hopefully, the page is already consistent in this regard. --Yath 22:50, 29 Sep 2004 (UTC)
- Okay, I updated some of the examples to do this, except where it didn't make sense or I wasn't sure about the language (eg. JavaScript *shouldn't* use a newline in popups.), and I also tried to fix a few places which were using "Hello, world" or similar because most of the examples used the standard "Hello, world!" (with exclamation mark.) -[Unknown] 21:01, Sep 30, 2004 (UTC)
- Well, if you want to get involved in the standard form, they should all say "hello, world". This was the first known use, in http://cm.bell-labs.com/cm/cs/who/dmr/btut.html Mga 02:12, 24 May 2005 (UTC)
Other Languages
It occurs to me that this page can be translated into other languages extremely easily. Since programming languages do not change between England and Germany, for instance, we could get a German translation with the simple replacement of "Hello, World!" with "Hallo, Welt!". Is this already done or have I overlooked something? ~~----
- Scroll to the bottom of the page when editing; you'll see that there are a great many languages featuring this article (or, that is, a translated version of it.) -[Unknown] 07:45, Oct 1, 2004 (UTC)
Translating the "Hello, World" concept into different languages
Hello. I think that these examples could be more useful and interesting if an attempt were made to translate the notion of "simplest interesting program in language X" rather than "simplest program to do console output in language X". Many of the languages listed are procedural languages which are not conceptually very different from C, so their "Hello, World" programs are not very different. However, Prolog, for example, is quite different from C, so its "Hello, World" program should show something about the concepts behind Prolog. Comments? Regards & happy editing, Wile E. Heresiarch 01:30, 6 Nov 2004 (UTC)
Unexplained part in ARM
For the RISC OS entry, somebody (anon) came up with a neat and more concise version of what I wrote, but there is this comment:
"or the even smaller version (from qUE);"
I have no idea what qUE is, does anybody happen to know, or should I remove the "from qUE" part?
Page too wide
The page is too wide. Maybe long lines should be splitted? It isn't much difference if you, for example, make line break between list of funcion parameters. --Derbeth 22:47, 16 Dec 2004 (UTC)
- I moved the "too-long-one-liner" Malbolge example over to the esoteric languages article, where it belongs, and took the chance of splitting the "offending line" of the Ruby GUI example in two, marking the split with a backslash ("\"), which is common in some text editors, and in some compilers/languages. I reckon I'll be swiftly corrected if that makes it incorrect Ruby syntax :-) --(talk to) Wernher 01:42, 17 Dec 2004 (UTC)
- It's correct syntax. Ruby [vaporware] developer confirms. The best source? Type in the program and run it. ^_^ Paulymer5 22:56, 18 January 2006 (UTC)
- I made some changes, now article has right width. --Derbeth 15:06, 17 Dec 2004 (UTC)
Too many BASICs!
IMHO there were far too many BASIC dialects listed in this article which used the same example. The vast majority of BASIC compilers and interpreters understand the following code:
10 PRINT "Hello, world!" 20 END
Yes, some dialects support minor variations on the above—Commodore BASIC allows one to substitute ? for PRINT, and many structured BASIC dialects make the line numbers optional. But there is no reason for showcasing all these little optional variations when the compiler/interpreter in question can process the elementary version above.
I have therefore removed all subsections on specific BASIC dialects which are capable of running the above example and added an explanatory note under the main BASIC heading. (I suspect that there may be more dialects which could also be collapsed, but I'm not familiar enough with them to test this hypothesis.)
In the future, I think it would be a good idea if people refrained from adding more BASIC dialects to the article unless they are incapable of processing the above example.
Likewise I recommend that similar procedures be followed for other programming languages on this page. We don't need to list all possible shortcuts and dialectical variations when the compiler/interpreter is capable of processing an ISO/ANSI/IEEE/ECMA/de facto standard version of the language. —Psychonaut 15:37, 2 Feb 2005 (UTC)
- Not only Commodore BASIC, but every BASIC variant I've used allows ? for PRINT. Most of them are Microsoft BASIC variants, i.e. Commodore BASIC, GW-BASIC and AmigaBASIC, but AMOS on the Amiga also allows it, and it is not related with Microsoft. Maybe they got the idea from AmigaBASIC? 85.76.152.179 15:42, 16 Feb 2005 (UTC)
- I'm pretty sure I was using ? for PRINT back in 1969 on a GE timesharing system. If not that far back, then in the mid-70s on whatever mini-computer we had at school (Data General, IIRC). Either way, long before the Amiga.
- I agree, I used ? on Tandy (Tandy 1000 ?) BASIC in the 70's. (My first contact with a computer... I didn't know anything about computers and figured out by myself that if I prefixed expressions like 1+2 with '?', it showed the result. If not, nothing seemed to happen... ;-) — MFH: Talk 20:20, 23 Jun 2005 (UTC)
- I am the user 85.76.152.179 above. By "Maybe they got the idea from AmigaBASIC?" I meant AMOS. I was not implying AmigaBASIC invented the entire concept. I used ? for PRINT in Commodore BASIC years before I had even heard of the Amiga. — JIP | Talk 28 June 2005 09:29 (UTC)
Java "OOP" version
Someone wrote a version in Java meant as an example of object-oriented programming. I'm not sure whether it was a meant as a parody of OO or Java, or as a well-intentioned contribution. I have removed this in any case because it was verbose. The point of Hello World is to be a simple test application. The more complicated you make your Hello World program the more you have to debug if it doesn't work, which defeats the purpose. Anyway the Java version as it stands is reasonably OO. System.out is an object that receives the message "println" with a string object as a parameter. You could instantiate Hello and do the work from the constructor, but you'd have to do that from the non-OO main method anyway. Ben Arnold 14:11, 19 Feb 2005 (UTC)
XML
Is there a valid reason that XML isn't featured, or should I add it? -- VJ 17:30, 22 Jun 2005 (UTC)
assembly needs not to be cryptic
I forgot most of what I knew about 65xx programming, but I think the given code does really make an effort on being as much cryptical as possible. I'd suggest at least the following:
putchar = $ffd2 ; system "chrOut" routine: send char to current output device LDX #0 loop: LDA message,X ; load character BEQ return JSR putchar ; print it INX BNE loop return: RTS message: .ASC "Hello, world!" .BYTE 0
I don't remember the exact address, but I'm sure that there was also a routine for sending a null terminated string "at once". (What was $EA17 ?) — MFH: Talk 17:45, 24 Jun 2005 (UTC)
- Your version is 3 bytes longer, but yes, easier to understand. Mirror Vax 18:13, 24 Jun 2005 (UTC)
- In the Commodore 16 at least, JSR $FF4F writes a null-terminated string that immediately follows the JSR; then returns to the instruction after the null byte. Another nicety is in the Canon X-07 where one of the single-byte RST instructions of the Z80-compatible processor vectors to the putchar routine.
<p> tag in HTML example
The information about the <p> in the simple HTML example was incorrect. The new block is simply stacked on top of the <h1> block (at least, it should be). Also, both tags are left open at the end of the document. Not really a problem, of course, but not formally correct. Even more, those whole header tags are unnecessary for the example.
I edited the example to close with the proper tag.
C: puts or printf?
It seems that at 22:08, 28 June 2005, an unknown user changed the C function used to write "Hello, world" from the classic "printf" to "puts", and also removed the "\n" (for \n, see the talk above).
I'm aware that puts is valid, and possibly even a better alternative than printf, which is designed to print formatted text, but I think of all the examples on the page, C is the one which should honor the original by using printf. This is reflected in the fact that every C example I have ever seen uses printf, including the original, and I quote from the article in question:
- The book had inherited the program from a 1974 Bell Laboratories internal memorandum by Kernighan —Programming in C: A Tutorial— which shows the first known version of the program:
main( ) { printf("Hello, world!"); }
We've updated it to conform to the new ANSI standards but should not change printf. Therefore, I have changed it back to printf and added the "\n" back in. —EatMyShortz 6 July 2005 16:41 (UTC)
- printf() for sure!
- Atlant 6 July 2005 16:48 (UTC)
- If the purpose of the "Hello World"-example is to present a minimal (and in this case ANSI C conforming) program that displays "Hello, World!" and a trailing newline, then
#include <stdio.h> int main(void) { puts("Hello, World!"); return 0; }
- is the way to go. (Observe that `puts' adds a newline to the output.)
Microsoft Word example
While I find the MS-Word section hilarious, is this really germaine to this article? Isn't this something that belongs in an article about MS-Word, perhaps in a section that discusses ineffencies in its storage methods?
(But let me say again, it's hilarious)
MFC example
I miss an MFC example. Somthing like that:
AfxMessageBox("Hello, world!");
C variants?
Would it be salacious to include important C variants such as this example coded with the programming library for the Sega Saturn:
#include "sgl.h" void ss_main(void) { slPrint("Hello, world!", slLocate(9,2)); slSynch(); }
There are important differences in these forms as compared to regular POSIX C. ThomasWinwood 15:44, 1 October 2005 (UTC)
Mathematica program misspelling?
I noticed that in the Mathematica example it says:
Prant["Hello world!"]
[sic] I've never used Mathematica, but that doesn't quite look right to me. Is the print command really called "Prant"?
Cheating in GUI examples
GUI example of "Hello World" may be considered as a "skeleton"-like example of GUI program, but different kinds of message boxes, alarms et al. are not equal substitute. That's why such simplifications could be considered cheats. See e.g. full blown example of Windows API Hello World vs. its MessageBox() implementation.
It's pity that many examples provide only "cheat" implementation, like Python/Tkinter (tkMessageBox), VisualBasic (MsgBox), Cocoa/GNUStep/objC (NSRunAlertPanel)...
If it's hard to find more appropriate examples, I propose just to place all theese into separate section and have, for example, the next split:
- Text user interface (Known as TUI, console or line-oriented)
- Graphical user interfaces (GUIs)
- Primitive graphical user interfaces
-- Xrgtn 14:52, 25 October 2005 (UTC)
- To distinguish "cheat" and "valid" GUI examples, I propose the next rule of extensibility: if it's easy to modify an example to add let's say a text field and/or a button, then the example is "good". For instance, the Tcl/Tk example:
label .l -text "Hello, world!" pack .l
- should be considered good, because you can easily add a button to the window:
label .l -text "Hello, world!" button .b -text exit -command exit pack .l .b
KML for Google Earth Section
Does the KML section really constitute a legitimate example of a Hello World program? --Dalziel 86 08:31, 1 November 2005 (UTC)
- I think it doesn't. --tyomitch 08:59, 1 November 2005 (UTC)
The PBASIC example
From the PBASIC example: "or, the typical microcontroller Hello World program equivalent with the only output device present being a light-emitting diode (LED) (in this case attached to the seventh output pin)".
And it blinks forever in a regular pattern. Would it be so wrong to have it blink "HELLO WORLD" in Morse code? --Damian Yerrick 04:26, 6 December 2005 (UTC)
- Not at all; a very nice "exercise for the student", actually. :) But not really required if we only want a simple test to see whether we have a minimum degree of functionality present in the controller, its connections, and the toolchain. --Wernher 06:28, 6 December 2005 (UTC)
Examples with empty lines
Some examples are shown in several boxes instead of one box. This happens when an example contains empty lines. Wikipedia interprets empty lines as end of the box.
I think the examples are easier to recognice and to read when each example is in one box (instead of several boxes). To reach this I added one space at the beginning of empty lines. I did this just for examples where it seems clear to me. Other spaces in empty lines should be added by someone else.