views:

471

answers:

11

I need an alternative to Java, because I am working on a genetics-calculation project. It takes a lot of memory and the most of the cpu time. And therefore it won´t work when I deploy it on a server, because many people use the program at the same time.

Does anybody know another language that is not running in a virtual machine and is similar to Java (object-oriented, using exceptions and type-safety)?

Best regards,

Jonathan

+6  A: 

You may try C++, it satisfies all your requirements.

Murali VP
You may also try the new Go language from Google, if you don't want to deal with garbage collection.
Murali VP
+9  A: 

If you don't like C++, you might consider D, ObjectiveC or the new Go language from google.

ammoQ
That is a good idea, because I don´t like c++.
Jonathan Frank
If you are currently developing in Java, and you say that you don't like C++, then you're certainly more concerned about code simplicity and maintainability than in performance or memory footprint...
Simón
Even if you don't like it, you may want to rethink, given C++'s history, popularity and adoption among compiled programming languages, you are likely to get better support.
Murali VP
I wouldn't bet on "Go" at this stage. It is too immature. Wait a couple of years and see how it pans out.
Stephen C
+22  A: 

To answer the direct question: there are dozens of languages that fit your explicit requirements. AmmoQ listed a few; Wikipedia has many more.

And I think that you'll be disappointed with every one of them.

Despite what Java haters want you to think, Java's performance is not much different than any other compiled language. Just changing languages won't improve performance much.

You'll probably do better by getting a profiler, and looking at the algorithms that you used.

Good luck!

Chip Uni
I completely agree... unless you know for sure that the code / algorithms are not the issue, you will just move a bottleneck in Java to a bottle neck in the new language.
mpeterson
Unfortunately, I don't think that the OP is listening ... :-(
Stephen C
+5  A: 

Use Python along with numpy, scipy and matplotlib packages. numpy is a Python package which has all the number crunching code implemented in C. Hence runtime performance (bcoz of Python Virtual Machine) won't be an issue.

If you want compiled, statically typed language only, have a look at Haskell.

Shailesh Kumar
Python runs in a virtual machine.Haskell is not object-oriented.(Though both are excellent languages!)
Chip Uni
Curiosly enough, I've read a paper a while ago in a computer science journal about OOHaskell, I believe this is the same paper: http://homepages.cwi.nl/~ralf/OOHaskell/
DrJokepu
Oooooh. Very cool extension to Haskell!
Chip Uni
There is also ocaml for a functional language equipped with oo thingies.
Christian
A: 

Well.. I think you are looking for C#.

C# is Object Oriented and has excellent support for Generics. You can use it do write both WinForm and server-side applications.

You can read more about C# generics here: http://msdn.microsoft.com/en-us/library/ms379564%28VS.80%29.aspx

Edit: My mistake, geneTIcs, not geneRIcs. It does not change the fact C# will do the job, and using generics will reduce load significantly.

rochal
I think he said genetics not generics.
DrJokepu
But C# is not much different from Java.Just as any other .NET languange, it runs on the CLR, which is just another kind of virtual machine.
Simón
A: 

F# or ruby, or python, they are very good for calculations, and many other things
NASA uses python

Omu
If NASA uses Python, that's because having a dedicate server for a new project is not an issue for them.
Simón
Ruby and python both run in virtual machines.
Chip Uni
than i guess is D or Go from Google, or C++, but he said he doesn't like it
Omu
+10  A: 

If your apps is consuming most of the CPU and memory on a single-user workstation, I'm skeptical that translating it into some non-VM language is going to help much. With Java, you're depending on the VM for things like memory management; you're going to have to re-implement their equivalents in your non-VM language. Also, Java's memory management is pretty good. Your application probably isn't real-time sensitive, so having it pause once in a while isn't a problem. Besides, you're going to be running this on a multi-user system anyway, right?

Memory usage will have more to do with your underlying data structures and algorithms rather than something magical about the language. Unless you've got a really great memory allocator library for your chosen language, you may find you uses just as much memory (if not more) due to bugs in your program.

Since your app is compute-intensive, some other language is unlikely to make it less so, unless you insert some strategic sleep() calls throughout the code to deliberately make it yield the CPU more often. This will slow it down, but will be nicer to the other users.

Try running your app with Java's -server option. That will engage a VM designed for long-running programs and includes a JIT that will compile your Java into native code. It may make your program run a bit faster, but it will still be CPU and memory bound.

Barry Brown
+3  A: 

Can your algorithms be parallelised?

No matter what language you use you may come up against limitations at some point if you use a single process. Using something like Hadoop will mean you can retain Java and ease of use but you can run in parallel across many machines.

Fortyrunner
+3  A: 

On the same theme as @Barry Brown's answer:

If your application is compute / memory intensive in Java, it will probably be compute / memory intensive in C++ or any other "more efficient" language. You might get some extra leeway ... but you'll soon run into the same performance wall.

IMO, you need to do the following things:

  1. You need profile your application, and look for any major performance bottlenecks. You might find some real surprises.

  2. In the light of the previous step, review the design and algorithms, paying attention to space and time complexity issues. Do some research to see if someone has discovered better algorithms for doing the computations that are problematic from a performance perspective.

  3. If the previous steps don't get you ahead of the curve, see if you can upgrade your platform; get a bigger machine with more processors, more memory, etc.

  4. If you are still stuck, your only other option is a scale-out design. Assuming that individual user requests are processed in a single-threaded, re-architect your system so that you can run "workers" across multiple servers, with a load balancer on the front. If you have a persistent back-end, look into how you can replicate that. And so on.

  5. Figure out if the key algorithms can be parallelized / distributed so that the resource intensive parts of a user request execute in parallel on multiple processors / multiple servers; e.g. using a "map-reduce" framework.

OK, so there is no easy answer. But simply changing programming languages is NOT a good answer.

Stephen C
A: 

You might find the computer language shootout here interesting. For example, here's Java vs C++.

You might find Ocaml (from which F# is derived) worth a look; it meets your requirements for OO, exceptions, static types and it has a native compiler, however according to the shootout you may be trading less memory for lower speed.

timday
+1  A: 

Regardless of language your program will need to share with others when running in multiple instances on a single machine. That is simply the way computers work.

The best way to allow your current program to scale to use the available hardware resources is to chop your amount of work into small, independent pieces, and make them implement the Callable interface. These can then be executed by a suitable Executor which can then be chosen according to the available hardware. See the Executors class for many preconfigured versions. THis is what I would recommend you to do here.

If you want to switch language then Mac OS X 10.6 allows for programming in the way described above with C and ObjectiveC and if you do it properly OS X can distribute the code over all available computing resources (both CPU and GPU and what have we).

If none of the above is interesting to you, then consider one of the Grid frameworks. Terracotta may be a good place to start.

Thorbjørn Ravn Andersen