The Java neighborhood feels very good these days

Introduction

I have been using Java continuously in my career as an engineer, but I feel that it is much easier to use than before. Also, while listening to lectures at JJUG, JSUG, etc., I personally feel that the recent Java area is very progressive and good.

Meanwhile, I saw tweets that "Java has a large population and there is no merit to adopt it specially" and "Java is legacy and low productivity", so I would like to write my thoughts with that counterargument. I will.

In addition, some of the contents described below are that ** Java is better than a specific framework, but it is not that it is just about Java "neighborhood" **.

What I like about Java these days

  1. Improvement of language specifications and standard library
  2. How quickly the project starts
  3. Utilization of type safety
  4. Support for microservices architecture
  5. Performance improvement

1. Improvement of language specifications and standard library

It's been a long time ago, but I feel that programming efficiency and accuracy have improved significantly since the introduction of lambda expressions and the Stream API. I also feel that the standard library is shifting from the once extreme minimalist to a positive idea towards the reality that "what developers often use is included in the standard library." Furthermore, the release cycle has been reviewed since JDK9, and it can be expected that the speed of language evolution will increase. (There is a problem with what to do with the JDK version, but I'll leave it for now)

2. How quickly the project starts

In Spring Framework, you can instantly create a web application with Spring Initializer or Eclipse plug-in. If you use the built-in server, you can start the server from the main function without preparing anything. Reference: How to make a hinadan for Spring Boot project using SPRING INITIALIZR

There are a lot of related libraries, and it's easy to use just by writing the dependency in pom.xml.

3. Type safety

I think there are pros and cons to static typing, but I think the recent Java community has brought out the good side. Stream API For example, the Stream API works well with static typing, and even if you write a fairly long code at once, it will work almost as intended if it compiles, and if you master it, you can code it very efficiently. Spring Boot The Spring Framework can now be type-safe with annotations, instead of the old XML-based configuration. I feel that this has dramatically improved the ease of bean definition and maintainability. Reference: Understanding how Spring Boot AutoConfigure works There are various merits of defining such a bean, but for example, test automation becomes easier, and the cost of upgrading the language and framework can be reduced.

DBFlute I have a very good O / R mapper called DBFlute which is my favorite framework and is resistant to DB changes. Type safety is maintained by reading the metadata of the schema and automatically generating the Java source code. With it, you can easily implement data access with simple and readable Java code, and if it compiles, SQL will be executed almost as intended, so you can expect extremely high productivity if you master it.

4. Support for microservices architecture

Various libraries are provided under the name Spring Cloud for microservices architecture. Although I haven't touched on it in practice, my approach to microservices using Spring is often the subject of lectures.

Reference: Basics of Spring Cloud to understand quickly Reference: [[Spring Fest 2018 Report] Journey to in-house payment system-Cloud-native system development with Spring and PCF](https://dev.classmethod.jp/etc/spring-fest-2018-sf_h1 /)

In addition, there is a library called micrometer that stores and provides data for metric measurement, and was featured in several lectures at JSUG 2018. After becoming Spring Boot 2 system, just by describing the dependency in pom.xml, it will run in the background at startup, and it seems easy to customize the measurement target. Reference: [Measure and send metrics using a micrometer in Spring Boot] (https://k11i.biz/blog/2018/03/24/spring-boot-with-micrometer/)

5. Performance considerations

With the recent Spring Framework, I feel that there is a lot of work being done to adapt to the environment where performance is severely required.

WebFlux With WebFlux, which is the main feature of Spring5, you can handle a large number of requests with a small number of threads and make effective use of resources. Reference: Understanding the overview of Spring WebFlux

However, as of now, JDBC does not support Reactive, so there are still considerable restrictions on using it in practice, but it seems that Spring is also working on this (I feel like doing it that much). Reference: R2DBC was announced at Spring One

Native

GraalVM seems to be able to nativeize Java applications. In a demo at the JSUG 2018 keynote, I saw GraalVM nativeize a Spring application that would normally take more than a second to launch in milliseconds. Currently, it seems that it can be applied only in quite limited situations, but I heard that we will aim for full support eventually (although I am not confident because it was an English lecture). Reference: SPRING FEST 2018

in conclusion

Let's try a series of bad sentences that are not very well organized.

About the slow progress of Java and the strong "idea"

I think Java is a language that has a strong "idea" despite the transitions of the times. I also feel that many Java frameworks have a strong idea as well. Perhaps there is a difference between likes and dislikes, and sometimes it develops into a conflict.

Feelings of particular likes and dislikes towards Oracle in response to the article "Why I have Oracle's shoulders over Google in Java API proceedings" I don't have it, but I agree with the content.

Discuss carefully and openly so as not to upset the overall balance, as described in "Can Java be Great Again with the Power of the Community" The process of determining specifications over and over may seem slow and unprogressive to some viewers. However, I think it makes a lot of sense to be totally consistent with this kind of prudence (although I'm not completely dissatisfied with the java spec).

Whether it's a language or a framework, I think it's important to understand "idea" in order to use it well. On the other hand, if you can't read the idea or if you can see a halfway compromise, you may be confused about how to use it or you may not like it.

About static typing

I also like to write JavaScript relatively, so I think I'm well aware of the goodness of statically typed languages. When moving from JavaScript to Java, the amount of description can be frustrating. So I know I'm feeling a backlash against Java's robust static typing system.

However, as mentioned above, I feel that it can be a powerful weapon depending on how it is used. I imagine that maintenance will be difficult without static typing when the scale of software grows.

Calmly discuss the advantages and disadvantages

Java is old in terms of language specifications and has some flaws, but I think that it is desperately seeking evolution while maintaining backward compatibility and overall balance. On the other hand, those who dismiss "Java is outdated and unproductive" wonder what kind of sharp technology they are using. For example, is there a framework that takes a Spring-like approach to microservices architecture (although I can't say anything because I'm not familiar with other frameworks)?

Ultimately, I think it will come down to likes and dislikes as to which language and framework to adopt, but I think it would be good if we could calmly discuss the advantages and disadvantages after knowing the recent circumstances.

Thank you for staying with us until the end.

2018/11/11 postscript

There was a description in the article that dissected a specific language, but it was deleted because the number of views was larger than expected and the deviation from the main subject was severe. (If you want to check it, please see the comment section.) I have no intention of burning it, so I would like to avoid criticizing a specific language in the future.

2018/11/17 postscript

There were quite a few opinions and concerns about the JDK, so I wrote my own thoughts. It may be off the mark, but please refer to it if you like. Organizing the current state of Java and considering the future

Recommended Posts

The Java neighborhood feels very good these days
The demon laughs. 2018 Java neighborhood dare choice.
The comparison of enums is ==, and equals is good [Java]
[Java] Get the date 10 days later with the Calendar class
In 2021, there is no topic in Java these days (Poem)