An introductory textbook written by netizen koalant. (Please log in to download)
Introduces the Ruby language, Rails installation and a simple example. Very useful for beginners. Highly recommended!
If you are engaged in j2ee development as a Java programmer, you will definitely use many application frameworks. No language is as active as the Java language community, and any new programming concept will soon have corresponding open source implementations on the Internet. Corresponding to the most commonly used website development model MVC, each layer will have many frameworks. Struts and Tapestry belong to the controller layer (C), and the Velocity framework belongs to the view layer (V). The data persistence layer you use may be Hibernate, iBatis, OJB , or any of the many open source implementations of JDO, such as JPOX. But having too many choices is not necessarily a good thing, and not everyone can adopt the right framework to do the right thing. If your development platform is .net, then you may avoid this situation. Usually you only need to install a Visual Studio .net as a development tool, and then install an MSDN to find information. For program developers, this is a very difficult situation. I personally like Java very much. Whether it is learning or practice, it does provide us with a lot. But why do I think "one-stop" solutions like .net are correct many times?
As a Java programmer, I think some of the more obvious problems with Java are that first of all, Java is too complex, and secondly, Java is too programmer-oriented, not user-oriented. Compared with C++, Java is already very simple. The fact that there are so many Java programmers now illustrates this point. But as someone once said, "On Linux, you can easily tell who is the master", but it is not so easy in the Java field. I often find that my colleagues around me are still making very low-level conceptual mistakes. They can still engage in j2ee development for many years even if they cannot accurately distinguish what interfaces, abstract classes and Servlets are. But why is Java said to be complicated? Because it requires too many different technologies to accomplish one thing. So for programmers who don't have very clear concepts, how can you ensure that they make the right choice? And how many of the many frameworks provide "one-stop" services? The recently emerged Spring framework provides the most services among many frameworks, but it has a new problem, that is, it is still too oriented to programmers, not users. Why do you say that? Frameworks are originally designed for programmers, isn’t this right? Although Spring provides many choices (but not enough, it does not have an ORM itself), it does not provide a simple way to use it, so we can only say that it is for programmers. Most java frameworks have this problem, that is, the learning curve is relatively high. I think the level of the learning curve is the key to distinguish whether a framework is for programmers or users. I think this is mainly reflected in the ease of use of the framework. In fact, the ultimate users of the framework are programmers. The reason why we use "users" and "programmers" to distinguish is because some frameworks for "programmers" are difficult to use. Although they provide a large amount of infrastructure and parts, they still require Programmers assemble it themselves. The "user"-oriented framework is simpler. Users only need to follow the instructions to use it. Why Ruby on rails will cause a sensation in the Java community, I think the reason is that it provides a "one-stop" user-oriented, simple and easy-to-use framework, which is lacking in the Java framework. Why can Ruby on rails do this? Isn't it possible that Java itself can't do this? The fact is that many designers of Java frameworks do not do this. It may be that their thinking has been limited to how to use patterns to design a good framework, and they have not done more about the ease of use of the framework. Anyone who has used Spring knows that its xml configuration file will gradually expand, although we can easily break it into more small configuration files to solve this problem. But in using xml configuration files, it follows the customary concept of Java programming: "Java is the best programming language, XML is the best language for describing data, and the combination of the two is the most perfect. If an application does not Use xml to describe it, then it is not a good java application."
However, it is on this point that Ruby on Raiils is distinguished from many Java frameworks and achieves a breakthrough in the ease of use of the framework. This idea runs through the entire design of Rails: convention over configuration. For example, when we write Java web applications, we usually distinguish corresponding classes according to MVC. I personally like to put the Controller class in the web directory, the View class in the view directory, and the model class in the domain directory. middle. But different people have different settings and different names. How to let the framework know these different directories? The only solution for the java framework is to let it know this information through the xml configuration file. Rails' solution is: I define the directory structure, and you just need to put things in the directory I defined. This is an important reason why there are very few configuration files in rails (but not none). Although the idea is very simple, the benefit it brings is that the development efficiency of Rails is 10 times that of Java development (this is claimed by rails fans, but I believe this, and I believe you will also know it after reading this article) . So does this alone make rails development faster than using java? Not entirely, because this also benefits from another design philosophy of rails: less code. Not any language can claim that. Rails achieves this entirely thanks to its design language Ruby. With Ruby you can indeed write a lot of functionality in a small amount of language that is simply not possible with other languages. To master Rails, you must understand Ruby. Someone once said: Zope (the famous python web framework) is a killer application of python, and python is zope's secret weapon. I think this sentence is most appropriate to describe the relationship between rails and ruby.
Expand