Aiming for Jarvis, Creating D.A.N.I.

Tutorial 1: Hello, world (or, How to Start Without Breaking Everything)

Welcome to the fold! If you’ve made it here, you’re either genuinely interested in Skink, or you’ve stumbled in while looking for a recipe for disaster. Either way, let’s get you writing some code that actually does something before the coffee goes cold.

Your first program

First, let's create a file called hello.skink. Don’t worry, we won't be doing any heavy lifting just yet. I usually start with this just to prove to myself that I haven't completely borked my environment variables again.

fn main() -> int {
    print("Hello, world!")
    return 0
}

Now, a bit of background: main is the entry point for every Skink program. It’s the door the OS knocks on when it wants your code to start doing the work. We return an int here—0 is the standard "everything went fine, nothing exploded, and the hard drive is still intact" status code.

Compile and run

Time to see if this actually works. Assuming you’ve got the environment set up (if not, go back to the installation docs—I promise I wrote them for a reason, and not just to hear myself type), run this in your terminal:

SKINK_HOME=/path/to/skink-lang skink -o hello hello.skink
./hello

If the stars have aligned and the compiler is in a good mood, you should see:

Hello, world!

If you see an error, take a deep breath. It’s likely just a missing path or a typo. Programming is 90% fixing things you didn’t realize you broke five minutes ago, and 10% wondering why it finally worked.

Using a variable

Hard-coding strings is fine for a quick test, but we usually want our programs to have a bit of personality. Variables in Skink are declared with :=. We use type inference, so you don’t have to waste time telling the computer things it already knows. It's smart enough to figure it out, unlike some other systems I could mention.

fn main() -> int {
    name := "Skinker"
    print("Hello, {name}!")
    return 0
}

See those curly braces? That’s string interpolation. Skink automatically handles the conversion to string for you. It’s one less thing to lose sleep over when you're debugging at 2 AM.

Exercises

Because you learn by doing (and failing, mostly), give these a spin:

  1. Change the program to print your own name instead of "Skinker."
  2. Add a second variable called greeting and use it in your print statement. Make it weird if you want.
  3. The "Why did it break?" test: Change main so it returns 1 instead of 0. Check your terminal after running it. What happened? Why? (Hint: your OS cares about that number).

Next

When you're ready to dive into the deeper end, head over to Variables and types.