* * *

Author Topic: FP vs Java Benchmark  (Read 4893 times)

johnsson

  • New member
  • *
  • Posts: 17
  • Lazarus Rocks
Re: FP vs Java Benchmark
« Reply #15 on: December 05, 2016, 05:59:20 pm »
Just my opnion

- Java needs more memory than FP (This may be a problem or not depending of your environment)
- Almost all the time a program compiled with FP is equaly or better in speed performance
- If you trade the memory manager to cmem (You got awesome results using multithread)
- You no need support of any kind of VM to work with FP
- And for the lest but no less important I really need work with SIMD and opencl sometimes, and the way how FP works with assembly and SIMD (Except the fact there is no support to intel intrinsics) is awesome.
Just a regular guy

Jay

  • New member
  • *
  • Posts: 31
Re: FP vs Java Benchmark
« Reply #16 on: December 05, 2016, 06:19:25 pm »
Just don't expose it to the internet. Let it perform its tasks and export just the generated data afterwards.

It seems that Oracle agrees with you.  :D

https://www.wired.com/2016/01/goodbye-applets-another-cruddy-piece-of-web-tech-is-finally-going-away/

lainz

  • Hero Member
  • *****
  • Posts: 1835
  • Nace una flor, todos los días sale el sol...
    • BGRABitmap
Re: FP vs Java Benchmark
« Reply #17 on: December 05, 2016, 06:22:04 pm »
I think no one here was talking about applets, of course they're dead ::)

Thaddy

  • Hero Member
  • *****
  • Posts: 3408
Re: FP vs Java Benchmark
« Reply #18 on: December 05, 2016, 06:27:33 pm »
I think no one here was talking about applets, of course they're dead ::)

Alas, it has nothing to do with applets..... <sigh>
It has to do with vulnerabilities elsewhere e.g. the implementation of the TCP/IP stack and e.g.2. the implementation of the security protocols and e.g.3 database interfaces to MySql and Oracle..
You can shoot holes in any java application if exposed to the internet and not up-to-date. And in  a jvm5 server application it is even easy.

It is a common misconception to relate it just to java applets (which run client-side) It is about hacking a server.
See the point?

Thanks for your reply, I was not thinking on that. And why they add support to make an installer like that in NetBeans? It bundles the java runtime plus your application, you must do that for each platform. They think that you will always pack the application with the latest java?
That packaging is OK as long as the system administrator makes sure java is always up-to-date.
BTW: There are more than one JVM brand, like Openjvm, msjava, Oracle's java..
BTW2: a lot is due to bad programming, relying on "features" that are undocumented.

The current state of Java is - after years of misery - that well written java code should run after an update of the jvm.
That's because Java no longer allows multiple VM's on the same system and will uninstall any deprecated ones.
When Oracle changed their policy into that (~7) , they also started to pay more attention to compatibility.

Not that Java is bad... I actually use it a lot ( as per my example ;) ) Just make sure it is always up-to-date.

And don't expose java server applications directly to the Internet. Not even now.
« Last Edit: December 05, 2016, 06:33:57 pm by Thaddy »

lainz

  • Hero Member
  • *****
  • Posts: 1835
  • Nace una flor, todos los días sale el sol...
    • BGRABitmap
Re: FP vs Java Benchmark
« Reply #19 on: December 05, 2016, 06:34:39 pm »
I get it, so you say that I better don't expose it to internet directly, so how for example I can do a secure connection (I'm a student, never worked in a company, so your explications are really good for me). Or I must just process the data and then use another tool to connect to internet?

I tested a java application with OpenJVM under Ubuntu and it didn't work well, so I prefer to use the Oracle's one: it should run the same jar in each platform the same. I did't test the other brands.

Thaddy

  • Hero Member
  • *****
  • Posts: 3408
Re: FP vs Java Benchmark
« Reply #20 on: December 05, 2016, 06:52:31 pm »
I get it, so you say that I better don't expose it to internet directly, so how for example I can do a secure connection (I'm a student, never worked in a company, so your explications are really good for me). Or I must just process the data and then use another tool to connect to internet?

I tested a java application with OpenJVM under Ubuntu and it didn't work well, so I prefer to use the Oracle's one: it should run the same jar in each platform the same. I did't test the other brands.

Ok, here's a very simple setup how I test my java server applications at home (on a RPi3 and on Windows 10 ;) :
- I run the java vm and the java applications in a chrooted very lite RaspBian lite environment.
- Every machine that needs processing against java code has a certificate for the Java chrooted environment.
- The chrooted environment will refuse password connections, accepts only certificates from known local ip's.
- Responses will be processed ad-verbatim and exposed through a webserver. (At that point the data is static.. get it?
- Data coming to the webserver from the outside is first validated ON the webserver (js validation, buffer cleaning, php validation, data validation, all standard).
- Once established it is a valid request it is given to the chrooted java application as a (static) package preferably as a request for a stored procedure in case of an underlying database.
- The internal IP for the chrooted java server is otherwise blocked.

At work, there are a few more steps, but the above is doable for students and very, very safe,

BTW: All three examples I gave for JVM5 servers are because of some malformed request, either SQL, TCP or a security key exchange.

You are right to prefer the Oracle one: better maintained and 2 to 5 times faster.

Note you only have to do this once per webserver. You can have as many applications that you like (unless you do a certificate per application/per user, which is what you do at the bank ;) )
« Last Edit: December 05, 2016, 07:04:36 pm by Thaddy »

lainz

  • Hero Member
  • *****
  • Posts: 1835
  • Nace una flor, todos los días sale el sol...
    • BGRABitmap
Re: FP vs Java Benchmark
« Reply #21 on: December 05, 2016, 07:19:44 pm »
Thanks for your nice step to step information. Currently I don't have the knowledge to try it myself, but now I get an idea of how secure servers can run with java.

Thaddy

  • Hero Member
  • *****
  • Posts: 3408
Re: FP vs Java Benchmark
« Reply #22 on: December 05, 2016, 09:37:18 pm »
maybe I do a little write up about this. Although it is not directly related to Laz/FPC.
All steps together can be done in a weekend without previous knowledge... and it is fun ;)
Especially combined with some friend(s) to whom you give a white hat hacking distribution.
Lean back, log, and have fun!

Anyway, back on-topic: I was surprised that the JVM on my RPi3 performed so well against native arm code!
Try and run the examples - including the pascal ppcjvm one - in this post on a Raspberry Pi 3....
« Last Edit: December 05, 2016, 09:40:18 pm by Thaddy »

Xor-el

  • Jr. Member
  • **
  • Posts: 71
Re: FP vs Java Benchmark
« Reply #23 on: December 05, 2016, 09:52:23 pm »
maybe I do a little write up about this. Although it is not directly related to Laz/FPC.
All steps together can be done in a weekend without previous knowledge... and it is fun ;)
Especially combined with some friend(s) to whom you give a white hat hacking distribution.
Lean back, log, and have fun!

Anyway, back on-topic: I was surprised that the JVM on my RPi3 performed so well against native arm code!
Try and run the examples - including the pascal ppcjvm one - in this post on a Raspberry Pi 3....

sorry for the off topic question, but
please what endianness is rpi3 and does Lazarus 1.6 / FPC 3.0 work on it?
also is there any newbie guide in setting up Lazarus on it?
« Last Edit: December 05, 2016, 10:00:05 pm by Xor-el »

Thaddy

  • Hero Member
  • *****
  • Posts: 3408
Re: FP vs Java Benchmark
« Reply #24 on: December 05, 2016, 10:04:21 pm »
sorry for the off topic question, but
please what endianness is rpi3 and does Lazarus 1.6 / FPC 3.0 work on it?
It is an arm processor so endianness depends on the OS you installed.
My preferred OS on the Raspberry Pi is Raspbian (which is Debian) and that is little endian.
And yes, 1.6/3.0 works on it. I use Laz 1.7(trunk)/FPC 3.0(stable) and FPC 3.1.1 (trunk) on it. Works amazingly well. (Even on a RPi 1 B it works,or just on a Pi zero)

Due to a bet I even use one of my Raspberry Pi's as my main computer at home, like testing code, posting and reading this forum and watching Youtube channels.
The longer I do that the more wine I get ;)  It is about almost 5 months now..... That's 5X6 bottles.

There are noob guides, but none of them much good.
The best was the getlazarus.org -tested - script one, but that seems to have issues nowadays. May be solved by now.
Another good one that - tested - works on and off properly is fpcup/fpclazup.

The authors for both are on the forum, so I am sure you will get help.
I can help you set it up too if you want. I simply give you my compiled version and installation instructions.
« Last Edit: December 05, 2016, 10:15:41 pm by Thaddy »

Xor-el

  • Jr. Member
  • **
  • Posts: 71
Re: FP vs Java Benchmark
« Reply #25 on: December 05, 2016, 10:15:41 pm »
thanks a lot for replying and offering to help.
will surely let you know when am ready to install.
thanks once again.

Graeme

  • Hero Member
  • *****
  • Posts: 1362
    • Graeme on the web
Re: FP vs Java Benchmark
« Reply #26 on: December 06, 2016, 12:13:39 am »
Huh? With the security history of Java?
I always find that statement funny. Java is the post popular programming language to date (search the net for multiple confirmations of this). That also means it is used by the millions of technical people. A lot of eyeballs looking for problems, so yes problems will show up - like  any software out there. Oracle had a slow start with Java, but they are on the ball now, and fix issue rather fast (for such a large company). An while the bug fixes come out, they also keep pumping out new features in Java. It's actually pretty darn amazing if you ask me.

I'm sure if you through 20 million developers at FPC, Mantis will be bogged down with bugs and security issues for the next couple of years. FPC isn't even a drop in the bucket compared to Java.

Bug reports volumes should take into account the number of developers and users.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Graeme

  • Hero Member
  • *****
  • Posts: 1362
    • Graeme on the web
Re: FP vs Java Benchmark
« Reply #27 on: December 06, 2016, 12:27:07 am »
I was expecting Java to be significantly slower than FP.
Why? There are tons of permances tests done before where Java smokes many other languages in raw number crunching.

Just because you saw years ago some crappy bloated Java GUI application running slowly, doesn't mean that applies today.  Java has moved on since the mid 90's. It actually performs extremely well (though memory hungry), especially with backend code. The mostly likely reason why it is the most popular programming language in the world.

Then again, if you compare Java's JavaFX (3d hardware accelerated GUI toolkit), it performs just as well as Qt5's hardware accelerated GUI. You don't just have to look at hardware acceleration either. I have been using jEdit (text editor) for years. It can load, parse and syntax highlight (using regex as its base for doing so - and everybody things regex is slow) MUCH faster than Lazarus IDE's editor can. I actually run quite a few GUI java programs, and well written ones perform very well. On the flip side, I've seen native GUI applications performing very good and very bad too. A lot is down to the quality of the program and how it was written. Not all applications are equal.

Comping back to your Java performance result. If you run performance tests with the Server VM, then the performance should be even better.  See 'java -h' for details on how to select the "sever" VM.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Thaddy

  • Hero Member
  • *****
  • Posts: 3408
Re: FP vs Java Benchmark
« Reply #28 on: December 06, 2016, 07:45:48 am »
Huh? With the security history of Java?
I always find that statement funny.
What is so funny if even Oracle's own engineers and instructors will put java servers in a closed environment?
You should really stop laughing.
Most of the tips I gave came straight of an Oracle (well, SUN, in my case) instruction course for systems engineers.
Don't expose Java servers to the Internet directly. It was never designed to do that.

Btw: I use and used a lot of Java server code, more specific in banking: stock and currency trading environments.
So I really know what I am talking about. I am not bashing java, but simply illustrate its limitations and how to work with those.

Your second remark makes more sense. JVM code can be really performant.
There's a wealth of code for professional users (most of it really expensive ;) TIBCO anyone? or several IBM products, like Websphere.
The latter - misleadingly - is also never exposed to the internet directly.
And bugs get fixed quickly nowadays, indeed because of the ecosystem.

Jay

  • New member
  • *
  • Posts: 31
Re: FP vs Java Benchmark
« Reply #29 on: December 06, 2016, 10:08:17 am »
I was expecting Java to be significantly slower than FP.
Why? There are tons of permances tests done before where Java smokes many other languages in raw number crunching.

Of course, but generally you would expect native code to out-perform a VM because a VM has an extra layer of abstraction. For the same reason you would expect assembly language to out-perform C. Not always, but "mostly". Anyway, as I said, it can be misleading to read too much into benchmarks because there are so many variables involved. And people can be rather religious about their pet languages, or have vested interests, so the tests may be biased.

Some more comparisons of Java vs FP:

https://benchmarksgame.alioth.debian.org/u64q/pascal.html

So because Java beats FP here on most algorithms, is it fair to conclude that Java is a "faster" language than FP? I don't think so.

https://benchmarksgame.alioth.debian.org/why-measure-toy-benchmark-programs.html
« Last Edit: December 06, 2016, 10:09:50 am by Jay »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus