Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a website that is about electronics. I want to make some functional calculators such as calculation for analog filters which will have to show lots of plots and stuff like that. This is a sample of what I am looking for and obviously it is only PHP and its graphic functions.

I want to have similar thing but much more interactive with realtime sliders and stuff like that.

What should I go for? Java Applets? or stick to JavaScript/PHP? I am asking this because I can do it with Java much faster (know it better than JavaScript and PHP). But I am afraid of browser incompatibility, security options for Applets and similar things. What is your suggestion?

share|improve this question
8  
If you want your website to look like it came out of 1995 then use java applets. If you want it to look any good use js. –  Raynos Oct 11 '11 at 9:24
7  
@Raynos: Care to explain how exactly JS can draw better-looking pixels than Java? Otherwise I call bullshit. –  Michael Borgwardt Oct 11 '11 at 9:29
3  
@MichaelBorgwardt java applets do not integrate nicely into a website. JavaScript works directly with the DOM therefore integrates more naturally. Java applets force me to boot up an instance of the java VM which is obtrusive. Java applets behave differently then normal web pages by default. –  Raynos Oct 11 '11 at 9:33
3  
@MichaelBorgwardt the content of the applet may look fine (even though most applets use java default themes which are completely different from HTML defaults) but it's how an applet sits and merges with the rest of the website, basically applets are and feel like foreign entities in a website, they do not integrate smoothly with the rest of the website. It's all about how polished you want the overall website to feel. –  Raynos Oct 11 '11 at 12:32
3  
@MichaelBorgwardt: while it doesn't have to do with how it looks (arguably, for example the font rendering of your JVM is almost certainly slightly different from that of your browser), it does have to do a lot with how it "feels", and that's just as important for a good interactive experience. I love Java, but for these kinds of things good JS is the superior solution. –  Joachim Sauer Oct 11 '11 at 12:40

10 Answers 10

up vote 9 down vote accepted

I am asking this because I can do it with JAVA much faster (know it better than javascript and php). But I am afraid of browser incompatibility, security options for applets and similar things. What is your suggestion?

Depends mainly on whether you want to support mobile devices (read: iPad - I don't think the iOS browser will ever support Java applets) and whether you expect users to either have or be willing to install a JVM.

If these are not show-stopper issues, go with Java. While Applets are ridiculously out of fashion, that does not matter to end users. On a modern machine, JVM startup time is not a problem, and browser incompatibility less of a factor than with JavaScript. Applet-specific security is irrelevant as long as you only draw stuff and don't want to do things like access the user's harddisk.

share|improve this answer

Personally I'd avoid Java applets. Generally speaking people don't like them. Corporates don't like them and they don't run in all browsers. Assess who is going to use it and establish the impact on them. If your target users are fine with it, and you feel more comfortable working in Java then fine.

share|improve this answer

Actionscript 3.0 with Adobe Flex is really recommended if you have a java background. Very easy to pick up if you are comfortable with object-oriented programming. You could build your backend in java and then have the frontend built in flash.

share|improve this answer
    
flash? flash already was obsolete in 2011. –  northkildonan Sep 11 at 9:07

I would look at JavaScript for the client.

  1. It is the defacto standard to lightweight web client development.
  2. Libraries like JQuery and ext_js make gui development as structured as java, and are fairly easy to pick up.
  3. Applets, while still somewhat viable, are fairly heavy weight and require client installs of java.
share|improve this answer

Have you considered using Flex? It is not Java exactly but it is fast to pick up AS 3 from java background and has nice browser support, good integration with Java back-end etc.

share|improve this answer
2  
Actionscript 3.0 with Adobe Flex is really recommended if you have a java background. Very easy to pick up if you are comfortable with object-oriented programming. –  marko Oct 11 '11 at 15:21

I'd suggest sticking to either javascript or Flash, or do the calculations server side in the language of your choice (which could be Java). There's no reason to introduce a dependency on the client machine (ie, JVM) that isnt actually needed to do something similar to that example page you link to. Fewer dependencies = less headaches. Almost everyone has Flash installed, and every modern browser version can handle HTML Canvas. But while most people will have Java installed, many wont.

share|improve this answer

I personally prefer JavaScript/PHP to Java and think you should consider as this is more widely accepted. Java applets are not quite as popular.

Also a JavaScript solution will be faster and more responsive as users will not have to wait before they can use your calculator. Moreover there are a lot of javascript graphics libraries you can use: try rapheal.js

share|improve this answer

Both Java or Javascript would work.

On balance, I'd probably suggest Java applets for your case - applets are very well suited for embedded client-side applications in a web page, and it sounds like you already have Java experience.

The main benefit is that Java gives you a huge number of libraries / tools for layout and graphics etc. Anything that works with the Swing graphics toolkit should work - e.g. you can use fun things like the Napkin Look and Feel all the way through to fairly sophisticated visualisation tools like Processing.

Also, Java applets can achieve very good performance, certainly well ahead of Javascript. May not be a real issue in your case, but you get all the usual advantages of the JVM JIT-compiling down to native code so numeric calculations should be very fast.

Of course, the user needs to have a Java browser plug-in installed but that's true for nearly everyone nowadays..... and the plus side of this is that the Java layer means you don't have to worry about browser differences / incompatibilities so much.

share|improve this answer

If you're already running in a servlet container and familiar with Java, check out the Google Web Toolkit. Your client code can be written in Java that gets compiled into browser-specific JS.

share|improve this answer

Also take a look at Java FX 2.0 that's come out recently - they are going to provide iOS support down the line.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.