Hello World

This is a demo page to test the features of this blog. Don’t expect much here.

In the software world, everything begins with Hello World. This is the beginning of my blog. Let’s see how this will go. This page stands to test the features of this blog.

This website has been completely designed using GNU Emacs. The static web pages are written in Emacs org-mode and exported to HTML. If you are not yet a GNU Emacs user, give it a try. It’s worth learning. If you are familiar with vim, see Spacemacs. You shall feel home.

To begin with, let’s see how code blocks in different language be handled. This should be pretty smooth, and cool .

Hello World

How about showing some real content? Have a look at a few examples below.

C Programming

Let’s begin with Hello World in C Programming.

#include <stdio.h>

main (void)
  printf ("Hello World!\n");

  /* Implicit in c99+ */
  return 0;

Save the above code into hello.c, then compile and run.

# Compile and run
gcc hello.c -o hello && ./hello

# An alternate way for the same.  If you are
# wondering, no, you don't need any Makefile.
make hello && ./hello

Emacs lisp

Now let’s try this in elisp. The code below will print “Hello World!” to the echo area. To run the program, write the code in GNU Emacs, put the cursor at end of the paren and press C-x C-e .

(message "Hello World!")
;; Put the cursor here  ^

GUI using GTK+ and C

The following example shows a window with a “Hello World!” label. The code will work with GTK+3 and GTK+4 without any change.

 * Hello world with GTK+ in C
 * By Mohammed Sadiq <sadiq [at] sadiqpk [d0t] org>
 * Date: 2018 October 25
 * License: None, Public domain (CC0)
 * Compile (Replace gtk+-3.0 with gtk4 for GTK4):
 * gcc $(pkg-config --cflags --libs gtk+-3.0) hello.c -o hello
 * Run:
 * ./hello

#include <gtk/gtk.h>

static void
activate_cb (GtkApplication *application,
             gpointer        user_data)
  GtkWidget *window;
  GtkWidget *label;

  window = gtk_application_window_new (application);
  gtk_window_set_title (GTK_WINDOW (window), "Hello World!");
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);

  label = gtk_label_new ("Hello World!");
  gtk_container_add (GTK_CONTAINER (window), label);
  /* Not required for GTK+-4 */
  gtk_widget_show (label);

  gtk_window_present (GTK_WINDOW (window));

main (int    argc,
      char **argv)
  g_autoptr(GtkApplication) application = NULL;

  application = gtk_application_new ("org.sadiqpk.example",
  g_signal_connect (application, "activate",
                    G_CALLBACK (activate_cb), NULL);

  return g_application_run (G_APPLICATION (application),
                            argc, argv);

The above code is a simple example that works with both GTK3 and GTK4. If you need a feature rich template to develop GTK+ applications, see My GTemplate project.