C+xcb+Cairo 2540 (82 lines)
Not exactly short. :) This is literally the PNG hello world from the Cairo docs, with just enough xcb to open a window and find the parameters needed to register the window with Cairo.
//xcr.c
//cc -o xcr $(pkg-config --cflags --libs cairo xcb xcb-icccm) xcr.c -lcairo -lxcb -lxcb-icccm
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <cairo-xcb.h>
#include <xcb/xcb.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_icccm.h>
int main (int argc, char *argv[])
{
int width = 300, height = 400;
int scrno;
xcb_screen_t *scr;
xcb_connection_t *connection;
xcb_screen_iterator_t iter;
xcb_drawable_t win;
unsigned int white;
xcb_visualtype_t *visual_type;
xcb_depth_iterator_t depth_iter;
connection = xcb_connect(NULL,&scrno);
iter = xcb_setup_roots_iterator(xcb_get_setup(connection));
for (; iter.rem; --scrno, xcb_screen_next(&iter))
if (scrno == 0)
{
scr = iter.data;
break;
}
win = xcb_generate_id(connection);
white = scr->white_pixel;
xcb_create_window(connection, XCB_COPY_FROM_PARENT,
win, scr->root,
0, 0,
width, height,
5,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
scr->root_visual,
XCB_CW_BACK_PIXEL,
&white);
xcb_icccm_set_wm_name(connection, win, XCB_ATOM_STRING, 8, strlen("xcr"), "xcr");
xcb_map_window(connection, win);
xcb_flush(connection);
depth_iter = xcb_screen_allowed_depths_iterator(scr);
for (; depth_iter.rem; xcb_depth_next(&depth_iter)) {
xcb_visualtype_iterator_t visual_iter;
visual_iter = xcb_depth_visuals_iterator(depth_iter.data);
for (; visual_iter.rem; xcb_visualtype_next(&visual_iter)) {
if (scr->root_visual == visual_iter.data->visual_id) {
visual_type = visual_iter.data;
goto visual_found;
}
}
}
visual_found: ;
{
cairo_surface_t *surface =
cairo_xcb_surface_create (connection, win, visual_type, width, height);
cairo_t *cr = cairo_create (surface);
cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
cairo_move_to (cr, 10.0, 50.0);
cairo_show_text (cr, "Hello, world");
cairo_surface_flush(surface);
xcb_flush(connection);
sleep(100);
cairo_destroy (cr);
//cairo_surface_write_to_png (surface, "hello.png");
cairo_surface_destroy (surface);
}
xcb_disconnect(connection);
return 0;
}
1Does 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 – 2013-11-26T19:55:35.983
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 – 2013-11-26T20:00:52.860
I can make it as short as Sven's, but with OK and Cancel buttons :( – Teresa e Junior – 2013-11-27T08:27:52.513
Looks like there's a Bash answer at 19 now. – Iszi – 2013-11-27T15:31:03.483
2Can I do a VB 6 solution with a label with "Hello World"? 0 code solution? – Cruncher – 2013-11-27T16:41:18.307
I think this post has reached the point where community decides. Post it, and lets see what the solution itself is. I mean it is impossible to have 0 code I believe since at least Hello World would go in somewhere. Nor am I good at VB to know what exactly you mean. – Quillion – 2013-11-27T16:48:23.240
Do the answers in this answer not qualify?
– David Murdoch – 2013-11-27T20:03:11.740I think this post has actually reached the point of pointlessness. The challenge was ill-defined enough that some people (whether joking or not) seem to think
Hello World
can be claimed as an answer for HTML/HTA. Some answers do nothing but output to the console, without actually creating a new window, in certain cases. – Iszi – 2013-11-27T21:39:54.793@Iszi I value your opinion, just tell me what to change and how then I shall do so. My english sucks, and that causes my ideas to be projected incorrectly, so I am always listening. However at this point I believe that I can't change requirement except not accept any answers that simply show hello world in notepad and expect it to be accepted. – Quillion – 2013-11-27T21:44:14.143
@Quillion I agree that it's really too late to change the requirements. I'm not sure really how to restrict the requirements in a way that prevents the current problems without being overly restrictive/verbose, though. – Iszi – 2013-11-27T21:52:14.793
I suggest adding some circles next time. HTML/Bash will have a hard time to draw them (forbid external images, force the circle to have at least a random width). Real toolkits shouldn't have a big problem with that requirements. And BTW: My
echo Hello World
answer was a try to exploit the rules. As such, I had do defend it. – Johannes Kuhn – 2013-11-27T23:28:25.957Can the "Hello World" text be the title bar text? – sergiol – 2017-11-15T01:19:23.440
@sergiol no the rule is that inside of the window it should say hello world, title doesn't count – Quillion – 2017-11-15T02:47:02.570
Submitted Windows Batch at 18 chars: http://codegolf.stackexchange.com/a/25100/571 This beats the 19 char bash one, but not the debated 16 bash one.
– TessellatingHeckler – 2014-03-31T01:21:35.620