|Designed by||Manuel Serrano|
|Stable release||2.1.1 (August 4, 2010)|
|Typing discipline||strong, dynamic|
|License||GPL version 3|
Hop is a Lisp-like programming language by Manuel Serrano for web 2.0 and also the name of the web broker that implements this language. It is written in Bigloo Scheme. A web broker is a program that can act as a web server and a web proxy.
Hop is a stratified language, which means that a single program file contains instructions for both the server and the client. The server executes CPU demanding computations and operations that require system privileges for accessing files or other resources. The client (of which there may be many such as browsers, cell phones, etc.) are dedicated to executing actions related to the programming of the graphical user interfaces.
1: (define-service (server-date) 2: (current-date)) 3: 4: (<HTML> 5: (<BUTTON> 6: :onclick ~(with-hop ($server-date) 7: (lambda (h) (alert h))) 8: "Server time"))
The code snippet above illustrates a few concepts.
- Hop is based on Scheme. Therefore a Hop program is essentially a list of words and/or lists that start and end with parentheses. For example "(HTML content)". "HTML" is the function name and "content" is the function parameter.
- Function names in Hop may contain characters other than letters and numbers. For example "<HTML>" is a valid name. Therefore the syntax of Hop looks very similar to HTML (by design). The Hop expression "(<HTML> content)" is similar to the HTML expression "<HTML>content</HTML>".
- HTML parameters start with a colon. For example ":onclick".
- The $ character in "$server-date" indicates that the server should substitute the variable name "server-date" with the variable's value before sending the HTML to the client. This is very similar to how ASP and JSP works.
- The ~ character in ":onclick ~(...)" indicates that the client should process what is between the parentheses.
- The "with-hop" function in "(with-hop (...) (...))"is a special function that delegates work to the server and takes two parameters. The first parameter contains the request the client should send to the server asynchronously. The second parameter contains the callback function that the client should invoke when the response arrives from the server. "(lambda (h) (alert h))" is the an anonymous function that takes a single input parameter "(h)", which contains the server response when the function is called. "(alert h)" is the function body.
Given its recent introduction, Hop currently exhibits a number of weaknesses.
|This programming language–related article is a stub. You can help Wikipedia by expanding it.|