HyperTalk is a discontinued high-level,
procedural programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming ...
created in 1987 by
Dan Winkler
Daniel Allen Winkler (born February 2, 1990) is an American professional baseball pitcher who is a free agent. He previously played in Major League Baseball (MLB) for the Atlanta Braves and Chicago Cubs.
Career
Winkler attended St. Anthony High ...
and used in conjunction with
Apple Computer
Apple Inc. is an American multinational technology company headquartered in Cupertino, California, United States. Apple is the largest technology company by revenue (totaling in 2021) and, as of June 2022, is the world's biggest company b ...
's
HyperCard hypermedia program by
Bill Atkinson. Because the main target audience of HyperTalk was beginning programmers, HyperTalk
programmers
A computer programmer, sometimes referred to as a software developer, a software engineer, a programmer or a coder, is a person who creates computer programs — often for larger computer software.
A programmer is someone who writes/creates ...
were usually called "authors" and the process of writing programs was known as "
scripting
Script may refer to:
Writing systems
* Script, a distinctive writing system, based on a repertoire of specific elements or symbols, or that repertoire
* Script (styles of handwriting)
** Script typeface, a typeface with characteristics of handw ...
". HyperTalk scripts resembled written
English
English usually refers to:
* English language
* English people
English may also refer to:
Peoples, culture, and language
* ''English'', an adjective for something of, from, or related to England
** English national ide ...
and used a logical structure similar to that of the
Pascal programming language
Pascal is an Imperative programming, imperative and Procedural programming, procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming an ...
.
HyperTalk supported the basic control structures of
procedural languages: repeat for/while/until, if/then/else, as well as function and message "handler" calls (a function handler was a subroutine and a message handler a procedure).
Data types usually did not need to be specified by the programmer; conversion happened transparently in the background between
strings
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
and numbers. There were no
classes or
data structure
In computer science, a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, a ...
s in the traditional sense; in their place were special
string literals, or "lists" of "items" delimited by commas (in later versions the "itemDelimiter" property allowed choosing an arbitrary character). Code execution typically began as a response to an event such as a mouse click on a UI widget.
In the late 1980s Apple considered
using
HyperCard's HyperTalk
scripting language
A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.
A scripting ...
as the standard language across the company and within its
classic Mac OS
Mac OS (originally System Software; retronym: Classic Mac OS) is the series of operating systems developed for the Macintosh family of personal computers by Apple Computer from 1984 to 2001, starting with System 1 and ending with Mac OS 9. The ...
operating system, as well as for
interprocess communication between Apple and non-Apple products. The company did not oppose the development of imitations like
SuperCard, but it created the HyperTalk Standards Committee to avoid incompatibility between language variants.
The
case-insensitive In computers, case sensitivity defines whether uppercase and lowercase letters are treated as distinct (case-sensitive) or equivalent (case-insensitive). For instance, when users interested in learning about dogs search an e-book, "dog" and "Dog" a ...
language was initially
interpreted, but gained
just-in-time compilation with HyperCard 2.0.
[Dave Kelly]
"Tools of the Trade: CompileIt! 2.0!"
''MacTech'', Vol. 7 No. 9
Description
Fundamental operations
For most basic operations including mathematical computations, HyperTalk favored natural-language ordering of predicates over the ordering used in mathematical notation. For example, in HyperTalk's
put
assignment command, the variable was placed at the end of the statement:
put 5 * 4 into theResult
whereas in the more traditional
BASIC
BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
programming language (and most others), the same would be accomplished by writing:
theResult = 5 * 4
The HyperTalk code has the side-effect of creating the
variable
Variable may refer to:
* Variable (computer science), a symbolic name associated with a value and whose associated value may be changed
* Variable (mathematics), a symbol that represents a quantity in a mathematical expression, as used in many ...
''theResult'' on the fly. Scripts could assign any type or value to a variable using the
put
command, making HyperTalk ''very''
weakly typed
In computer programming, one of the many ways that programming languages are colloquially classified is whether the language's type system makes it strongly typed or weakly typed (loosely typed). However, there is no precise technical definition o ...
. Conversions between variable types were invisible and automatic: the string "3" could be multiplied by the number 5 to produce the number 15, or the number 5
concatenated onto the string "3" to produce the string "35". HyperTalk would not complain unless the types could not be automatically converted.
Flow control and logic were generally similar to other common languages, using a
if ... then ... else ... end if
structure for
conditionals
Conditional (if then) may refer to:
*Causal conditional, if X then Y, where X is a cause of Y
*Conditional probability, the probability of an event A given that another event B has occurred
*Conditional proof, in logic: a proof that asserts a co ...
and supporting
loops based on a flexible
repeat ... end repeat
syntax.
Comments
Comment may refer to:
* Comment (linguistics) or rheme, that which is said about the topic (theme) of a sentence
* Bernard Comment (born 1960), Swiss writer and publisher
Computing
* Comment (computer programming), explanatory text or informa ...
were prefaced with two minus signs:
-- this is a comment
.
Objects, containers and scripts
HyperCard's primary
user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine f ...
concept was the ''card'', a display system that emulated an
index card
An index card (or record card in British English and system cards in Australian English) consists of card stock (heavy paper) cut to a standard size, used for recording and storing small amounts of discrete data. A collection of such cards e ...
. Cards were normally used to store information, similar to a record in a conventional
flat-file database. The graphical layout of the card was created using the mouse by placing various elements on the card, such as text fields and buttons. A master layout "card" known as the ''background'' was shown behind the transparent areas of each card. Objects placed on the background, such as fields and buttons, would be shared as a common layout among several cards, but with card-specific content. The collection of cards, backgrounds and the associated data stored in them were stored in a single file known as the ''stack'' (of cards). Collectively, all of these data-containing objects are referred to as ''containers''.
HyperTalk functions, or ''scripts'', were normally stored within the
script
property available in many of the stack's containers. Scripts could access the properties of a container, corresponding to
instance variables, using the
get
and
set
instructions. The script property held plain text and had no special properties; scripts could be placed in, and run from, any text container, including string variables, or imported from other stacks using the
start using
command. A script could even be user-provided text typed into an on-screen text field. Arbitrary text could be executed using the
do
command, in a manner similar to Dynamic SQL.
Referring to containers
A key concept in HyperTalk was the way it referred to containers through a navigational system based on the visual hierarchy of the stack. Every container in the stack was given a unique ID number when created and could also be given an optional name. Scripts could refer to objects by using either of these identifiers, along with an object ''type'' specified using the
of
operator. This operator used a natural language syntax making for easily readable,
self-documenting code. For instance, a script stored in a button on a card might wish to take user-supplied text gathered using a text field and store the text in a variable called ''theValue'':
put the value of card field "typehere" into theValue
Various contextual aspects of statements could be inferred by the interpreter. In the statement above, for example, because the script would be running in the context of a button on a specific card, the identifier ''card'' was understood to refer to the card the user was interacting with, even though the button itself would normally be on the background. In addition, "''the value''" (the text submitted by the user) was assumed to be the main property and to be the target of operations if not otherwise specified. Likewise, "''card field''" was assumed to be the target of the command, as opposed to the background field, so that information could also be omitted. Even container types had short forms that programmers could use to save typing. Thus the code above is equivalent to the shorter form:
put fld "typehere" into theValue
Objects within a given context—the card or background, for instance—were also given a runtime number based on their
z-order
Z-order is an ordering of overlapping two-dimensional objects, such as windows in a stacking window manager, shapes in a vector graphics editor, or objects in a 3D application.Foley, James, Andries van Dam, Steven Feiner, and John Hughes. "Comput ...
on the screen. To assist in using their position for navigation, HyperTalk also included a variety of
ordinal and
cardinal
Cardinal or The Cardinal may refer to:
Animals
* Cardinal (bird) or Cardinalidae, a family of North and South American birds
**''Cardinalis'', genus of cardinal in the family Cardinalidae
**''Cardinalis cardinalis'', or northern cardinal, the ...
referencing systems to simplify the syntax further. Assuming the field "typehere" is the only field on the card, the code above could also be written:
put the first card field into theValue
or:
put card field 1 into theValue
The choice of addressing style was left to the programmer; often different styles were used in different statements in order to make the code more readable.
HyperTalk included the
me
container which acted in the same fashion as the
self
qualifier found in most
object-oriented languages
Object-oriented programming (OOP) is a programming paradigm based on the concept of "Object (computer science), objects", which can contain data and Computer program, code. The data is in the form of Field (computer science), fields (often kno ...
, allowing simple access to the current container object. Less common was the
it
variable, which held the value of the last operation for certain built-in operators. For example:
ask "What is the value?"
put it into card field "display"
uses the
ask
command to display a
dialog box
The dialog box (also called dialogue box (non-U.S. English), message box or simply dialog) is a graphical control element in the form of a small window that communicates information to the user and prompts them for a response.
Dialog boxes are ...
and capture the text typed into an accompanying text field; when the dialog is completed by hitting or clicking , the value is assigned to the
it
pseudo-variable. This code then copies that value into a card field using the
put
assignment operator.
Collections
Containers of a given type were also available as collections with a pluralized version of that container type as its name—the collection of the fields on a card was
card fields
. These collections were themselves containers with their own properties. Key among these was the
number
property which was widely used during iterations and similar tasks. For instance, if one wanted to hide all the fields on a card, this could be accomplished with this code:
repeat with i = 1 to the number of card fields
hide field i
end repeat
This code exposes another common feature of HyperTalk: that a property might have several names and operators. In this case the
hide
command, and the associated
show
, act by setting the value of the container's
visible
property. Thus
hide field i
is exactly equivalent to . A similar example was the
lock screen
command that stopped visual updating, which was a short form for , where
lockscreen
is a property of HyperCard itself—also a container. Many examples of this sort of
syntactic sugar were found in HyperTalk, in order to simplify the syntax and improve readability of common code.
In HyperCard 2.2 and later, the collection of collections was also available as a container's
parts
. This allowed a script to address all of the objects in a container with a single iterator.
Handling text
A notable feature of the HyperTalk container model was its handling of text. Every collection of text, whether a literal string in a program or text typed into a text field, was itself considered a container with multiple collections of containers within it. This allowed scripts to parse text using the same navigational commands as any other container. For instance, while parsing a space-delimited data file, one might want to extract the third column, like this:
put the third word of theFilesText into colThree
This syntax allowed the script to "walk" down the text to find particular data, as in this example:
put the first character of the third word of line 5 of card field "sometext" into theChar
This process of treating text as a container was known as "chunking", and the functions as "chunk expressions". These same sorts of expressions were used to handle file manipulation, along with a set of file management functions. The following code opens a known file, reads from it, extracts data, and then closes the file:
on mouseDown
answer file "Please select a text file to open."
if it is empty then exit mouseDown
put it into filePath
if there is a file filePath then
open file filePath
read from file filePath until return
put it into cd fld "some field"
close file filePath
set the textStyle of character 1 to 10 of card field "some field" to bold
end if
end mouseDown
HyperTalk also included functions for chunking strings using a substring-find operation using the
in
operator. The following code finds all examples of a given pattern using the
in
as part of the
repeat
loop, while
offset
finds the location of that pattern within the string:
function replaceStr pattern,newStr,inStr
repeat while pattern is in inStr
put offset(pattern,inStr) into pos
put newStr into character pos to (pos +the length of pattern)-1 of inStr
end repeat
return inStr
end replaceStr
Lists and other collections
HyperTalk used the same chunking system to produce structures like arrays or lists. Such a structure would be created by placing multiple data items in a variable, separated by commas. Various types of data could be imported into a HyperTalk script using strings that would get parsed as required. For instance, the position of objects on the screen was defined by a pair of numbers representing the X and Y coordinates relative to the upper left corner. The following code creates a variable called ''pos'' that holds a coordinate pair, and then manipulates this to re-position all of the buttons on a card in a diagonal from top-left to bottom-right:
on mouseUp
put "100,100" into pos
repeat with x = 1 to the number of card buttons
set the location of card button x to pos
add 15 to item 1 of pos
end repeat
end mouseUp
The
item
chunking expression was originally based on a comma
delimiter
A delimiter is a sequence of one or more characters for specifying the boundary between separate, independent regions in plain text, mathematical expressions or other data streams. An example of a delimiter is the comma character, which acts a ...
, but later versions of HyperCard changed this to the value of
itemDelimiter
, offering the ability to parse arbitrary lists and structures.
Messages and events
HyperTalk used an object-oriented concept for calling scripts, with objects in the stack sending "events" as ''messages'' that would be processed by ''handlers'' that declared their interest in receiving the events using the
on
syntax. For instance, most GUI containers would send the
mouseDown
message when the mouse button was clicked down, and then a
mouseUp
message when it was released while still on top of that container, and a script could capture these events like this:
on mouseUp
-- place additional code here
end mouseUp
Messages for events were first sent to the script in the object that created the event, for instance, if the user clicked on a button the
mouseUp
message was first sent to that button. If the button's script object did not have a
mouseUp
handler (or no script at all), it was then passed to the card, the background, the stack, any stacks whose scripts had been explicitly imported using the
start using
command, the "home stack" (a user-selected always-open HyperCard stack), and finally to the HyperCard application itself.
For many simple events like mouse clicks on buttons the script would be placed directly within the object in question, the button itself. For instance, one might use the example code above within a button handler in this fashion:
on mouseUp
repeat with i = 1 to the number of card fields
hide field i
end repeat
end mouseUp
In the case where code was being called from multiple locations, or it was being used as a global handler for an event, the script could determine the original sender of the event using the
target
function. Likewise, scripts could send events to other containers using the
send
command and then using the navigational code to refer to the container holding that handler's code:
send "mouseUp" to card button "OK" of card "Veracity"
Combining HyperTalk's string processing with the
do
command allowed for the construction of interactive interpreters by placing a text field on a card and then placing this code in the field's script:
on mouseUp
select the clickLine
put word 2 of the clickLine into linenum
do line linenum of cd fld 1
end mouseUp
clickLine
is a global property that returns the name and line number of the last field clicked, in a form like . This code first selects all of the text on the clicked line, then extracts the line number into a local variable, then uses
do
to run the text as a HyperCard script.
The
mouseDown
message was sent to a button when the user clicked it, and
mouseUp
was sent when the user released the mouse inside it to trigger its action. Similarly, HyperCard sent periodic
idle
message,
mouseEnter
,
mouseLeave
, ... and various other messages related to navigation between different cards in a HyperCard stack, as well as user input (
keyDown
,
functionKey
, ...), and system events. As far as the scripters were concerned, there were no main event loops like in other procedural programming languages.
Controlling HyperCard
Unlike general
rapid application development
Rapid application development (RAD), also called rapid application building (RAB), is both a general term for adaptive software development approaches, and the name for James Martin's method of rapid development. In general, RAD approaches to ...
platforms, HyperCard stacks always looked like stacks - the menu bar was HyperCard's and not the programmer's (by default—scripting could add, delete and modify menus), the single window was a fixed size (in early versions), and in certain cases, commands that were central to the operation were part of the application itself, and not directly available in HyperTalk itself.
A good example of this was the creation of new cards, which was part of the application, not directly accessible from the HyperTalk language itself. A new card could only be created using the New Card menu item, which could be simulated in code using
doMenu "New Card"
. While HyperTalk called into menu commands, menu commands also invoked handlers in HyperTalk. To run custom code when the Copy menu item was selected, one would place a script in the stack using the
on doMenu itemName
handler, and then examine
itemName
to see if it was "Copy".
HyperTalk also provided script control over the built-in drawing tools, simply by scripting the needed changes in paint tools and simulating mouse movements using the
drag from ''start'' to ''end''
and the
click at ''position''
commands.
Forgiving Semantics
One unique distinction between HyperCard's programming language HyperTalk and seemingly similar languages like AppleScript was that HyperTalk scripts were more lenient in what input they accepted.
Apart from the above implicit declaration of variables when a value was assigned to them, and the way values were implicitly converted between types (allowing you to e.g. ask for
character 2 of 1234
), HyperCard would also recognize certain expressions and extract sub-values from them.
For example:
put the selectedLine of card field "Listbox" into theSelection -- gives 'line 2 to 3 of card field "Listbox"'
select line 1 of card field "Listbox"
select line (word 2 of theSelection) of card field "Listbox"
select (the selectedLine of card field "Listbox") -- parentheses added for illustrative purposes only
or
play harpsichord c e g
play harpsichord "c e g"
put "c e g" into theMelody
play harpsichord theMelody
While the end result felt similar to scripters as a Bash script's expansion of variables before parsing, this was special-case syntax and did not have the pitfalls where data would be evaluated as code. So for example, all of the following are syntax errors in the melody, not function calls:
play harpsichord "c e g()"
put "c e() g" into theMelody
play harpsichord theMelody
Extending HyperTalk
Although the HyperTalk language languished just like HyperCard itself, it received a second lease on life through its plugin protocol, so-called External Commands (XCMDs) and External Functions (XFCNs), which were native code containers attached to stacks (as Macintosh-specific
resources) with a single entry point and return value. XCMDs and XFCNs could be called just like regular message and function handlers from HyperTalk scripts, and were also able to send messages back to the HyperCard application. Some enterprising XCMD authors added advanced features like full color support (ColorizeHC, HyperTint, AddColor), multiple special-purpose windows (Prompt, Tabloid, Textoid, Listoid, ShowDialog, MegaWindows), drag and drop support and various hardware interfaces to the language.
Descendants of HyperTalk
Various
scripting language
A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.
A scripting ...
s have implemented a superset of HyperTalk (collectively known as xTalk):
* CompileIt!-Talk – A HyperCard stack and XCMD by
Tom Pittman that allowed compiling native 68000 machine code (e.g. for XCMDs and XFCNs) from HyperTalk code, and calling the native Macintosh toolbox routines. CompileIt was
bootstrapped
In general, bootstrapping usually refers to a self-starting process that is supposed to continue or grow without external input.
Etymology
Tall boots may have a tab, loop or handle at the top known as a bootstrap, allowing one to use fingers ...
, that is, later versions were compiled using earlier versions of itself.
* Double-XX-Talk – Double-XX was a lightweight HyperCard clone that shipped as an addition to CompileIt! and allowed running XCMDs and XFCNs without HyperCard, and even included a small HyperTalk interpreter.
* MediaTalk – The language of
Oracle Media Objects, a descendant of Plus, and the first cross-platform HyperCard clone. Furthermore, the only one that was truly modular.
* PlusTalk – The language of Plus, from Spinnaker Software (originally developed by Format Verlag), which was used as the basis for
Oracle Media Objects.
*
SenseTalk
SenseTalk is a high-level English-like scripting language in the XTalk family, that supports both procedural and object-oriented paradigms. SenseTalk scripts are intended to be largely readable by ordinary people, including those with little to n ...
– The language of the NeXT-originate
HyperSenseand the VNC-based testing too
*
SuperTalk
SuperTalk is the scripting language used in SuperCard. SuperTalk is a descendant of HyperTalk.
Extensions to the HyperTalk base language
Additional syntax
One of the most powerful features SuperCard adds to the HyperTalk language is ''user prope ...
– The language of
SuperCard, the first HyperCard clone, by Bill Appleton. Appleton also wrote the popular
World Builder
World Builder is a game creation system for point-and-click adventure games. It was released in 1986 by Silicon Beach Software and had already been used for creating Enchanted Scepters in 1984. On August 7, 1995, developer William C. Appleton ...
adventure construction kit.
*
Transcript (formerly revTalk and MetaTalk) – The language implemented in the
LiveCode
LiveCode (formerly Revolution and MetaCard) is a cross-platform rapid application development runtime system inspired by HyperCard. It features the ''LiveCode Script'' (formerly MetaTalk) programming language which belongs to the family of xTalk ...
(formerly Revolution and MetaCard) software platform and development environment. MetaCard was an early Unix-originated HyperCard clone that ran on Classic Mac OS, Mac OS X, Windows, Linux and Solaris.
* XION - Originally the language of an open-source HyperCard clone that never materialized. Now implemented a
OpenXION
These clones and dialects (commonly referred to under the moniker of xTalk-languages) added various features to the language that are expected from a modern programming language, like exception handling, user-defined object properties, timers, multi-threading and even user-defined objects.
There are also languages whose syntax and structure show influences from HyperTalk, such as:
*
ActionScript
ActionScript is an object-oriented programming language originally developed by Macromedia Inc. (later acquired by Adobe). It is influenced by HyperTalk, the scripting language for HyperCard. It is now an implementation of ECMAScript (meaning i ...
– The scripting language for
Adobe Flash
Adobe Flash (formerly Macromedia Flash and FutureSplash) is a multimedia Computing platform, software platform used for production of Flash animation, animations, rich web applications, application software, desktop applications, mobile apps, mo ...
.
*
AppleScript – The main scripting language of Apple's Classic Mac OS, and still supported in
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
.
*
Lingo
Lingo, a contraction of language, often refers to jargon, but in a less formal or technical sense.
Lingo may also refer to:
Technology
* Lingo (programming language), one of several unrelated programming languages
* Lingo (VoIP Service operator ...
– The programming language of Macromedia Director started out with an xTalk-like syntax, although later versions went in a direction resembling JavaScript.
*
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
– A scripting language created by
Brendan Eich which is commonly implemented as part of a
web browser
A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen. Browsers are used on ...
in order to create enhanced
user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine f ...
s and dynamic
website
A website (also written as a web site) is a collection of web pages and related content that is identified by a common domain name and published on at least one web server. Examples of notable websites are Google Search, Google, Facebook, Amaz ...
s.
It was later generalized and standardized as
ECMAScript
ECMAScript (; ES) is a JavaScript standard intended to ensure the interoperability of web pages across different browsers. It is standardized by Ecma International in the documenECMA-262
ECMAScript is commonly used for client-side scripting o ...
.
Many method names first popularized by HyperTalk made it into later languages, such as the
onmouseup
event handler in JavaScript.
[Brendan Eich]
"Splash keynote 2011, slide 10"
/ref> Although Asymetrix ToolBook
ToolBook was a Microsoft Windows based e-learning content authoring application, initially released in 1990 by Asymetrix Corporation, now SumTotal Systems. ToolBook uses a book metaphor — a project file is thought of as a ''book'' containing ' ...
is often also considered a HyperCard clone, its scripting language apparently bears little resemblance to HyperTalk.
See also
* Inform 7
Inform is a programming language and design system for interactive fiction originally created in 1993 by Graham Nelson. Inform can generate programs designed for the Z-code or Glulx virtual machines. Versions 1 through 5 were released between ...
– a programming language with similarly English-like syntax
Notes
References
External links
Pantechnicon HyperTalk Wiki pages
– HyperTalk language reference (control structures, events, built-in functions, etc.)
{{Authority control
Domain-specific programming languages
Educational programming languages
Scripting languages
HyperCard products
Programming languages created in 1987
XTalk