What language to use for most comatibility

Posted on 2003-10-27
Last Modified: 2010-04-17

(2 part question)
- I am planning to write an interpreter. Anyone know of any good books on the topic?

- Now the 2 langages I'm considering are C++ and Java

The reason for choosing C++ is Borlands new C++ Builder which can compile the code for windows, Linux and Solaris.

The reason for choosing Java is because Java can be executed on Windows, Unix, Apple and most probably Linux also.

Up till now I have been using Visual studio to design software using C++, but the key elements of this project need to be compatibility accross platforms and SPEED.

Can anyone give me an insight to what code executes faster C++ or Java or is there another langage I should consider when thinking of speed?

Also what Language and Development environment should I use to capitalize on the most possible cross platform compatibility?

I was even thinking C code for a while because it can be embedded (But is it worth the complexity). To use such a low level langauge.

Question by:auk_ie

Accepted Solution

jcwlc earned 125 total points
Comment Utility
C is not a low level language and C++ is basically a superset of C and gives it an OO flavour. Java was originally intended for web development and removes many of the difficult concepts in C/C++ that programmers had trouble with, namely pointer notation. Java is also 'more' OO by design.

However, any 'engine' type code, such as your interpreter or number crunching or string processing or graphic or io manipulation is handled far better in C/C++. You are much 'closer' to the machine level and can exercise more control over memory and other system resources. Java makes your memory management life easier, but comes at a performance cost.

For best speed, flexibility and performance go C/C++ and stick to ANSI if you want it to run on platforms other than win32.

Also, You could split your program and use both technologies... C/C++ for the intensive processing part, java for the user interface driven parts. Use JNI to get them to talk.


Assisted Solution

harris_c earned 125 total points
Comment Utility
Check this out:   Comparison b/w C, C++, D, Java and C#


Assisted Solution

marcin1 earned 125 total points
Comment Utility
jcwlc is right, Java is not good for this project. Java was designed to write portable applications, which can be run on PC, mainfames, and mobile phone.

The main difference is that C/C++ programs are compiled directly to the low-level machine code, which makes it fast, but machine dependent. Java is compiled to the platform independent intermediate language, which can be run on anything that has the virtual java machine. That unfortunately affects speed of application.

The point is that you don't want the application itself to be used on different platform, you want only to port the code, so you don't need the features of Java.
LVL 22

Assisted Solution

cookre earned 125 total points
Comment Utility
Bear in mind, however, there's speed and there's speed.  

Unless your scripts are expected to be long ones with palpable run times, what does it matter if the C version runs in barely two seconds where the Java one runs nearly 3 seconds?  In a case such as that, I would opt for ease of mantenance - in particular if you expect your scripting language to grow.

Note further that if your scripting language is fairly simple, the bulk of the time won't be spent parsing, it will be spent executing the parsed commands, in which the lion's share of the heavy work will be done by API calls into the same DLLs, regardless of which language was used.

Author Comment

Comment Utility
OK, so C++ seems to be a winner, But Java did come close behind (speed is essential for me). Ofcourse by using C++ I loose the amount of compatibility I had when using Java. I mean The virtual java machine can run on anything (Apple, Windows, Unix etc.). But The Borland Compiler C++ Builder only compiles for Windows, Linux and Solaris. Does anyone know how I can easily port the code over to Unix and Apple as well.

I'm asking cause so far I only have experience programming Windows 9X, NT, 2K and XP using visual studio. So I want to buy correctly if I want to develop for these new softwares.

I am surprised nobody mentioned C sharp. Some say this will replace C++. And that it is operating system independant. However it does require, Does anyone know what operating systems the dot net framework is available for?

Nobody mentioned anything about a book on the topic of interpreters neither?


Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now