Ur (programming Language)
   HOME

TheInfoList



OR:

Ur also called Ur/Web is a
free Free may refer to: Concept * Freedom, having the ability to do something, without having to obey anyone/anything * Freethought, a position that beliefs should be formed only on the basis of logic, reason, and empiricism * Emancipate, to procur ...
and
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
functional programming language In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions. It is a declarative programming paradigm in which function definitions are trees of expressions that m ...
specific for
web development Web development is the work involved in developing a website for the Internet (World Wide Web) or an intranet (a private network). Web development can range from developing a simple single static page of plain text to complex web applications ...
, created by Adam Chlipala at the
Massachusetts Institute of Technology The Massachusetts Institute of Technology (MIT) is a private land-grant research university in Cambridge, Massachusetts. Established in 1861, MIT has played a key role in the development of modern technology and science, and is one of the ...
that from a single program produces
server Server may refer to: Computing *Server (computing), a computer program or a device that provides functionality for other programs or devices, called clients Role * Waiting staff, those who work at a restaurant or a bar attending customers and su ...
code, browser client code and SQL code specific for the chosen
database In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases sp ...
backend. Ur supports a powerful kind of
metaprogramming Metaprogramming is a programming technique in which computer programs have the ability to treat other programs as their data. It means that a program can be designed to read, generate, analyze or transform other programs, and even modify itself ...
based on row types. Ur/Web is Ur plus a special standard library and associated rules for
parsing Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lati ...
and optimization. Ur/Web supports construction of dynamic web applications backed by SQL databases. The signature of the standard library is such that well-typed Ur/Web programs "don't go wrong" in a very broad sense. Not only do they not crash during particular page generations, but they also may not: * Suffer from any kinds of
code injection Code injection is the exploitation of a computer bug that is caused by processing invalid data. The injection is used by an attacker to introduce (or "inject") code into a vulnerable computer program and change the course of execution. The res ...
attacks * Return invalid
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
* Contain dead intra-application links * Have mismatches between
HTML forms A webform, web form or HTML form on a web page allows a user to enter data that is sent to a server for processing. Forms can resemble paper or database forms because web users fill out the forms using checkboxes, radio buttons, or text fields. F ...
and the fields expected by their handlers * Include client-side code that makes incorrect assumptions about the "
AJAX Ajax may refer to: Greek mythology and tragedy * Ajax the Great, a Greek mythological hero, son of King Telamon and Periboea * Ajax the Lesser, a Greek mythological hero, son of Oileus, the king of Locris * ''Ajax'' (play), by the ancient Greek ...
"-style services that the remote web server provides * Attempt invalid SQL queries * Use improper marshaling or unmarshaling in communication with SQL databases or between
browsers Browse, browser or browsing may refer to: Programs *Web browser, a program used to access the World Wide Web *Code browser, a program for navigating source code *File browser or file manager, a program used to manage files and related objects *Ha ...
and
web servers A web server is computer software and underlying hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initiates ...
This
type safety In computer science, type safety and type soundness are the extent to which a programming language discourages or prevents type errors. Type safety is sometimes alternatively considered to be a property of facilities of a computer language; that is ...
is just the foundation of the Ur/Web methodology. It is also possible to use metaprogramming to build significant application pieces by analysis of type structure. The Ur/Web compiler also produces very efficient object code that does not use
garbage collection Waste collection is a part of the process of waste management. It is the transfer of solid waste from the point of use and disposal to the point of treatment or landfill. Waste collection also includes the curbside collection of recyclable m ...
. The implementation of all this is
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
. SQL syntax templates embedded in the language facilitate the handling of tables. Although the syntax is based on
Standard ML Standard ML (SML) is a general-purpose, modular, functional programming language with compile-time type checking and type inference. It is popular among compiler writers and programming language researchers, as well as in the development of the ...
the language includes concepts from
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lang ...
with additional type manipulation.
Ajax Ajax may refer to: Greek mythology and tragedy * Ajax the Great, a Greek mythological hero, son of King Telamon and Periboea * Ajax the Lesser, a Greek mythological hero, son of Oileus, the king of Locris * ''Ajax'' (play), by the ancient Greek ...
call/response is serialized through a
monad Monad may refer to: Philosophy * Monad (philosophy), a term meaning "unit" **Monism, the concept of "one essence" in the metaphysical and theological theory ** Monad (Gnosticism), the most primal aspect of God in Gnosticism * ''Great Monad'', an ...
called ''transaction'' (corresponds to
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lang ...
's IO) and its marshalling and decoding is encapsulated in the ''rpc'' function. The browser client side includes
functional Functional may refer to: * Movements in architecture: ** Functionalism (architecture) ** Form follows function * Functional group, combination of atoms within molecules * Medical conditions without currently visible organic basis: ** Functional sy ...
reactive programming In computing, reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change. With this paradigm, it's possible to express static (e.g., arrays) or dynamic (e.g., event emitters) data streams ...
facilities using the ''(source a)'' type and a ''signal
monad Monad may refer to: Philosophy * Monad (philosophy), a term meaning "unit" **Monism, the concept of "one essence" in the metaphysical and theological theory ** Monad (Gnosticism), the most primal aspect of God in Gnosticism * ''Great Monad'', an ...
''.


Example program

This is a demo program showing client, server and database code with
Ajax Ajax may refer to: Greek mythology and tragedy * Ajax the Great, a Greek mythological hero, son of King Telamon and Periboea * Ajax the Lesser, a Greek mythological hero, son of Oileus, the king of Locris * ''Ajax'' (play), by the ancient Greek ...
communication, from the web demos, with extra comments to outline each of the components: Interface file ( ML-like signature) with extension: (* the environment monad is called transaction, corresponds to Haskell's IO monad *) val main : unit -> transaction page Implementation file (.ur extension): datatype list t = Nil , Cons of t * list t table t : PRIMARY KEY Id (* server side database access, called through AJAX XmlHttpRequest encapsulated as ''rpc'' function (remote procedure call) *) fun add id s = (* sql dml template with *) dml (INSERT INTO t (Id, A) VALUES (, )) fun del id = dml (DELETE FROM t WHERE t.Id = ) fun lookup id = (* haskell style monadic code *) ro <- oneOrNoRows (SELECT t.A FROM t WHERE t.Id = ); case ro of None => return None (* return is the ''monad'' lifting function *) , Some r => return (Some r.T.A) (* ''check'' called by client side onClick event handler, so it will be compiled to JavaScript as page embedded client script *) fun check ls = case ls of Nil => return () , Cons (id, ls') => ao <- rpc (lookup id); (* Ajax call to server side *) alert (case ao of None => "Nada" , Some a => a ); check ls' fun main () = idAdd <- source ""; aAdd <- source ""; idDel <- source ""; (* generates web page with JavaScript inclusions *) return