mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Programming (https://www.mersenneforum.org/forumdisplay.php?f=29)
-   -   Converting applets to Javascript (https://www.mersenneforum.org/showthread.php?t=20258)

alpertron 2015-05-17 20:57

Converting applets to Javascript
 
Given that the Java ship is sinking, I've started to convert the applets in my Web site to C and then I'm using Emscripten to generate the optimized Javascript.

My first applet converted to Javascript is the Ulam spiral, which can be seen at: [url]http://www.alpertron.com.ar/ULAM.HTM[/url]

Apart from working in mobile devices, the good news is that the speed of the generated Javascript code is similar (if not better) than Java. And of course that are no annoying pop-ups and no certificates are required.

There are about 15 applets to be converted, so this task will need a few months.

alpertron 2015-06-11 13:16

Using my Web server statistics, I found that only a few people is able to see Java applets. When the plugin is enabled, it downloads the JAR file which includes the Java program to be executed.

So I computed how the Java usage decreased in the last four years according to the hits of my factorization calculator.
[CODE] ECM.HTM jar file Java usage

Sep 2011 4183 2261 54%
Jan 2012 5156 2100 41%
May 2012 4623 1472 32%
Sep 2012 3488 1179 34%
Jan 2013 3814 1107 29%
May 2013 4456 1417 32%
Sep 2013 3008 1164 39%

Jan 2014 4114 1440 35%
Feb 2014 3569 1116 31%
Mar 2014 3632 1000 28%
Apr 2014 3623 986 27%

May 2014 3843 760 20%
Jun 2014 3107 555 18%
Jul 2014 3283 507 15%
Aug 2014 3216 610 19%
Sep 2014 3593 513 14%
Oct 2014 4263 724 17%
Nov 2014 4078 689 17%
Dec 2014 4110 685 17%

Jan 2015 4386 732 17%
Feb 2015 3842 663 17%
Mar 2015 3723 596 16%
Apr 2015 4277 639 15%
May 2015 3400 665 20%
Jun 2015 1030 186 18%[/CODE]
With these figures, it is clear the importance of converting Java applets to Javascript.

Stargate38 2015-06-11 13:21

I think it's because people are using YAFU to factor their numbers. It's a lot faster.

alpertron 2015-06-11 13:24

That's not the problem. Notice that the HTML page is loaded but the JAR file is not in the vast majority of instances. That means that the Java plugin is not installed or the browser is blocking it (Chrome blocks the Java plugin, and most of the traffic to my Web site comes from this browser).

Mark Rose 2015-06-11 15:27

Lots of users block flash by default, too, like me.

The problem is that advertisers are moving to HTML5, so the web will become annoying again.

Stargate38 2015-06-11 21:30

The Java site has instructions on how to unblock Java:

[url]https://java.com/en/download/faq/chrome.xml#npapichrome[/url]

It worked for me. :grin:

alpertron 2015-06-11 21:44

[QUOTE=Stargate38;403919]The Java site has instructions on how to unblock Java:

[url]https://java.com/en/download/faq/chrome.xml#npapichrome[/url]

It worked for me. :grin:[/QUOTE]

Yes, I know that. Unfortunately that workaround will be disabled on Chrome 45 that will be released on September.

LaurV 2015-06-12 03:07

[QUOTE=alpertron;403883](Chrome blocks the Java plugin, and most of the traffic to my Web site comes from this browser).[/QUOTE]
Good and unexpected for the NSA-enabled browser! :razz:
Firefox also blocks it here (in fact it detects it as insecure and asks you to block it if you want; of course all possible insecure stuff is blocked here, by hand).

alpertron 2015-10-16 11:44

I finally had several days free to convert my sum of four squares applet from Java to C so Emscripten could convert it to optimized Javascript (asm.js). I had to develop the big number support from scratch. I still have not converted the expression analyzer. You can see it at [url]http://www.alpertron.com.ar/newfsquares.htm[/url] (this a temporary URL that will be deleted when the expression analyzer is finished, so the current applet continues to be accessible in the meantime if you use Firefox or IE in desktops).

The most interesting bit of information here is the benchmark between Java implementation and asm.js implementation.

I found that for decomposing the 617-digit number RSA2048 in a sum of three squares, the Java applet needs 3 seconds and the Javascript application needs 11 seconds. I think the main problem is that the multiplications in Java are done in 64 bits while in Javascript are done in 32 bits, so the latter needs 4 times more multiplications than the Java implementation.

alpertron 2015-11-10 22:02

Another hit for Java applets: 64-bit Firefox will not have support for them and 32-bit Firefox will drop support at the end of 2016. See [URL]https://blog.mozilla.org/futurereleases/2015/10/08/npapi-plugins-in-firefox/[/URL].

rogue 2015-11-10 23:55

[QUOTE=alpertron;415740]Another hit for Java applets: 64-bit Firefox will not have support for them and 32-bit Firefox will drop support at the end of 2016. See [URL]https://blog.mozilla.org/futurereleases/2015/10/08/npapi-plugins-in-firefox/[/URL].[/QUOTE]

Now if Microsoft would stop supporting ASP in their browsers...

My company rolled out a neat features in IE a couple of weeks ago. You can go to the internal company home page with IE and click on a link to immediately see your total compensation. Isn't that cool? If I leave my computer to use the bathroom and don't lock it, then someone can walk up, click on the link and see how much I earn. Awesome! They are extending this functionality so that one can look at all benefits and personal information such as SSN, date of birth, address, etc without requiring a password. This is great because that is one less password that I have to remember.

Enough of the sarcasm.

Guess who's idea this was. HR! Guess who okayed this change. The head of IT!

Instead of taking the five minutes to remove the link from the home page, it has been available for almost two weeks.


All times are UTC. The time now is 04:36.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.