Curl (programming language)

From Bauman National Library
This page was last modified on 8 June 2016, at 21:04.
Curl
fraimed
Paradigm multi-paradigm: object-oriented, markup
Designed by Steve Ward, MIT
Developer Curl, Inc., Sumisho Computer Systems Corp., SCSK Corporation
Typing discipline strong
Website www.curl.com
Dialects
none

Curl - a reflective object-oriented programming language designed for writing interactive Web applications. It combines the possibility of marking text (like HTML), scripting (as JavaScript), as well as a fairly powerful computing mechanism (as in Java, C # and C ++), all of which are within a unified framework. Language is mainly used for making internal corporate tasks, B2B- and B2C-applications.

History

The programming language Curl - designed Curl Corporation (http://www.curl.com), founded by 12 members of MIT in Cambridge in 1998. Language designed specifically for use on the Internet and in particular in the World Wide Web. Development was carried out in the financing and participation of MIT (Massachusetts Institute of Technology (MIT)). Curl Corporation "for the development of new-generation programming language for computers and communication" got Grand established World Wide Web Consortium (W3C). According to company management, technology Curl is universal and provides distinct advantages for both end users and for developers and internet providers. The first commercial version of the language was published in the spring of 2001 - after just six years after the appearance of Java.

This name was chosen for the reason that the language constructs are curly brackets.

Description

Curl language oriented programming at the same time and on the formation of product information (content). The Curl any character not enclosed in braces is treated as plain text directly on the screen. Everything is enclosed in braces is interpreted as an expression of the language of the Curl. These brackets can be nested. Language operates concepts values ​​(scalar types, notably integer and real numbers, bytes, etc.) and objects (reference value). From the point of view of the object model Curl has much in common with the language Java. The principal difference between Curl and Java is that Java is an object-oriented programming (OOP), while Curl combines the PLO with text formatting and scripting. Unlike Java language Curl supports multiple inheritance, and uses parameterized types, which work similar to C ++ templates. Curl supports advanced microprocessing tools (some of them only on paper), including an expression to include the insertion of fragments of the original text. For language is characterized extensible syntax and support strong typing at the same time preserving use without declared variables. As the authors of the language, a significant impact on the design Curl had Lisp, C ++, Tcl/Tk, TeX, and HTML. Generation of executable code made "on the fly" with the built-in special plug-in Surge dynamic compiler (JIT). Tooling system Curl compiler written in the Curl (supplied in source code). The security system is built around a variety of model sandboxes adopted in Java. An important feature of the implementation of the language is that it is taken into account when compiling (inherited) the context of the medium (depending on the powers and facilities generated and the appropriate code). To store information on a user's computer to Curl provides a mechanism for long-term data storage (persistent data), is much more flexible than the known means of cookie-files. But exception handling, similar to Java, implemented in some limited way.

Basics

Curl language combines text formatting capabilities, similar to the use of tags HTML, and software functionality. Text formatting rules can be defined in the document and to be downloaded or imported from external files.

Text formatting and layout

Below is a description of some of the operators Language:

  • {curl 8.0 applet} - language identifier Curl, which indicates that the file contains an applet written in API 8.0, which can be executed on the Surge plug-in version 8.0 .
  • || - operator comments, this statement is placed in the beginning of the line; the text of which is after him, but before the end of the line is a comment.
  • {title font-family = "Font name", font-size = Npt, color = "color", text} - the operator describing the title of the text, where the font-family - the name of the font, font-size - font size, color - the color of text, text - the text of the title; determinants of font-family, font-size and color are optional, and if they are not described, they will be accepted meaning of the text by default.
  • {paragraph font-style = "style", text} - the operator describes a paragraph of text, where the font-style - font style, text - the text of the title. It can be used with the following operators text, italic, bold, itemize.
  • {heading level = N, font-family = "Font name", font-size = Npt, color = "color", text} - the operator to describe titles where the level - pre-header type, font-family - font name, font-size - font size, color - the color of text, text - the text of the title.
  • {italic text} - operator is laying down on a text attribute italics.
  • {bold text} - operator setting to the text attribute of the increased thickness of characters.
  • {text font-style = "style" text} - the operator establishes a specific style to the text.
  • {itemize {item text1} {item text2} {item text3}} - the operator, which allows to format the text as a list.
  • {center object} - the operator align objects on the center of the document.
  • {image source = {url "image.jpg"}, width = Nin, height = Min} - the operator, including a document image files.
  • {hrule color = "color", height = Npt} - operator mapping a horizontal line in the document.

Data Types

Each variable within the Curl program associated with a particular data type. It offers a number of built-in "primitive" data types, as well as all the tools for designing classes and their applications.

  • Integer types - to the integer types in Curl include the following: int, int8, int16, int32, int64, uint8, uint16, byte. Each declared variable is automatically initialized to zero. If the value exceeds the upper or lower limit is "wrapping", as in most modern programming languages.
  • 'Floats '- these are only two types: float and double . They differ in dimension (32 and 64 bits, respectively), having at initialization default value of 0.0. In the event, when the floating-point number is not specified suffix, it is considered related to type double. To indicate that a number is of type float, you need to use the suffix f. It is noteworthy that in Curl there is such a thing as infinity, and infinity are both positive and negative (+Ґ, -Ґ): {value (1.0/0.0) == <infinity>} ||true
  • Logical types - this is the only one: bool . It occupies 1 bit.
  • Symbols - the size of one character in the Curl - 16 bits, the default \u0000 .
  • 'Value - seems to be the language the authors sought to cover all possible applications of Curl and his enthusiasm to hit upon such a thing as a special kind of physical and mathematical quantities. To include a built-in Acceleration, Angle, Area, Distance, Fraction and many others. Their internal representation - number in the format double or float , but it looks completely different things, and subtracted from the distance the speed you do not get.

It is possible to expand the list of "pre-defined" values ​​using the type-of .

Classes and procedures

  • Classes- as the vast majority of modern programming languages, Curl provides all the tools for comfortable work with the classes. The supply has a number of built-in classes for strings, arrays, sets, and hash tables. Since the class is also a data type, the instances of this type there is a default value - null . There is nothing new in terms of classes Curl does not open, but it has everything it used to programmers C ++: classes support multiple inheritance, abstract, and there is support for parameterized classes. Everything else regarding access functions and modifiers, brought to perfection. Modifiers that control the use of the class, are of four types: abstract ,informs the user that the class - an abstract; final ,prohibiting the inheritance from the class with a modifier; sealed - only subclasses " home package "with a modifier class can inherit from him. However, there is a loophole that allows you to inherit from a class with the modifier and outside the "home package»; shared - a virtual analogue of the class in C ++. All the concepts expressed in the syntax, such as: {define-class public Mule {inherits Horse, Donkey} ||description} In addition, there is a special Curl abstract class Object , which implicitly generated by all classes of the language. Thus, any hierarchy in the Curl has only one root.
  • Procedure - in Curl and programming is possible using conventional procedural approach, which uses the keyword define-proc . Procedures Curl very similar to the procedure in other languages, but there are some differences: First, the procedures are in Curl data type, and secondly, there is the concept of anonymous procedure.

Sample Code

Formatting and page layout

As with HTML, Curl can be designed in graphics and text markup directly in the source code:

{curl 8.0 applet}

{set-document-properties
    margin = 0.5in,
    background = "beige",
    border-width = 5pt,
    border-color = "blue"
}

{title
    font-family = "Times New Roman Bold Italic",
    font-size = 24pt,
    color = "green",
    Fruit}

{center {image source = {url "images/logo.gif"}}}

{paragraph
    {bold font-style = "italic", Definition}: Many fruits !! }

{heading
    font-size = 14pt,
    color = "black",
    Types of Fruits}

||Second level heading
{heading level = 2,
    {Frame
        width = 100pt,
        height = 30pt,
        background = "yellow"}
    {EllipseGraphic width = 30pt, height = 40pt, fill-color = "orange"}
}

At the beginning of the program it was declared a special operator {set-document-properties margin = Npt, background = {url "image.jpg"}, border-width = Mpt, border-color = "color"}, where margin - the left margin, backgroud - background document (instead of an image file as a parameter can be used and the background color), border-width - the width of the frame of the document, border-color - the color framing the document. Next, use the operator title, center, image, paragraph and heading , which have been described previously as well as Frame and EllipseGraphic , the first of which creates a separate area, and the second draws an ellipse. The result of the example:

Object-Oriented Programming

Curl allows you to work in an object-oriented environment:

{curl 8.0 applet}

{define-class public Foo
    {method public {hello}: void
        {popup-message "Hi!"}
    }
}

{define-class public Bar {inherits Foo}
    {method public {hello}: void
        {popup-message "Hello World !!"}
    }
}

{do
    let foo: Foo = {Foo}
    {foo.hello}

    let bar: Foo = {Bar}
    {bar.hello}
}

At the beginning of the program it was declared a class Foo and its successor class Bar {inherits Foo} to override a method hello . After that were created for one instance of these classes, and both caused by this method. The result of the example:

Event-programming

The Curl has the ability to handle various events, such as clicking on the button:

{curl 8.0 applet}

{CommandButton
    label = "Push me!",
    {on Action do
         {popup-message
             "Noooo !!"
         }
    }
}

It was declared a key CommandButton with the word "Push me!" and click handler on Action do which describes in a popup window with the inscription "Noooo !!". The result of the example:

The use of language

The main idea of ​​creating such a language was its versatility for all types of browsers that are based on the resulting code would automatically "adjust" the format of the browser page (self-describing format), to the language itself was compact, intuitive and easy to use. Curl can be used as a replacement for the HTML for the presentation of formatted text, on the other hand, it does not cover the possibility of inferior capabilities compiled, strongly typed object-oriented system programming languages. As a "decorations» (HTML-level), and software design Curl can be expanded in the user code. Thus Curl is the environment that brings together all the popular WEB technologies - HTML, CSS, JavaScript - into a single entity and enables comfortable working in a single development environment. At the moment, support and development of Curl is conducted in a Japanese corporation SCSK (Japanese).

Links