400 likes | 407 Views
This presentation provides an overview of Chapters 4 and 5 of the book "Beyond Java" by Bruce Tate and Jim Fawcett. It discusses the changing landscape of Java development, the limitations of Java, alternative languages, and the rules of the game in the software development industry.
E N D
Beyond Java, Chapters 4 and 5Bruce Tate Jim Fawcett Brown-Bag Seminar 17 February 2006
A Useful Definition for this Presentation • Spin – from WordReference.com • A distinctive interpretation (especially as used by politicians to sway public opinion); “the campaign put a favorable spin on the story” • When spun, your job is to: • Listen, but be somewhat skeptical • Make up your own mind
Some Spins • Author • Java is nifty, but growing too complex for a lot of the jobs we need to do. Enter Ruby? • Kanat • Java is nifty, has lots of tools that let me do interesting research. I love it! I’m sceptical of what the author says. • Jim Fawcett • Windows world is where most of the jobs are. There are lots of interesting, but complicated, technologies to use there. But windows development isn’t the only game in town; Its just the one in which I have most interest. • I think the author is smart, has lots of interesting things to say, and will give us a view into another world, if we let him.
Plea • These presentations can’t do the book justice – go read it! • Sci-tech library on reserve • Under CSE687 since the library needs a course to associate with a book reserve.
Chapter 4 – Glass Breaking • Java’s new job description • Early use to develop quick applications • Then moved server-side • Web site applications • Enterprise Systems • Mapping objects into relational model • Distributed transactions • Messaging middleware • Java is flexible, so its been able to accommodate these changes.
Typical Requirements • Good fit to middleware development because of its existing packages • Servlets and web programming is not as productive as PHP • “Java just isn’t very good for the simplest and most typical applications.” • Better alternatives exist for XML processing. Java’s strings are too verbose. • Natural fit to large enterprise projects due to its libraries and large number of Java developers.
The Learning Curve • Most Java-based web applications use Java Server Pages (JSP) technology, probably through Tomcat. • There are more steps, now, in using Tomcat, which take longer to learn. • But that’s not all. You’ll need to understand: • Ant – build and deploy web applications • Tapestry or Struts – organize user interface code • Hibernate – object relational mapper • Spring – organize application resources and support testing
Resources • See the End Notes for summaries of: • PHP Hypertext PreProcessor • JSP Java Server Pages • J2EE Java, Enterprise Edition • EJB Enterprise Java Beans • Apache Apache web server • Tomcat Containers for Java Server Pages • Struts Model-View-Controller application management • Tapestry Simpler MVC application management • Spring Framework Framework for building containers of Java Server Pages • BeeHive Builds object model on top of J2EE and Struts • Hibernate Object-Relational mapper • Ibatus Data mapper framework • Maven Manage build, reporting, and documentation
Java for the Typcial Application • For the basic problem, a web-based user interface for a relational database, you have to learn a lot more today than you did five years ago. • The advanced frameworks will drive the Java language away from the base that made it popular
Agile Development • Simplicity • Use the simplest thing that will work • Automated Unit Testing • Junit framework is recommended • Shortened Iterations • Shorter schedules, better integration of customer feedback, and smaller iterations
Development Processes & Java • Java’s community and tools provide excellent support for agile programming • Java is not such a good language for agile development • Not the simplest language • Not friendly to very short iterations • Because of the need for frameworks (implied)
Basic Java Limitations • Frameworks make experienced Java developers more productive but make a steep learning curve for new developers. • Compile-time type checking adds safety at the cost of additional time and syntax. • Java is not able to express structured data leading to over-dependence on XML. • Java’s many compromises, like primitives (different than user types) make Java harder to learn and more complex to write. • Java is nowhere near as dynamic as Smalltalk and Ruby. • Java’s long compile/deploy cycle is much longer than interpreted, dynamic alternatives.
Alternatives • Are the Java community and large code base worth sacrificing the productivity of other alternatives? • The waters are rising. • A clean, dynamic language could gain footing in the gap between Visual Basic (6.0) and Enterprise Java. • The lion’s share of Java development, even in the enterprise, is not full of distributed transaction and backbreaking loads. • Developers want a way to baby-sit a big relational database with a web-based user interface.
Chapter 5 – Rules of the Game • Portability • Must have a virtual machine for: • Security, portability, extensibility, interoperability • Internet Focus • The internet has two interfaces, for people and machines. • The next language should build better interfaces more easily, using a component model. • It should deal with XML productively and efficiently. • Enterprise Integration • The next language will should interoperate with the existing code base. • Database Integration • The language should access relational data in a natural, productive way. • Transactions and Security • Needs to integrate with existing enterprise security frameworks.
Generating Buzz • Technically superior languages have failed because they didn’t generate buzz. • Walter Bright’s D is probably superior to C++, but it’s generating little interest among the developer community. • Without buzz there is no community • Now is a good time for a new language: • Open source software makes it easier for smaller companies to become a force by virtue of numbers. • Web services and other protocols make it easier to interoperate between languages. • A JVM (or CLR) can support other languages. • But generating buzz is more art than science, and perhaps more luck than art.
Necessary Ingredients • Economics • Someone has to pay the check, and superior productivity makes that likely. • Approachability • New language needs to grab new users quickly to prosper. • You should be able to get started quickly, and solve a problem that is important to you quickly. • C was approachable because you could solve low-level problems with a high-level language. • C++ was approachable because you could add C++ features to C, as you needed them. • Java was approachable because the syntax was familiar and it had a clear path to internet applications. • The killer App • A language needs an active community to prosper. • A killer application can quickly draw new users. • Applets and servlets did that for Java.
Language Features • Dynamic typing • Static typing promotes safety through compile-time checks, at the cost of productivity. • Dynamically typed languages are easier to explore and build prototypes. • Code blocks • Code blocks are anonymous functions that are used to quickly assemble callbacks, provide thread processing, and do repetitive operations on databases and collections. • They’re useful anywhere you need a “once-only” small function, and that’s lots of places. • They also reduce the remoteness factor. • The function body is defined right where it is used. • Continuations • Saved stackframe hierarchies that can be re-applied to go back to a prior state. • Proported to be very useful for supporting backtracking in the stateless web model. • Rapid feedback • Reduce the time between making a change and seeing the result. • The interpreted languages Smalltalk, Lisp, Perl, Ruby, and VB 6.0 all have rapid feedback and are very productive languages.
More Language Features • User Interface Focus • “User interface focus demands more than Java has to give”. • Dynamic Class Model • A Java successor should be much more dynamic and reflexive. • Java’s reflection API is verbose, partly because of the distinction between primitives and user types. • It has to deal differently with primitives, arrays, and classes. • Tate gives two examples where a dozen lines of Java code are replaced with one or two lines of Ruby code. • With Ruby “you can also change classes, at runtime, on the fly. You can change a method on an object and leave the class untouched. Also, interceptions are childs play”. • Sound Foundations • The next language should be object oriented and purer than Java. • Here, the author means that primitives are first class objects. • Consistency is important. • Languages with consistent naming and behavior are far easier to learn.
Potential Suitors • Perl • Productive scripting language • Write only language with cryptic syntax • Python • A successful dynamic programming language, close to Ruby in syntax and power and supports the specified features. • Syntax depends too much on white space. • Has weak web development tools. • Ruby • Object oriented dynamic language, created in Japan, and just now becoming popular in US • Beautiful syntax that stays out of your way. • Highly dynamic • Educated core of Ruby community works hard to produce clean, simple APIs. • Has strong web frameworks, good support for XML and web services. • Ruby has a couple of high profile frameworks, like Ruby on Rails. • Ruby has good commercial backing in Japan, but not in US. • JVM support is immature, though improving rapidly.
More Suitors • PHP • Scripting language. • Start with html and mark up with tags for scripted actions with databases and request and response objects. • Easy to understand and learn. • Good for controlling a database from a web page. • Technically awful • Couples user interface and database together. • Method names are inconsistent. • C# and .Net Languages • C# is a Java clone with many of the same benefits and drawbacks. • Microsoft languages are a closed ecosystem. They succeed or fail with the Microsoft platforms, rather than on their own merits. • Smalltalk • Never really caught on commercially, dispite attempts by IBM as late as 1995. • “Hughly productive, slightly awkward, and quirky to the extreme.” • Clean object model, incredible expressive power, and an intelligent design and community. • Not seen as a credible alternative. • “It just wasn’t ever approachable enough.”
A Random Quote from the Web • “I've been developing web apps for years, in both PHP and Java. You really notice how much stuff is repeated and unnecessary. How many times to you enter the same variable or field name in the database, in the classes, in the HTML/view? It's a waste of time.I had developed some helper utilities that are basically a crude form of ActiveRecord. I used to do a lot of Java development. J2EE [#@$%^&]. Servlets, entity beans, etc. The amount of garbage you have to go through just to get something deployed made me angry.Seeing Rails was wonderful. It was all my "good ideas" implemented cleanly with none of the PHP hacks or Java verbosity”. • Note: There are many quotables about Ruby on Rails that are favorable, and many that are not.
Next UP • Chapter 6 - Ruby in the Rough • Chapter 7 – Ruby on Rails
End Notes • PHP, JSP, Java Beans, EJB, J2EE • Apache, Tomcat, Spring Framework • Struts, Tapestry • BeeHive, Hibernate, IBatus • Maven
PHP - http://us3.php.net/manual/en/introduction.php • (recursive acronym for "PHP: Hypertext Preprocessor") is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. • Simple answer, but what does that mean? An example: • Example 1-1. An introductory example<html> <head> <title>Example</title> </head> <body> <?php echo "Hi, I'm a PHP script!"; ?> </body></html>
JSP - http://www.webdevelopersjournal.com/articles/jsp_build.html • “If you've ever used Microsoft's very popular Active Server Pages (ASP) then you'll have a good idea of what JSP is. It consists of HTML or XML markup into which special tags and code blocks are inserted. The code is executed on the server and the result is a dynamic page that is returned to the client browser. Although JSPs are simple to build they have at their disposal the full power of object-oriented Java and the Java Server API. JSPs make heavy use of Java Beans, which are classes that follow a standard pattern of a no-argument constructor (required in JSPs) and public GET and SET methods.”
Java Beans - http://en.wikipedia.org/wiki/Java_Beans • JavaBeans are software components written in the Java programming language. • The JavaBeans specification by Sun Microsystems defines them as "reusable software components that can be manipulated visually in a builder tool". • In spite of many similarities, JavaBeans should not be confused with Enterprise JavaBeans (EJB), a server-side component technology that is part of J2EE. • In order to function as a JavaBean class, an object class must obey certain conventions about method naming, construction, and behavior. These conventions make it possible to have tools that can use, reuse, replace, and connect JavaBeans. • The required conventions are: • The class should be serializable (able to persistently save and restore its state) • It should have a no-argument constructor • Its properties should be accessed using get and set methods that follow a standard naming convention • It should contain any required event-handling methods • Because these requirements are largely expressed as conventions rather than by implementing interfaces, some developers view Java Beans as Plain Old Java Objects that follow certain naming conventions. However, this view is misleading for Java Beans that support event handling, because the method conventions and associated support classes for event handling are fairly intricate, and require the use of specific base classes and interfaces.
EJB - http://en.wikipedia.org/wiki/EJB • The Enterprise JavaBeans specification is one of the several JavaAPIs in the Java 2 Platform, Enterprise Edition. EJB is a server-side component that encapsulates the business logic of an application. • The specification details how an application server provides server-side objects known as Enterprise JavaBeans, or EJBs, with: • persistence • transactions • concurrency control • events using Java Message Service • naming and directory services • security • deployment of components in an application server • remote communication using CORBA • Additionally, the Enterprise JavaBean specification defines the roles played by the EJB container and the EJBs as well as how to deploy the EJBs in a container.
J2EE - http://www.webopedia.com/TERM/J/J2EE.html • Short for Java 2 Platform Enterprise Edition. J2EE is a platform-independent, Java-centric environment from Sun for developing, building and deploying Web-basedenterprise applications online. The J2EE platform consists of a set of services, APIs, and protocols that provide the functionality for developing multitiered, Web-based applications. Some of the key features and services of J2EE: • At the client tier, J2EE supports pure HTML, as well as Java applets or applications. It relies on Java Server Pages and servlet code to create HTML or other formatted data for the client. • Enterprise JavaBeans (EJBs) provide another layer where the platform's logic is stored. An EJB server provides functions such as threading, concurrency, security and memory management. These services are transparent to the author. • Java Database Connectivity (JDBC), which is the Java equivalent to ODBC, is the standard interface for Java databases. • The Java servlet API enhances consistency for developers without requiring a graphical user interface.
J2EE - http://en.wikipedia.org/wiki/J2EE • Java Platform, Enterprise Edition or Java EE (formerly also J2EE) is a programming platform – part of the Java platform – for developing and running distributed multi-tier architecture applications, based largely on modular components running on an application server. The Java EE platform is defined by a specification. Java EE is also considered informally to be a language or standard because providers must agree to certain conformance requirements in order to declare their products as Java EE compliant; albeit with no ISO or ECMA standard. • Java EE includes several API specifications, such as JDBC, client-side applets, RPC, CORBA, and defines how to coordinate them. Java EE also features some specifications unique to Java EE for components. These include Enterprise Java Beans, servlets, portlets (following the JSR 168 specification), JavaServer Pages and several web service technologies. This allows the developer to create an enterprise application that is portable between platforms and scalable, while integrating with legacy technologies.
Apache - http://httpd.apache.org/ • The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards. • Apache has been the most popular web server on the Internet since April 1996. The November 2005 Netcraft Web Server Survey found that more than 70% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined. • The Apache HTTP Server is a project of the Apache Software Foundation.
Tomcat - http://java.sun.com/products/jsp/tomcat/ • is a free, open-source implementation of Java Servlet and JavaServer Pages technologies developed under the Jakarta project at the Apache Software Foundation. • Apache Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies.
Spring Framework - http://www.springframework.org/about • The most complete lightweight container, providing centralized, automated configuration and wiring of your application objects. The container is non-invasive, capable of assembling a complex system from a set of loosely-coupled components (POJOs) in a consistent and transparent fashion. The container brings agility and leverage, and improves application testability and scalability by allowing software components to be first developed and tested in isolation, then scaled up for deployment in any environment (J2SE or J2EE). • A common abstraction layer for transaction management, allowing for pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues. Generic strategies for JTA and a single JDBC DataSource are included. In contrast to plain JTA or EJB CMT, Spring's transaction support is not tied to J2EE environments. • A JDBC abstraction layer that offers a meaningful exception hierarchy (no more pulling vendor codes out of SQLException), simplifies error handling, and greatly reduces the amount of code you'll need to write. You'll never need to write another finally block to use JDBC again. The JDBC-oriented exceptions comply to Spring's generic DAO exception hierarchy. • Integration with Toplink, Hibernate, JDO, and iBATIS SQL Maps: in terms of resource holders, DAO implementation support, and transaction strategies. First-class Hibernate support with lots of IoC convenience features, addressing many typical Hibernate integration issues. All of these comply to Spring's generic transaction and DAO exception hierarchies. • AOP functionality, fully integrated into Spring configuration management. You can AOP-enable any object managed by Spring, adding aspects such as declarative transaction management. With Spring, you can have declarative transaction management without EJB... even without JTA, if you're using a single database in Tomcat or another web container without JTA support. • A flexible MVC web application framework, built on core Spring functionality. This framework is highly configurable via strategy interfaces, and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. Note that a Spring middle tier can easily be combined with a web tier based on any other web MVC framework, like Struts, WebWork, or Tapestry.
Struts - http://struts.apache.org/ • The goal of the Apache Struts project is to encourage application architectures based on the "Model 2" approach, a variation of the classic Model-View-Controller (MVC) design paradigm. Under Model 2, a servlet (or equivalent) manages business logic execution, and presentation logic resides mainly in server pages. • The Apache Struts project encourages Model 2 designs in two ways. First, by providing open source frameworks and toolkits that help developers build applications for the web. Second, by providing friendly and honest mailing lists where both newcomers and veterans discuss how to use Struts software in their own Model 2 applications.
Tapestry http://jakarta.apache.org/tapestry/index.html • Tapestry is an open-source framework for creating dynamic, robust, highly scalable web applications in Java. Tapestry complements and builds upon the standard Java Servlet API, and so it works in any servlet container or application server. • Tapestry divides a web application into a set of pages, each constructed from components. • Developing Tapestry applications involves creating HTML templates using plain HTML, and combining the templates with small amounts of Java code using (optional) XML descriptor files. • In Tapestry, you create your application in terms of objects, and the methods and properties of those objects -- and specifically not in terms of URLs and query parameters. Tapestry brings true object oriented development to Java web applications.
BeeHive - http://beehive.apache.org/ • The Beehive goal is to make J2EE programming easier by building a simple object model on J2EE and Struts. Using the new JSR-175 annotations, Beehive reduces the coding necessary for J2EE. The initial Beehive project has three pieces. • NetUI: An annotation-driven web application programming framework that is built atop Struts. NetUI centralizes navigation logic, state, metadata, and exception handling in a single encapsulated and reusable Page Flow Controller class. In addition, NetUI provides a set of JSP tags for rendering HTML / XHTML and higher-level UI constructs such as data grids and trees and has first-class integration with JavaServer Faces and Struts. • Controls: A lightweight, metadata-driven component framework for building that reduces the complexity of being a client of enterprise resources. Controls provide a unified client abstraction that can be implemented to access a diverse set of enterprise resources using a single configuration model. • Web Service Metadata (WSM): An implementation of JSR 181 which standardizes a simplified, annotation-driven model for building Java web services. • In addition, Beehive includes a set of system controls that are abstractions for low-level J2EE resource APIs such as EJB, JMS, JDBC, and web services.
Hibernate - http://www.hibernate.org/ • Hibernate is a powerful, high performance object/relational persistence and query service. • Hibernate lets you develop persistent classes following object-oriented idiom - including association, inheritance, polymorphism, composition, and collections. • Hibernate allows you to express queries in its own portable SQL extension (HQL), as well as in native SQL, or with an object-oriented Criteria and Example API.
iBatis - http://ibatis.apache.org/ • The iBATIS Data Mapper framework makes it easier to use a database with Java and .NET applications. iBATIS couples objects with stored procedures or SQL statements using a XML descriptor. • This framework maps classes to SQL statements using a very simple XML descriptor.
Maven - http://maven.apache.org/ • Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.