📜 ⬆️ ⬇️

Changing the main stack from .NET to Java



I want to describe my observations and impressions about the most popular server programming language for Enterprise called Java . Observations and impressions on comparison and contrast with the “similar” .NET platform, with which I am very well acquainted. I am sure that ~ a year ago, when the future of the new dotnet once again seemed to me 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 minor technical / stylistic differences in programming languages ​​that are easy to google, but rather offer a top view of the ecosystem as a whole. So, Java through the eyes of a experienced hard worker with a decade of experience. I ask under the cat.

Disclaimer


Once upon a time, I already had similar thoughts to write about the interesting differences of Microsoft Sql Server / Oracle , in the style of “wow, no bool type”, “long transactions are the norm, is it serious?”, “As this is not an auto-commit in settings default ”etc. But the inner perfectionist thought everything that I had “not studied long enough and well”, “I will make a mistake somewhere,” “hurry people out of humor,” etc. - put everything on “later”, and then all the impressions literally washed away and there was nothing to write. So this time I decided not to wait too long, otherwise there could be nothing to write 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 banality of “how awkward it is to write without var” (Java 10 was already waiting for the other day), there are no “ extension methods ” and other “ type erasure ” and “ multiline -strings”.
So, the ecosystem.

1. IDE and terminology


In .NET the choice is obvious - Visual Studio. Work in the studio comes with projects (projects), which are grouped into a solution (the latter is .sln, then .json, then again .sln, not very important). Everything is quite simple.
')
In the Java world, as an IDE, two guys currently deserve attention - Intellij Idea and Eclipse . In the “post-Soviet space” first won. In foreign authors, Eclipse is very much alive. It would seem that what a difference you use, even though a notebook, but in this place a problem in terminology immediately arises.

In Eclipse, the topmost layer is the workspace , which consists of projects .
In Idea, the topmost level is the project , which consists of modules .

In what terminology to communicate to the developers using different IDE, it is not clear. Often taken to communicate in the terminology of "collectors". So, in the case of maven , for example, the distribution is built from modules ( modules ), which are grouped in a pom- file.

If I understand correctly, then this lack of confusion was brought about earlier by the lack of the modularity language “out of the box” and each tool previously heaped up “modularity” in those terms in which he considered it necessary.

Separately, I want to mention bins ( Beans ). In .Net, no one would think to introduce new terms for ordinary classes registered in the container. On many projects, containers are not used at all, even in 2018 (yes, it hurts to look at it, but I watched it more than once). In the Java world , the opposite is a container cult and it is often customary to communicate in terms of bins.

2. Build the project


First of all, in a new ecosystem, a slightly different utilitarian “cutting” is striking. In some cases, larger, in some - smaller.

In the .Net world, nuget is used as a package / dependency management tool, msbuild is used for building.

In Java, everything is glued together in one tool (however, here again there is a choice - Maven or Gradle ). For each there are a bunch of plugins. In the bloody interframe dominates the first.

There are very comfortable wrappers over the collectors that allow you to simply take and start the build (anyone who has come across the search for the right 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


Here is the absolute dominance of the Java platform. There are two main monsters: EJB and Spring with a huge ecosystem and “around” practices. Dominates the second. Over time, it also became big and complex, so even came up with a framework for the framework - Spring Boot. Which, I want to pay tribute, really makes life much easier.

There is nothing of this in .Net. But there is an invention of bicycles "in each project in its own way." Up to the choice of the desired DI / IoC container, the developer tastes (if the developer is generally aware of the existence of containers) and how to manage transactions (if the developer again knows what a transaction is and someone guesses to disable the autocommit on Sql Server) . Unless ASP.NET MVC is a bit like Spring MVC (which is only 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 a new Reactive Streams (hi .Net Async Controllers) and many implementations, of which Tomcat is one of the most popular “boxed” ones.

5. Community


Java Community Process and that says it all. A formal process in which interested parties can participate in the discussion and the 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 correctly” (remember the now-disbanded Microsoft Patterns and Practices group?) And came up with an analogue - the .NET Foundation .

6. Work with DB


This is still not a clear point for me why people continue to use JPQL in 2018. The only explanation I have found is that the typed Criteria is terrible and verbose.

This is one of the few places where pretnetchikam luckier 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 at least in something resembling production. Perhaps because it is a semi-paid replica without JSR, perhaps for another reason.

7. XML hell


It is still a popular misconception that java is tons of xml when. But at the current stage of development of the ecosystem, this is not at all the case. Quite the contrary! I can write a web application in Java without a single xml line (hello Spring Boot), and I can't do it on .Net (hello web.config, which is “essentially” the same web.xml, just also mixed with the config) .

findings


Everyone, if he wants, will do it himself. There is no black and white, pros, cons and compromises are everywhere and on all platforms. I can only write 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 begin to look at many conceptual and architectural things in a different way and from a different angle.

PS: At KPDV - an old, but still funny video .

Source: https://habr.com/ru/post/352404/


All Articles