• Forum
  • Lounge
  • isn't multilple languages a sign of bad?

 
isn't multilple languages a sign of bad?

closed account (iw0XoG1T)
I was reading a different thread where individuals stated that when creating something they often use multiple languages to get the job done. I often will hack a few utility programs together to get a job done; but I always consider this a sign that I don't know what I am doing.
It seems to me that when I am using multiple languages to get a job done that what I am also creating is a mess if the job ever has to be modified.
I hear people say best tool for the job—I do not know what they mean. When I decide on language my only consideration is do I know how to do it—and can I get it done in a reasonable amount of time.
That's usually the way people define "best tool for the job", though there are other definitions. Some may argue that python's list comprehensions (which provide a way to operate on a large amount of data that doesn't need to reside in RAM all at once) beat C++ in that to provide the same kind of functionality in C++ would require a lot of extra coding. Some may argue that they can implement some functionality F in some functional programming language P in 3 lines of code whereas in C++ it might take 50. Etc, etc.

IMHO, some language jumping is ok, and some create flimsy apps. For example, you can call C++ from Java via JNI; this is a fairly robust interface. But to call, say, some script from C++ via fork()/exec() or system() is prone to error (script not there, no permissions, wrong permissions, script corrupt, can't find interpreter because environment not set up, etc, etc, etc, etc) and IMHO flimsy.

@chwsks

I'm pretty sure you were referring to me, right? I wasn't very clear on what my rules for using multiple languages are. For me it all depends on the size and complexity of the job, but more importantly the nature of what it is my program is going to be doing. If the project is huge and can (or should) be broken up into smaller parts, there is a good chance another language would be better suited for one of the smaller parts than a general purpose language like any of the big 4 (C/C++, Java, C#, Objective-C) would be. If there are things that would make more sense to be scripted I'll implement an interpreter for which ever scripting language I feel like embedding in the general purpose language I use for the main program. (thus avoiding the issue with invoking a script using system calls). A lot of the time with my larger projects it would make more sense to use a functional programming language for a large portion of the modules that go into it, though I didn't realize this until very recently...

My philosophy in code is to use what ever best suits the task. But my over all rule of thumb when mixing languages is to never mix two or more of the same type. (e.g. never mix C/C++ and Java, or Python and Perl, or Haskell and Lisp)
Depending on where you come from, if you are a manager, your concern will be more on maintenance aspects. If a program is break down into different programming languages and that developer left, the manager may have a hard time trying to find someone well-versed in multiple programming languages to do future maintenance of the program.

But from the developer point of view, we want to get the job done in the fastest time and run fast enough to serve the business users isn't it? Business users do not care what programming language is used underneath, all they want is a usable program that is fast and accurate and serve their business needs.

So conclusion, depend which position you are, you hold different view isn't it ?
I'm currently both positions, except none of what I do or will do is targeted at business users. I'm going in to CS research. A tough field to say the least, but dammit I will live that adolescence dream.

CS research


Depend on your country government attitude towards "research". We all know research need a lot of funds and time but it is also possible nothing fruitful turn up after a long period due to various reason e.g current technology limitation, material not found yet etc. So during that period, how to justify the funds injected into it? Already we have seen some expensive US military-related projects that have been "talked down" on the taxpayers funds going down the "drain".

"Research" this word is a highly debatable topic. We need them to improve our lives but yet how long are we willing to wait and "sponsor" it's growth, isn't it ?
never mix C/C++ and Java
Hm, however, it would make sense in some situations. For example, suppose you have a basic framework in C++ and you want to let the user specify part of the program's behavior. You need the user's code to run as fast as possible and as dynamic modules, but without forcing them to compile DLLs. In that case, the sensible thing to do would be to embed a JIT-compiled language.
If the example sounds too far-fetched, game engines do something like this for gameplay programming.
Last edited on
Aren't most games (except Source engine games) written in Python or Lua (with a C++ game engine) or something like that?

I would say language mixing is alright, but I wouldn't mix more than two languages. The GNU website actually recommends it; it suggests that you create a scripting language for your program and write part of it in that language (to make it easily customisable I guess). I'd also stick to languages that interface well; like C/C++ and Python, where you can compile the Python interpreter into your program.

@jsmith,
Would you approve of a program that consists of several executables? I was writing a scripting engine for GTA IV (I stopped writing it when I realised there was already an existing scripting engine (which works in a really smart way and supports Lua which I'm now going to learn so I can write my own scripts); I'm considering starting it again since that engine doesn't work with the newest version of GTA IV) which originally consisted of four executables and a DLL file - a main client, an injector program, a script editor, program that kept track of running scripts, and a DLL file that would be injected into the game to run the scripts
Last edited on
If you want to have a little fun, try mixing a Python interpreter with graphics code, or just anything that will run many times per second.

Most games complex enough to use a game engine are written in some scripting language (may be Lua, may be a custom language) which gets compiled either to bytecode or native code. Second Life is an example of the latter. It uses C# as the scripting language.
I assumed the code was compiled to bytecode already or when the game engine was launched.

Edit: actually, compiling to bytecode doesn't make Python scripts any faster (since the interpreter does that as soon as the script is loaded anyway); running pre-compiled scripts just makes loading it faster (compilation is already done).
Last edited on
I have a library of headers I've written composed of various classes that I use constantly and are implemented how I think they should be implemented. My most recent addition was a derived class from plugin system. my base class for module handling is designed for dynamic libraries written in c++ exclusively. but as it would be ideal to allow scripting i added a derived template class that lets me use various scripting languages, with an api wrapper class that inherits from my script interpretting base class as the templated type.

the point of me saying all this is just to share a situation when language mixing is ideal.. well that and to talk about what I've been up to :P
xander337 wrote:
talk about what I've been up to

I'm writing a Gtk+ widget to play videos with libAV.

(quick, make this relevant)
Uhh... uh... and I wrote a Makefile which isn't in C so that's language mixing
(damnit)
closed account (1yR4jE8b)
I like JVM and .NET languages because they can all integrate and communicate fairly seamlessly without any kind of fork()/exec() nonsense, and still gives you the flexibility to use a certain language for a certain task.
That too is a major bonus in my eyes.
That is also one of the major reason why Java is used heavily in a lot of business applications as the language integrate quite well with most common business needs like email,pdf read-write/, office documents,zip etc.

You can still do it in C++ but their standard lack the API for such business-oriented tasks. So you need to write your own or source for other Open Source C++ libraries and include into your program. A rather time-consuming affair IMO.
Topic archived. No new replies allowed.