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.
Related
I am an autodidact, teaching myself how to program and script in different languages (novice in: Java, C++, Javascript/Node.js, HTML/CSS), design projects and schematics, adding electronics and peripherals.
What I have seen a lot of while researching is the use of multiple languages to achieve a set of goals (such as building a Web server in Javascript/Node to handle HTTP requests and responses, responding with a Web page written in HTML and customized/stylized with CSS and embedded with Javascript mannerisms; or instead of Node, you write it in PHP or Python).
I'm having a hard time wrapping my mind around WHY multiple languages are used instead of just one (some high-level languages are capable of performing a large portion, if not all, of the required tasks) and HOW information is passed in between the different languages. Could one program call another (I know that an HTML file can make "calls" to CSS and Javascript files, so, I understand that instance)?
I think the reason why I am hung up on this is because of my inexperience and lack of knowledge of other common languages. Does that mean that certain languages are meant to handle only specific tasks in a specific manner?
I feel like some languages, such as Java and C++, for example, can be used in various ways and in various instances to handle a myriad of different tasks. Is that not true of some of the others (PHP & Python, for instance)?
I'm digging into the wealth of knowledge and the collective experience of some of the most brilliant minds this world has to offer but remember that I am new to this and I don't have the advantage of doing this in a classroom but I have read and own many books on programming in specific languages and the like. Please answer in a way that I and the others that may follow can understand.
Thank you for your time and I look forward to the responses.
Cheers.
Fantastic answers!
I'm curious though; when working towards a solution for a specific problem, when does the programmer know when to stop in one language and continue a segment in another language?
That's where I am confused. Is it typically up to the software developer and his/her own particular and artistic preference on how something is done or are certain things just not possible without using multiple languages?
I do understand scripting and when it's beneficial to use rather than a program or application and I know runtime execution/compiled code, environments and frameworks and virtual machines but none of that clearly lays out a defined perimeter or a limit in functionality/ability for any particular language. Why call a C++ function in Python? Could Python not accomplish what was needed in the first place and could choosing a more appropriate language have mitigated the need for adding another level of complexity to the solution? I may be overthinking it but knowing this will guide me in my learning and help me map out better solutions as a programmer.
Basically the different technologies (browsers, operating systems etc) and with it programming languages evolved over time so that there are many different languages used in practice. For the same reason that there are multiple real languages. You could design a web browser that supports Python instead of JavaScript for front-end programming, but this would involve designing the APIs the scripts use to access the pages (DOM HTML model), it would need to be supported by all major web browsers, standardized, and web developers would need to use it.
Yes in many cases it is possible for programs written in one language to call programs written in another languages. There needs to be some kind of interface connecting the two parts, depending on the context. For example:
C and C++ are both compiled languages. That is, they get translated into machine code to be executed by the processor. The positions in the machine code where code for one function is located are stored with it. The linker of the operating system is responsible for linking two modules (.c files) such that function calls made in one module towards a function defined in the other result in the right machine code being loaded. For a C++ program to call a C program, one problem (many others) is that functions are named differently (name mangling). In practice the functions from the C program would need to be declared extern "C" in the C++ source code for the linker to set this up correctly.
JavaScript, CSS and HTML are interpreted and executed (for JavaScript) by the browser, but not necessarily translated into machine code. (JavaScript engined may use Just-in-time compilation). So the browser provides possibilities for the JavaScript code to access the CSS definition, for example. .style.color = ....
For scripting languages like Perl, PHP, Python etc to call each other, different libraries exist that handle the necessary intermediate steps ("glue code"). There are many possibilities, for instance the PHP code could invoke the Python interpreter to execute a Python program, or it could pass data to a running Python program through the operating system's mechanisms etc.
Wrappers such as SWIG allow C/C++ code to be called from scripting languages. They add the necessary symbols (functions) to the code that Python would call internally. Than the C++ program is compiled as a Python extension, which is loaded by the Python interpreter, itself a compiled program, and the operating system's linker is used. The Python interpreter then interprets Python code in such a way that calling a given Python function results in the machine code of the extension's wrapper function to be executed.
There are many ways to classify programming languages into categories. For example from low level (machine code) to higher level (more abstraction, translation to machine code handled automatically):
Assembly (for expressing machine code instructions)
Compiled languages for system-level programming. (C, C++, Pascal, ...)
Compiled languages running in a VM (Java, C#, ...)
Scripting languages (Python, Perl, PHP, ...) Less focused on efficiency, but more flexible.
Higher domain-speficic level languages (MATLAB, AppleScript)
Shell scripting (bash, sh)
Programming is all about creating solutions to problems. People think differently. People see the world from different perspectives. People like to tweak solutions and play with tools. Languages are created by people in order to solve different problems and in some cases just for play. My response is more along the lines of 'Why would there only be one language?'.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Learning to write a compiler
I looked around trying to find out more about programming language development, but couldn't find a whole lot online. I have found some tutorial videos, but not much for text guides, FAQs, advice etc. I am really curious about how to build my own programming language. It brings me to SO to ask:
How can you go about making your own programming language?
I would like to build a very basic language. I don't plan on having a very good language, nor do I think it will be used by anyone. I simply want to make my own language to learn more about operating systems, programming, and become better at everything.
Where does one start? Building the syntax? Building a compiler? What skills are needed? A lot of assembly and understanding of the operating system? What languages are most compilers and languages built in? I assume C.
I'd say that before you begin you might want to take a look at the Dragon Book and/or Programming Language Pragmatics. That will ground you in the theory of programming languages. The books cover compilation, and interpretation, and will enable you to build all the tools that would be needed to make a basic programming language.
I don't know how much assembly language you know, but unless you're rather comfortable with some dialect of assembly language programming I'd advise you against trying to write a compiler that compiles down to assembly code, as it's quite a bit of a challenge. You mentioned earlier that you're familiar wtih both C and C++, so perhaps you can write a compiler that compiles down to C or C++ and then use gcc/g++ or any other C/C++ compiler to convert the code to a native executable. This is what the Vala programming language does (it converts Vala syntax to C code that uses the GObject library).
As for what you can use to write the compiler, you have a lot of options. You could write it by hand in C or C++, or in order to simplify development you could use a higher level language so that you can focus on the writing of the compiler more than the memory allocations and the such that are needed for working with strings in C.
You could simply generate the grammars and have Flex and Bison generate the parser and lexical analyser. This is really useful as it allows you to do iterative development to quickly work on getting a working compiler.
Another option you have is to use ANTLR to generate your parser, the advantage to this is that you get lots of target languages that ANTLR can compile to. I've never used this but I've heard a lot about it.
Furthermore if you'd like a better grounding on the models that are used so frequently in programming language compiler/scanner/parser construction you should get a book on the Models of Computation. I'd recommend Introduction to the Theory of Computation.
You also seem to show an interest in gaining an understanding of operating systems. This I would say is something that is separate from Programming Language Design, and should be pursued separately. The book Principles of Modern Operating Systems is a pretty good starting place for learning about that. You could start with small projects like creating a shell, or writing a programme that emulates the ls command, and then go into more low level things, depending on how through you are with the system calls in C.
I hope that helps you.
EDIT: I've learnt a lot since I write this answer. I was taking the online course on programming languages that Brown University was offering when I saw this answer featured there. The professor very rightly points out that this answer talks a lot about parsers but is light on just about everything else. I'd really suggest going through the course videos and exercises if you'd like to get a better idea on how to create a programming language.
It entirely depends on what your programming language is going to be like.
Do you definitely want it to be compiled? There are interpreted languages as well... or you could implement compilation at execution time
What do you want the target platform to be? Some options:
Native code (which architectures and operating systems?)
JVM
Regular .NET
.NET using the Dynamic Language Runtime (like IronRuby/IronPython)
Parrot
Personally I would strongly consider targeting the JVM or .NET, just because then you get a lot of "safety" for free, as well as a huge set of libraries your language can use. (Obviously with native code there are plenty of libraries too, but I suspect that getting the interoperability between them right may be trickier.)
I see no reason why you'd particularly want to write a compiler (or other part of the system) in C, especially if it's only for educational purposes (so you don't need a 100-million-lines-a-second compiler). What language are you personally most productive in?
Take a look at ANTLR. It is an awesome compiler-compiler the stuff you use to build a parser for a language.
Building a language is basically about defining a grammar and adding production rules to this grammar. Doing that by hand is not trivial, but a good compiler-compiler will help you a lot.
You might also want to have a look at the classic "Dragon Book" (a book about compilers that features a knight slaying a dragon on the front page). (Google it).
Building domain specific languages is a useful skill to master. Domain specific languages is typically not full featured programming language, but typically business rules formulated in a custom made language tailor made for the project. Have a look at that topic too.
There are various tutorials online such as Write Yourself a Scheme in 48 hrs.
One place to start tho' might be with an "embedded domain specific language" (EDSL). This is a language that actually runs within the environment of another, but you have created keywords, operators, etc particularly suited to the subject (domain) that you want to work in.
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).
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I read something about Lua today, and I was wondering what it was.
I did a Google and Wikipedia search, I understood it until they began talking about C and API. I still don't understand it.
What is Lua and are there any tutorials for beginners?
Lua is a lightweight interpreted programming language developed in Brazil with a focus on embedding.
It is written in Pure ANSI C which means high portability, even as C++ code.
Here is an example:
print("Hello World!")
Wikipedia Summary
Official Site
I'm surprised everyone is getting this one wrong.
Lua is the Hawaiian word for "toilet".
Lua is a scripting language for C and C++. It allows to use the simpler syntax of Lua and execute these scripts in your C/C++ application. Therefore you don't have to compile the program on each change, but simply deliver a new script version.
For tutorials just use google, you'll find enough to keep you busy the next days.
Lua is a simple lightweight highly portable dynamically typed embeddable and extendable multi-paradigm scripting language. The "vanilla" (some would say official) implementation of it is made purely on ANSI C and has an awesome (simple yet powerful) C API that you can use to both embed Lua on your app or extend the behavior of the language itself. It is developed at the Informatics Department of the Pontifical Catholic University of Rio de Janeiro (PUC-Rio).
Thought it was not primarily designed for that, Lua found a big niche in game scripting, with big names such as "Grim Fandango" and "World of Warcraft". Nonetheless, because of its speed, simplicity and portability, it is also heavily used in embedded systems (see, for example, eLua project) and graphic computing.
Its philosophy is to be minimalistic, i.e its core libraries are very small with only minimum functionality (quite like C's standard libraries), though through the C API it is very simple to add features that wouldn't be possible through the pure core library, such as sockets, GUIs etc. In fact, Lua is so minimalistic that its main -and only- structured data type are 'tables', that could be described as associative arrays on 'roids.
Lua is procedural in its essence, but also supports multiple paradigms such as functional programming and object orientation.
Though Lua is not the fastest scripting language around (probably javascript's V8 project wins the prize) it is very fast (faster than vanilla Python or Ruby, for instance) and also features a non-official just-in-time implementation called LuaJIT.
In the end, Lua is actually no more than a fun language to play with, which I recommend!.
=)
About tutorials, I'd recommend the article about that on the lua-users wiki.
I hope I helped! =)
PS: I couldn't post all the links because I'm new on stack overflow, but it shouldn't be hard to find everything on Google. Sorry. =(
Lua is a scripting language. Link is to lua.org. It is heavily used in game development, most notably (to me) World of Warcraft.
Lua is a lightweight, embeddable scripting language. It's garnered a lot of popularity partly due to it's use in many popular games. A good example of this is World of Warcraft which uses an embedded version of lua to drive the behavior of the UI elements in the game.
A good intro to the language can be found here: http://computer-programming-languages.suite101.com/article.cfm/a_brief_introduction_to_lua_scripting
And the official online reference for the language can be found here: http://www.lua.org/manual/5.1/
It's a scripting language that is designed to work with C (and C++). It is designed to be embedded into C/C++ programs. Which means unlike a lot of other scripting languages, it makes no use of global variables and such, this means you can easily thread lua scripting engines.
It also makes claims about being the fastest dynamic scripting language.
I've made use of it in PC based C++ application for creating a plugin scripting interface, and also used it as a embedded scripting language. Its quite versitile, nice and small.
as a general purpose scripting language? Its not quite in the same league as your ruby/python/perl type stuff. It doesn't have as many libraries and the user community is pretty small.
But for extending C++/C apps? its awesome.
The C API, which looks to be the part that confused you, is designed to make it very easy for you to take existing C code (or new C code) and control it with a Lua script. This is what is meant by embedding. Via embedding, you can get a lightweight, programmable, interactive, text-based interface to any C code, for very little effort. Even if you don't embed things yourself, Lua is a very nice little scripting language.
My favorite example is that a nice person put a great many POSIX system calls into Lua. When I want something that is like a shell script but is more sophisticated, I can just use this library. Likewise with the MD5 library and with many others.
When learning Lua you can ignore the C API completely—just benefit from other people's work with the API—and if you ever need to embed your own code, you can come back to it later.
Lua is a SCRIPTING language written in C and is commonly used in game development because of its power and flexibility. Lua is also cross-platform so it can be used anywhere on any platform. Lua can also be used as a programming language with a handy program I use called AutoPlay Media Studio which allows you to create fully fledged applications for the Windows platform. I hope this clears things up for you.
Website: http://www.lua.org.
AutoPlay Media Studio: http://www.indigorose.com.
Lua is a powerful, fast, lightweight, embeddable scripting language.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
for more you can read here
Polyglot, or multiple language, solutions allow you to apply languages to problems which they are best suited for. Yet, at least in my experience, software shops tend to want to apply a "super" language to all aspects of the problem they are trying to solve. Sticking with that language come "hell or high water" even if another language is available which solves the problem simply and naturally. Why do you or do you not implement using polyglot solutions?
I almost always advocate more than 1 language in a solution space (actually, more than 2 since SQL is part of so many projects). Even if the client likes a language with explicit typing and a large pool of talent, I advocate the use of scripting languages for administrative, testing, data scrubbing, etc.
The advantages of many-language boil down to "right tool for the job."
There are legitimate disadvantages, though:
Harder to have collective code ownership (not everyone is versed in all languages)
Integration problems (diminished in managed platforms)
Increased runtime overhead from infrastructure libraries (this is often significant)
Increased tooling costs (IDEs, analysis tools, etc.)
Cognitive "bumps" when switching from one to another. This is a double-edged sword: for those well-versed, different paradigms are complementary and when a problem arises in one there is often a "but in X I would solve this with Z!" and problems are solved rapidly. However, for those who don't quite grok the paradigms, there can be a real slow-down when trying to comprehend "What is this?"
I also think it should be said that if you're going to go with many languages, in my opinion you should go for languages with significantly different approaches. I don't think you gain much in terms of problem-solving by having, say, both C# and VB on a project. I think in addition to your mainstream language, you want to have a scripting language (high productivity for smaller and one-off tasks) and a language with a seriously different cognitive style (Haskell, Prolog, Lisp, etc.).
I've been lucky to work in small projects with the possibility to suggest a suitable language for my task. For example C as a low-level language, extending Lua for the high-level/prototyping has served very well, getting up to speed quickly on a new embedded platform. I'd always prefer two languages for any bigger project, one domain-specific fit to that particular project. It adds a lot of expressiveness for quickly trying out new features.
However probably this serves you best for agile development methods, whereas for a more traditional project the first hurdle to overcome would be choosing which language to use, when scripting languages tend to immediately seem "newcomers" with less marketing push or "seriousness" in their image.
The biggest issue with polyglot solutions is that the more languages involved, the harder it is to find programmers with the proper skill set. Particularly if any of the languages are even slightly esoteric, or hail from entirely different schools of design (e.g. - functional vs procedural vs object oriented). Yes, any good programmer should be able to learn what they need, but management often wants someone who can "hit the ground running", no matter how unrealistic that is.
Other reasons include code reuse, increased complexity interfacing between the different languages, and the inevitable turf wars over which language a particular bit of code should belong in.
All of that said, realize that many systems are polyglot by design -- anything using databases will have SQL in addition to some other language. And there's often scripting involved as well, either for actual code or for the build system.
Pretty much all of my professional programming experience has been in the above category. Generally there's a core language (C or C++), SQL of varying degrees, shell scripting, and possibly some perl or python code on the periphery.
My employer's attitude has always been to use what works.
This has meant that when we found some useful Perl modules (like the one that implements "Benford's Law", Statistics::Benford), I had to learn how to use ActiveState's PDK.
When we decided to add interval maths to our project, I had to learn Ada and how to use both GNAT and ObjectAda.
When a high-speed string library was requested, I had to relearn assembler and get used to MASM32 and WinAsm.
When we wanted to have a COM DLL of libiconv (based on Delphi Inspiration's code), I got reacquainted with Delphi.
When we wanted to use Dr. Bill Poser's libuninum, I had to relearn C, and how to use Visual C++ 6's IDE.
We still prototype things in VB6 and VBScript, because they're good at it.
Maybe sometime down the line I'll end up doing stuff in Forth, or Eiffel, or D, or, heaven help me, Haskell (I don't have anything against the language per se, it's just a very different paradigm.)
One issue that I've run into is that Visual Studio doesn't allow multiple languages to be mixed in a single project, forcing you to abstract things out into separate DLLs for each language, which isn't necessarily ideal.
I suspect the main reason, however, is the perception that switching back and forth between many different languages leads to programmer inefficiency. There is some truth to this, I switch constantly between JavaScript, C#, VBScript, and VB.NET and there is a bit of lost time as I switch from one language to another, as I mix my syntax a bit.
Still, there is definitely room for more "polyglot" solutions particularly that extend beyond using JavaScript and whatever back-end programming language.
Well, all the web is polyglot now with Java/PHP/Ruby in the back and JavaScript in the front...
Other examples that come to mind -- a flexible complex system written in a low level language (C or C++) with an embedded high level language (Python, Lua, Scheme) to provide customization and scripting interface. Microsoft Office and VBA, Blender and Python.
A project which can be done in a scripting language such as Python with performance critical or OS-dependent pieces done in C.
Both JVM and CLR are getting lots of new interesting scripting languages compatible. Java + Groovy, C# + IRonPython etc.