Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is it possible to do GPU programming in Java ?
I mean without using native libraries.
And how much of a performance improvement can one expect when we switch over to gpu's ?
Edit:
I am not looking at game programming, I want to do hard core number crunching.
Yes. Java3D, LWJGL and JOGL support GLSL (OpenGL Shading Language).
Edit:
You can use OpenCL if you want to do platform-neutral, general-purpose computation on GPUs. This framework lets you write code that treats all processing units identically, despite wildly varying feature sets and execution environments. Though, this is very low level programming compared with Java.
It seems your ideal would be a JVM written with OpenCL support. Searching online, I found a little bit of interest in the idea but no evidence of any major backing.
how much of a performance improvement can one expect
That depends on the system you're running on and what sort of data you're processing (Matrix and vector math is extremely efficient on GPUs). You'd likely get some major gains on a system like mine with two powerful GPUs and a modest single-core CPU. However on a computer with a modest GPU and a quad-core CPU, the performance gains might have a hard time overcoming the overhead.
Rootbeer1 has just been released on github: https://github.com/pcpratts/rootbeer1
With Rootbeer you can program using almost any Java except the following:
native methods and fields
reflection
dynamic method invocation
garbage collection
sleeping inside a monitor
This means you can use arbitrary object graphs with composite types.
If you are still considering hard core number crunching in Java on GPU without using native libraries, you might be interested by this blog article http://ateji.blogspot.com/2011/02/java-on-gpu-with-ateji-px.html
We (I am part of the Ateji team) have seen performance of up to 60x so far on Java applications that can be massively parallelized.
def check out rootbeer1, but you need to make sure you have a CUDA accepted GFX card first before you start on it and have done all of the NVIDIA setup etc
download Link:
google CUDA download
getting started guide
http://developer.download.nvidia.com/compute/DevZone/docs/html/C/doc/CUDA_C_Getting_Started_Windows.pdf
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have recently learned some basic Java and was thinking of seeing if I can use these new skills for an embedded computing project.
I have been looking around but I can't seem to be able to find any microcontrollers that are capable of running Java.
Does such a thing even exist?
Because of Java virtual machine architecture, you need considerable resources just to run the JVM. The path of least resistance to getting an JVM is probably to run an OS on the target that already supports it such as Linux, but that itself requires relatively huge resources.
There are a few stand-alone JVMs that either work bare-metal or integrate with and embedded RTOS for threading support. I compiled a list a while ago in an answer to a similar question, but some of the links are now out of date.
Running Java on an embedded system will certainly hit performance, and is probably not suited to hard real-time applications without a great deal of care.
Microcontrollers are not made for this use. Controllers called "mini computers" can embed JAVA applications (Raspberry PI, BeagleBone, Intel Edison, etc, because they embed an OS, and so can use JRE).
For microcontrollers, C/C++ are really better and more reliable.
Microcontrollers are meant for real low level - they normally don't have much functionality and won't have enough memory/processor speed to run JAVA.
Most entry level microcontrollers use C/C++ and maybe even their own variant of it.
Arduino/Atmega uses Haiku VM to run java. Using the haiku VM you can compile your JAVA code into C - and this will be programmed into Arduino. This makes debugging a little difficult, but it's not that bad - and hey, a high level language like JAVA cuts down your coding time a lot. Issue with this is normally your memory will get over soon, and you cant write huge pieces of code.
PIC - Muvium claimed support for PIC, but they stopped supporting it after a while and have closed down now. I don't think PIC has JAVA support for now.
Renesas is another popular microcontroller provider which has it's own SDK called MicroEJ for java o n RX and RZ boards of theirs. I've never used it, but their boards boast more RAM and flash memory - which helps a lot.
Single board computers (basically, a microcontroller/processor which is more powerful + has more peripherals) is useful when using JAVA for embedded programming. The two most popular ones are Beagle bone and Raspberry Pi. These are basically computers on a chip - and can run a full fledged ARM Ubuntu + Java/Python/any other language.
The easiest to use is Raspberry Pi (in my opinion) - which has huge community support.
Recently I started working on a CM12001/1000000 board that runs Java. It contains two controllers on the same board. Currently I do not have much knowledge of this thing. I will update the answer as soon as I get more info.
To answer your question: Yes, such a thing exists, but it is quite rare. Python however is gaining popularity in the embedded field recently using MicroPython, that includes a small subset of the Python 3 standard library and is optimized to run on micro-controllers.
Edit: ATOP Modules from Telit provide such functionality. Generally they have good amount of both RAM and Flash(A few MB to a few hundred MB). They run Linux over which they load JVM (as pointed by Clifford). Telit provides Java APIs to so control stuffs like GPIO (though very limited) and do stuffs like serial communications, GPS, GSM control etc.
Yes, microcontrollers that are capable of running Java on the bare metal exist
But JVM on this microcontrollers optimized for speed, and low memory usage. It's mean optimized JVM have some limitation instead of regular JVM, it's like Python and MicroPython
But pure code on Java allow you to transfer code with ease from the desktop to a microcontroller or embedded system
For self education with embedded computing project you can try to use Javaino
allow execute Java programs on this development board, read data from sensors via i2c, UART, etc like Arduino
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm building Rest webservice and I would like to have the best performance. I was thinking about using Scala. I read in some sources that it's faster than java. Is there any way to achieve better performance mixing java & Scala, when my project use maven? I found maven-scala-plugin but still don't know what is an influence on performance.
Java and Scala both compile to the same bytecode; more-or-less anything you can do in one you can do in the other. What is true is that sometimes Scala makes it more practical to do the things that performance requires, e.g. async I/O is much easier to work with in Scala, and #specialized can autogenerate implementations of generic code for primitive types, which would have to be done manually in Java. IIRC scala libraries spray and unfiltered placed highly in the techempower benchmarks before they were removed.
But those benchmarks are about theoretical performance limits you are unlikely to ever reach. In practice it's highly unlikely that you can afford the optimization effort it would take to achieve those levels of performance. "I want the best performance" is unlikely to be your real requirement. Would you spend 10x as long developing in order to have 1% better performance? If you really do need that kind of absurd level of performance, you should be able to run your own benchmarks on the scale of the techempower ones; it's a lot of work, but it's peanuts compared to the amount of work you need for "best performance" in a real program.
In more realistic scenarios, any language implementation that supports asynchronous i/o (assuming a typical REST workload here) and doesn't actively slow everything down by being full of hashtable lookups (i.e. python or ruby) is likely to be more than fast enough. Maybe you need parallelism (though I doubt it), but fortunately the JVM has that. You are extraordinarily unlikely to be working at the level where the difference between Scala and Java makes a difference, as long as you use a sensible framework (i.e. an async one) in either language.
And as always, the key to performance, far more than technology choices, is to measure and experiment. Profile, automatedly; look for bottlenecks, address them and measure whether your solutions worked. In any realistic codebase a few minutes profiling will produce a much greater speedup than any possible difference between Java and Scala.
You need to define performance. A good way to define is to by using specific scenarios.
For example -
99% of my REST request to complete within 1 seconds
the REST service should provide results for 1000 concurrent clients within 2 seconds on a WAN network
Once you have an idea of this you need to design/architect your system. Performance depends on a lot of factors
overall structure of your system
data structures and algorithms used
latency and bandwidth of your network
available resources (memory, CPU and storage type)
frameworks and libraries used
databases
other qualities in your system (for example, security will degrade performance)
...
...
HTH
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Why are there no "High Graphics 3D games" made with Java on the market? Isn't Java a good option? And why so? The only big game i've seen is basically Minecraft, and there can't be a large amount of polygons and lighting/physics-engines in that one. Still a relatively good pc is needed? There are games incredibly more graphics heavy than Minecraft and stills runs faster. I suppose Java "wastes" resources. Anyway, the question is: Is it possible to make good graphics application with Java, or why not.
The game development world is a funny one: On one hand, they're often
quick to accept new ideas, on the other hand, they're still in the
stone age.
The truth is, there's rarely that much incentive in switching to
.NET/Java/anything other than C/C++.
Most game companies license parts of the game engine from other
companies. These parts are written in C++, and although you might have
access to the source so you could port it, that takes a lot of effort
(and of course, the license needs to allow it).
Also, a lot of legacy code already exists in C++. If code from
previous projects can be reused (say, if you're writing a sequel),
that counts even more in favor of sticking with the same language,
instead of rewriting it in a new language (more so since you'll likely
reintroduce a ton of bugs which you'll need to spend time ironing out.
Finally, it's rare for games to be written in 100% C++ anyway - a lot
is done using scripting languages, whether they're custom or just
integrating an existing languages (Lua being one of the more popular
ones these days).
As far as garbage collection is concerned, that can be a bit of a
problem. The problem is not so much that it exists, it's more how it
works - the garbage collector MUST be non-blocking (or at least be
guaranteed to only block very briefly), since it's simply unacceptable
to have the game freeze for 10 seconds while it scans all the
allocated memory to see what can be freed. I know Java tends to choke
quite a bit in GC'ing when it's close to running out of memory (and
for some games out there, it will).
You're also a bit more restricted in what you can do: you can't fully
exploit the hardware due to the overhead of the runtime. Imagine
Crysis being written in Java... even if that's the only visible
difference, it just wouldn't be the same (I'm also pretty sure you'd
need a Core i7 to run it.).
This doesn't mean these languages don't have their place in game
development - and no, I'm not just referring to tool programming. For
most games, you don't need that extra bit of performance you get from
C++, including 3D games, and if you're writing it all from scratch, it
can make perfect sense to use something like XNA - in fact, there's a
good chance it will.
As far as commercial games are concerned - does RuneScape count?
That may well be the most succesful Java game out there.
Source: Why are only a few video games written in Java?
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have zero experience building website with Java. Recently I need to develop complex web application.
Currently I'm converting PHP apps to get it works in PHP 5.4. With modern website requirement, PHP application needs better frameworking from start. Use Zend framework or Drupal 7 looks good move.
But Zend or Drupal 7 comes with a price. 300MB VPS seems not relevant anymore for an average PHP website. In this case, Resource usage rate is very important to me.
Because lots of complex web application is built with Java web framework, I just wonder how high is Java resource usage (memory & CPU) compared with PHP 5.4?
I hope it will be same or even better, so that I have more choice.
This should provide some info about resource and cpu usage of both languages
Basically, based in that series of test (and until this date) Java memory consumption is in average bigger than PHP, but execution time tends to be faster
Overall memory usage will depend much more upon what frameworks you use and how well you code your application than whether you write it in PHP or Java. The baseline memory cost of both is small enough that you can ignore it on modern machines, so it is the application that matters.
In terms of CPU usage, Java will ultimately perform much better since it is JIT-compiled to native code and has an efficient statically typed in-memory object representation (This benchmark shows Java as over 25x than PHP on a set of benchmark programs)
Having said that, either would be probably be fine for most normal web applications. My advice would be:
Given you are familiar with PHP you may want to stick with it simply because the learning curve of picking up a new language and associated frameworks is significant.
If you are serious about developing a robust, high performance enterprise-grade application then it would certainly be worth learning and using Java. But you have to be sure that you are prepared to face a big learning curve.
Some interesting links:
JVM memory usage for selected application servers - shows a baseline memory overhead in the range of 25-100mb for some common Java application servers
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm soon to start on a new project where I am going to do lots of text processing tasks like searching, categorization/classifying, clustering, and so on.
There's going to be a huge amount of documents that need to be processed; probably millions of documents. After the initial processing, it also has to be able to be updated daily with multiple new documents.
Can I use Python to do this, or is Python too slow? Is it best to use Java?
If possible, I would prefer Python since that's what I have been using lately. Plus, I would finish the coding part much faster. But it all depends on Python's speed. I have used Python for some small scale text processing tasks with only a couple of thousand documents, but I am not sure how well it scales up.
Both are good. Java has a lot of steam going into text processing. Stanford's text processing system, OpenNLP, UIMA, and GATE seem to be the big players (I know I am missing some). You can literally run the StanfordNLP module on a large corpus after a few minutes of playing with it. But, it has major memory requirements (3 GB or so when I was using it).
NLTK, Gensim, Pattern, and many other Python modules are very good at text processing. Their memory usage and performance are very reasonable.
Python scales up because text processing is a very easily scalable problem. You can use multiprocessing very easily when parsing/tagging/chunking/extracting documents. Once your get your text into any sort of feature vector, then you can use numpy arrays, and we all know how great numpy is...
I learned with NLTK, and Python has helped me greatly in reducing development time, so I opine that you give that a shot first. They have a very helpful mailing list as well, which I suggest you join.
If you have custom scripts, you might want to check out how well they perform with PyPy.
It's very difficult to answer questions like this without trying. So why don't you
Figure out what would be a difficult operation
Implement that (and I mean the simplest, quickest hack that you can make work)
Run it with a lot of data, and see how long it takes
Figure out if it's too slow
I've done this in the past and it's really the way to see if something performs well enough for something.
Just write it, the biggest flaw in programming people have is premature optimization. Work on a project, write it out and get it working. Then go back and fix the bugs and ensure that its optimized. There are going to be a number of people harping on about speed of x vs y and y is better than x but at the end of a day its just a language. Its not what a language is but how it does it.
it's not language you have to evaluate, but frameworks and app servers for clustering, data storage/retrieval etc available for the language.
you can use jython and use all the java enterprise technologies for high load system and do text parsing with python.