About SenseTalk

SenseTalk is a language for controlling your computer. It is an English-like language that is easy for people to read, write, and understand. People who use SenseTalk may find themselves trying something without knowing whether it will do what they want and are often pleasantly surprised when it just works!

Computers, of course, are not intelligent. For the computer to correctly understand your instructions, they must be stated in a clear and unambiguous way. For this reason, SenseTalk is a more structured language than English, with rules that must be followed.

Introducing SenseTalk

SenseTalk enables you to communicate with your computer to harness its power and abilities in a refreshingly easy and understandable manner. SenseTalk provides access to the full range of capabilities inherent in your computer while remaining easy to learn and understand. It achieves this by leveraging the powerful concepts behind many words that have become buzzwords in the computer industry.

In today’s technical jargon:

SenseTalk is a very high level, object oriented, interpreted scripting language, based on a modular, extensible architecture.

Now, in plain English, what does that really mean?

SenseTalk is “object oriented” because thinking about objects is a natural and understandable way to describe and deal with potentially complex systems. We deal with “things” daily in our lives, whether they are tangible things like a telephone or a glass of water, or intangible things like our bank account or our child’s soccer schedule. With SenseTalk you can create “objects” in your computer which represent each of these things.

SenseTalk is considered a “very high level” language because it can do a lot with very few words. High level commands make your job easier. Suppose you have a list of names that you would like to sort into alphabetical order by last name. In a lower level programming language you would need to write instructions to find the last name by locating the last space in each name, and then write many more instructions to carefully rearrange the names alphabetically. In SenseTalk you could simply give the command “sort the lines of nameList by the last word of each” and be done with it.

As an “interpreted scripting language”, SenseTalk is very responsive, providing immediate feedback as you learn the language and try out new commands. You can type commands or partial scripts and have the computer carry out your instructions at once.

And SenseTalk’s “modular, extensible architecture” allows you to add new commands and functions to extend the range of what SenseTalk can do. The language is not cast in stone, but can grow and evolve according to your needs. The underlying structure has been crafted to support new and changing requirements as computer capabilities advance and your knowledge and understanding grows.

To put it simply, SenseTalk is an English-like language that lets you tell your computer what you want it to do. You do this by creating software “objects” that organize the information you want to work with in understandable ways, and by writing “scripts” that describe how you want each object to behave.

You could think of it as being a little bit like writing a play. You create a cast of characters, and provide each of them with their own script which defines their role, and how they should respond to various messages which might be sent to them. Unlike a play, though, the action doesn’t have to follow the same sequence every time the script is run. The characters (objects) interact with one another and with the user of the system (you) by sending and receiving messages.

A message may tell an object what to do, or provide it with information. When it receives a message, it may respond in different ways at different times depending on what else is going on in the system at that time. It all depends on what the object’s script tells it to do. Each object has its own script — its own set of instructions to follow — and the instructions are written using the SenseTalk language.

SenseTalk was originally created as the scripting language of HyperSense, Thoughtful Software’s powerful authoring system. While some examples and descriptions in this manual may refer to HyperSense objects or other features of that system, SenseTalk also stands alone as an independent scripting language. This manual aims to describe the SenseTalk language separately from any particular environment or host application in which it might be used.

Why SenseTalk?

About now you may be thinking: Okay, that all sounds nice enough, but there are plenty of scripting languages out there already. Does the world really need another language? What makes SenseTalk different?

That's an excellent question, and there isn't necessarily one answer for everyone. Every language has its own strengths and peculiarities, and different characteristics of a language will appeal to different people. Probably the single thing that distinguishes SenseTalk the most from other languages – the theme that provides its unique flavor – was stated in the first sentence of this section: SenseTalk is "remarkably English-like".

Now, some people may not see being "English-like" as a benefit for a programming language. English can be wordy, and may at times be ambiguous in its meaning. Such people may prefer a more concise and precise language with stricter rules of syntax. So be it.

On the other hand, an English-like language offers some special benefits: it can be easier for a beginner to learn; easier for an experienced user to remember; and much easier for everyone to read and understand. This feature – readability – can make scripts much easier to maintain and modify.

Let's take a look at SenseTalk's readability by comparing it to some other popular languages. We'll start with a comparison to Perl and Python, two of the most widely-used scripting languages in the world today.

Perl is described on Wikipedia as a language designed to be "practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal)" and is famous for being rather cryptic and unreadable, so it serves to illuminate SenseTalk through extreme contrast. Here is an example Perl script that is taken almost verbatim from a popular book written by Perl experts (the “Perl Cookbook”, p. 247). We’ll explain what it does in a moment.

sysopen(FH, "numfile", O_RDWR|O_CREAT)or die "can’t open numfile: $!";
$num = <FH> || 0; # DO NOT USE "or" HERE!!
seek(FH, 0, 0) or die "can’t rewind numfile: $!";
truncate(FH, 0) or die "can’t truncate numfile: $!";
print FH $num+1, "\n" or die "can’t write numfile: $!";
close(FH) § or die "can’t close numfile: $!";

Python, on the other hand, is another popular scripting language that is known for being easy to read. Here is the equivalent script written in Python:

file = open("numfile", "r+")

num = int(file.read())

file.seek(0,0)

file.truncate(0)

file.write(str(num+1) + "\n")

file.close()

Finally, here is a SenseTalk script which accomplishes the same thing (if it's not clear yet what these scripts do, maybe this will help):

add 1 to file "numfile"

Okay, is it becoming clearer now? The purpose of all three scripts is to add one to a counter which is kept in a file called “numfile”. The purpose of this comparison is not to bash Perl or Python, which are very powerful languages used extensively by many people, but to point out the advantage that SenseTalk offers for scripters whose needs are perhaps less rigorous but who would like to get something done quickly and easily.

To be fair, there are ways the Perl and Python scripts could be shortened somewhat, and SenseTalk also offers longer ways of doing the same thing which might be more comparable. Here is another script in SenseTalk which performs the same task, following more closely the approach used in the other scripts:

open file "numfile"

read from file "numfile" until end

put the first word of it into num

seek in file "numfile" to the beginning

write num+1 & return to file "numfile"

close file "numfile"

If you eliminate all of the “or die” parts of the Perl script (which are just there to be very careful about reporting mostly unlikely errors) you’ll see that this SenseTalk script is now slightly longer than either the Perl or Python version. But you’ll probably agree that the SenseTalk script is also much clearer, easier to read and understand, and also easier to learn and remember. Because it is so much more readable, it is also easier to find and correct mistakes, or to make changes to a script you wrote several months earlier if you decide it should do something slightly different.

Here's one more example, in several languages this time, showing how to perform a fairly common operation: deleting the last character of a text string that is stored in a variable called var:

  • PHP: $var = substr($var, 0, strlen($var)-1)
  • Ruby: var.chop
  • Perl: chop($var)
  • Java: var = var.substring(0, var.length()-1);
  • Python: var = var[0:-1] // (or, commonly: var = var[:-1] )
  • JavaScript: var = var.slice(0, -1)
  • Excel VBA macro: ActiveCell.Value = Left(ActiveCell.Value, Len(ActiveCell.Value) - 1)
  • SenseTalk: delete the last character of var

Here, the Ruby and Perl versions are the shortest, and are very easy to read once you know what the "chop" function does. Would it be clear to someone new to the language what any of these examples do?

Now, suppose you need to modify your script to delete the first character of var instead of the last? Or to delete the last two characters of var? Would it be obvious how to do that? (Hint: In case you did not guess already, the actual SenseTalk commands to do those operations are embedded in italics in the questions!)

Perhaps that’s enough of an introduction to give you some idea of what SenseTalk is about and what we’re trying to achieve. Now it’s time to dig in and learn something about how this language works and how to use it.

 

This topic was last updated on October 01, 2018, at 01:49:19 PM.

Eggplant icon Eggplant.io | Documentation Home | User Forums | Support | Copyright © 2018 Eggplant