1 / 18

Why use Java?

Why use Java?. Chris Loftus cwl@aber.ac.uk. It’s easy to knock the top dog. Maturity Lots of support documentation Huge standard libraries (3777 classes in Java 6) Big community Etc But is it a super-tanker, and does that matter?. My general view.

apu
Download Presentation

Why use Java?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Why use Java? Chris Loftus cwl@aber.ac.uk CS25510: Why use Java?

  2. It’s easy to knock the top dog • Maturity • Lots of support documentation • Huge standard libraries (3777 classes in Java 6) • Big community • Etc • But is it a super-tanker, and does that matter? CS25510: Why use Java?

  3. CS25510: Why use Java?

  4. My general view • Don’t be dogmatic; use the right language for the right job... • Don’t slavishly follow the latest trends • Dynamically typed script languages are also not that “silver bullet” • Sometimes there are several equally valid choices... CS25510: Why use Java?

  5. Promises of Java: WORA • An aim of Java in 96 was ability to program small devices, e.g. set-top boxes... • Write Once Run Anywhere is important • There are JVMs for all computer platforms • Symbian OS 47% of smart mobile phones (2008), includes Java ME... • Amazon Kindle, Blu-ray Disc, EA Mobile, etc...(http://www.java.com/en/java_in_action) • Large usage on server-side: e.g. eBay uses Java, Infosys Technologies, parts of Amazon (Jboss, servlets), parts of Google, Twitter (Scala on top of JVM for backend),... CS25510: Why use Java?

  6. Promises of Java: WORA: Issues • GUIs: Swing pure Java components give WORA, but performance issues and pluggable OS-specific LAFs not accurate... • Initially Java 1.1 Green Threads, now native used... • Performance issues: cross platform means use of interpreters and/or JIT compilers...(more on this later) • Not the only WORA kid on the block: those script languages and Mono .NET IL...

  7. Promises of Java: Network/Web programming • From the start: sockets, applets, HTTP support, RMI (97), servlets (97), CORBA support (98), JSP (99), JMS (2001), etc • Web service support: • JAX-WS etc for W3C SOAP/WSDL style... • JAX-RS for REST style... • Web programming support: • Struts, JSF (with Ajax), Java EE 5, Spring, Google Web Toolkit, JavaFX ...

  8. Promises of Java: Network/Web programming: Issues • All programming platforms now support networking • However, Java maturity in this area • Some platforms (e.g. Ruby-on-Rails) support web development more succinctly... • JavaFX is commonly believed to be too late as compared with Adobe Flex/AIR and Silverlight... • EJB and J2EE bloat-ware, the steep learning curve, and the influence of affluence...

  9. Promises of Java: Security • Networking requires security: • Java sandbox for applets... • Java Security Model... • Java Cryptography Architecture/Extension... • Java Authorization and Authentication Service... • Support for web service security (e.g. message-level encryption, in-progress as part of JAX-WS) • More comprehensive support than most platforms... CS25510: Why use Java?

  10. Promises of Java: Type-safe • Strong typing that is statically checked (at compile time) long v1 = 10.2; Object e = new Employee(); Employee e1 = e; • Strong typing that is dynamically checked... • Array index bounds checking... • No pointer arithmetic... • Consistent handling of floating point types... • Garbage collection rather than dealloc (memory management issue)... • Removes a class of runtime faults but performance and flexibility issues...

  11. Criticisms: Performance • Java’s had this poor performance tag for some time, is it still justified? • The HelloWorld comparison of Java and C is a little misleading: • A large JVM must be loaded and initialised... • For short-lived programs this might be an issue... • What do the benchmarks show us?... CS25510: Why use Java?

  12. See “The Computer Language Benchmarks Game” http://shootout.alioth.debian.org/

  13. CS25510: Why use Java?

  14. CS25510: Why use Java?

  15. Why performance worse than C/C++? • Load-time bytecode verification, array bounds checking, floating point simulation, garbage collection… • Loading the large JVM • Big start-up hit… • Big memory footprint… • Initially bytecode interpretation, JIT (1998), and then HotSpot (2000) • Adaptive compiler: initially interpreted but hotspots are compiled to native…

  16. Criticisms: Java is simply not fun • Lack of: • Default parameter values, operator overloading, closures, pure object orientation, string cases in switch statements, meta-programming support, convention over configuration... • And: • Boiler-plate code, checked exceptions... CS25510: Why use Java?

  17. HelloWorld in Java and Groovy public class HelloJava { public static void main(String [] args){ if (args.length > 0) System.out.format("Hello %s", args[0]); else System.out.print("Hello"); } } if (args) println "Hello ${args[0]}" else println "Hello" CS25510: Why use Java?

  18. Java is a super-tanker but I don’t think it matters • Criticised by many developers as not including features discussed earlier, and slow to add new features... • But many big projects want API stability, large mature reusable code libraries, proven technology, type safety, good security, and sufficient performance... • eBay replaced C++ with Java in 2002, citing Java’s good engineering support for their 1500+ developers • However Amazon use C++ for compute intensive work • And if you want to use those fun languages and have many of Java’s benefits why not use Scala, Groovy or Jruby?

More Related