ForgeCrowdBookWe don't sell the fish – we give you the rod.

Why an Intention Language

A book that grows with its language. This is an early edition. Part I is complete and every example in it runs in the current Forge Runner. While writing Part III we found parts of SMS that the native compiler does not handle correctly yet – so we are fixing the compiler first, and the chapters on SML and SMS will follow. Check back: new chapters appear here as soon as they are tested.

Most programming languages ask you a question before you have even started:

How?

How do I allocate this window? How do I register this callback? How do I keep the button and the label in sync? How do I build, package, sign and ship it?

ForgeIL asks a different question first:

What do you intend?


Describing instead of instructing

Imagine you want a small app: a window, a greeting, a button. When the button is pressed, the greeting changes.

That sentence is already the whole program. Everything else is translation.

In most toolkits, that translation is long. You import a framework, subclass something, override a lifecycle method, create objects in the right order, attach a listener, remember to update the UI on the right thread.

In Forge4D you write down what is there:

Window {
    id: mainWindow
    title: "Hello"
    size: 480, 320

    VBoxContainer {
        anchors: left | top | right | bottom
        Label { id: greeting  text: "Hello, Forge!" }
        Button { id: btnHello  text: "Say hello" }
    }
}

And you write down what should happen:

on btnHello.clicked() {
    greeting.text = "Hello again!"
}

(greeting is the id of the label in the SML file. The script uses it directly – you will see more of this in the next chapter.)

That is the idea of an Intention Language. You describe what is there and what should happen. The Forge Runner takes care of how.


Two halves of one language

ForgeIL has two halves. They are deliberately different, because they do different jobs.

SML – Simple Markup Language describes structure. Windows, containers, labels, buttons, themes, texts, even whole websites. SML has no logic at all. No loops, no conditions, no variables. Only things and their properties. That makes it calm to read and very hard to break.

SMS – Simple Multiplatform Script describes behaviour. Variables, functions, decisions, and above all events: when this happens, do that. Its syntax is small and borrows from Kotlin, so it feels familiar if you have seen any modern language.

Together they form ForgeIL:

Half Answers File Example
SML What is there? .sml Button { id: save text: "Save" }
SMS What should happen? .sms on save.clicked() { … }

A screen in Forge4D is usually a pair of files with the same name: main.sml describes it, main.sms brings it to life. The Runner finds the script automatically.

Names and files. ForgeIL is the name of the language as a whole. The two halves keep their established names, SML and SMS, and the files still end in .sml and .sms. You will also meet the name ForgeIL in the compiler that is written in SMS itself – more about that in Part IV.


Why separate structure and behaviour?

You could put everything into one language. Many frameworks do. Here is why Forge4D does not.

Structure changes slowly, behaviour changes often. A designer can rearrange the whole layout without touching a single line of script, as long as the ids stay the same.

Structure can be checked before anything runs. An unknown property in SML produces a warning, not a crash. A typo does not take your app down.

Structure is easy for humans – and for machines. SML is so regular that an AI model can write it reliably. That is not an accident. ForgeDesigner, the AI assistant you will meet at the end of this book, builds apps by writing SML and SMS for you.

Behaviour stays small. Because the script does not have to build the UI, it only contains what really is logic. A typical screen needs a few dozen lines of SMS.


What the Runner does

You never compile, link or package by hand while you develop. The Forge Runner does three things for you:

  1. It reads your SML and builds the native user interface from it – on macOS, Linux and Android.
  2. It compiles your SMS. Not into bytecode for a virtual machine, but straight into native machine code through LLVM. There is no garbage collector and no runtime to install.
  3. It connects the two: when the user presses btnHello, your on btnHello.clicked() handler runs.

When your app is ready, the same project is built into a real application – a .app for the Mac, an .apk for Android – with the Runner inside.


SML is everywhere

Once you know SML, you will find it in more places than apps.

Forge4D uses it for themes and translated texts. The ForgeDesigner settings are SML. CrowdBooks, the platform this book is published on, describes books in SML. And ForgeCMS builds complete websites from SML files – pages, menus, blogs, shops.

ForgeCMS is not part of this book. But everything you learn about SML in Part II will feel familiar there.


Free, and meant to stay free

Forge4D is open source under the GNU General Public License (GPL 3.0 or later).

The intention behind that choice is simple: what is built with Forge should be free as well. If you ship an app with the Forge Runner inside, you share its source under the same license – and the next person can learn from your work, just as you learned from this one.

There is also a commercial license. It exists for one reason: so that companies who only want to take, close and sell cannot do so for free. If you build in the open, you will never need it.

The details are explained in the chapter on licensing in Part IV.


How this book works

This is a hands-on book. Every chapter follows the same rhythm:

  • Goal – what you will be able to do at the end.
  • Example – a small, complete program you can run.
  • Explanation – what each part means, and why.
  • Pitfalls – the mistakes everybody makes once.
  • Exercise – something to try on your own.
  • What you learned – a short summary.

The parts build on each other:

  • Part I – Intention: the idea, and your first running app.
  • Part II – Structure: SML in depth – layout, elements, themes, texts.
  • Part III – Behaviour: SMS in depth – variables, functions, events, files.
  • Part IV – Shipping: building real apps, native speed, a compiler that compiles itself, and licensing.
  • Part V – Intention with AI: describing apps in plain words with ForgeDesigner.

All examples are available in the examples folder next to this book in the CrowdWare books repository.

Forge4D is alive and growing. This book grows with it. New chapters will be added as new parts of the platform arrive.


What you learned

  • ForgeIL is an Intention Language: you describe what, the Runner handles how.
  • SML describes structure, SMS describes behaviour. Together they are ForgeIL.
  • A screen is usually a pair: name.sml and name.sms.
  • The Runner builds a native UI and compiles your script to native code.
  • Forge4D is GPL – what you build with it is meant to be free, too.

Next: Your First App