views:

76

answers:

4

hi using html5/css3/javascript with some frameworks as sproutcore/gianduia as apple recommend for webapps developing (like apple's iworks.com, mobileme.com) is better or java?could i develop mid-scale webapps by javascripts especially that is mainly client-side language? is java better in server-side and OOP? thanks

+1  A: 

The question is a bit confusing as to what you're comparing java to, so I can't answer whether java is better or not. But Javascript is for client-side code only and should not be used for server-side for security reasons and you could use ajax/jquery to retrieve and send data to server but that depends on your needs and application. If the webapp is highly client-side then java, ajax and jquery are good ways to go.

Hope this is a start, let us know more a little about what you're trying to make/do.

Best

Ehsan
JavaScript *can* be used as a server-side language as well (see Rhino). In this role (on the server side) it has the same role as any other server-side language. But your point about limiting client access/trust is valid.
pst
+1  A: 

Java is a good server-side language. As user pst mentioned, JavaScript can apparently also be used as a server-side language, but this is extremely rare I would say. In regards to OOP, my opinion is that OOP is easier, more straight-forward, and better supported in Java compared to JavaScript. So my recommendation would be to use Java as your server-side language.

Michael Angstadt
+2  A: 

You can use either. Which you choose will bring with it a number of competing advantages and disadvantages. I'm not too familiar with Java frameworks though many exist. JavaScript server side frameworks such as Rhino, node.js, and platforms that make development on those easier are becoming more and more popular. Look up any of the many JavaScript conference talks to find out more.

If you are just getting started or have a history with JavaScript, that might be easiest to pick up, though you won't find a lot of documentation outside of the web. Java will give you a ton of books, media, etc, but you'll have a greater learning curve if you haven't done a lot of development.

You mentioned OOP specifically. Java follows OOP, but JavaScript uses prototype inheritance and can be difficult to use in an OO style without a framework. JavaScript lends itself to a more functional style, though, so if you are interested in that, you might gain some advantages there.

Ryan Riley
A: 

Typically a language like Java is been mainly for the server side and Javascript on the client side. On the client side you can write Java Applets, but for various reasons, they aren't used very often on websites. All modern web browsers support Javascript, so it is a natural choice for the client side.

These days Javascript can be run on the server. This would be a great solution for someone who is really good with Javascript. Though, java may be a better choice if you want the app to be highly performant and scalable.

Java can be used on the client side if you write your app with GWT. GWT takes Java code and compiles it into Javascript which will run natively in the browser. GWT does a lot of optimization of your code so it runs very efficiently in the browser. It also allows you to use the many development tools available for Java such such as IDE's which offer code completion and unit testing frameworks.

Java is statically typed and object oriented, javascript is dynamically typed and based functional language. They use very different paradigms despite having fairly similar syntax. Comparing them is a little bit like comparing apples and oranges. They both have their strengths and weaknesses.

It's possible to write an entire javascript that only lives on the client side but you sacrifice the ability to interact with extremely large datasources, share data with other users, or allow the user to save data and access it from another computer. You could also write an entire Java app that only lives on the server side, but you lose interactivity.

Jay Askren