0 reply content: two lines of python Ming cuiliu, a lump of java on the West Day... Everyone mentioned that development is fast, and I will mention another one: Debugging and testing are more convenient.
On the one hand, static language compilation takes a long time. Both debugging and testing are not as fast as dynamic languages. I remember writing an Android program some time ago. debugging and running tests had to go through a long process of compilation and packaging. I had to watch a movie while waiting for it to be compiled for about half a minute, just watch a movie for half a minute ).
On the other hand, static languages have made a lot of effort in the "dynamic" direction for testability. The most obvious example is that many Java development frameworks use dependency injection containers to produce objects to increase testability. Let's see how they implement dependency injection-Write the XML configuration file (or Annotation, one thing) and then the DI container uses the reflection API to dynamically instantiate objects at runtime. I would like to laugh at this: static language strictly separates the three sections in the compilation phase-loading phase-runtime phase, but the framework tries its best to transfer the actions during the loading phase to the runtime phase. Why not use dynamic languages directly?
Dynamic proxies implement AOP or something. A bunch of concepts can be developed in the Java framework, which is a daily task in dynamic languages. Most static languages use the two banners "compiler check" and "better performance. In these two banners, the former cannot guarantee anything at all-No tests rely solely on compiler checks, and the consequences are unimaginable; the latter has been very powerful in the second point above, the dynamic implementation of DI containers and AOP containers cannot be compared with the implementation of native dynamic languages in the VM kernel in terms of performance. In addition, Web applications are generally not processor-intensive, and the bottleneck is generally I/O rather than computation. Therefore, the efficiency of running loops and tuning functions at the language level is nothing.
These problems actually exist in most development projects, but they are especially exposed in Web application development. I think this is related to the rapid lifecycle of Web applications. In the development of Web applications, the above problems are magnified due to extremely fast iteration and a large number of dependency tests. Therefore, I think this is why developers prefer dynamic languages for Web applications. In general, it is not a problem with Web programs, but the Java language is outdated in the current programming era.
Java was born in the OOP era. Its original design was intended to complete some very huge software engineering, in that era, people believe that modularity, standardization, and reusability are more important than anything else, and OOP is the only solution to these problems. In the Internet era, the importance of code standardization and reusability has declined. Speed and availability are more important than any indicator, because slowness means death. Even in the Internet era, many developers allow some bugs as long as they do not seriously affect user experience. The rise of the concept of FP (functional programming) has also severely impacted the world view of Java's "Everything is an object.
Java programs are usually lengthy and contain a lot of files. without reading them all, they cannot understand the code at all. Many files only define the specifications (that is, interfaces) that an object should follow, but do not do any practical work. Without such work, code reuse cannot be achieved. Many objects only contain a set of data without any practical methods, the data must first define the storage variables, and then define a set of getter and setter for each variable to ensure good access control capabilities.
Even if you follow all these principles, when you find that the original interface definition does not meet your actual needs and you need to add new interface functions, you will face the embarrassment of modifying all interface implementation classes. If this new feature only exists in some classes that implement this interface, you will have more trouble. You must define a new interface and implement the old interface, then implement the new interface again for the class with this feature. This makes Java programmers reluctant to modify the interface implementation, but by adding various hack to complete the function, resulting in strong coupling and hard-to-understand between modules due to the well-defined and well-structured code, more and more hack will eventually turn the program into a disaster.
Relatively, the script language emphasizes the actual functions, basically there is no code that does not complete the actual functions. The Dynamic Language feature makes it easy to modify the data structure, especially with serialization algorithms such as json, to a large extent, the concept of "not strictly defined data structures cannot be stored" that follows C/C ++ is a revolution. Dynamic languages can even achieve reusability more easily. For example, for python, many library functions do not require the input parameter to be a certain data type, instead, you can use an attribute or interface with a specific name. Most fundamentally, the scripting language uses the defined rigor in exchange for the flexibility of program design. Such a program not only has a small amount of code, but also "the boat is too small to turn the head ", in order to adapt to the needs of the Internet era, the fast-paced development model is changing frequently.
Compilation languages such as Java and C/C ++ are still very useful when developing complex systems. However, for Internet applications, there are not many complex systems. It is acceptable to say that dynamic language development is fast, and that testing and debugging are fast.
For Java and C #, the default debugging must be IDE, breakpoint, single step, and dynamic language? Sorry, I am not familiar with these dynamic languages. In recent years, JavaScript can finally be used in a browser for a single step. Do node servers have easy-to-use single-step debugger? What about python? Pdb? What is ruby used? I really don't know. I just asked my colleagues next to ruby. The answer is yes. The debugging of Dynamic Language is faster. Do you really think that the debugging method of println is faster than that of IDE's single-step breakpoint?
It takes about half a day to package and release Java. This is not an error. What can you use android as an example? We seem to be talking about web development, right? Let's talk about android first. android is slow because google's android simulator is too slow. When I was doing android, I used vbox as the simulator, from the Code Point debugging button to the breakpoint, it usually takes no more than 20 s to take a breath. It's too late to watch a movie with coffee.
Besides, the packaging and restart of web applications is similar to that of dynamic languages. I have restarted web applications seven or eight times a day, but who told you that each code modification must be restarted? The tomcat plug-in that comes with eclipse requires you to re-release jsp every time to take effect. That is because the plug-in is too bad and there are many useful plug-ins. Why should I use it? Who told you to restart the java code to take effect? I have never heard of jrebel? Even if jrebel is not used, hotspot supports hot code replacement. Do you know? Oh, can't your company's java programmers tell you? That's why his salary is not higher than mine (how to avoid restarting in java web development: the second half of the http://www.zhihu.com/question/20218920/answer/34155532 ).
Let's talk about the compilation check. It is useless to check the compilation. Is there a test guarantee anyway? Is your code refactored? In IDE, Java code is reconstructed, and all the reference relationships can be correctly guaranteed. This is due to static types and compilation checks. How is it easy to refactor dynamic languages? Search and replace? Let alone the powerful refactoring tools of tiniu xite, and so on, I feel the conscience to say, is it so safe to have a static language such as Java/C? I already pushed the code when you are still repairing the test. OK?
There is only one benefit of dynamic language. It is fast to develop and can quickly make usable prototypes. This is of great significance in the Internet era, and no one can erase it, but why should we use java for web? Because the static characteristics of java can provide a longer life cycle for the code, the java IDE can greatly improve the efficiency of code debugging. When the code base is large enough, the advantage of easy-to-use IDE single-step breakpoint debugging is very important, because the efficiency of reading the code to understand the relationship between the two is definitely not as high as that of a breakpoint.
Well, I am actually talking about it. Fast Development speed? In fact, java web development has the most mature framework. I don't think it is a development block.
In addition, java is a powerful ide, such as eclipse and debugging, which is very convenient.
For Script Development, I think it is mainly lightweight, that is, it does not need many peripheral tools and is easy to deploy, such as using perl for development:
1. Download The mojolicious module: cpanm Mojolicious and then install the web framework.
2. Use the mojo generate lite app to generate a web site template.
3. You need to modify it and write something as needed.
4. Use perl script/myapp. pl to start the site.
Ps: perl web development is still very efficient. We recommend using the Mojolicious framework. The Code style is very good, real-time, non-blocking, event-based, less dependent, and easy to install. The advantage is fast development, many people mentioned this. DHH (the creator of Rails) also wrote an article about why he invented Rails for Web development without using Java.
I just want to talk about the debugging problem, as someone asks. In fact, the command line debugging tool for Ruby/Python is similar to that for GDB-it is also useful if GDB is used. Of course, if you want to use IDE, there are some plug-ins in Eclipse, or you can use other Ruby/Python IDE. In fact, for Web development, debugging with IDE is rare-except debugging code in a local test environment, other cases are basically useless. I have been developing Web applications for so many years and have never used IDE To tune things. The command line debugger allows you to easily tune code on remote machines, such as staging and even production environments, so it is more practical. However, in Web debug, most of the situations are due to the complexity of distributed systems. When you really need to use a debugger, you only need to use the log to lock the root cause of the problem to a very small and debuggable range.
Anyway, the tools you are familiar with are naturally advantageous to you. You are not familiar with Ruby, but you are familiar with Java. You will not be able to use Ruby any longer. More time to write code, less time to configure the environment.
On an OS X system that only has a standard Python environment and JDK environment, pip installs flask to write a hello world time. It is estimated that Tomcat has not been downloaded and started ...... It has no advantages.
The key is that you are not familiar with it.
- The Java World also has a fast development framework, which is more mature at the underlying layer and can be developed quickly by people who know it. For example, grails and play
- At the beginning, the script language framework provides scaffolding and templates for you to quickly build a prototype. However, if you are not familiar with the application, it will take a long time.
- It is true that xml is bloated by many people, but the defined xml can easily implement DSL code prompts in many IDE or editors, which is rigorous and convenient.
All in all, the way to use, save your mind. Rails knocks on two lines of commands, and the model addition, deletion, modification, and query and database table creation are all completed, 30 s. The most important thing that can become popular is lightweight.
Of course Java is very powerful, but it is too correct.