开发者

Alternative to Java

开发者 https://www.devze.com 2022-12-11 05:30 出处:网络
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,

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, becau开发者_运维百科se 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


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!


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.


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


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


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.


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.


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.


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.


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


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(VS.80).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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消