XSharp

X# (pronounced X-sharp) is an XML-oriented programming language for creating Web applications and services. Instead of using functions, development in X# is done by adding, removing or changing nodes from an XML representation of the information. X# is Turing complete and is influenced by functional and object oriented programming languages.
Origins
X# is developed by CodeGlide. Originally the language was used internally by CodeGlide as the foundation of an open source integrated suite of business applications. In late 2008 the language was released as open source.
Overview
The main advantages of X# are:
* XML-oriented
*: XML-oriented programming is a paradigm that brings together different aspects of functional, imperative and object oriented programming. Objects, relational databases, file systems, mail servers and any other data structure or repository is represented using an XML document. Just by manipulating this XML document using four operations (append, remove, update and execute) any complex action can be performed. Developers do not have to learn hundreds of functions to work with different technologies, repositories or protocols; any possible action can be performed by manipulating the XML representation of the data using just four operations.
* Simple
*:Unlike other programming languages which require developers to learn hundreds of libraries and thousands of functions, X# is simple, intuitive, and easy to learn. It uses 30 statements and four data types (node, string, number, and boolean) to create any type of application or service.
* Wide technology support
*:X# can be used to write virtually any type of application. Includes native support for multi-threading, exception handling, SOAP and RESTful web services, IMAP4/POP3, SMTP, SQL databases, XML databases, Excel documents, HTTP, WebDAV, FTP, Windows Shares (Samba), ZIP compression, DNS lookups, encoding/hashing and many other features.
* Fast
*:X# code is compiled to Java Byte code and has the same performance as Java applications. X# byte code is compatible with all Java virtual machines.
* Portable
*:X# programs can be executed under Linux, Windows, Mac OS, BSD, Solaris, or any other platform with Java support.
* Open Source
*:Released under the terms of the GPL version 3 license. Developers can freely distribute or sell applications created using X#.
XML-oriented Programming Examples
Instead of relying on functions as application building blocks as many other languages do, X# replaces those functions with four basic node operations (append, remove, update and execute) on an XML document that represents the actual information. Let’s say we want to create a multi-threaded application that shuttles data to and from SQL databases, email repositories, and Web services:
To insert a record into an SQL database, an XML node representing the table in the database is instantiated and another XML node representing the record is appended to it to perform the insertion.
<xsp:append-child target="document('xdbc:mysql://192.168.1.27:3306/ncc1701')/crew">
<row>
<id>100</id>
<name>James T. Kirk</name>
<occupation>Captain</occupation>
<age>30</age>
<email>jkirk@ncc1701.org</email>
</row>
</xsp:append-child>
To send an e-mail, an XML node representing the SMTP server is instantiated and another XML node representing the e-mail is appended to it to send the e-mail.
<xsp:append-child target="document('smtp://smtp.gmail.com')">
<mail importance="high" subject="Test message"
from="spock@vulcan.org" to="jkirk@ncc1701.org">
Hi James,

This is my first X# plain text message.

-- Spock
</mail>
</xsp:append-child>
To create a file in a directory, an XML node representing the target directory is instantiated and another XML node representing the file is appended to it to create the file.
<xsp:append-child target="document('file:///home/jkirk/documents')">
<file name="proposal.txt">
This is the content of the text file...
</file>
</xsp:append-child>
Other operations just as intuitive:
To delete a record from an SQL database, the XML node representing the record is selected and then deleted. Or, to change the value of a record column, the XML attribute representing the column is changed and then updated.


<xsp:variable name="sql" type="node" select="document('xdbc:mysql://192.168.1.27:3306/ncc1701')"/>


<xsp:remove-node select="$sql/crew/*[ends-with(@name, 'Borg')]"/>


<xsp:set-attribute target="$sql/crew/*[@id = '100']" name="seen" select="'James Tiberius Kirk'"/>
To delete an e-mail message from an IMAP4 server, the XML node representing the e-mail is selected and then deleted. Or, to change the message status to read, the XML attribute representing the seen flag is changed to “true” and then the node is updated.

<xsp:variable name="inbox" type="node" select="document('imap://imap.gmail.com?useradmin&passsecret')/folder[@name='INBOX']"/>


<xsp:remove-node select="$inbox/mail[@size > 1048576]"/>


<xsp:set-attribute target="$inbox/mail[@subject = 'Newsletter']" name="seen" select="'true'"/>
To delete a file from the local file system, the XML node representing the file is selected and then deleted. Or, to rename a file, the XML attribute representing the file name is changed and then the node is updated.

<xsp:variable name="documents" type="node" select="document('file:///home/jkirk/documents')"/>


<xsp:remove-node select="$documents/directory[@name='personal']/file[@name='photo.jpg']"/>


<xsp:set-attribute target="$documents/file[@name='report.xls']" name="name" select="'sales report.xls'"/>
It doesn’t matter if the developer is working with database records, e-mail messages or files; X# abstracts the programmer completely using just four basic operations. Working with other repositories or types of information is similar; for example threads are created by appending the program code node to a node representing the thread manager:
<xsp:append-child target="/threads">
<xsp:pi>



</xsp:pi>
</xsp:append-child>
Or, a Web service function can be called simply by executing an XML node representing the Web service operation and passing the nodes representing the parameters:
<xsp:with>
<xsp:context>
<appid>testSearch</appid>
<query>xsharp manual</query>
</xsp:context>
<xsp:execute select="document('rest:http://search.yahooapis.com/WebSearchService/V1/webSearch?messagetypex-www-form&httpmethodget')"/>
</xsp:with>
 
< Prev   Next >