Faramita draft language design 0.1 - truly mobile code (mobile code)

sponsored links
Faramita draft language design 0.1
Advertising language (not really): The real mobile code (mobile code), a real distributed computing

Abbreviation explanation:
RPC: Remote Procedure Call Remote Call
DSL: Domain Specific Language Domain Specific Languages
AOP: Aspect Oriented Programming Aspect Oriented Programming

1. Why is it called Faramita this name?
Sanskrit Paramita Special (Faramita) means "to reach the other side" or "do things successfully." Legend boat was traveling across a foreign businessman, the risk pool of the sea waves, when they reached the "yellow wood of the Bay" in Hong Kong Fu Xu, Yao Jian mountain temple when the South China Sea, can not help but send "Faramita" cheers!
(Adapted from Chen Bojian "Guangzhou is China's foreign trade port city of enduring")
Faramita is the other side of the mean. At the beginning of the three letters "Far" means a "far" means. Faramita name is suited to this programming language is designed to be - a language designed for the purpose is to move to a remote server to run.
I searched the Internet about Faramita the word and found not a programming language called Faramita, so he chose the name.
Faramita this language does not exist, it is envisaged, and the embryonic stage. In order to avoid "overrating" the surprise, do a disclaimer here first. These days, DSL has gained ideas, a man casually designed a language really is not anything outrageous, overestimating their own strength to do.
Of course, language is one thing, achieving it is another matter. Mind the language of the majority of temporary fever designers do not have the realization of a programming language ability. For example, I do not have this gate capacity. I've done the work of parsing, I know how difficult that work. Let alone a language but also turn up and running.
Well, no BS, get down to business. Although Faramita this language from the truly distant future, but I want this design language first written.

2. Database service inspired by the model

Faramita language typical scenario is this. Client to send a code to the server-side, the server receives the client sent the code, interpreted and the results are returned to the client.
I know that using such language usage patterns, there are two, one is a relational database query language SQL, a kind of XML database query language XQuery. I am not familiar with XQuery, Take the SQL as an example.
Assembling a SQL database client code, sent to the database server, database server to explain the implementation of SQL, the results are returned to the client.
I use JDBC programming time, have encountered this problem many times - we need to before the results of a SQL, SQL to determine what the next one.
In the general programming model, the client start a SQL, to get results, and then send the next SQL.
Some databases support dynamic temporary stored procedures, this time in order to reduce the number of inquiries and improve operational efficiency, the client can dynamically assemble a stored procedure that contains SQL and the judge is not complex logic. The client to assemble distributed database stored procedure, database stored procedures can be performed directly back to the final result.
In theory, stored process should be defined in the database and then call the client. However, this temporary assembly stored procedure approach has its flexibility and application scenarios.
Faramita language works a bit similar to this pattern.

3. On the idea of the current Web Service Web Service implementations, there are two. One is the SOAP protocol, a REST style.
Let's look at a typical example of SOAP.
The SOAP request:
POST / InStock HTTP/1.1
Host: www.example.org
Content-Type: application / soap + xml; charset = utf-8
Content-Length: nnn

<? Xml version = "1.0"?>
<Soap: Envelope
xmlns: soap = "http://www.w3.org/2001/12/soap-envelope"
soap: encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName> IBM </ m: StockName>
</ M: GetStockPrice>
</ Soap: Body>

</ Soap: Envelope>

The SOAP response:
HTTP/1.1 200 OK
Content-Type: application / soap + xml; charset = utf-8
Content-Length: nnn

<? Xml version = "1.0"?>
<Soap: Envelope
xmlns: soap = "http://www.w3.org/2001/12/soap-envelope"
soap: encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPriceResponse>
<m:Price> 34.5 </ m: Price>
</ M: GetStockPriceResponse>
</ Soap: Body>

</ Soap: Envelope>

We can see, SOAP is a XML format, however, RPC, and XML-RPC is no essential difference.
A simple RPC calls, why not do a simple script?
For example,
The Faramita request:
POST / InStock HTTP/1.1
Host: www.example.org
Content-Type: application / soap + xml; charset = utf-8
Content-Length: nnn

GetStockPrice (StockName = IBM)

The Faramita response:
HTTP/1.1 200 OK
Content-Type: application / soap + xml; charset = utf-8
Content-Length: nnn
Price = 4.5

If the above written REST RPC style should be like this.
http://www.example.org/InStock/GetStockPrice/IBM

You can see, REST style is simple and a lot of, all parameters are shown in the URI in the. However, REST-style restrictions also obviously, it can not express complex data types. Of course, it is said, REST-style resources aimed at positioning, rather than RPC. REST style has its own query language resources, such as XPath.
Faramita language targeted mainly SOAP, not REST. The current Web Service is essentially a matter of fact RPC library, provided by the RPC interfaces are relatively high-level package. Clients can use a simple way to call the Web Service RPC service.
I have such an idea, Web Service, as the database server so why not work? Web Service can only provide some basic functions, the client can freely assemble these basic functions, like assembly, like SQL. Furthermore, Web Service or even as a database for dynamic stored procedures work as the client are free to assemble the basic functions of Web Service functions can also be added complex control logic, and then peremptorily sent to the Web Service server to perform, as the client database stored procedure to send dynamic assembly to the database server.

4. Ordinary language to explain the limitations of

Faramita language usage patterns and scenarios is similar to SQL. But, Faramita language is a complete variety of syntax elements common programming language, rather than a special query language.
To accept a code, and then explain the implementation of any one interpretation of the language can do this. For example, ErLang, Python, Ruby, Javascript and so on. These languages have such a dynamic code interpretation function eval, the specific call as follows:
eval (context, code)
One context is the operating environment contains the variable table, code is interpreted code. Specific function names are not necessarily called eval, but many interpreted languages have similar functions.
So why do I have to design a language? There are several reasons.
First, the code cross-border issues. The interpretation of the language was not intended to "send to the remote server to perform" The purpose of the design, so the code can be cross-border access beyond the scope of the function of external variables or global variables. This will give the code of the package sent great trouble. To ensure the code is implemented, also need to send the entire operating environment are packaged in the past. Of course, this problem can be resolved by the programmer. Code a programmer can restrict access to areas, which can reduce the Context. However, such constraints depend on the human brain to carry out the practice, can not always make sense.
Second, the function named parameters problem. SOAP by the previous examples we can see the remote call, in order to match the parameters, the parameters of the function name with the name of all. The interpretation of existing languages, there are many languages can be achieved indirectly named parameters, such as ErLang, Python, Ruby, etc.. But these languages are not directly supported in the syntax of named parameters, the parameters of packaging will always be some work.
Third, do not support Curry. Almost all of the dynamic interpretation of the language support Closure (closure) of this feature. Such as Javascript, ErLang, Python, Ruby and so on. However, these languages are not supported Curry. I only know one that supports the interpretation of the language Curry - Haskell, and derived from the Haskell Jaskell.

5. Explain Curry

Curry What does that mean? Partial Evaluation Curry little meaning. A function has multiple parameters, the parameters if we give enough, then the function will execute. If we give the parameters of less than the function requires parameters, then we get only a part of the assignment of function. The following example.
If we only give the first parameter, such as f1 (2), this time that the result is another function of two parameters.
f (x, y, z) (
return x + 2 * y + 3 * z;
)
If we give a parameter, such as f1 (2), this time the result returned is a parameter to another function.
f12 (z) (
return 1 + 2 * 2 + 3 * z; / / ie 5 + 3 * z
)
If we give a parameter, the function will be completed, a return of the result is a number.
To string together the whole process is: f (1) (2) (3) = 1 + 2 * 2 + 3 * 3
Curry is a functional language features. Curry and functional languages on a specific description, is not the focus of this article describes. If readers have doubts about this, then you can find many online easy to understand examples.
I have always felt, Curry than the Closure (closure) this feature is more important and more practical.
For Python, Ruby, Javascript object-oriented language that is, Closure (closure) in most cases, that is sad to general features. Of course, such a functional language for ErLang for closure is required. However, if ErLang to support Curry, then do not have to write such a wide definition of the anonymous function closure.
About what is Closure (closure), please many readers to the Internet to find a straightforward example.

6. Faramita design language summary

From the above examples can be seen SOAP, Web Service remote call or a function call nature. Therefore, Faramita language is a functional programming language. Function is first-class citizens, object, function objects can be used as parameters and return values are passed around. As to whether to support the class definition of object-oriented language features such as, not that necessary.
In order to better map and even alternative SOAP, Faramita language from the linguistic level to support named parameters. For consistency, Faramita mandatory for all function calls are used named parameters approach. Although the named parameters to write longer, but with the parameter name instead of position parameters, allowing the program to improve readability, especially when more parameters.
Faramita language from the linguistic level to support Curry, however, Faramita language does not support the Closure (closure). In Faramita language, the name is very important, even the function call using named parameters it should be mandatory, Faramita nature does not define an anonymous function. For analysis, links, packaged convenience, Faramita language and even the definition does not allow nested functions.
In order to prevent the function code to access cross-border, Faramita language does not allow functions to access any external variables and global variables, Faramita language is also not allowed to enter the function code of the transmission parameters of any change, that is, Faramita languages, function parameters are only Reading. This design draws on some of the features ErLang language, to better support multi-CPU parallel, or multi-core parallel.
ErLang very strict set of language, any variable is read-only variables, only one assignment. So, ErLang even loop control statements do not support this. In Faramita languages, function parameters are read-only, but local variables inside the function body but can be changed, and change local variables to the function will not spread outside. Thus, while Faramita does not support statement-level parallelism, but can support the function-level parallelism.
Note, Faramita does not limit the function within the IO access. The IO access may give rise to global state of read-write conflicts. This time, the function-level parallelism is lost.
Faramita is not a language designed for parallel computing, but for remote interpretation of the implementation of design language, therefore, not Faramita efficiency considerations. Parameter read-only result of the function-level parallelism, but Faramita function in order to prevent cross-border access to a product code only.
Similarly, on parallel computing, or online readers to search their own information.
SOAP program statements expressed with XML although swollen, but had to admit, XML analytical or analytical than the simple script some.
Faramita language on the one hand to please the programmers, let the program to write as simple as possible, on the one hand to please the parser, to process analysis up as simple as possible.
Faramita language draws on the one hand, Python, Ruby, Javascript, ErLang grammatical features some simple, try to simplify conditional statements and loops and other flow control statements, on the one hand draw a coherence to the characteristics of XML, the introduction of a lot of begin, end of grammar, slightly cumbersome to write.
Explain the specific syntax of the following characteristics Faramita.

7. Faramita data type

Faramita is a functional programming language, does not support the class definition, syntax elements are simple, but contains not a simple concept.
Faramita is a weak type of dynamic interpretation of the language. Variable has no type, but there are types of variable values. Faramita types include the following.
number: that number of types, such as integer, floating-point type. Faramita is not a scientific computing language, the basis and no special abilities,, Faramita does not distinguish between numeric types are unified for the number. The digital computing, in full accordance with the convention.
string: a string type. Internal contain byte [] and the encoding charset. Faramita the type name, variable names, parameter names are all with the string expression.
list: for example, [1,2, x, y]. Significance with the python, ruby, ErLang the list, like the definition.
function: function type. Context parameter contains the definition and function code. The function of its meaning and definition of ErLang difference is that, Faramita the function to support Curry, Partial Evaluation.
diction: the dictionary type. This is Faramita the most special type of language. diction some data types such as HashMap, which can put a lot of pairs of name - value. Just, diction also provides a wealth of information, diction allows the definition of empty names, that is, only definition of the name, not the definition of the corresponding value. diction is Faramita the most common and most important type. Defined way of example (a = 12, b, c, d = 4).

8. Faramita function definition

Faramita language, the function definition is divided into two segments - context and code.
For example, f (x, y, z) (return x + 2 * y + 3 * z) This function, with Faramita language performance, is like the following.

begin_function f
begin_context
x, y, z
end_context

begin_code
return x + 2 * y + 3 * z
end_code
end_funciton f

You can see, a simple function, with Faramita language performance, seems a lot of red tape. From the function defined in terms of, Faramita not a very friendly language for programmers, but this function definition, one to please the parser to reduce the difficulty parsing, code pack easily, and second, to achieve Curry. The above function definition in Context, a member of the function object is actually a list of variables, the data type is diction.
Faramita in language function call on the goodwill of many, of course, mandatory for named parameters or trouble some. Function call must be so written.
For example, f (x = 1, y = 2, z = 3)
The results of the function call is 1 + 2 + 3 * 2 * 3 = 14.

9. Faramita flexible support function to Curry

Then, f (x = 1) call the result? Faramita support Curry, and support very flexible.
Require attention here is, f (x = 1) of this call. (X = 1) This is actually the creation of the object diction statement.
f (x = 1) the true meaning is that the (x = 1) f the diction of this function object is assigned to the object. f (x = 1) can be written in the form below.
dict_x = (x = 1)
f (dict_x)

When the f function to get a diction when the parameter list of type, f function will take the parameters d pass come in their own context and compared to 11. First, the parameter names must match, if the parameter name does not match, then an error. Secondly, the number of parameters to match the number of parameters if the transmission came less than required number of arguments context, the function will not be truly implemented, but will pass the first record came in the context of parameters to produce a new function object . At this time, curry happened. For example, f (x = 1) results is just another function objects f1, equivalent to the following function definition.

begin_function f1
begin_context
x = 1, y, z
end_context

begin_code
return x + 2 * y + 3 * z
end_code
end_funciton f1

Similarly, f (x = 1) (y = 2) the implementation of the result is a new function object, equivalent to the following function definition.
begin_function f12
begin_context
x = 1, y = 2, z
end_context

begin_code
return x + 2 * y + 3 * z
end_code
end_funciton f12

Fully successful only if the parameters after the function code code will be implemented only to produce results.
For instance, f (x = 1) (y = 2) (z = 3) the implementation of the result is 1 +2 * 2 +3 * 3 = 14.

We can see, Faramita support for the curry is very intuitive. In addition, because the parameters of context which has the name, Faramita's Curry does not insist parameters of the incoming order, write f (z = 3) (x = 1) (y = 2) can get the same result.
In addition, Faramita function to support the initial default parameter values, for example, the above f12 function definition, x = 1, y = 2 x and y can be seen as the default parameter values. When called f12, fully able to take another x, y values.
Attention to two points. 1, the function returns the result object may have two types, one is the context part of the assignment of function objects, one is the implementation of the final result obtained after completion of the type. The distinction between these two types of results, the programmer needs to deal with in the program under the semantics. Otherwise, it will cause runtime error.
Second, because the function changes the contents of the object does not allow context, can only create a new context object, thereby creating a new function object. Therefore, all the function calls, regardless of the result returned is a value object or a function object, is a new object.

10. Faramita language conditional statements if, switch

From the previous example can be seen, Faramita block for each grammatical structure are defined in pairs begin, end keyword. Python language mandatory for line indent, Faramita not force the indentation, but the force line breaks. For example, the previous function definition, begin_function, end_funciton, begin_context, end_context, begin_code, end_code these keywords must occupy a separate line. This approach makes the syntax slightly bloated, but it can clear the semantic parser to facilitate dealing with them
Faramita the if statement style adhering to the begin end, defines if, else_if, else, end_if and other keywords.
For example,
if a = b
do_something
end_if

Another example
if a = b
do_something
else_if a> b
do_otherthing
else
do_morething
end_if

Similarly, switch, case statements like is similar to the definition of conditional branches. Defines the switch, case, case_any, end_switch other keywords. For example.

switch a
case 1:
calculate_something
case 'abc':
do_something
case_any:
do_general
end_switch a

We can see that, switch block syntax is very flexible, while the variable type and variable values of the branch distribution case. Note that, case_any said that apart from the case outside the case. case_any this branch can not write. switch block after completing the implementation of each case branch are automatically exit the switch block, and will not leak down. Therefore, switch but if abbreviated form of the syntax block.

11. Faramita the loop

Faramita the loop as a simple form.
for i in 1 .. 10
do_someting (i)
end_for

for a in list1 / / Note: list1 is a list of
do_something (a)
end_for

for
listen_on_port (80) / / Note: infinite loop
end_for

In addition, multi-loop nested statement, break statement to jump directly to a more outer loop is also supported. This requires the definition of label used. For example.

a, b = 0 / / Note: Faramita support the bulk of this temporary variable assignment statement
label: outter_loop
for
b = b + 2
for
a = a + b + 1
if a> 100
break outter_loop
a = a * 2
end_for
end_for

Therefore, for, break, break label statements in this together, can achieve advanced process control.

12. Faramita language module

Faramita language is the Java source file management of the Package and ErLang the module combination of both.
Faramita the source file suffix is. Far. For instance, we have such a source of the path.
sample / math / calculate.far
The contents of which should be the case.
begin_module sample.math.calculate

The middle is the function definition.

end_module sample.match.calculate

Faramita the source file name is very strict principles. A source file can contain only one module, and module name and file path must correspond. This stringent requirement is to facilitate the source document management.
If a source file only one module, then begin_module must be the first statement, end_module must be last line of the statement, why so much hassle, it must write begin_module and end_module? But also must follow the full name of the module? This requirement because, Faramita is designed to transmit the code language of migration. This begin end module definition, can easily put together a different package transmission module. For example, we may be transmitted in the HTTP version of this code.

begin_module sample.math.calculate

The middle is the function definition.

end_module sample.match.calculate

begin_module sample.math.calculate2

The middle is the function definition.

end_module sample.match.calculate2

In this way, we can in a text agreement, and transfer more than one source code module.

13. Faramita language function links

Faramita the call, to the strict limitations. In addition to the basic system functions, all of the function call must be defined through the context or parameters entered. Even if it is a function of this module is also true. This is to express more clearly the link between function relationship. For example.
begin_module sample.math.calculate

begin_funciton count
begin_context
list
end_context

begin_code
count = 0
for item in list
count = count + 1
end_for
return count
end_code
end_function count

begin_funciton f
begin_context
count = sample.math.calculate.count
list
end_context

begin_code
if count (list)> 0
doSomething
else
return 0
end_if
end_code
end_function f

end_module sample.match.calculate

We can see that the function f to call the count function of this module must be explicitly introduced in the context of the full name of the count function - the module name with the function name. This definition, although laborious, but it is very flexible to use. For example, we may so call the function f.
f (list = [1,3,5])
f (list = [2,7,8], count = anotherModule.count)

anotherModule.count is another statistical function, there may only odd or even number of statistics may also be only statistical non-zero value. This can be any replacement.

14. Faramita sent packing function

With the syntax elements described above, we can pack up to Faramita function, sent to the Web Service server-side executed.
For example, the remote Web Service server provides such a basic function, service.sum, service.count, service.filter so.

Clients can organize such a code.
begin_module client
begin complex_query
begin_context
sum = service.sum, count = service.count, filter = service.filter, serviceContext,
myFilter = client.filter_out_0
end_context

begin_code
if sum (serviceContext) = 0
return 0

list1 = serviceContext.list1
quantity = count (myList = list1)

if (quantity <100)
return list1

return filter (myList = list1, myFilter = myFilter)
/ / When the parameter names and values of equal time, you can omit the assignment
/ / Can be written return filter (myList = list1, myFilter)
end_code
end_complex_query

begin_function filter_out_0
begin_context
myList
end_context

begin_code
result = []
for item in myList
if item = 0
continue
result.add (item)
end_for

return result
end_code
end_function filter_out_0

end_module client

This code will call the function through a remote Web Service server to send to a service port.

RPC (intialContext = myContext, queryFunction = client.complex_query,
port = 80, host = "example.com")

This time, complex_query will be packaged up and sent to the example.com port 80. Parser will check complex_query function links the introduction of the function. If the parser found complex_query quoted a function of the local client, then the parser will correspond to the corresponding function modules come packaged together, until the whole package come in all relevant functions. For example, the example above, filter_out_0 this function will be packed come.
Therefore, the programmer must pay attention to, sent to the remote server function call relations should not be too complicated, otherwise it will transfer much of the code.
For this line,
sum = service.sum, count = service.count, filter = service.filter

As the parser on the client can not find the corresponding local function definition, will only service.sum these values stored as a string, until a real up and running before we go back and try to find corresponding function definition. That occurred on the server side of the. The name of the definition of these functions can be placed on the definition of the function of context, can be placed on the definition of RPC function initialContext.
Analysis of the implementation of the remote server when the client-side scripting, context of the assignment process is as follows. First, the first intialContext content inside the cover to the context, generating a new context. Then, the server will also cover the context of serviceContext, and then try to execute client.complex_query.
Therefore, serviceContext the definition of priority in the best, followed by initalContext, the last is the default function context in the original definition.

15. Remote Call Text Transfer Protocol

SOAP-XML format using the tree data structure used to express, but not suitable for that code. We can adopt a flexible text agreement. Of course, this is the underlying protocol layer of the work. However, the simple text protocol, people read and easier to understand.
When the remote service call is only one parameter the time, you can use REST style. For example the previous example.
When the remote service call if there are several simple parameters, you can directly call the script code used Faramita way. For example the following text.
The Faramita request:
POST / InStock HTTP/1.1
Host: www.example.org
Content-Type: application / soap + xml; charset = utf-8
Content-Length: nnn

service.GetStockPrice (StockName = IBM, month = July)

When initialContext parameters with complicated tree structure (which is rare), we still need to use SOAP in the XML format to express the tree data structure. Of course, some of the specific code calls, either directly call the server side of the remote service, or client-side script to package a good pass in the past, we can use the most intuitive scripting language to express. In this way, the readability of the text transfer protocol will be a lot higher.
The text of the agreement specifically, this article not be discussed. In short, to comply with two principles. People read to be convenient, the computer should be easily read.

16. Faramita language run-time type checking

Web Service is a loosely coupled protocol, if using Java, C # and other statically typed languages to achieve, they must use code generation. If you use Python, Ruby, Javascript and other dynamically typed languages to achieve, they would simply much.
Statically typed language, while loosely coupled protocols in dealing with troublesome, but also has its advantages, that is, the generated code to force the type of match.
In order to introduce this feature type checking, Faramita context allows the function definition contains the type checking information. For example.
begin_function f
begin_context
number: / / must be a separate trip
x, y, z
end_context

begin_code
return x + 2 * y + 3 * z
end_code
end_funciton f

The program is running, when the function f is called when the parser will be under the number: the type definition information, the parameters of the incoming transmission type checking. The definition of various types is also similar. For example.
begin_context
anything, something, / / do not need to type checking of variables
number:
x, y, z = 10,
w = 20,
string:
a, b, c,
function:
f1, f2
var:
otherting / / var that any type that does not require type checking
end_context

17. Faramita language AOP

Dynamic AOP language is very simple, such as Ruby's mixin, Python, Javascript running on the modification type definition, and so on.
Faramita simple to implement AOP in particular. Because Faramita is functional programming language, function objects can be seen as only one method of the object. We know, AOP implementation model is the main Proxy, all methods need to package the object. Function objects only one way, packing up is particularly easy. Moreover, Faramita all the function calls are set in the Context can be any replacement. Because of these advantages, Faramita very easy to implement AOP.
Meanwhile, Faramita also, and Lisp, as a direct interface to the internal parser Interpreter exposed, Hook hook function provides a definition, the programmer can modify the behavior of the resolver. In this case, AOP to achieve them, the more simple.

18. Faramita language string

string is the most common programming languages, the most important data types, it is also an important type of Faramita language.
Faramita in the string, contains two main parts, a byte [], part enconding charset (encoding). Faramita in, string is the default initial encoding utf-8. Programmers can define a string object for each charset, can also be unified parser Hook function to replace all string encoding.
Faramita the variable name and the ruby of the symbol, ErLang the atom similar. In Faramita, the string variable assignment agreement are as follows.
a = '1 '
a = 'bcd'

These statements are strings assignment.
When the bcd is not any one variable name, we can also write this.
a = bcd / / omit the quotation marks when the string contains., like the special characters, it is best protected with quotes. If the string itself contains single quotes, double quotes, commas, line breaks, special characters like slash, then the best way to define string constants.
begin_text contant_str
this is
some, very, very complex
text, here ....
end_text contant_str

Faramita the same as in the string and the python are constants can not be changed. Each new change operation, will generate a new string object.

19. String in the variable substitution

Here the first mention I had to do open source project called fastm. Some friends sent me messages, asking me fastm status quo. I am very sorry and ashamed. An explanation is given here.
fastm is written in a java string template tools, used Java MVC Web in the View layer.
In the JSP, Velocity, Freemarker, PHP, ASP, using model
Data + Script = Text
In fastm, the use of model
Data + Template = Text
That is, in fastm template, the script does not contain any logic, only contains a placeholder.
I realize a lot of features fastm even provides DOM, SAX, and dynamic data directly binding function. After that step finished, fastm no more you can upgrade the space. At that time, I obviously feel, Java static type of language used to develop this Web application such loosely coupled, it is not suitable. In order to achieve the object attribute data, the dynamic addressing, I use a lot of crappy Reflection. In dynamic languages, this is easy.
Since then, I basically gave up Java development, instead, to study other dynamic languages. For example, Python, Ruby, ErLang, Javascript and so on. The course of the trial, I found that each language has its own advantages and disadvantages, have their own corresponding field. Web Service, SOA these buzz word began to rise. So, I sprouted a vague idea that Faramita prototype that integrates the functions I want. When the idea of a little mature, I would write out.
Java, a Message Text, you can simply replace the variables. Some languages also support the wildcard string replacement. Also some heavyweight Template engine, such as Velocity, Freemarker script can be used to generate the string. I want to do a simple task, to thinking fastm introduce faramita string parsing processing. For example, we can define a string so template.
begin_text template1
hello, this is ($ name), please repeat following words ($ n) times.
(Begin_block: block1) war, (end_block: block1)
end_text template1

In this template, only two dynamic part of the definition. One is the variable placeholder, the definition of a block. To write very simple, very simple to use. As long as a data block and the template for a match, the final result will come out.

20. Faramita parser implementation

Faramita can run a variety of ways. Can be run as an independent language can also be run as an embedded language. Initially envisaged, Faramita the host language is Python and Ruby. Faramita and between the host language, should be able to integrate seamlessly, the free interaction. In this case, the complex features many ready-made, so that the host language can do.
Faramita the syntax definition is simpler, especially in the module, function, context, code-level, have provided the name begin end pair block. These syntax elements are separate and make the trip more easier to handle. However, the specific function to the interior of the statement level, you need to use a complex parser.
Faramita parser how to achieve it? Can be generated using the static definition of the syntax grammar compiler. Can also be written in Haskell Parsec with ajoo in multiple languages on the transplant. ajoo prepared JParsec, NParsec, Ruby Parsec, unfortunately, has not yet written Python Parsec.
Faramita parser not too difficult to achieve together, the actuator will not be too difficult to achieve together. Java is implemented in Groovy, Javascript and other dynamic interpretation of the language of analysis and implementation, looked at the implementation code, basically defines the corresponding wrapper class. In Python, Ruby, the do this much easier. Of course, not too simple, because the string parsing work, always very complicated very troublesome work.
Maybe so I covered all the clear, I will be hands-on realization of this language. I am only a preliminary idea of not fully mature, the first written here is to draw more views.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Faramita draft language design 0.1 - truly mobile code (mobile code)

  • Rails is that the development of those plug-ins are indispensable

    RT I reprint a reference When I programmed in some things is necessary. So I summed up the 10 most important ruby gems list, they will make your life easier, even if you only a small amount of time spent programming ruby. Gems There are many, but these ar

  • ruby + sourceinsight + gmake build unix development environment

    Recently, a small program to do, some data from the Web crawl, and treatment, This flow is more or less, java write a spider, through hibernate write postgresql, maven run, and put maven on crond. Online at the data there is a need to more or less ti ...

  • ruby + sourceinsight + gmake build collections unix development environment

    Recently, a small program to do, some data from the Web crawl, and treatment, This flow is more or less, java write a spider, through hibernate write postgresql, maven run, and put maven on crond. Online at the data there is a need to more or less ti ...

  • Ruby on Rails and to use Action Web Service to create Web Services

    Action Web Service Module will be at Ruby on Rails implementation of Web services. Action Web Service will be the creation of SOAP and XML-RPC Web Services in support of server-side protocol. You can use the Declaration and the Action Web Service released

  • Ajax improve client response speed skills

    The emergence of AJAX greatly changed the Web application client mode of operation, which allows users to work in the whole-hearted do not have to put up with frequent page refreshes it offensive. Theoretically AJAX technology in a large extent on user op

  • Stage next week, summed up the goal - to Li Gang, the auction system struts2 read: Struts2 + spring + jdbc

    After nearly a month of spring of the study, summed up the next spring for some of the core things: 1.DI (spring dependency injection) This chapter is spring inside the most easy things, but for advanced assembly Bean will have to go look. The main applic

  • Java terminology

    DAO: data access object data access object ORM: object relational mapping Object-Relational Mapping JDBC: java database connectivity JPA: java persistence api ----- ORM framework JDO: java data object ------ ORM framework OJB: apache object ralationa ...

  • 10 essential ruby gems

    10 essential ruby gems Author:, source: yeeyan translation of words and the responsibility of Editor: Li Yu, 2008-02-14 11:02 At the time I programmed some things are necessary. So I summed up the 10 most important ruby gems list, they will make your ...

  • ROR environmental configuration (rails2.2.2 fell from 1.2.6)

    ROR environment structures put my steps down - Memo 2009.1.26 ROR online to find some tutorials are ruby 1.8.5, rails1.2.6 to do based on the demonstration I use the version downloaded from the Internet are the latest version at the installation encounter

  • Buffalo has PHPRPC and those differences

    zhou7707 wrote Asked about Comet support on how to? Chen Jinzhou of Buffalo and has those differences ? 1, PHPRPC with Buffalo positioning different, Buffalo only positioning in a Javascript to Java's remote procedure call. PHPRPC not only suppor ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries