What is xTalk?
xTalk is a family of programming languages that read almost like English. It began in 1987 with HyperTalk, the language of Apple's HyperCard, which let teachers, artists and shopkeepers build their own programs. It lives on in LiveCode, OpenXTalk and OXT-Beyond, which is free and runs on Windows, macOS, Linux and in your browser.
Here is a whole xTalk program. Even if you have never programmed, you can probably guess what it does:
put "The total is" && 12 + 30
The total is 42
It works out 12 plus 30, joins the answer to some words, and shows the result. That is the idea behind xTalk: you spend your time on what you want the computer to do, not on punctuation.
Stacks, cards and scripts
An xTalk program is called a stack. A stack is a window, and it holds one or more cards, like a stack of index cards. On each card you place controls: buttons, text fields, pictures, menus and so on. You drag them onto the card from the Tools palette and arrange them with the mouse, much as you would in a drawing program, then set their colours, words and names in the Property Inspector. You do not need a line of code to lay out a window.
Every object, from a button to the stack itself, can have a script: the xTalk that says what it does. A button's script usually waits for a click:
on mouseUp
answer "Hello from Beyond!"
end mouseUp
When you click the button and let go, xTalk sends it the message mouseUp. The script has a handler for that message (everything from on mouseUp to end mouseUp), so its lines run: answer shows a little dialog with the words in quotes. You will meet handlers and messages properly in later lessons, and drag out a button and give it a script like this one in Stacks, cards and controls; for now, notice how readable it is.
Your first line
The first command most people learn is put. With nothing after it, put shows a value. Text goes inside double quotes; numbers do not need them.
put "Hello, world!"
put 2026
put 7 * 6
Hello, world! 2026 42
The program runs from the top, one line at a time. Each line is one instruction, which xTalk calls a statement.
Where to run the examples
You can try every example in these lessons yourself, in OXT-Beyond. The bar on top of each one says where it goes:
- Example: run it in the playground. Choose Help > xTalk Academy. The playground on the right of the window runs whatever you type when you press Run (or Ctrl+Enter), and shows every
puton a line of its own in the Output, exactly as the lessons do. The first part of the course, about values, text and handlers, happens here. - Build it: your own stack. From the lesson Stacks, cards and controls on, you build a card of your own, the way most xTalk programs are made: choose File > New Stack > Default Size, drag controls from the Tools palette (Tools > Tools Palette) onto the card, and name them in the Property Inspector (double-click a control). A box marked Build it lists the steps.
- Message Box: lines to type. Choose Tools > Message Box, type a line and press Return: it runs at once, on the card in front. A
putshows its value there, and each one replaces the last, so these examples show what eachputshows, in turn. - Script: what an object does. In Edit mode (the arrow at the top of the Tools palette), select the object and choose Object > Object Script, or right-click it and choose Edit Script. Paste the script and press Apply. Then click Run (the hand) at the top of the Tools palette, and click the object.
How to read the lessons
Each example has a bar on top that says what it is, and a Copy button. Under it, Output shows exactly what the playground shows when you run it, and Message Box what the Message Box shows. The lessons are checked by running every example on the OXT-Beyond engine (on a card built as the steps say, for the ones on your own card), so what you see here is what you get.
Some examples are mistakes on purpose, so that you know what an error looks like. This one asks xTalk to add 1 to a word, which has no number value:
put "ten" + 1
The playground stops, highlights the line, and explains what went wrong in plain words. Errors are normal: every programmer meets several an hour. The lesson Debugging is all about finding and fixing them.
Try it yourself
Open the playground and make the Output show your name on the first line and your favourite number on the second.
Show a solution
put "Ada"
put 7
Ada 7
Words in this lesson
Each one finds every lesson that uses it. The Dictionary has the whole story of each, with its syntax and more examples.