Changing the main stack from .NET to Java
I want to describe my observations and impressions of the most popular server-side programming language for Enterprise called Java . Observations and impressions on comparison and contrast with a “similar” .NET platform , which I am very familiar with. I’m sure that ~ a year ago, when the future of the new subsidiary once again seemed too vague and the idea of changing the technological stack finally materialized in my head, this article would be very useful. I will try not to go into the minor technical / stylistic differences of programming languages that are easy to google, but rather offer a top view - on the ecosystem as a whole. So, Java through the eyes of a seasoned affiliate with ten years of experience. I ask for cat.
Once upon a time I had similar thoughts to write about interesting differences between Microsoft Sql Server / Oracle , in the style of “wow, there is no bool type”, “long transactions are normal, seriously?”, “How is it not auto-commit in settings by default ”, etc. But the internal perfectionist kept thinking that I hadn’t “studied long enough and well enough”, “I’ll be wrong somewhere,” “hurry to make people laugh”, etc. - put off everything on the “later”, and then all the impressions literally disappeared and there was nothing to write. So this time, I decided not to wait too long, otherwise there might be nothing to write about again. Therefore, a separate request to indicate to me inaccuracies, if they are present. And I, in turn, will try not to go into the platitudes “how inconvenient it is to write without var” (Java 10 has already waited the other day), “extension methods are missing ”and other“ type erasure ”and“ multiline -strings ”.
1. IDE and terminology
In .NET, the choice is obvious - Visual Studio. Work in the studio goes with projects (projects), which are grouped in solution (the latter is .sln, then .json, then again .sln, not very important). Everything is quite simple.
In the Java world, two guys currently deserve attention as an IDE - Intellij Idea and Eclipse . In the "post-Soviet space" the first won. For foreign authors, the eclipse is more alive than all living things. It would seem that it makes no difference what you use, even a notepad, but in this place there immediately arises a problem in terminology.
In Eclipse, the highest level is the workspace , which consists of projects .
The Idea is the top level - projectwhich consists of modules .
The terminology for developers using different IDEs is unclear. It is often customary to communicate in the terminology of “collectors”. So, in the case of, for example, maven , the distribution is assembled from modules ( modules ), which are grouped in a pom- nick.
If I understand correctly, this confusion was caused by the lack of modularity “out of the box” in the language earlier, and each tool has previously acclaimed “modularity” in those terms in which it considered necessary.
Separately, I want to note the beans ( Beans) In .Net, it would never occur to anyone to introduce new terms for ordinary classes registered in a container. On many projects, containers are not used at all, even in 2018 (yes, it hurts to look at it, but I have seen it more than once). In the Java world , on the contrary, it is a container cult and it is often customary to communicate in terms of bins.
2. Assembly of the project
First of all, in the new ecosystem, a somewhat different utilitarian “cut” is striking. In some cases, larger, in some - smaller.
In the .Net world as a means of package management / dependencies used NuGet , for assembly - msbuild .
In Java, everything is glued into one tool (however, there is again a choice - Maven or Gradle ). Each one has a bunch of plugins. The first dominates in bloody interprise.
There are very convenient wrappers over the collectors that allow you to just start and build (those who have come across the search for the necessary versions of msbuild on different machines will understand me).
Dotnet is now also trying to move in the same direction (hello, Cake ).
3. Application frameworks
This is the absolute dominance of the Java platform. There are two main monsters: EJB and Spring with a huge ecosystem and “around” practices. The second dominates. Over time, it also became large and complex, so they even came up with a framework for the framework - Spring Boot. Which, I want to pay tribute, really makes life a lot easier.
There is nothing of this in .Net. But there is an invention of bicycles “in each project in its own way”. Up to choosing the right DI / IoC container for the taste of the developer (if the developer is even aware of the existence of containers) and the decision how to manage transactions (if the developer again knows what transactions are and someone guessed to disable auto-commit on Sql Server) . Unless ASP.NET MVC is a bit like Spring MVC (which is just a small part of the Spring Framework).
4. Application Server
And IIS was one and monolithic. And Microsoft realized that System.Web is bad. And they came up with OWIN. However, adequate alternatives to IIS for Windows did not appear from this (yes, I know about Kestrel for .Net Core).
In Java, the choice is huge, there is a Servlet API, or the brand new Reactive Streams (hello .Net Async Controllers) and many implementations, of which Tomcat is one of the most popular “boxed" ones.
Java Community Process and that’s it. A formal process in which interested parties can participate in the discussion and formation of new versions of the platform.
Only 15 years later, Microsoft realized that it was good and it was time to stop dictating to the world “how to live” (remember the now disbanded Microsoft Patterns and Practices group?) And came up with an analogue - .NET Foundation .
6. Work with the database
This is still not a fully understood moment for me why people continue to use JPQL in 2018. The only explanation I found is that typed Criteria is horrible and verbose.
This is one of the few places where affiliates are more fortunate, because 99% of database queries in .NET are written on typed Compile-time LINQ.
Yes, I know about jOOQ , but I have never seen its use in at least something reminiscent of production. Perhaps because it's a semi-paid remake without JSR, maybe for another reason.
7. XML hell
The misconception that java is tons of xml when is still popular. But at the current stage of ecosystem development, this is not at all the case. Quite the contrary! I can write a web application in Java without a single line of xml (hello Spring Boot), and I can not do it on .Net (hello web.config, which is "essentially" the same web.xml, but also mixed with the config) .
Everyone, if he wants, will do it himself. There is no black and white, pluses, minuses and compromises are everywhere and on all platforms. I can write only personal - that changing the main programming language and the ecosystem as a whole after many years of development on the same platform is very interesting, useful and literally like a breath of fresh air. You start to look at many conceptual and architectural things in a different way and from a different angle.
PS: On KPDV - an old but still funny video .