Java is an outstanding industrial development language because it brings great unity and attention to the fact that it does not exist before. But like all languages, Java will fade in the future. Based on the study of the Java, a repeated theme is that more and more people believe that Java is no longer sufficient. One of the following technologies can make you more efficient. They are not suitable for all the projects, but they are excellent tools when they are applied to the appropriate project. 1. Dynamic language dynamics can be more efficient than static languages like C or Java. They can make you express more in less language. Here, I will pay attention to the current most popular dynamic language Ruby. Comparison with Ruby's "Hello, World" and Java:
"Hello, World." This is obviously simple and clear. You don't need to write some other code to do this. Here is a description using Java language:
Class HelloWorld
{
Public static void main (string [] args)
{
System.out.println ("Hello World!")
}
} In Java, the type is static. This represents the compiler to check all types; you must build and compile a complete program. In Ruby, the type is dynamic, so you don't need to declare them, you can write and run them immediately. Below is the Fibonacci sequence described in two languages:
First, Ruby: X1, X2 = 0, 1
//110.Times Do Puts x2 x1,
X2 = x2, x1 x2
// 4END notes two variables at the first and four lines, allowing you to simply express two different statements. Also, note that 10 is an object, which supports methods such as: Times. Further, it is a code block between DO and END. The Ruby code block allows you to get the code block in the method. . This technique leads to incredible efficiency and concise code. Next, take a look at the code implemented with Java:
Class Fib
{
Public static void main (string args [])
{
INT x1 = 0;
INT x2 = 1;
Int total = 1;
For (int i = 0; i <10; i )
{
System.out.println (Total);
Total = x1 x2;
X1 = x2;
X2 = Total;
}
}
} You need to declare all variables, and write it in detail you to use the iteration of for loops. Each variable is independent, so you have to have a temporary variable for storing Total. Compared to dynamic languages are more concise. According to an ordinary rule, if you can write less code without sacrificing readability, these code will lead to higher efficiency. (But you can't sacrifice readability to achieve this step, we can use Perl as the end.) More important, dynamic language is better, such as: Yuan programming. Hibernate uses meta programming technology to persist in objects. Spring uses meta-programming to increase services for Java objects, while exempting you have an additional support for them. On the Rails framework, when the red Ruby uses its own capabilities to build some of the most efficient application development framework. Surprisingly, many Java developers used Ruby. The inventors of Ant and Tomcat James Duncan Davidson are using ruby on rails, as well as one of Java's bestseller. Many people with smart thinking in the Java community are turning to use dynamic languages like Ruby. This is because this new language can better solve the most interesting questions. Dynamic language will not completely replace Java, but they are suitable for solving small, lightweight problems. 2, Continuation Service Web programming is definitely a disaster. Ten years after Java is born, we still can't build a framework that makes the return button correctly. Web applications are invincible, so web applications will develop better. But it is difficult to build an application in China, and our existing framework cannot give us enough help. When you use most Java web frameworks, fundamentally, you have built a lot of applications that use servlets or JSP technology. Then use manual save the object to integrate them, these objects are what you need, used to temporarily store the object. Continuation is a language constructor that allows you to quickly store a state of a thread, and execute this thread later. The Continuation-based web framework is generally made by simulating a monitoring state to make Web development easier. This framework uses Continuation to save the status of the application when your application needs data from the user. If the user presses the back button or returns to the previous page through the browser's history, the application can re-read a Continuation. The best framework based on Continuation is developed in dynamic languages. So far, the most robust frame is Seaside. He is a framework based on a SMALLTALK SQueak language. Seaside supports a good debugging feature, you can check, debug, and change your code in your browser. Borges, Iowa and WEE are Ruby-based frameworks. Java does not support Continuations, but some Java frameworks constructed under special restrictions support the simulation of Continuations. These frameworks have some features of the Continual framework written in other languages. A popular frame is to use some advanced technologies such as bytecode enhancement, reflection, and special type loaders. These techniques have achieved Continuations in part of Java. Cocoon 2 Adds Continuations in the Rhino JavaScript virtual machine to simulate the application of monitoring status. Spring WebFlow uses a state machine to provide support for return buttons, as well as some of the other Continuation services. Lakeshore uses a hanging thread to simulate Continuations. This approach is not as scalable as other methods, but also lacks support for return buttons, but these are expected to have in the future.
There will be a new framework every month. I think we will use the Web development framework that supports Continations-based methods, which is written in a language or other language. 3. The practice of convention Beyond the configuration Java developers often explore ways to improve configuration. The new frame is increasingly configured using Java 5 annotations. Other frameworks are in a different way. Ruby's common practice in Rails to infer the connection that needs to be configured in other frameworks. For example: At the end, a Rails controller called BlogController and has a show method will automatically submit a view called show.rhtml in the blog_controller directory. Rails also uses a naming convention to bind a class that persisted in the database table. By default, the PerSN class matches the plurality of PEOPLE with English. The new framework will support conventions instead of configuration. 4, meticulous as mentioned above, there is a lot of HYPE in Ruby on the Rails programming frame. I think this HYPE is correct. Ruby on Rails allows you to write your programs at a more abstract level than Java. With Ruby on Rails, you can create domain objects, which can discover the contents of the associated database table. For example: You can write such a simple model object: Class Person Person = person.newPerson.name = 'Bruce Tate'Person.Email = The'Bruce.Tate@j2life.nospam.com'Person.save the column name and behavior of the database will be added to the Person class after running. You can easily extend the Person class: Class Person HAS_MANY: CARSEND passed the simple method of Belongs_to in Ruby and: DEPARTMENT marker, I realized all I want to do. Activity record implicitly invokes Ruby's meta-programming to add all methods and variables, these methods and variables are used to manage a pair of relationships between any department. Rails users use domain languages to manage such relationships like inherit, and can work with the Ruby language in a more abstract level. Rails seamlessly expands the Ruby language. Will Rails will be the next generation of great framework? possible. To make a choice, Rails should be the first in the flyback of the Ruby or other dynamic programming language. Alternatively, you may see that Rails will be the center of some loose alignment technology, which is based on meta-programming. In any case, you will be more efficient. Summary in "Beyond Java" this book, I expressed Java and won't eliminate the meaning, but in the last ten years, we have witnessed innovations outside the Java field. These four technologies will play an important role in the near future. Please pay close attention to them.