S2 (programming language)

S2 (programming language)
S2
Paradigm(s) Object-oriented
Appeared in 1999 (1999)
Developer Brad Fitzpatrick, Martin Atkins
Website livejournal.com/doc/s2

S2 (Style System 2) is an object-oriented programming language developed in the late 1990s by Brad Fitzpatrick, Martin "Mart" Atkins, and others for the online journaling service LiveJournal in order to allow users full control over the appearance of their pages. S2 source code is compiled into Perl, which the webserver can then execute directly for individual web page requests.

The S2 system is, at its heart, completely general and can be used for almost any web application; however there exists no documentation for the implementation of S2 within other applications, which ties it relatively closely to LiveJournal.

This article will make use of LiveJournal's implementation of S2 for examples. A link to detailed documentation about this implementation can be found at the bottom.

Contents

Language features

S2's structure closely resembles that of most imperative programming languages, and includes basic instructions such as variable assignments, arithmetic operations, conditional flow control and for loops over finite sets (however, it distinctly lacks while loops). Being object-oriented, S2 allows the declaration of classes with members and methods, but global (non-class-specific) functions can also be defined. Recursion is allowed, but nesting functions is not.

Layers and properties

A distinguishing feature of S2 is that source code is organised into individual layers, of which there are six different types (core, i18nc, layout, i18n, theme and user). These layers form a tree-like structure.

At the root lies the core layer, a layer which specifies all the classes and their methods which are specific to the website on which S2 is being used. In the case of LiveJournal, these classes represent individual journal views (Recent Entries, Archive, etc.) and site-related objects (users, journal entries, etc.). It provides simple default implementations of all the methods, but also global functions that are of general use. Some of the functions are specified as being "built-in" functions and are implemented in Perl in the S2 subsystem; all other functions are implemented in S2 itself and are compiled into Perl code by the S2 compiler.

The S2 language introduces a concept of properties — these are variables that are not specific to a particular object or class, but to a layer. Such a property can be a textual string, an integer number, a hexadecimal colour code, etc. The core layer, for instance, defines textual string properties to hold user-visible text in the English language.

Subordinate to the core layer are the i18nc ("core internationalisation") layers, which allow for the textual string properties in the core layer to be overridden with translations into other languages.

Also subordinate to the core layer are the layout layers. A layout layer specifies a particular site layout (journal layout in the case of LiveJournal), and it may provide new properties that influence the look and behaviour of the layout in various ways. A layout layer normally overrides almost all of the methods defined in the core layer, and it may introduce new ones to perform certain layout-specific tasks. If a core-defined method is called which is not overridden in the layout layer, but the same method is overridden for a superordinate class, then this superordinate method is called, rather than the class-specific default implementation in the core layer.

The remaining three types of layers — i18n layers, theme layers and user layers — are all subordinate to a specific layout layer. In general, all three of them can override both properties and functions/methods from the layout layer, but their intended purpose varies. i18n are provided to internationalise the layout; this is to allow the layout to be used by speakers of other languages, but not primarily to provide a way to customise the user-visible text. theme layers can be used to provide suggested sets of values for the properties of a layout. A common application of this is to create aesthetically consistent colour themes, but in principle non-colour properties (fonts, sizes, etc.) can also be overridden in a theme layer. user layers, finally, are meant to store a particular user's preferences with regard to the values of the properties. The user layer ultimately has the "final say" on the values of the properties.

Internationalisation

As mentioned in the previous section, i18nc layers are used to translate the core layer, while i18n layers are used to translate a layout. In its simplest form, such an internationalisation layer overrides textual string properties in order to replace English text with a translation into another language.

However, often the intricacies of languages require more sophisticated mechanisms, which is why the internationalisation layers sometimes override entire functions. For example, a plural-mapping function is provided which specifies how many and which strings a language uses following an integer number.

Documentation

S2 incorporates the idea of providing documentation for a class, method, function or property directly within the source code, separate (machine-distinguishable) from conventional comments. Small strings of explanatory text can be added after the header of a class, method, function or property, and they can be used to generate documentation.

At the time of this writing, however, none of these strings are actually used, except for those associated with properties, which appear in the customisation wizard; see below. An i18n layer can override these documentary strings for properties in order to allow for speakers of other languages to be presented with explanations of the available options in their language.

The customization wizard

The S2 web user interface allows users to change the values of the properties of a layout without requiring them to write actual S2 source code. This interface is termed the "customization wizard", and it creates a user layer which stores the user's preferred values of the properties.

Unintended uses of S2

S2 was entirely designed to be a web layout programming language. It had not originally been anticipated that it would soon be used to create "geeky" applications.

In particular, at the time of this writing, four games have been written in S2: Towers of Hanoi [1], two versions of Tic Tac Toe, and a game called "Pawns" [2]. One of the Tic Tac Toe versions has been embedded into a journal style as a box in a side-bar.

See also

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Programming language — lists Alphabetical Categorical Chronological Generational A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that… …   Wikipedia

  • Programming language theory — (commonly known as PLT) is a branch of computer science that deals with the design, implementation, analysis, characterization, and classification of programming languages and programming language features. It is a multi disciplinary field, both… …   Wikipedia

  • Programming Language Design and Implementation — (PLDI) is one of the ACM SIGPLAN s most important conferences. The precursor of PLDI was the Symposium on Compiler Optimization, held July 27–28, 1970 at the University of Illinois at Urbana Champaign and chaired by Robert S. Northcote. That… …   Wikipedia

  • Programming Language for Business — or PL/B is a business oriented programming language originally called DATABUS and designed by Datapoint in the early 1970s as an alternative to COBOL because its 8 bit computers could not fit COBOL into their limited memory, and because COBOL did …   Wikipedia

  • programming language — ➔ language * * * programming language UK US noun [C] ► COMPUTER LANGUAGE(Cf. ↑computer language) …   Financial and business terms

  • programming language — Language Lan guage, n. [OE. langage, F. langage, fr. L. lingua the tongue, hence speech, language; akin to E. tongue. See {Tongue}, cf. {Lingual}.] [1913 Webster] 1. Any means of conveying or communicating ideas; specifically, human speech; the… …   The Collaborative International Dictionary of English

  • Programming Language One — Programming Language One, oft als PL/I (auch PL/1, PL1 oder PLI) abgekürzt ist eine Programmiersprache, die in den 1960er Jahren von IBM entwickelt wurde. Die Bezeichnung PL/1 ist vor allem in Deutschland gebräuchlich. Ursprünglich wurde PL/I… …   Deutsch Wikipedia

  • Programming Language 1 — noun A computer programming language which combines the best qualities of commercial and scientific oriented languages (abbrev PL/1) • • • Main Entry: ↑programme …   Useful english dictionary

  • Programming Language —   [engl.], Programmiersprache …   Universal-Lexikon

  • Programming language specification — A programming language specification is an artifact that defines a programming language so that users and implementors can agree on what programs in that language mean.A programming language specification can take several forms, including the… …   Wikipedia

  • programming language — noun (computer science) a language designed for programming computers • Syn: ↑programing language • Topics: ↑computer science, ↑computing • Hypernyms: ↑artificial language …   Useful english dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”