Curl - a gentle slope language for web

Curl is a new language for creating web documents with almost any sort of content, from simple formatted to text to complex interactive applets.

·         Text formatting. Curl provides a rich set of formatting operations similar to those implemented by HTML tags. Unlike HTML, the Curl formatter can be extended by users to provide additional functionality, from simple macros (e.g., to provide a convenient way to switch to a particular font, size and color) to direct control over the positioning of subcomponents (e.g., as in a TeX-like equation formatter). Several packages of useful formatting extensions are currently under development.
·         Scripting simple interactions. Using a TK-like interface toolkit of interactive components, Curl makes it easy to build simple interactive web pages. One can view interactive objects like buttons or edit-able fields as extensions to the basic formatting operations provided above -- one uses the same easy-to-learn syntax to create interactive documents as to create regular text documents. There's no need to learn a separate scripting language!
·         Programming complex operations. components can also be developed using Curl since, at its heart, Curl is really an object-oriented programming language. Curl expressions, class definitions and procedure definitions embedded in the web document are securely compiled to native code by the built-in on-the-fly compiler and then executed without the need for any sort of interpreter. Curl provides many of the features of a modern object-oriented programming language: multiple inheritance, extensible syntax, a strong type system that includes a dynamic "any" type, safe execution through encapsulation of user code and extensive checking performed both at compile and run time. Almost all of the Curl system and compiler are written in Curl.

 

HISTORY
The other key deliverable from the 1995 MIT project was the invention of a new computing language called Curl. This was designed from the ground up to be able to handle all the different application requirements found on the Internet. It can be used to create simple text formatting or markup documents at one end of the application scale, and highly interactive, rich–interface, complex enterprise applications at the other.
In 1998, many of the key members of the MIT project realized that they had created a language that really could revolutionize the way Internet applications were developed. The group decided to make the language commercially available, and Curl Corporation was formed in 1998.
 Curl Corporation shipped the first version of the language and toolset, collectively known as Curl, in 2001.Curl Corporation, based in Cambridge, Massachusetts, continues to enhance and improve on the baseline work done during the MIT DARPA project.
They have made available a number of incremental releases of the Curl language, the runtime engine, and the integrate development environment (IDE) tools. It offers a technology to the enterprise that addresses a number of key In-ternet application concerns:
·         Run over small bandwidth (sometime as low as 14KB)
·         Provide a rich graphical user interface (GUI)
·         Integrate with existing Web standards
·         Create applications that are written in one language and are easy to maintain
·         Be easy to learn
·         Enable quick application development
·         Utilize a user's PC processing power
What Is Curl?
Curl was conceived to provide a full-featured and robust technology beyond HTML and JavaScript, enabling the development of very rich Web client applications. The Curl platform is designed around the Curl content language, which features a unified notation for information, style, and behavior, enabling its use to implement a broad range of descriptive and active elements ranging from HTML-like text formats to high-performance 3D graphics.
By covering this whole spectrum of capabilities, the Curl content language provides "one-stop shopping" where the whole range of content and behavior requirements of Web applications can be satisfied within one framework. If not using Curl, a developer would have to integrate multiple technologies to achieve similar results, for example by embedding applets in HTML pages, but getting such multiple technologies to work with each other is inherently complicated, increasing application development costs and reducing maintainability.
Furthermore, the Curl content language is designed from the ground up for the purpose of building user interfaces and presenting information to people. Curl's unique and powerful layout and styling capabilities help you build sophisticated user interfaces quickly and express them in compact, concise code.
Curl applications do not require changes in the back-end infrastructure used today for Web-based enterprise applications, mostly built upon J2EE or Microsoft's .Net. Curl provides a new client-side technology fully complementary to these server-side alternatives, able to connect to any server product irrespective of operating system or manufacturer, and thus making efficient use of your existing data and system assets.
The full Curl platform consists of three components:
  1. An extensible programming language (the Curl content language) designed to create interactive Web content.
  2. A runtime engine (the Curl RTE) that executes Curl programs and renders the resulting content.
  3. An IDE (integrated development environment) to construct rich Internet client-side applications.

WORKING OF CURL APPLICATIONS

An application programmed in the Curl language is placed on a Web server as source code or in a compressed "pcurl" format that is not human-readable. When requested by a client machine's Web browser, the Web server sends the application file or files to the client, where a just-in-time compiler compiles the application into native code that runs with the full performance of the client processor. From that point, the full power of the application is literally in the hands of the user because the application runs on the user's machine, not on the server. When the application needs additional data from the server, it can request just the needed data. Typically, this data is much more compact than the successive HTML page loads that characterize the typical path through the screens of a first-generation Web application.
The server is freed from much of the processing it typically does because all of the presentation work, as well as appropriate business logic tasks, are offloaded to the client. The network is freed from constant back-and-forth requests and downloading of fresh web pages. Huge savings in server load and network bandwidth result, making Curl-based applications highly scalable.
Since Curl applications can run autonomously on the client side, they can even keep running when there is no network connectivity. Thus, Curl can be used to build "occasionally connected" applications that cache data on the client machine while connected to the network, and can then use the cached data to continue working even when out of range of a network connection.


CURL OVERVIEW
The name Curl derives from the principal syntactic feature of the language: Curl source files are arbitrary text, punctuated by expressions enclosed by curly brackets. Like HTML, plain text is valid source; unlike HTML, the escapes extend to a real programming language. For example:
Curl source
What user sees
The following characters are displayed using a {bold bold-faced font}. There are {+ 10 4} bold characters altogether.
The following characters are displayed using a bold-faced font. There are 14 bold characters altogether.
Interpreting the Curl source above requires definitions for the bold and + operators. In Curl, the meaning of {operator ...} is determined by first locating a definition for operator in the current environment and then calling upon that function to parse and interpret the remaining text "..." of the expression. Note that this mechanism allows the "..." text to have any desired structure since the parsing rules are dynamically defined. In this example, the bold operator treats its arguments as a sequence of Graphic objects (in this case simple characters) to be displayed with the 'bold property set to true, while the + operator parses the remaining text as a sequence of subexpressions to be evaluated and then summed. Every Curl object can be converted to a Graphic object (the conversion process is controlled by a method defined by the object's type) which in turn can be assembled into a formatted display by the Curl browser. An interesting side-effect of being able to view all Curl objects is that we can use the browser metaphor to good effect when building debuggers, inspectors, etc.
Curl comes with a large (and growing) repertoire of predefined operators which provide formatting operations and a TK-like toolkit of user-interface components. The widespread adoption of TCL/TK and, to a lesser extent, JavaScript/HTML, demonstrates that simple applications of these operators are often sufficient to fulfill many, if not most, of the needs of interactive documents. The following example assembles a few of these components into a simple order form:
Since the values for color and quantity are Dynamic objects, the last line of the display changes automatically as the user manipulates the color and quantity controls. A Dynamic object incorporates a simple mechanism for propagating changes in its value to other dynamic objects that depend on first object's value. More sophisticated propagation rules could be supplied by the user by creating a new class of objects derived from Dynamic objects that have a different "propagate" method.
The screen shot above reflects the fact the user has selected something besides the default color (red) and quantity (0). Note that the "text-as-program paradigm" means that the value operator must be wrapped around variable names inside of paragraphs. Otherwise, the name of the variable as a text string will be displayed instead of its value. This example illustrates several Curl features:
  • Formatting model. A TeX-like hierarchical "box-and-glue" formatting model that makes it easy to construct layouts.
  • Naming environment. A lexically-scoped naming environment which allows one to construct modular documents with interchangeable components. Languages with "flat" name spaces, like TCL, can make it difficult to reuse components since naming conflicts need to be resolved as code fragments are moved from document to document.
  • Object-oriented programming. The use of objected-oriented programming to extend the behavior of the Curl system in an easily-accessible way. In this example the creator of the Dynamic class has encapsulated the knowledge of how a change in the value of a Dynamic object results ultimately in the updating of the display. Of course the current user doesn't have to understand how the underlying mechanism works in order to put it to effective use. This sort of extensibility is beyond the ken of most simple scripting languages.
CURL AS A PROGRAMMING LANGUAGE
Curl is both a language and an authoring environment where the authoring environment was as implemented as user extensions to Curl. The language can be used as an HTML replacement for the presentation of formatted text, but whose capabilities include those of scripting languages as well as to compiled, strongly-typed, object-oriented system programming.
Obvious influences on Curl's design include LISP[4,13,14,15], C++, Tcl/Tk[5], TeX[9] and HTML. Language design decisions directly reflect the goal of reconciling its simple accessibility to naive users with the power and efficiency demanded by sophisticated programming tasks. Salient features of Curl include
Programs as documents
Execution of every Curl program results in a document containing a set of objects that may be displayed or otherwise manipulated. Curl includes an extensible GUI which provides for simple, structured arrangement of displayable objects. The debugging and development environment is integrated and accessible. Curl objects, along with the type information which describes them, may be browsed along with other Web content. Objects seen on the screen may be identified and inspected.
Syntax and Semantics
  • Extensibility
  • Strong typing
  • Ambiguous types
  • Lexically-scoped environment. Curl provides a structured name space whose bindings include variables, constants, types, and compilation hooks for arbitrary syntactic forms. The name space is instantiated as an environment which spans compile and run times, and which completely dictates the semantics which will be associated with source code during compilation
  • Procedural semantics. Procedures are first-class data, implemented using closures as necessary. Positional and keyword arguments are supported.
IMPLEMENTATION OF CURL
Our Curl implementation contains the following components, all written in Curl:
  • Platform-independent GUI.
  • An incremental compiler that produces native code for x86 and Sparc. Work is underway on producing code for the Java Virtual Machine.
  • An object inspector and symbolic debugger for code.
  • A browser for viewing Curl programs.
The basic infrastructure code, such as the incremental compiler, are built into a static program image using a bootstrap compiler that compiles the non-formatting portion of Curl into C. This generated C code is linked with some hand-written C code that supports bootstrapping the Curl type system and kernel. Currently supported platforms are:
  • PC running WindowsNT, Windows95 or Linux.
  • Sparc-based machines running SunOS or Solaris.
Curl is available as a stand-alone executable for these platforms with plans for a compatible subset of Curl on the Java Virtual Machine in the near future. Interested readers are referred to the Curl website (http://groups.csail.mit.edu/cag/curl) for up-to-date information status and availability of the various Curl implementations.

CLIENT VS SERVER SIDE PROCESSING
Because Curl is a general-purpose, efficient programming language it can be used to perform both client side and server side processing. In fact, when both the client and server are Curl programs, functionality can be adjusted dynamically between the client and server. We currently use a Curl program on our server to distribute Curl documents by translating them, on the fly, to HTML. This mechanism allows the browsing of Curl documentation without downloading the Curl display engine and compiler. Of course, many things that can be expressed in Curl cannot be translated into HTML, but could be translated into code for the Java virtual machine. Such code would run much less efficiently than our native Curl implementation but would allow a Curl author/programmer to rely on the fact that even the most naive user would be able to look at at her document.

GENTLE SLOPE SYSTEMS
Is a new language for specifying the content of web documents really necessary? We think the answer is "yes" because of (1) the changing role of the web and (2) the wide range of skills present in the community of Web authors. The World Wide Web is evolving from the constrained goal of hypertext presentation to a much more demanding role in networked computing: it is becoming the standard user interface to a wide and potentially unbounded class of computational services. This evolution naturally strains the capabilities of the simple markup language on which most Web content has been based. In order to accommodate new user-interaction models and functionality, the simple formatting functions of HTML[6,7,8] are commonly augmented by applets and scripts based on more powerful linguistic tools such as JavaScript[1], Java[2,3], or C++[16]. Curl is designed to have the positive features of markup languages, scripting languages and statically-typed object-oriented programming languages.
This complex of independently-conceived content production tools confronts potential Web authors with annoying -- and potentially crippling -- semantic and performance discontinuities. The enhancement of a Web page to include, say, an animation or interactive simulation requires escape from the simple markup language to an unrelated programming language within which the new functionality may be encapsulated. Such discontinuities are undesirable for at least two reasons. First, they represent technological barriers which require substantial new skills to overcome: they tend to partition the content creators into nearly disjoint sets of authors versus programmers. Second, they present serious interface constraints among separately encapsulated functions. It is difficult, for example, to reference some result of an encapsulated computation from external hypertext. It is also difficult to share structured data between different language levels because they usually use different representations.
Curl avoids these problems by using a consistent syntax and semantics for the expression of Web content at levels ranging from simple formatted text to contemporary object-oriented programming. Thus authors with simple tasks can write straightforward code and add more details when more complicated functionality or performance is required. We characterize Curl as a "gentle slope system" because it makes it easy to transition from one point to another in the function/sophistication spectrum.
Technical challenges confronted in the design of such a language stem largely from tensions between ease-of-use characteristics we demand of formatting and scripting languages, and the performance and expressiveness goals we expect of contemporary system programming languages. Strong compile-time typing, for example, is inhumane in the former but essential in the latter. Storage allocation, object orientation, and the handling of English textual content are further examples where the tension between ease-of-use and performance/expressiveness present interesting conundrums for the language designer. In most cases where compromise was necessary, the scripting language aspects were treated as most important.
More generally, we are anxious to capture in Curl the easy approachability to which the Web owes much of its popularity. To a great extent this approachability derives from careful design decisions which allow (or even require) under-specification of function (e.g. output format), in contrast to conventional programming language semantics geared to the complete specification of behavior. Curl's design is explicitly aimed at reconciling the spirit of under-specification with the requirement that it scale to the sophisticated end of the programming spectrum.

Efficient implementation on contemporary processors, as well as easy interfacing to foreign software environments, dictates the use of conventional C/C++ representations of data. To provide type less simplicity for simple scripting-level programming, Curl provides the ambiguous type any which may require the run-time representation of type information. Thus
  {
        let a:any=5
    {
             define {f x:int}:int {return {+ x 3}}}
             {f a}}
will be compiled so that the ambiguously declared variable a carries a run-time type, while the formal parameter x to the integer procedure f does not. Passing a to f requires a cast, which involves a run-time type check after which the value portion of a is passed as an integer. To perform such casts efficiently, type information (when present) is separated from the representation of values. Because the storage for a value of type any is allocated by the compiler, casting a value to the ambiguous type never causes dynamic storage allocation.
Note that the omission of a type declaration for a variable means something different than in, for example, ML[12]. In ML the variable has a static type that the compiler must determine. In Curl, an omitted type is an under-specification and the actual type may change during program execution.
Since run-time representations are required for our extensible system of types, it is convenient to represent them as Curl objects and to expose them in the programming model. Thus Curl types are simply values: they are named, passed, stored, and accessed identically to other Curl data.
Naming and Environments
The resolution of names outside of classes, and its graceful integration with names within the class hierarchy, again involves the exposure of compilation machinery to potentially introspective Curl programs. Our goal was to provide a simple, structured, lexically-scoped environment for binding variables, types, constants, and language extensions.
Classes are bound within the environment, neatly embedding the hierarchy of class names as subtrees of the namespace. Name resolution is kept simple and unambiguous by requiring the syntax obj.x to access x from an object's class; the unqualified name x always references the innermost lexical binding. Thus for example in
   {let x:int=3                  | Initialize local variable
        c:type={class {}         | Define local class c
                             x:int
                                     {define {m}:int {return {+ x self.x}}}}
        y:c={new c}              | Allocate an instance of c
        {set y.x 4}                    | Assign to instance variable
               {y.m}}                   | invoke method & return value

the reference x within the method m gets 3, while self.x gets 4.
Note that types may be generated anonymously, e.g. via class. Names of types derive solely from bindings in the environment, whence c is the name of a type in the above example. The define-class form builds a class and enters it into the current (lexically enclosing) environment.
This treatment of types provides a natural and consistent semantics for type extension, for type portability (which reduces to the problem of object portability), and for extended type semantics. For example, in
  {let t1:type={array int}
       t2:type={list-of t1}
       x:t2
       ...}
array and list-of are procedures which generate types. This emancipation of types, while semantically appealing, presents certain challenges. It requires that compilation order be somewhat lazy, to accommodate circularities. Moreover, the expressibility of mutable type variables admits constructs whose efficient translation, or even whose meaning, is questionable. We currently forbid such constructs, requiring that types used in declarations be evaluable to compile-time constants.
Ambiguous types, as well as the object class hierarchy, yield a type lattice in which a value may have arbitrarily many types, only some of which are compile-time constants. The run-time type of a value v may be explored using {typeofv}, which returns the most specific type object appropriate to v, using run-time tags if necessary. Similarly, {isa t v} tests the membership of v in type t, again using the fully-disambiguated run-time type of v.

COMPARISION WITH OTHER LANGUAGES
Curl shares with formatting and markup languages (like TeX and HTML) the property that its input defaults to a textual document, and that its explicit output is itself a viewable image of that document. Markup languages like HTML don't address general-purpose programming; to the extent that TeX does, it addresses it poorly.
Through the object tag, HTML allows an arbitrary external computation to be invoked from an HTML document and its result to be embedded in the document. Of course, the rest of the document cannot interact with the computation; in Curl, by contrast, the markups are expressions in the underlying language and can have arbitrary interactions with the document.
Tcl/Tk provides a scripting language and widget set that allows user interfaces to be constructed easily and integrated with a program. Curl procedures with types defaulting to any also provide this functionality but offer several advantages. First, Tcl is very inefficient because it represents everything as a string at the semantic level, while Curl's representations are based on objects and can be compiled to efficient code. Second, in order to provide new widgets in Tcl/Tk one has to write code in C. Curl provides a uniform interface between code at all levels.
Syntactically, Curl resembles LISP and its dialects. We rely on the syntactic extensibility of prefix notation provided by LISP and extend it to include extensible text formatting as part of the language. Curl also differs from LISP in that it is, at its foundation, a statically-typed object-oriented language with non-tagged basic data representations. The part of Curl that is used like a conventional programming language most resembles Dylan[10], before it was changed to use C-like syntax.
The object semantics of Curl are similar to those of Java and C++. Unlike Java, Curl embeds objects within a lexically-scoped procedural programming model, it supports multiple inheritance, and it allows trusted code to exploit the semantic and efficiency advantages of unsafe operations. Unlike C++, Curl supports type safety.

APPLICATIONS

Because of its support for the whole content spectrum, the range of applications for  the Curl technology is inherently broad. To date, most commercial applications have been Web-deployed,data-driven enterprise applications: for example, tools for browsing and visualizing enterprise performance data such as sales figures. Some B2C applications have also been created and deployed: for example, a premium tool for bank customers to visualize the state of their investments and an interactive on-line tour of a museum. The same advantages that make Curl useful for these applications make it useful for many other enterprise applications, as well as other B2B and B2C applications including e-commerce, ticket sales, on-line tax forms, etc.
The increased responsiveness that results when presentation logic moves from the server side to the client side benefits the users of such applications, but the client’s interaction is still exclusively with one server. Client-side execution enables more radical application architectures than this, however. A rich-client technology such as Curl fundamentally shifts the center of control of a Web application from the server machine to the client machine. Executing on the client machine, an application can act as the user’s agent in accessing a broad range of services and information sources on the Internet, not just the server on which the application was deployed.
 For example, a portfolio management application could collect information about a user’s holdings from one server,security prices from another, and research and news from yet other servers, bringing all this information together for the user. Such an architecture cuts out the middleman in many current Web services approaches, which involve application server machines communicating with Web services on other servers, then packaging up the results and sending them to the user’s client machine.“Web applications” are not the only domain where a content language can be useful.

THE CURL APPROACH:
The Curl language is based on a third approach: define a platform that excels for both presentation and programming, so that applications spanning the entire content spectrum can be built efficiently within one unified framework. The term “content language” has been coined to describe the resulting language architecture [24].Content expressed using the Curl language can be deployed to a Web site and served from there to a client machine, where it is executed and displayed either as an applet embedded in an HTML page or directly as the top-level contents in a browser window. In either case, the content is processed by a Curl runtime system (including a browser plug-in) installed on the client machine.
Like HTML content, Curl content can be transmitted from the server to the client as source code. A just-in-time compiler in the Curl runtime compiles this source code to the native machine language of the client machine, which can then be executed with the full performance of the client hardware. (In addition to Curl source code format, a compressed and preprocessed, but not yet compiled, format called “pcurl” is supported for users who want to deploy a more compact file to a Web server or do not want to reveal the original source code.)
1 .First-Class Treatment of Content
The basic philosophy behind the “content language” concept is to elevate content for presentation to an equally first-class status as the classical data structures and abstractions of contemporary programming languages such as Java, C++, or Lisp. The implications of this philosophy are seen even at the level of the language syntax, which unlike the syntax of other familiar languages must be equally as friendly for HTML-like markup as for conventional programming. The infix syntax of Java, C++, and related languages is not well suited to this task, so Curl adopts as its basic syntactic model the prefix syntax originally pioneered by Lisp [17]. In Lisp, each prefix expression begin sand ends with a parenthesis, but parentheses are frequently useful in textual content, so Curl chooses the less frequently used “curlybraces” {} instead. (The use of these braces, in turn, gives theCurl language its name.) Thus, the basic syntax of a Curl
expression is just{operator operands…}where the operator controls the
interpretation and processing of the operands. Curl takes this concept considerably beyond
traditional language models based on prefix syntax, however.When the operator is an identifier, Curl allows all of the following possibilities:
• Procedure and class names. In this case the operands are interpreted as Curl expressions to be
evaluated. The resulting values are supplied as arguments to the procedureor the class constructor. This category of operators corresponds to the subroutines and functions provided by
most programming languages.
Text procedures. In this case the operands are treated as text to be formatted, but if an unescaped { character appears in the operands, the material from that character to the next matching } character is treated as an expression and the result of evaluating that expression is substituted into the text at that point. Curl includes predefined text procedures such as bold and italic that provide markup functionality can define and use additional text procedures.
• Macros. In this case the entire operand text, up to the closing } character, is passed unmodified to the macro expression to be used in place of the macro expression. Macros are procedural and hygienic [24], in contrast to the simple declarative rewrite rules offered in languages like C
[13], and therefore are very powerful. Many built-in Curl operators such as if are actually defined as macros. User applications can also define and use additional macros.
• Primitives. A small number of fundamental Curl features are provided by specially defined primitive operators. This set of operators cannot be extended by user applications.
Despite using the prefix syntax described above as its primary common arithmetic and relational operators such as + and >. This concession to centuries of mathematical practice helps Curl
programming feel familiar even to new developers. The top-level source code of a Curl applet is treated somewhat like the operand of a text procedure, so the “Hello World”
program in Curl can be written as just {curl 3.0 applet} Hello World! The {curl 3.0 applet} herald identifies this file as an applet that uses version 3.0 of the Curl API, and the remaining
text is treated simply as content to be displayed, leading to the legend Hello World!
appearing in the content area of the user’s browser window. This next applet illustrates some of the different kinds of Curl
operators:
{curl 3.0 applet}
{let a:int = 3}
The square root of {italic a+1} is
{sqrt a+1}.
leading to the displayed result
The square root of a+1 is 2.
This example shows the difference between the text procedure italic, used here for markup purposes, and the ordinary procedural operator sqrt, used to embed the results of a computation in the presented output.

CONCLUSION
It is time to finally realize the ten-year-old vision of Web deployed rich-client applications. Actual experience has confirmed that the “content language” approach exemplified by the Curl language can successfully support such applications. In developing this approach, the Curl design team has admired and adopted many features of the Lisp family of languages, notably
the following:
• Prefix syntax, which provides a much better basis for syntax extension than C++/Java syntax. Lisp’s macros provide a powerful model of how syntax extensions can be defined.
• Automatic garbage collection.
• Anonymous procedures.
• Dynamic type checking and the availability of the any type. We thought it best to diverge from the Lisp approach in the following respects:
• We are confirmed believers in strong static typing as the fundamental typing model, for the reasons discussed earlier.
• Lisp implementations are optimized to operate on any objects as fast as possible. We are willing to accept slower performance for anys in return for achieving the full performance of platform-native data representations for values not declared as any.
• We find the performance advantages of C++-style static classes over Lisp-style dynamic classes to be compelling.
• We think the ability to define parameterized classes is important.
• Lisp is famous for its proliferation of parentheses
Finally, Curl diverges from Lisp in some ways that reflect Curl’s special mission as a content language for mobile code:
Overall, the strongest technical influences on the Curl design project have been the Lisp languages, C++, HTML, and TeX.The project has focused on defining a single coherent framework that could accommodate the best ideas that each language brings
to its area of strength. Taken as a whole, the architecture derived from this process comprises a “critical mass” that can finally get us over the hump and make Web-deployed applications as good as — or better than — the best non-Web applications of the past.

No comments:

Post a Comment

leave your opinion