Related
I am searching for two (one?) languages. One of them would be a host, capable running some "environment", and second, which could used to script "agents" acting in this environment.
Some details:
host should be capable to run multiple "agents" (threads of embedded language), ideally capable to limit number of instructions executed by every thread at a time (though more sophisticated ways of control are welcome)
embedded threads should have access only to objects explicitly exposed by host
embedded threads should be isolated. No shared memory, all communication going via host
embedded language should be rather simple, with dynamic typing
hosting language should be rather high-level
performance is not a primary concern
I was thinking of Python being a host embedding Lua, for example Lunatic Python, or some pair of JVM languages (Scala / Groovy ?), but i'am not sure of possibilities of real isolation of embedded threads (see 2, 3). So I am searching for any ideas, frameworks, successfull implementations etc...
I think the conditions that you have listed aren't very restrictive, you are going to find a large list of pairs of host/thread scripting languages that fall within your six requirements.
So my most important recommendation is that you choose the languages that the intended users will like the most.
There are a couple of ways to approach this. If you decide to start picking a host language, then I think you have the following options:
C/C++: If your intention is to have more freedom of choice for the thread language, then having a C or C++ host will give you the most options, since most interpreted scripting languages are written in C/C++ and have easy mechanisms for embedding into C/C++ applications. Choices for thread languages could be Lua, Javascript, Python, Ruby, PHP, Basic, Scheme, Pascal, Lisp, and many many more.
Java: With Java as a host language you have a short number of scripting languages that are embed friendly. Here is a list.
.NET: I would only go with this if you intend to run on Windows and nothing else, if not I would avoid it. Like Java, you'll find a list of interpreters that can be embedded in a .NET application.
Something else: If you don't like C/C++ or Java as a host language, then you'll have to decide what kind of host language you like, but no matter the choice, you will have a very limited set of options for an embedded language. You suggested Python as a possible host language, which I think is a decent choice. I would advise against using Lua over Python though, that could be a debugging nightmare should you ever need to debug at the language VM level. Instead, I can offer two suggestions: (1) also use Python for the thread language, then you have a nice uniform language across the entire system; (2) find a scripting language that has a native interpreter written in Python (there aren't many that I know of). Instead of Python, you can go with Ruby, PHP, or any other major scripting language for the host, but in all cases you'll have not many options for the embedded language.
Now, instead of looking for a host language, you could pick the embedded language first, then find a host language that can embed that language. You suggested Lua as an embedded language, which is also a very good option. If you are set on using Lua, then I think C or C++ should be your host language, as that will give you the best embedding experience.
To summarize, I recommend one of two following approaches to choosing your pair of languages:
(a) pick a pair of languages where the embedded language interpreter is implemented in the host language. Examples: Lua and C++, Javascript and C++, Python and C++, Scheme and C++, Jython and Java, JRuby and Java, Rhino and Java, etc.
or
(b) pick the same high level scripting language for host and threads, and work on an unified platform without embedded scripting. Examples: Python and Python, Lua and Lua, Ruby and Ruby, etc.
Good luck with your search!
You could also use Common Lisp in particular thru its SBCL implementation.
Using javascript/v8 as the embedded language, and c++ as the host language might be a good solution. See this for how to embed.
V8 provides Contexts, each of which has its own Security Context. These allow you to create multiple separate threads for different clients, each of which is in their own sandbox.
Another alternative is java/javascript(rhino) which also allows embedding. Limiting access to other objects will be harder in java (you have to use a security manager), but you can limit the time a script is allowed to take, see an example in the javadocs here.
I know this question is a couple of years old now, but I'd recommend ObjectScript language.
ObjectScript, OS for short, is a new programming language. It's free, cross-platform, lightweight, embeddable and open-source. It combines the benefits of multiple languages, including: JavaScript, Lua, Ruby, Python and PHP. OS features the syntax of Javascripts, the "multiple results" feature from lua, syntactic shugar from Ruby as well as magic methods from PHP and Ruby - and even more!
A good example here is SnapScript it can be run on any Java compatible environment. In addition to the standard JRE it can also be run on Android (Dalvik and ART) without any modifications.
The IDE actually manages an agent pool for hot execution.
I would like to create a set of domain objects in multiple languages, so that I can target different platforms. I have been looking at external DSLs as a way to define a language for my domain, and then potentially writing adapters that generate code for the languages I'm interested in targeting. Is this the best way to solve this problem? Or is it just simpler to maintain multiple versions of the project?
I think that Apache Thrift delivers what you are asking for.
Sorry for late answer, but as you mention C# being your main language, this practically fully supported Visual Studio based technology is exactly what you are looking for.
You have to understand what you want to abstract with your DSLs, but the multiple-platform support is trivial on top of that.
Disclaimer: This is our technology, but it's publicly open and it solves exactly the problem presented in the question.
http://abstraction.codeplex.com/
Note! Mind the very "alpha" stage of the current download, I suggest you skip the zipped download and grab the latest source. I am updating better construct in relatively near future. Check out the "Context" implementation in "Production/Dev/AbstractionTemplate" solution.
It is difficult to be helpful without understanding what you are planning to use your DSL for.
Is portability your main problem here?
To succesfully target these different platforms, you will probably have to maintain plaftorm-specific layers anyway (generated or not).
If you plan to write your whole application in your DSL, then use your own compiler to transform it into runnable code for each platform, well it is most probably a bad idea, too complex and overengineered.
However, if you have a well-defined chunk of platform-independent logic, then a DSL is a good choice. Just write an interpreter for it on each target platform (provided that performance is not critical, this is also simpler and easier than generating code).
What is the best way to create multiple language versions of a domain?
This is (was?) somehow the idea of Model Driven Architecture (MDA). Quoting Model-driven architecture from Wikipedia:
The Model-Driven Architecture approach
defines system functionality using a
platform-independent model (PIM) using
an appropriate domain-specific
language (DSL).
Then, given a platform definition
model (PDM) corresponding to CORBA,
.NET, the Web, etc., the PIM is
translated to one or more
platform-specific models (PSMs) that
computers can run. This requires
mappings and transformations and
should be modeled too.
The PSM may use different Domain
Specific Languages (DSLs), or a
General Purpose Language (GPL) like
Java, C#, PHP, Python, etc. Automated tools generally
perform this translation.
Depending on the complexity of your domain and the availability of a MDA Tool, this might be an option (with a lower implementation cost).
See also
MDA: Nice idea, shame about the ...
Language Workbenches and Model Driven Architecture
UML vs. Domain-Specific Languages
DSL in the context of UML and GPL
UML or DSL: Which Bear Is Best? (be sure to read this one)
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
When is a language considered a scripting language?
I am really confused between different types of languages.
Can any one guide what are diff types of languages or diff categories.
Like some saying python is scripting langauge. Now what does that mean. Are other langueages like php , asp , java not scripting langauges
The name "Scripting language" applies to a very specific role: the language which you write commands to send to an existing software application. (like a traditional tv or movie "script")
For example, once upon a time, HTML web pages were boring. They were always static. Then one day, Netscape thought, "Hey, what if we let the browser read and act on little commands in the page?" And like that, Javascript was formed.
A simple javascript command is the alert() command, which instructs/commands the browser (a software app) that is reading the webpage to display an alert.
Now, does alert() related, in any way, to the C++ or whatever code language that the browser actually uses to display the alert? Of course not. Someone who writes "alert()" on an .html page has no understanding of how the browser actually displays the alert. He's just writing a command that the browser will interpret.
Let's see the simple javascript code
<script>
var x = 4
alert(x)
</script>
These are instructs that are sent to the browser, for the browser to interpret in itself. The programming language that the browser goes through to actually set a variable to 4, and put that in an alert...it is completely unrelated to javascript.
We call that last series of commands a "script" (which is why it is enclosed in <script> tags). Just by the definition of "script", in the traditional sense: A series of instructions and commands sent to the actors. Everyone knows that a screenplay (a movie script), for example, is a script.
The screenplay (script) is not the actors, or the camera, or the special effects. The screenplay just tells them what to do.
Now, what is a scripting language, exactly?
There are a lot of programming languages that are like different tools in a toolbox; some languages were designed specifically to be used as scripts.
Javasript is an obvious example; there are very few applications of Javascript that do not fall within the realm of scripting.
ActionScript (the language for Flash animations) and its derivatives are scripting languages, in that they simply issue commands to the Flash player/interpreter. Sure, there are abstractions such as Object-Oriented programming, but all that is simply a means to the end: send commands to the flash player.
Python and Ruby are commonly also used as scripting languages. For example, I once worked for a company that used Ruby to script commands to send to a browser that were along the lines of, "go to this site, click this link..." to do some basic automated testing. I was not a "Software Developer" by any means, at that job. I just wrote scripts that sent commands to the computer to send commands to the browser.
Because of their nature, scripting languages are rarely 'compiled' -- that is, translated into machine code, and read directly by the computer.
Even GUI applications created from Python and Ruby are scripts sent to an API written in C++ or C. It tells the C app what to do.
There is a line of vagueness, of course. Why can't you say that Machine Language/C are scripting languages, because they are scripts that the computer uses to interface with the basic motherboard/graphics cards/chips?
There are some lines we can draw to clarify:
When you can write a scripting language and run it without "compiling", it's more of a direct-script sort of thing. For example, you don't need to do anything with a screenplay in order to tell the actors what to do with it. It's already there, used, as-is. For this reason, we will exclude compiled languages from being called scripting languages, even though they can be used for scripting purposes in some occasions.
Scripting language implies commands sent to a complex software application; that's the whole reason we write scripts in the first place -- so you don't need to know the complexities of how the software works to send commands to it. So, scripting languages tend to be languages that send (relatively) simple commands to complex software applications...in this case, machine language and assembly code don't cut it.
A scripting language is typically interpreted instead of compiled.
See scripting-and-programming,
whats-the-difference-between-a-script-and-an-application
and many similar discussions.
There are many taxonomies for classifying programming languages.
In regard to scripting, a scripting language (python, ruby, php) is a language that runs on an interpretor directly from source code.
Other languages are either compiled languages (run from binary form: c, c++, pascal) either intermediate, compiled to an intermediary form and run inside a virtual machine (java, c#).
A scripting language is a language that focuses on making it easy to chain together or manipulate other programs
Wikipedia says:
"When a language is used to give commands to a software application (such as a shell) it is called a scripting language"
"A scripting language, script language or extension language is a programming language that allows control of one or more software applications."
This is orthogonal from whether it is interpreted or otherwise - Java was originally interpreted, for example, but nobody called it a scripting language. It just happens that, if you're implementing a scripting language, interpreting it is a straightforward approach to take.
Many scripting languages are compiled, either to bytecode or to machine code, often with JIT.
The distinction between script languages and other languages is mostly between interpreted, dynamically typed languages (for example PHP, VBScript, JScript and Javascript), and compiled, statically typed languages (for example C#, VB.NET, Java, C++ and Delphi).
ASP is not a language, but a platform for scripting languages (VBScript / JScript), while ASP.NET is a platform for compiled languages (mainly C# / VB.NET).
I'm interested in creating a visual programming language which can aid non-programmers(like children) to write simple programs, much like Labview or Simulink allows engineers to connect functional blocks together without the knowledge of how they are internally built. Is this called programming by demonstration? What are example applications?
What would be an ideal platform which can allow me to do this(it can be a desktop or a web app)
Check out Google Blockly. Blockly allows a developer to create their own blocks, translations (generators) to virtually any programming language (or even JSON/XML) and includes a graphical interface to allow end users to create their own programs.
Brief summary:
Blockly was influenced by App Inventor, which itself was based off Scratch
App Inventor now uses Blockly (?!)
So does the BBC microbit
Blockly itself runs in a browser (typically) using javascript
Focused on (visual) language developers
language independent blocks and generators
includes a Block Factory - which allows visual programming to create new Blocks (?!) - I didn't find this useful myself...except for understanding
includes generators to map blocks to javascript/python
e.g. These blocks:
Generated this code:
See https://developers.google.com/blockly/about/showcase for more details
Best wishes - Andy
The adventure on which you are about to embark is the design and implementation of a visual programming language. I don't know of any good textbooks in this area, but there are an IEEE conference and refereed journal devoted to this field. Margaret Burnett of Oregon State University, who is a highly regarded authority, has assembled a bibliography on visual programming languages; I suggest you start there.
You might consider writing to Professor Burnett for advice. If you do, I hope you will report the results back here.
There is Scratch written by MIT which is much like what you are looking for.
http://scratch.mit.edu/
A restricted form of programming is dataflow (aka. flow-based) programming, where the application is built from components by connecting their ports. Depending on the platform and purpose, the components are simple (like a path selector) or complex (like an image transformator). There are several dataflow systems (just I've made two), some of them has no visual editor, some of them are just a part of a bigger system, and there're some which don't even mention the approach. (Did you think, that make, MS-Excel and Unix Shell pipes are some kind of this?)
All modern digital synths based on dataflow approach, there's an amazing visual example: http://www.youtube.com/watch?v=0h-RhyopUmc
AFAIK, there's no dataflow system for definitly educational purposes. For more information, you should check this site: http://flowbased.org/start
There is a new open source library out there: TUM.CMS.VPLControl. Get it here. This library may serve as a basis for your purposes.
There is Snap written by UC Berkeley. It is another option to understand VPL.
Pay attention on CoSpaces Edu. It is an online platform that enables the creation of virtual worlds and learning experiences whilst providing a more flexible approach to the learning curriculum.
There is visual coding named "CoBlocks".
Learners can animate and code their creations with "CoBlocks" before exploring and sharing them in mobile VR.
Also It is possible to use JavaScript or TypeScript.
If you want to go ahead with this, the platform that I suggest is the one used to implement Scratch (which already does what you want, IMHO), which is Squeak Smalltalk. The Squeak environment was designed with visual programming explicitly in mind. It's free, and Smalltalk syntax can learned in half an hour. Learning the gigantic class library may take just a little longer.
The blocks editor which was most support and development for microbit is microsoft makecode
Scratch is a horrible language to teach programming (i'm biased, but check out Pipes Visual Programming Language)
What you seem to want to do sounds a lot like Functional Block programming (as in functional block programming language IEC 61499 and other VPLs for mechatronics development). There is already a lot of research into VPLs so you might want to make sure that A) what your are trying to do has an audience and B) what you are trying to do can be done easily.
It sounds a bit negative in tone, but a good place to start to test the plausibility of your idea is by reading Davor Babic's short blog post at http://blog.davor.se/blog/2012/09/09/Visual-programming/
As far as what platform to use - you could use pretty much anything, just make sure it has good graphic libraries (You could use Java with Swing - if you like pain - or Python with TKinter) just depends what you are familiar with. Just keep in mind who you want to eventually launch the language to (if its iOS, then look at using Objective-C, etc.)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm interested in Domain Specific Languagess design and implementation.
Much of the DSLs that I know stem from the academic world.
Can you give me some pointers to DSLs that are actually used in the industry ? and that you use on a daily-basis...which are really convenient..
(I'm interested in declarative languages too, but not really xml-based ones...)...
I'd like to establish a (non-exhaustive) list of industry-deployed languages...i know this is huge...
Sometimes, I'm implementing using a General Purpose Language things that could be trivially done using a DSL.
EDIT
I'm mainly interested in application-directed DSLs, not small-embedded languages. For instance, SQL matches what I'm looking for but SQL embedded in java does not interest me.
Another example of the kind of language i'm looking for is X#
A DSL that's so succesful that it got its own SO tag is the regex language. Specific to the domain of string pattern matching, of course.
Another popular one, but with which I have no experience is VHDL. VHDLs popularity stems from the fact that it's easily converted for use in an FPGA.
[edit]
While it's certainly not Turing complete, C's printf() format specifier can be considered as another domain-specific language.
NMake, MSBuild, lex, yacc, bison, flex, TeX, PostScript, XAML, SSIS, Wix
EBNF is probably the most widely-used domain specific language within its domain - a language to describe languages.
Wikipedia suggests that spreadsheet formulas and shell scripts are both domain specific languages. This would make them probably the most wide spread examples.
Awk provides is a domain specific language for the processing of semi structured textual data.
Many of the more powerful unix command line tools in wide spread use such as find and grep could be classed as having a domain specific language (even when limited solely to command line arguments)
I don't know if you want to consider graphical DSLs as well. I'd include
NORMA, a DSL for conceptual domain modeling, based on Object-Role Modeling notation (ORM2)
Web Service Software Factory, which uses three DSLs to model web services
Both of the above were created using the DSL Toolkit.
Here is a question I had asked about DSLs written in Ruby: Ruby DSL (Domain Specific Language) repositories, examples
Aside from Ruby DSLs, SQL is a fine example of a very popular DSL, as is AWK.
MEL (Maya Expression Language) is a command line-esque language that AutoDesk Maya uses throughout its entire design. The Maya Ascii file format that scenes can be saved in uses MEL to compose its scenes. The user interface is largely built and controlled using MEL scripts. The expressions you can use to drive channels and attributes on objects are MEL.
I suppose it could technically be considered an embedded language in cases where you're just writing scripts for it. However, without MEL, Maya basically wouldn't exist. No ascii file format, no user interface, etc.
You can write a domain specific language in languages like Boo, but I think the very definition of domain specific indicates that most of the time it will be in a specific industry or even just a single company...
Wikipedia has a good introductory article on this.
This overview has an examples section with some good links.
There are parts of ruby on rails that can be considered domain-specific languages. In particular its language for specifying relational tables.
Mak Stealth's language for programming charcter behaviors (Do not think it has a name)
Slang - Goldman Sachs language (I've heard of it but never used it)
CMS-2 Navy programming language
Google's web search supports some increasingly sophisticated parametrization
You could argue that this is one of the most widely used DSL's if even a small fraction of their userbase ever uses one of them as opposed to the standard list of words.
Erlang was originally a telecom-specific language, although it is now (occasionally) used as a general-purpose language.
The two (not already mentionned) which have impressed me most are:
OpenSCAD for solid 3D modelling
TaskJuggler for project management (!)
I'm a big fan of declarative DSLs. Operational DSLs (like Maple, Mathematica and R are nice too, but not that different from conventional langauges).
Tcl is a language that was originally designed to be a framework for building DSLs — providing basic functionality like programmability and I/O while the domain-specific parts were created fresh for each application — and which grew up into a generic scripting language. One of the more widely known Tcl-based DSLs is Expect.
For business processes we have e.g.
BPEL which is expressed in XML and is executable
BPMN which is a visual language and is used for modeling