All Topics  
S2 programming language

 

   Email Print
   Bookmark   Link






 

S2 programming language



 
 
S2 (Style System 2) is an object-oriented programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
 developed in the late 1990s by Brad Fitzpatrick
Brad Fitzpatrick

File:Brad Fitzpatrick by Anton Nossik.JPGBradley Joseph "Brad" Fitzpatrick , often seen on the Internet under the nickname bradfitz, is an United States programmer....
, Martin "Mart" Atkins, and others for the online journalling service LiveJournal
LiveJournal

LiveJournal is a virtual community where Internet users can keep a blog, journal or diary. LiveJournal is also the name of the free software and open source software Server software that was designed to run the LiveJournal virtual community....
 in order to allow users full control over the appearance of their pages. S2 source code is compiled into Perl
Perl

In computer programming, Perl is a high-level programming language, List of programming languages by category, Interpreter , dynamic programming language....
, which the webserver can then execute directly for individual web page requests
Hypertext Transfer Protocol

Hypertext Transfer Protocol is an application-level protocol for distributed, collaborative, hypermedia information systems. Its use for retrieving inter-linked resources led to the establishment of the World Wide Web....
.

The S2 system is, at its heart, completely general and can be used for almost any web application
Web application

In software engineering, a web application or webapp is an Application software that is accessed via web browser over a network such as the Internet or an intranet....
; 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.






Discussion
Ask a question about 'S2 programming language'
Start a new discussion about 'S2 programming language'
Answer questions from other users
Full Discussion Forum



Encyclopedia


S2 (Style System 2) is an object-oriented programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
 developed in the late 1990s by Brad Fitzpatrick
Brad Fitzpatrick

File:Brad Fitzpatrick by Anton Nossik.JPGBradley Joseph "Brad" Fitzpatrick , often seen on the Internet under the nickname bradfitz, is an United States programmer....
, Martin "Mart" Atkins, and others for the online journalling service LiveJournal
LiveJournal

LiveJournal is a virtual community where Internet users can keep a blog, journal or diary. LiveJournal is also the name of the free software and open source software Server software that was designed to run the LiveJournal virtual community....
 in order to allow users full control over the appearance of their pages. S2 source code is compiled into Perl
Perl

In computer programming, Perl is a high-level programming language, List of programming languages by category, Interpreter , dynamic programming language....
, which the webserver can then execute directly for individual web page requests
Hypertext Transfer Protocol

Hypertext Transfer Protocol is an application-level protocol for distributed, collaborative, hypermedia information systems. Its use for retrieving inter-linked resources led to the establishment of the World Wide Web....
.

The S2 system is, at its heart, completely general and can be used for almost any web application
Web application

In software engineering, a web application or webapp is an Application software that is accessed via web browser over a network such as the Internet or an intranet....
; 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.

Language features

S2's structure closely resembles that of most imperative programming
Imperative programming

In computer science, imperative programming is a programming paradigm that describes computation in terms of statement s that change a program state ....
 languages, and includes basic instructions such as variable assignments, arithmetic operations, conditional flow control
Flow control

In computer networking, flow control is the process of managing the rate of data transmission between two nodes to prevent a fast sender from over running a slow receiver....
 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
Source code

In computer science, source code is any collection of statements or declarations written in some human-readable computer programming language....
 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
English language

English is a West Germanic language that originated in Anglo-Saxon England and has lingua franca status in many parts of the world as a result of the military, economic, scientific, political and cultural influence of the British Empire in the 18th, 19th and early 20th centuries and that of the United States from the mid 20th century onwa...
.

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
User interface

The user interface is the aggregate of means by which people—the User s—Interaction with the system—a particular machine, device, computer program or other complex tools....
 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 , two versions of Tic Tac Toe, and a game called "Pawns" . One of the Tic Tac Toe versions has been embedded into a journal style as a box in a side-bar.

See also

  • LiveJournal
    LiveJournal

    LiveJournal is a virtual community where Internet users can keep a blog, journal or diary. LiveJournal is also the name of the free software and open source software Server software that was designed to run the LiveJournal virtual community....


External links

  • - outlines shortcomings of LiveJournal's previous style system, now referred to as S1.