Technical,

Beyond Hello World

951 Words ,

Anytime anyone starts learning a Programming langauge they start out with the traditional "Hello-World" program.

This is great for a beginner i.e for someone who's done little to no programming before because it gives some form of output immediately without putting in much effort ^1 .

This is good because it provides instant gratification in some sense and acts as bait to get a newcomer hooked.

There's amazement -- "I just made the computer talk! So cool!"

It's all very exciting... for a beginner.

When a person who's been programming for a while tries to pick up a new language, the "Hello World" route isn't necessarily the best way to get started.

It serves no real purpose to start out outputting text to screen because it's no longer amazing and isn't a great indicator of the languages real capabilities, strengths or flaws.
The only thing that is immediately clear is how verbose the language is likely to be.

Here are "Hello World" Programs in a couple of common languages:

# Bash
echo Hello World
# Python
print 'Hello World'
// C
#include<stdio.h>
int main(){
    printf("Hello World\n");
}
;; Scheme/Racket
(print "Hello World")
/* Java */
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
}
// Rust
fn main() {
println!("Hello World");
}
// Javascript
console.log("Hello World");

Looking at these 7 odd snippets of code all one can really conclude is that Bash, JavaScript, Python and Scheme are a little less tedious to write than the rest.

In real life scenarios all 7 of these languages are used for vastly different things and have vastly different advantages, the tedium of writing them is typically the last concern.

What I'm trying to say is sometimes a "Hello World" isn't enough.
All the smart people I've talked to always suggest picking up a small "project" when learning a language because:

  • It keeps you interested.
  • Projects typically force you to explore different parts of the language.
  • You get some real world experience with the language.


I've tried taking this advice and it works out fairly well.
Pick a language, run through it's basics fairly quickly (a day or so) and then get hacking on an easy-ish project, typically it helps if you don't have to learn a lot of other concepts while you're building your project so that you can dedicate most of your time to learning the language itself.

Recently I've been trying to pick up Racket as a language in my spare time (It's also used in a course I'm taking, but a very limited subset).

Now there's an amazing #racket community on freenode and they use Pasterack to share code amongst themselves.
The clever thing about this pastebin is that it's an evaulating pastebin. It takes your code, runs it in a sandbox and shows the evaluated output as well as the code itself.

Pretty neat.

I wanted to start using this pastebin as well, but having gotten used to mozpaste, fpaste and pastebinit, I no longer have the patience to actually copy text from my terminal, paste it into a webpage, submit the form and the copy and paste the url to the person I'm taking in IRC.

It's a hassle.

And so I decided that I would write a pastebin script for Pasterack.

I've written pastebin scripts before and it's not a really complicated task.
The reason writing a pastebin script is so useful is because despite its simplicity, it typically covers a very wide subset of language's capabilities. You'll be using the language's OS interfacing capabilities.

Filesystem I/O, string Parsing, HTTP/Network libraries, command line parsing, Error handling and bit of regex thrown in here and there for good measure.

I'm not claiming that a pastebin script is the miracle program that will tell you everything about the language, it's not.

It will on the other hand definitely give you a better idea of how much it excels at doing various things. Questions like:

  • "Is the language great for prototyping?"
  • "Is it easy to write readable code?"
  •  "Does it come with a great builtin set of tools?"
  •  "Is it fast?"
  • "Is it a nightmare to debug?"


and many others can be answered with an easy-ish project like this.

I did end up writing that pastebin script for Pasterack and it can be found at PasteRackIt.

It took me about 2 days and lots of blundering through the Racket Docs^2 before I had anything substantial, but as a result of it all I've seen a lot more of the language than I would have if I were limited to using it in my course.

The takeaway from this article is that when learning something it's always a great idea to go beyond the usual "Hello World" equivalent. Find your own "Pastebin" and work on it, hack away in the language of your choice and maybe, just maybe there's some skill to be gained that way.


 

^1 Unless you're writing Java. Tough luck in that case pal.

^2 The Racket Docs are amazing btw.