Skip to content

Hello World!

Matt Carmody edited this page Jan 22, 2020 · 1 revision
// HelloWorld.dog - a comment ( begins with //)

// BUILDS
LinuxBuild: Platform='Linux' CPU='amd64' Lang='CPP' optimize='speed';
//SwingBuild: Platform='Java' CPU='JavaVM' Lang='Java' optimize='speed';
//AndroidBuild: Platform='Android' CPU='JavaVM' Lang='Java' optimize='power';
//iPhoneBuild: Platform='IOS' CPU='amd64' Lang='Swift' optimize='speed';

// TAGS
Title = "Hello World"
FileName = "helloWorld"
Version = "1.0"
CopyrightMesg = "Public Domain"
Authors = "Bruce Long"
Description = "This is an example of a very minimal program"
ProgramOrLibrary = "program"
featuresNeeded = []
LicenseText = `Public Domain`
runCode=`sayHello()`

// CLASSES
struct GLOBAL{
    void: sayHello()<-{
        print("Hello World!\n")
    }
}

High level structure of a CodeDog script

At a high level, a CodeDog script can be broken down into three parts: builds, tags and classes. There are a few more optional components of a script that fall outside these three categories which will be covered later.

Builds

A CodeDog script is used to generate programs for different platforms & languages. The builds, lines 4-7 above, determine the names of the directories that will be generated (ie. LinuxBuild) and can also optionally include tags such as which platform, language, priority, etc. to generate. Easily toggle builds on and off with comments.

If no build spec is included, CodeDog will default to the system type you're currently running.

Tags

A common theme in CodeDog is the use of tags. The tag block, lines 10-19 above, typically follows a build spec and is used to specify metadata and design choices for the generated programs. The same optional tags used in the build specs above can be set here instead if they will not change across builds. (Note that if there is a conflict of tags specified in both places, the tag specification will overwrite the build spec.) Optional tags can be used in many places in a CodeDog script and will be seen again.

Classes

Classes make up the meat of a typical script. In this example, lines 22-26, there is only one class, GLOBAL, and GLOBAL is composed of just one function, sayHello. In a typical application this will be much bigger. Meanwhile, the build spec and the tag spec stay relatively small as scripts grow more complicated.

Hello World

This hello world scripts generates one build which is for a Linux platform, written in C++. The runCode tag is the lead domino and sets things in motion. It calls the GLOBAL function sayHello, which prints "Hello World!\n" in the terminal.

Clone this wiki locally