4 ms·
To be more fair, java is mostly slow on startup which which is mostly due to: 1) Swing. I have no idea what this does on startup but it is bad. This is what k
by mohaine 9y ago
To be more fair, java is mostly slow on startup which which is mostly due to:
1) Swing. I have no idea what this does on startup but it is bad. This is what killed most java GUI apps. A simple AWT or SWT app will pop open while a simple swing app will take a few seconds to get started
2) Jars on systems with virus scanners. Jars are just zip files. Many virus scanners will unzip and scan a zip on every open which leads to each jar being unziped at least 2 times and often more if the app has to load more things from the jar at a later time.
3) Spring. Really spring is just a bad idea all the way through and most of the reason people hate java is Spring. Huge XML configuration files instead of code? Spring (mostly annotations now). Stupid names like AbstractSingletonProxyFactoryBean? Spring. That aside, on startup Spring will auto generate classes which really slows things down. This could have been done during the last build but spring does it at each startup which is really slow. Spring Boot has helped with startup times but it is still slower.
After startup Spring continues to kill performance. The underling code is full of maps to control request lifecycle so instead of just calling a method it has to ask "who all is configured to do something at step PreParseRequestEncoding?" then again at ParseRequestEncoding, PostParseRequestEncoding, PrePareRequestBody, ParseRequestBody.... Not real names but the idea and number of steps is. Most of the time the answer is "nobody" but it has to ask for every step that might ever need something done.
Add on top of this JPA which is super easy but quickly breaks down to a lot of DB calls. JPA is great for people who don't want to learn SQL and simple CRUD apps but anything with any amount of data will quickly slow down to thousands of DB round trips.
- karmakaze 9y ago> JPA I'd like to see some reallife-ish comparisons with Jooq
- nova22033 9y ago>JPA is great for people who don't want to learn SQL That's like saying Java is for people who don't want to learn C...or C is for people who don't want to learn assembly. It's the right tool for the right job. If you use it for everything, it's no so good.
- jacques_chester 9y agoI like Spring, I find it makes Java development pleasant, plus I have unfair access to the Spring team members by working for the same company. So I'll bite. > Huge XML configuration files instead of code? Spring (mostly annotations now). Spring 3, yes. Spring 4 and 5, no. XML has not been the blessed configuration approach for ~4 years. > Stupid names like AbstractSingletonProxyFactoryBean? Spring. Java is a language that has evolved enormously in expressiveness since Spring began, meaning heavyweight Go4 patterns were necessary early on to maintain a flexible substrate with a uniform interface serving very many use cases? Spring. > That aside, on startup Spring will auto generate classes which really slows things down. I believed this urban legend too. Dave Syer, who is understandably interested in Spring criticism, has done more empirical investigation than anyone on this topic[0]. The tl;dr is that boot time is proportional to total classes loaded. That's all, that's it. In-memory reflection operations are hilariously, stupidly, insanely faster than I/O. The JVM fetches and loads classes individually. So if you have a lot of classes, it takes a longer time to load. The other thing to bear in mind is that Spring relies on this much less than it used to. As the language and JVM have evolved, so has Spring. > The underling code is full of maps to control request lifecycle ... Not real names but the idea and number of steps is. Are you talking about servlet filters? Because any web framework is going to have a few of these. Spring MVC adds a handful and all of them can be removed, replaced or added to. Spring Security adds a bunch and all of them can be removed, replaced or added to. But the defaults are chosen because of feedback, not just for the heck of it. > Add on top of this JPA which is super easy but quickly breaks down to a lot of DB calls. JPA is great for people who don't want to learn SQL and simple CRUD apps but anything with any amount of data will quickly slow down to thousands of DB round trips. In general, yes, I agree that JPA is a PITA. For a small to medium system I would try to avoid it where possible. For a sufficiently large codebase -- thousands of domain objects, dozens or hundreds of programmers -- it might be a necessary evil. Mind you, if you want to see a world where the database goes from abused to outright mocked and ignored, pay a visit to Rails land. It drives me batty. [0] https://github.com/dsyer/spring-boot-startup-bench https://github.com/dsyer/spring-boot-startup-bench, particularly https://github.com/dsyer/spring-boot-startup-bench/tree/master/static https://github.com/dsyer/spring-boot-startup-bench/tree/mast...
- mohaine 9y ago
- diebir 9y agoNot sure about using Spring for creating Web services (most use JAX-RS), but otherwise Spring is great. Not sure what we would do without it. The two major aspects are the dependency injection and just sheer number of service libraries to do anything imaginable. I generally try to stay away from strong opinions and assume that when something has an opinion there may be a reason behind it, but in the case of Spring and Java, I have concluded that those not using or familiar with Spring are simply clueless jokers.
- StevePerkins 9y agoI don't even know what to say about items #1 and #2 here. Unless you work for JetBrains, is Swing relevant to anything? And virus scanners shouldn't be an issue unless you're running on a Windows server, in which case I question whether you know what you're doing. If you really believe that JPA means "you don't have to understand SQL", then you definitely don't know what you're doing. As for Spring, I get so tired of reading lengthy critiques that boil down to: 1. "It uses XML! (or at least it did 10 years ago, when my personal experience with it was last up-to-date)" 2. "It has some classes with long names! Named after design patterns that I don't like!" By all means, don't use Spring if you don't want to. But know that Spring is very modular, letting you include or exclude whatever you like, and the core is rather light. If you're not using at least some of it, then you're probably re-writing it... and doing a worse job than they did. Either way, stop ranting about it on web forums if your knowledge is from 2007.
- timthelion 9y ago> And virus scanners shouldn't be an issue unless you're running on a Windows server, in which case I question whether you know what you're doing. Is "the server" the only place where code is run today? That is a sad image for privacy and user sovereignty. I certainly still run a lot of code on my local system, and I wish more people did the same.
- mohaine 9y agoI (sadly) have production experience from within the last year. I don't use Spring by choice, but it still gets forced on me by coworkers and teammates, so I reserve the right to complain. I've heard the "you're probably re-writing it... and doing a worse job than they did" argument so many times, is this on the spring forums or something?