开发者

What are the extensible languages people are using today?

开发者 https://www.devze.com 2022-12-14 19:28 出处:网络
Wikipedia says: Extensible programming is a term used in computer science to describe a style of computer programming that focuses on mechanisms to extend th开发者_JS百科e programming language, comp

Wikipedia says:

Extensible programming is a term used in computer science to describe a style of computer programming that focuses on mechanisms to extend th开发者_JS百科e programming language, compiler and runtime environment.

For example, Tcl lets you write your own control structures. See here.

I'm interested in compiling a list of extensible programming languages that are being used in real-world code. It would be nice if you could supply an example for your language as well.


Languages in the LISP family (Common Lisp, Guile, et cetera), are extremely extensible--more so than any other language I have ever used. Think of it like the C macro system on steroids. If you were bored enough, you could redefine the + operator as subtraction: now that is extensibility!

LISP has fallen out of fashion in many places, but Guile (a dialect of Scheme) is the official extension language of the GNU Project.


Ruby is not strictly an extensible language, but the syntax is flexible and powerful enough that if you squint, it kind of looks like it is... which for many purposes is plenty good enough.

At any rate, people actually use Ruby :-)


Scala is not strictly extensible either, but you can define what look like operators. For instance when defining a Map, you can use:

val romanNumeral = Map(
    1 -> "I", 2 -> "II", 3 -> "III"
)

The -> is actually a method called on the object 1, but looks like an operator.


Jeebox is an extensible language that can describe anything, including code.

It is used purely to describe things, right now...

But an extensible programming language, could be built ontop of Jeebox, very easily.

(I'm building a normal, non-extensible programming language ontop of Jeebox, simply because building extensibility into a programming language is more than just a language feature. It needs a kind of recursion, where you write code that can create more code. And doing this properly would require more time than I have available. But it's nice to know that the language I'm using, Jeebox, can support this, once I have time to do it.)


Jetbrains MPS (Meta-programming System) offers a projectional editor based extendible language workbench. It helps you in creating editors, type-systems, constraints, refactorings and code generators for your language extensions. It ships with some Java language implementation and extensions.

mbeddr is a C implementation utilizing this technology. It has component system, send/receive + client/server interfaces, dependency injection, state machines, testing and PLE extensions. It also contains an extensible debugging system so you can map your extensions to gdb and provide a comfortable debugging experience. Almost entire C language features are mapped so code generation can be mostly handled by reduction to C constructs instead of dumb M2T transformations.

Aynth is a simple monophonic synth written using mbeddr for the demonstration of components and send/receive interfaces.

Anyway, the first thing you'll notice if you use it will be, projectional editing isn't as comfortable as text editing in many cases. We're so much used to text based editing. But extensible languages have plenty benefits.


The Wikipedia article about Extensible programming mentions the language Seed7. The Wikipedia article of Seed7 describes it as:

In addition to many other features it provides an extension mechanism. Seed7 supports the introduction of new syntax and their semantics into the language and it allows new language constructs to be defined using the Seed7 language itself. E.g.: Programmers can introduce syntax and semantic of new statements as well as user defined operator symbols.

Seed7 is designed as extensible language from ground up. The whole language is not hard-coded in the compiler. Instead Seed7 is defined in libraries, which are loaded when the program is compiled. IMHO Seed7 is the only language where extensibility is a basic feature and everything else is based on it. Other approaches use a conventional language, where the compiler uses hard-coded syntax and semantic analysis, and bolt some extension mechanism on it.


The TCL language is a dynamic language with few fundamental rules:

The spirit of Tcl is "Everything is a string", "everything is a command", even control flow constructions.

For instance let to replace while loop with custom one.

# rename original while to orig_while for future usage.
rename while orig_while; 

#redefine while
proc while {cond body} {
# add customization code

# calculate while call count.
global while_call_count;
incr while_call_count;

# call original while in uper level stack 
 uplevel orig_while $cond $body;

# add customization code
}

Tcl has C language interface which allow to integrate Tcl into exists program very easily. Tcl used in EDA tools very extensively.

And finally TCL so powerful that it is not possible to define Tcl BNF, which brings lot of headaches.

0

精彩评论

暂无评论...
验证码 换一张
取 消