Paradigm | People Oriented Programming, Multi-paradigm, Object-oriented |
---|---|
Family | Scripting language |
Designed by | Douglas Simons |
Developer | Eggplant (software) |
First appeared | 1992 |
Stable release | 2.18 / June 2024 |
Typing discipline | Duck |
License | Proprietary |
Filename extensions |
|
Website | www |
Influenced by | |
xTalk, HyperTalk |
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 no training in programming.
To this end, SenseTalk includes a number of language elements that provide functionality oriented towards human tasks rather than the underlying machine behavior. For example, to check whether a quantity is divisible by 3, the script could use the expression ifquantityisdivisibleby3…
or ifquantityisamultipleof3…
, with the emphasis being on readability and a focus on the human concept of divisibility. [1] Compare this to more traditional programming languages (C, Java, Python, etc.) where the same test would typically be written as if(quantity%3)==0…
, with the focus being on the machine operations needed to determine the result. [2]
This shift in focus away from the underlying machine computation, towards an English-like description of the behavior in human terms leads to the description of SenseTalk as a “People Oriented Programming language”. [3]
As a self-styled “People Oriented Programming” language, certain aspects of SenseTalk’s design distinguish it from other programming languages, and give it a distinctive flavor. These range from mundane characteristics such as case insensitivity, to syntactic elements that enhance readability, to more subtle characteristics such as fluid variable types, to advanced features like units and the SenseTalk Pattern Language.
SenseTalk keywords and variable names are all case-insensitive. This allows people to be casual in their use of capitalization without any change of behavior.
Put12IntoApplesput5intoBananasPUT"Total Pieces of Fruit: "&apples+bananas--> displays "Total Pieces of Fruit: 17"
This is also true of the names of properties in a property list (SenseTalk’s name for a dictionary or hash table).
Put{Name:"Green",HexCode:"#00FF00"}intoAColorputaColor's name--> displays "Green"puttheHEXcodeofacolor--> displays "#00FF00"
In addition, text operations, including comparisons, searches, and so forth, are case-insensitive by default, although they can be made case-sensitive when needed.
Setnameto"McMaster"putnamecontains"master"--> displays True (case is ignored)putnamecontains"master"considering case--> displays False
In addition to having case-insensitive names, variables in SenseTalk are unusual in some other respects. Variables don’t need to be declared, and are typeless. A variable comes into existence when it is first used, and its type depends on the type of value that is stored in it.
This flexibility goes beyond the “duck typing” found in other languages, in which a given variable has a type which is established when a value is assigned to the variable. In SenseTalk, a variable is considered a “container” that may contain any type of value. The type of value a variable contains can change during a script run, so the same variable may start off containing a number, then later a string, and then a list of values. This “type fluidity” allows people to work in a very flexible way, manipulating values at will, and treating each value according to how it is being used at a given point in the script.
One consequence of SenseTalk’s typeless variables is that, in general, there are no “overloaded” operators — that is, operators which perform different operations depending on the type of variable they are working with. For example, in some languages, the +
operator will perform addition when it is used with numeric operands, and will perform string concatenation when it is used with string operands. In SenseTalk, operands are all fluid, so it is necessary to have one operator to perform addition (+
, which will treat its operands as numbers), and another operator for string concatenation (&
, which will treat its operands as strings).
Put1+2&3+4--> displays 37
In this example, the +
operator has higher priority than the &
operator, so the expression is equivalent to '(1 + 2) & (3 + 4)' or '3 & 7' giving “37”. If parentheses were used to perform the &
operator first, then '1 + (2 & 3) + 4' would become 1 + “23” + 4 giving a result of 28.
SenseTalk includes hundreds of “predefined variables”. These are variable names which can be used as ordinary variables, but which start off with a predefined value if they are used without first storing a value into them. Some of the predefined values are numbers, such as pi or zero. Many are special characters or symbols, such as euroSign, copyrightSign or hotBeverage. And a few have other types of values, such as jsonListFormat, which is a property list containing several key/value pairs that can be used for setting the listFormat global property.
Put"Area of a circle with radius 5 is: "&pi*5squared
Any variable that doesn’t have a predefined value, and hasn't yet been explicitly assigned a value, will evaluate either as its own name or as empty depending on the context where it is used. This allows words to be used unquoted in many cases where quotes would otherwise be required.
PutCookieCount--> displays "CookieCount"Add3dozentoCookieCount--> treated as empty, or 0putCookieCount--> displays 36
SenseTalk includes full support for many different types of units (length, mass, time duration, volume, frequency, etc.). Numeric values may have associated units. Unit values are converted as needed when performing arithmetic operations.
Put5yds+2ft--> displays 17 feet
Variables may contain values with units. The units are carried along with the value and applied in subsequent calculations.
Put5ydsintolengthadd2fttolength-- the value in length is converted to a compatible unit to perform the additionputlength--> displays 17 feetput42inchesintowidthsetareatolength*widthputarea--> displays 59.5 square feet
More complex units such as velocity (miles per hour, or meters/second) or acceleration (m/s^2) are also supported.
SenseTalk recognizes dates and times in a wide variety of formats, and supports date and time calculations.
Put"8:22"-"8:15"--> displays 420 seconds
Date/time values can be stored in variables, and formats are maintained through calculations.
Put"March 3"+34days--> displays "April 6"
Put"2021-03-04"intonextDateAdd4weekstonextDateputnextDate--> displays "2021-04-01"Add4monthstonextDateputnextDate--> displays “2021-08-01”
SenseTalk’s chunk expressions come from its heritage as a member of the XTalk family of languages derived from HyperTalk. Chunk expressions allow working with chunks of text using familiar English terms: characters, words, items, lines. SenseTalk expands upon the original chunk syntax, and extends their use beyond text, to items within a list and bytes within binary data as well.
Putcharacters7to11of"Rumpelstiltskin"--> displays" stilt"
Putthefirst3charsofthesecondwordof“bookcatalog”--> displays “cat”
Chunk expressions can also be used to modify values. In Xtalk language terminology, a chunk of a container (such as a variable) is also a container, so any command that changes the value of a container can also be used to change a chunk.
Put"Rumpelstiltskin"intofunnyNamePut“bump”intocharacters7to12offunnyNameputfunnyName--> displays “Rumpelbumpkin”
SenseTalk includes commands for opening, reading, and writing files. A text file can be treated as a container (like a variable), so the file contents can be read by simply putting the file into a variable. Similarly, writing a file can be accomplished by putting a variable or other expression into the file.
Putfile"/tmp/addressList.txt"intoaddressesPut"Miriam,219 Sparrow Ln,Freeburgh,MA"&returnafteraddressesPutaddressesintofile"/tmp/addressList.txt"
Because a file is a container, any command that modifies a container can be used directly on a file.
Putreturn&"Earlybird,12 Elm St,Vista,NM"afterline1offile"/tmp/addressList.txt"
Accessing records in a database is more complex than reading a file, but SenseTalk applies the concept of containers here, too. This makes it possible to connect to a database and update a field in a specific record with very little code.
Put{type:”ODBC”,DSN:”customers”,user:”admin”,password:”sEcrEt”}intocustDBPuttable“subscriptions”ofcustDBintosubs-- makes connection to a DB tableAdd12monthstoexpDateoftherecordofsubswhereCustNumis“83946-d”-- updates a value in a particular record
SenseTalk’s “pattern language” [4] implements regular expressions using a readable, English-like syntax. The following example creates a pattern to identify an American Social Security number (like “999-99-9999”):
SetssnPatternto<3digitsthendashthen2digitsthendashthen4digits>
Patterns can be used in a variety of ways.
ifuserEntrymatchesssnPatternthensetvalidSSNtotrue
puteveryoccurrenceofssnPatterninfile“userData”intossnList
ifclientInfodoesn’tcontainssnPatternthenput“<SSNmissing>”afterclientInfo
The pattern language allows patterns to be built up from other patterns. This example uses the previous ssnPattern to define a pattern that will avoid matching in cases where the immediately preceding or following character is also a digit:
setisolatedSSNto<ssnPatternnotprecededbydigit,notfollowedbydigit>
The SenseTalk language first appeared in 1992 as the scripting language in HyperSense, a multimedia authoring application for the NeXTSTEP platform, modeled after HyperCard. At that time the language was little more than a copy of HyperCard's HyperTalk language. A more ambitious rethinking and redesign of the language resulted in the beginnings of the present language, with version 0.02 shipping as the scripting language in Eggplant V1.0 in 2002. The language has continued to grow and evolve, with such enhancements as the addition of support for:
AWK is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems.
In programming languages, a closure, also lexical closure or function closure, is a technique for implementing lexically scoped name binding in a language with first-class functions. Operationally, a closure is a record storing a function together with an environment. The environment is a mapping associating each free variable of the function with the value or reference to which the name was bound when the closure was created. Unlike a plain function, a closure allows the function to access those captured variables through the closure's copies of their values or references, even when the function is invoked outside their scope.
The J programming language, developed in the early 1990s by Kenneth E. Iverson and Roger Hui, is an array programming language based primarily on APL.
HyperTalk is a discontinued high-level, procedural programming language created in 1987 by Dan Winkler and used in conjunction with Apple Computer's HyperCard hypermedia program by Bill Atkinson. Because the main target audience of HyperTalk was beginning programmers, HyperTalk programmers were usually called "authors" and the process of writing programs was known as "scripting". HyperTalk scripts resembled written English and used a logical structure similar to that of the Pascal programming language.
The C shell is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp.
In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral at the level of its individual bits. It is a fast and simple action, basic to the higher-level arithmetic operations and directly supported by the processor. Most bitwise operations are presented as two-operand instructions where the result replaces one of the input operands.
In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable. In most imperative programming languages, the assignment statement is a fundamental construct.
ActionScript is an object-oriented programming language originally developed by Macromedia Inc.. It is influenced by HyperTalk, the scripting language for HyperCard. It is now an implementation of ECMAScript, though it originally arose as a sibling, both being influenced by HyperTalk. ActionScript code is usually converted to byte-code format by a compiler.
In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, ternary if, or inline if. An expression a ? b : c
evaluates to b
if the value of a
is true, and otherwise to c
. One can read it aloud as "if a then b otherwise c". The form a ? b : c
is the most common, but alternative syntax do exist; for example, Raku uses the syntax a ?? b !! c
to avoid confusion with the infix operators ?
and !
, whereas in Visual Basic .NET, it instead takes the form If(a, b, c)
.
In computer science, the Boolean is a data type that has one of two possible values which is intended to represent the two truth values of logic and Boolean algebra. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is primarily associated with conditional statements, which allow different actions by changing control flow depending on whether a programmer-specified Boolean condition evaluates to true or false. It is a special case of a more general logical data type—logic does not always need to be Boolean.
In computer science, a relational operator is a programming language construct or operator that tests or defines some kind of relation between two entities. These include numerical equality and inequalities.
The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.
In computer programming, an integer overflow occurs when an arithmetic operation on integers attempts to create a numeric value that is outside of the range that can be represented with a given number of digits – either higher than the maximum or lower than the minimum representable value.
The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program.
The null coalescing operator is a binary operator that is part of the syntax for a basic conditional expression in several programming languages, such as : C# since version 2.0, Dart since version 1.12.0, PHP since version 7.0.0, Perl since version 5.10 as logical defined-or, PowerShell since 7.0.0, and Swift as nil-coalescing operator.
Protel stands for "Procedure Oriented Type Enforcing Language". It is a programming language created by Nortel Networks and used on telecommunications switching systems such as the DMS-100. Protel-2 is the object-oriented version of Protel.
In 1979, Honeywell Information Systems announced a new programming language for their time-sharing service named TEX, an acronym for the Text Executive text processing system. TEX was a first-generation scripting language developed around the time of AWK and used by Honeywell initially as an in-house system test automation tool.
This article compares a large number of programming languages by tabulating their data types, their expression, statement, and declaration syntax, and some common operating-system interfaces.
A file format is a standard way that information is encoded for storage in a computer file. It specifies how bits are used to encode information in a digital storage medium. File formats may be either proprietary or free.
Proteus is a fully functional, procedural programming language created in 1998 by Simone Zanella. Proteus incorporates many functions derived from several other languages: C, BASIC, Assembly, Clipper/dBase; it is especially versatile in dealing with strings, having hundreds of dedicated functions; this makes it one of the richest languages for text manipulation.