开发者

Are there programming languages that extend more than one language at the same time? [Question Edited]

开发者 https://www.devze.com 2023-02-08 23:14 出处:网络
AspectJ extends the Java language with new concepts. Are there other languages that extend more than one开发者_如何学JAVA language at the same time? If so, please give me an example.

AspectJ extends the Java language with new concepts.

Are there other languages that extend more than one开发者_如何学JAVA language at the same time? If so, please give me an example.

.


EDIT: I wasn't clear enough. A Java program is still considered a correct AspectJ program.

I'm looking for this kind of extend:

A language A that extends B and C, but a program written only in B or C, still is a a valid program of A.


PFront (and its underlying language MBase) extends multiple target languages - .NET CLR directly (via a Csharp-alike embedded DSL), a Lisp running on top of this CLR, and LLVM IR (and effectively any target platform supported by LLVM) via C-like embedded DSL.

Any language created within this framework may target any of the underlying platforms or languages, and can be extended by another language - i.e., languages forms a hierarchy, with every new language extending one or more of the already defined languages.

Update: to reflect an updated question - there are two ways of extending languages in pfront. First is to, plainly, extend a language by adding new constructions and forms. Second is to implement a restricted superset of a language which allows only a subset of a target language. Both ways are used - e.g., most of Csharp programs are valid subsets of PFront, as well as Lisp programs.


Clojure is a Lisp dialect that runs on the JVM. JRuby is an implementation of Ruby that runs on the JVM. Scala is a very cool language that (you guessed it!) also runs on the JVM. All can call existing Java APIs, so you might consider that 'extending' the Java language.


Fantom is an object-oriented language that targets the JVM (and can thus be said to "extend Java"), the CLR (and can thus be said to "extend C#") and JavaScript (and can thus be said to, well, "extend JavaScript").

Mercury is a logic programming language that targets C (and can thus be said to "extend C"), Java (and can thus be said to "extend Java"), C# (and can thus be said to "extend C#") and Erlang (and can thus be said to "extend Erlang") for the four currently-active back-ends.

That's two languages off the top of my head. If you squint right I'm sure you can say that Ruby does this because of the various dialects (Ruby, JRuby, IronRuby, etc.) that target a variety of platforms and can thus be said to extend the primary languages of those platforms. There are probably many others.

0

精彩评论

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

关注公众号