Java (OpenJDK)

I mentioned in these groups several years ago that trying to port Java to Haiku was putting too much energy into something that wouldn’t yield any great long-term benefits. Java may be good for enterprise back-end progrmming but it has a very poor track record for GUI app development. You can see now how this effort is treading water and will likely just fade away.

It makes far more common sense to have a complete Mono port. Someone ported monolite to Haiku about a year ago which was accepted into the main baseline. That’s a good start.

Writing C++ programs are so error-prone over writing in C# were you can be at least one order of magnitude more productive in your app creation time plus you get a nice development environment with MonoDevelop for free with a full Mono port. You really do have to consider that C++ was the cutting edge when the BeOS came to market. That time is over. .Net apps can access so many powerful libraries in enough interoperable languages to please virtually anyone.

The core Haiku developers should wake up and realize this:

You will get more application developers targeting Haiku if you A) achieve a full Mono port and B) write a P/Invoke layer over the Haiku core C++ library set. Otherwise, I think all you have is a super nitched hacker’s platform which can’t attract enough mainstream developers.

P.S. A 2 gig blank virtual disk isn’t enough space. This project should offer pre-made 10, 20 and 30 gig downloadable virtual drives. Putting the onus on “drive-by programmers” (such as myself) is a real turn-off. Make it easy and inviting to load up the Alpha release and add an extra drive that’s roomy enough to try and port large pre-existing software packages onto.

I’m anything but not a java fan. It’s true that c++ is not as productive as c# for example, but that’s not that much because of c++. You must notice that c++0x has also a lot of features that java also has. I think in most cases c++ is not that productive because we dont have a good IDE. If you take a look at the toolkit “ultimate++”, you will notice that with few c++ lines of code you can creat also a lot of things just using c++.

What i like even more than c++ is “d programming language” (version 2.0) , it’s like c++ a system language but it has a lot of nice features that make programming much easier and safer.
I read a good part of the book written by Andrei Alexandrescu related to D programming. And I really love it. Alexandrescu is a very famous c++ guru which is/was praised by big names from the c++ area, but he is now actively working on the development of D, because he has a clear vision that D has a great future.

It may be true that Java/c# could bring a lot of programs, but at the moment i dont remember one single program written in java/c# that i would love to have on haiku.

I would like to have Calibre, which is written mostly in python.

I was going to resist, but I have to put my 2.04 (adjusted for inflation) cents in. I am a professional software engineer (have been since the early 90s).

Anybody claiming language a is better than language b probably shouldn’t be making any claims :slight_smile: Every language (even java :slight_smile: ) has its pros and cons. C# may allow rapid prototyping, but is horrid in performance/resource usage and bug tracing. Wrap in native code and you have a disaster. I know this from first hand knowledge as I had to try to fix a project that ported a working C++ app to C# and has gone horribly wrong. It is not that C# is bad, just that it was totally the wrong solution. Now before all the MS guys jump on me, I’ll say again that C# has its place - in rapid prototyping and non performance/system related projects. It is great for rapidly trying guis for example.

C++ is much harder to write the same functionality, however it is much more robust, significantly faster, and has a smaller footprint. C is even faster/smaller, but at an even longer (read harder) development, because even less is done for you.

Haiku, for me, is all about fast apps with sensible preferences. Compare BeZilla and WebPositive. One native, one ported. The ported one has far more functionality, but is slow and cumbersome in comparison. Java/python/mono etc. would add the ability to run other apps on haiku, however you might as well just use linux, or even worse MS :slight_smile:

I’d personally prefer to have the OS working 100% rather than a plethora of pretty python/java/mono based config apps which slow the system down. After R1, then sure, lets add more toys.

Last little example - lets build a racing car. We could design it, get every part custom made and individually assembled. Takes a long time, but goes like the clappers. Alternatively, we could pick standard component from a “library” and have a car up and running in no time. Wheels from a mazda, chassis of a range rover, body of a beetle, engine from a ford, gearbox from a merc. I know which I would like to drive :slight_smile:

Cheers,
Vader
PS. sorry about the long rant…

Long rant, but good rant.

I can’t speak for the Haiku team, but it seems they’re in the throes of getting out the MVP to rapidly iterate on the road to beta. I don’t think anybody is saying Haiku needs to write parts of the core OS in [insert non-C language here], which is silly.

Language bindings and separate runtimes create a few more avenues for developing applications. Should somebody come along and write a better app with (well written) C, C++, Ada, Haskell or assembly, even better! Nonetheless, the main API is still C++, and unless somebody comes along and does a darn good port of the (terrrrrrible) Swing libraries for Java, or the GSoC language bindings port for Perl or Python pans out, the only way to make quality apps that take advantage of the Haiku frameworks and UI will continue to be C++. That won’t change, unless the developers decide to go API wrapper-crazy. :slight_smile:

Though this is an interesting discussion, it takes away from the focus of getting to R1. If the developer who started this topic wants to attempt to work on a port of OpenJDK, I don’t see any reason to turn them down. Not because I want to see JVM or even the C# CLR on Haiku right now; if it’s a project they’d personally love to work on, hack away!

However, Haiku’s #1 priority right now is shipping, in a stable state. As fun as it is to talk about new features, if this isn’t someone’s labor of love that won’t get in the way of R1, or a GSoC project, Alpha 3’s on the horizon, and there’s going to be a series of beta releases before Haiku’s ready for everyday usage.

The best contribution any dev can make right now would be to make sure Haiku’s foundations are solid. Depending on how my work schedule looks after June, I’ll see if I can knock off a few low hanging fruits and lend a hand.

Looks like Andrew made a commit to the openjdk repository back in March, so he is still working on it. I would contact him directly. He’s a great guy … helped me and others with the original Java port to BeOS way way way back when.

http://mail.openjdk.java.net/pipermail/haiku-port-dev/2011-March/000085.html

Wholeheartedly agree. Let’s get the stuff that BeOS was going to deliver done right. We’re not in a race except to stay relevant. I’m not sure adding Java now will help the relevancy thing, except last I checked it was the most widely used programming language in the world : nothing to sneeze at.

Furthermore, as someone who has an interest in dynamic and functional languages, many of the more compelling implementations that develop rapidly are hosted in the JVM. While many folks here rightfully gripe at Java, the JVM is one of the most compelling places where new languages and features are going right now. The JVM is very, very fast, too. It can allocate memory about 10x faster than C/C++ can with new and delete. You could beat the JVM with your own implementation of memory management in C/C++, but right out of the gate the JVM can beat C++ on many fronts speedwise. It cannot, however, support the kind optimization you can do in C/C++, but getting there is another matter.

Java may be dead, but the JVM is here to stay. It might help Haiku to have a JVM.

I know exactly how you feel ti.teg.tnod.I
I’ve been following the development of Haiku from the beginning with my retail BeOS3-box on my desk :slight_smile:

The only thing missing for me is also Java (JDK, OpenJDK) so i can try to start doing my normal daily stuff on Haiku (Yes, java development, but java is very much alive - but not on the desktop, with eclipse and netbeans as an exception). So discussing here about “java is bad, good etc…” is not relevant, since the development is not for Haiku, but on Haiku.

The discussion here about Java is more like someone requesting a port of ‘The Gimp’ and saying he may not use it because there is already ‘wonder brush’ so he must start learning that instead of using his own old tools.

I asked Andrew Bachman about the JDK port:

There are still some hangups to getting the first bootstrap build
going. It would be really helpful if someone could figure out the
issues between haiku and gcc such that gcc could be built with the
java support, so we could use it for bootstrapping.

Andrew

So the first hangup seems to be getting OpenJDK to correctly build on Haiku with GCC. But GCC is newer now, so would someone like to get it compiled?

As someone who has worked with, and who continues to work with C, C++, C# and Java, I question the claim that managed languages are slower.

The Hotspot JVM is a compiler. Like every compiler, it has strengths and weaknesses. 100 million JPEG inverse DCTs take 8.5 seconds in optimized GCC, but 18.5 seconds in Java, because GCC makes heavy use of SIMD, while Hotspot currently uses SSE registers only for one value at a time. By comparison, I’ve seen an audio codec, ported from C to Java, be 3-4 times faster in Java, because Hotspot is brilliant at method inlining and it does inter-procedural optimizations that most C compilers still do not do. Also JVMs can do biased locking, adaptive spinning, escape analysis, and other things that AOT copilers with their statically generated code cannot.

LLVM might be able to eventually bring some of those optimizations to JITed C/C++, but they have it much harder, since pointers make correct compiler optimizations very hard. And just like writing C turned out to mostly outperform hand-written assembly, higher level languages will eventually outperform C - and already are getting competitive.

As for the alleged lack of applications in Java someone mentioned, uhm, it is only the leading language on Sourceforge.

By excluding Java from Haiku, you’re not just excluding significant applications and developers, but an entire platform, something a small project really shouldn’t be doing.

1 Like

Its a sucky platform :stuck_out_tongue: while execution speed may be comparable for longer running programs java programs lack the responsivness and lightweightness due to the requirement of a usually heavy VM and especially heavy in the case of OpenJDK VM.

That aside who really cares as long as it says merely optional and I am sure it will. Java isn’t so bad for some things I actually used it in a digital signal processing class recently oddly enough and it was much better than Matlab for our use case.

I will say one thing though Java is alot more fun if you have a decent autocompleting IDE…and if you are doing graphical programs a layout system like netbeans.

Mega-LOL: MATLAB makes heavy use of Java internally :-).

1 Like

How is the above statement (excerpt from the post) judged by haiku developers and haiku ‘users’ today?

Things have changed since 9 years ago. Java JDKs from 8 to 13 are already included as third-party packages on HaikuPorts.

Also with some significant applications running on it: Java & Python IDE packages

1 Like

@return_0e Thank you for your reply!

A long time ago there was a “Haiku apps repository” from Michel Clasquin-Johnson with very interesting and (at that time) executable Java software.
Since then I have been keeping an eye on “Ancestris” for Windows (https://www.ancestris.org/index.html , not to be confused with Ancestry).
It was available as version 0.9 (more like 9.x) in the professor’s repository.
I reported about this to Frédéric Lapeyre (President Ancestris Team) and shortly afterwards I found Haiku (albeit incorrectly) under ‘Download Linux’ as an OS + link to the repository of Prof. Clasquin-Johnson.
But that was a flash in the pan, because not long afterwards Ancestris could no longer start under Haiku. Most Java software doesn’t either. What a shame!

mmu_man

That’s also why we ask people to write recipes. A script can be rerun by someone else, modified, fixed…
Experience is much harder to transmit. It doesn’t mean the time spent by people is not appreciated, it’s just that it is more efficient to transmit written stuff.

And it’s totally possible to use haikuporter to repackage binaries btw…
<<<

Aaahh, so the professor ‘failed’ to write recipes !?
Despite the availability of OpenJDK + NetBeans for Haiku, the software still has to be ‘rebuilt’ in order to be able to use it with Haiku … this is probably even necessary ‘within’ the different Linux distributions …

No. If the java app is distributed as a JAR package,you only need to open a Terminal and type:
java -jar <filename>

That command could be included in a simple .sh script, and then running the app by doing double click on it.

1 Like

un_spacyar
Thank you for your answer!

Unfortunately it doesn’t help me, not even Haiku + JAVA and neither do the answers at Ancestris!
I am primarily a user. All answers received so far, no matter where and from whom, are unfortunately written in such a way that I could only use them if I am a freak or at least an ‘insider’.

It is probably better if I continue to use my old (also an older version) software (sometimes with serious errors, including data loss, but simply brilliant) under Windows.
I would have preferred to use Ancestris via haiku, but there are more important things in life!

One last try. Even if I’m annoying …

Zurga from the Ancestris team gave me the following answer to my answer, which was similar to the previous post.
Are there any similarities or derivations?

OK, I will try to be less technic.

First install Java for Haiku. Prefer OpenJdk 11 rather than 13. (Long term support involved, but technic part).
Then download the zip file with all Ancestris distribution. (generic linux file or v11 package).
Unzip the content of Ancestris zip file in a directory.
In a command line console, go to bin directory inside ancestris directory.
Type ./ancestris

What happens ?

The basic launch installation is there : https://docs.ancestris.org/books/user-guide/page/install-and-start-ancestris#bkmrk-start-ancestris

Zurga

I installed openjdk11 from HaikuDepot, which also installed openjdk11_jre. However, ‘java’ could not be found until I also installed openjdk11_default.

Running ./ancentris resulted in… “an illegal reflective access by org.netbeans”

So, probably not very helpful to you but it does try to do something.

Update:
Using JDK8, I got the Ancestris splash screen, and then it crashed.

1 Like

This is from the java debug report that got saved, if it helps anybody.
Frame IP Function Name
-----------------------------------------------
00000000 0x15bbe5af072 _kern_snooze_etc + 0xa
Disassembly:
_kern_snooze_etc:
0x0000015bbe5af068: 4989ca mov %rcx, %r10
0x0000015bbe5af06b: 48c7c0bb000000 mov $0xbb, %rax
0x0000015bbe5af072: 0f05 syscall <–

	0x7ffdba6c8d20	0x15bbe630ce7	clock_nanosleep + 0x67 
	0x7ffdba6c8d40	0x15bbe632493	nanosleep + 0x13 
	0x7ffdba6c8d50	0x1af14933478	/boot/system/lib/openjdk11/lib/server/libjvm.so + 0xb47478 
	0x7ffdba6c8f10	0x1af149e4c02	/boot/system/lib/openjdk11/lib/server/libjvm.so + 0xbf8c02 
	0x7ffdba6c90c0	0x1af14b277f3	/boot/system/lib/openjdk11/lib/server/libjvm.so + 0xd3b7f3 
	0x7ffdba6c9130	0x1af14b27af3	/boot/system/lib/openjdk11/lib/server/libjvm.so + 0xd3baf3 
	0x7ffdba6c91b0	0x1af14ac12b4	/boot/system/lib/openjdk11/lib/server/libjvm.so + 0xcd52b4 
	0x7ffdba6c91f0	0x1af1493512e	/boot/system/lib/openjdk11/lib/server/libjvm.so + 0xb4912e 
	0x7ffdba6c9220	0x15bbe5bea05	pthread_thread_entry(void*, void*) + 0x15 
	00000000	0x7ffffe5ec260	commpage_thread_exit + 0
1 Like