DEV Community

loading...

The niche guy writing

greenroommate profile image Haris Secic Updated on ・3 min read

Intro

I worked with Spring + Java for a while but I changed a lot of jobs in 6 years of development and I was always treated more like "Jack of all trades master of none". Not that it's not true as I worked with Java, C#, ColdFusion, PHP, NodeJS + fronted stuff like AngularJS, vanilla JS, React, and if that's not enough had some experience setting up dev servers with Debian, Apache, mail server... Enough of naming stuff! I heard about Groovy but never had time to learn yet another thing I'm not going to be good at. So in 2017 when I got back on track with JVM and started working again with Java I had discussions with work colleagues and watch webinars, read articles about JVM stuff. Heard and liked a lot of thing about Scala and Kotlin but thought Kotlin was mainly hype and it's going to be best used on Android.

A bit more

After a while got a job interview for Java developer but they told me they're switching to Kotlin on new APIs. Even though I never really cared about better C# for JVM :D, I wanted to learn something which is going to be in use and stick with it. Scala was a bit too hard and too niche and you had to know FP + OOP good and be really smart to get into projects/companies that use it as it was mainly used on high scale projects or big data processing. So I took a job in .NET Core and boy was I disappointed with the framework comming from Spring background. In spare time I played with Micronaut and I think it's amazing. Now knowing about Grails and GORM I thought why not build more APIs with Groovy since it's easier and faster to write in than Java, and why do we even need Kotlin except to replace Java since too many people hate it?

The rhetoric questions

Couple of days ago I saw Groovy being #20th on the TIOBE index and Kotlin #35. Today, 11.04.2019 (04.11 in US :D) it's still the same. So I started wondering about Groovy. Is it gaining popularity because of Micronaut as most examples are combination Java + Groovy where Groovy is mainly used with spock examples for testing? Is Kotlin getting pushed by it or is it loosing battle in mobile world were we can expect Flutter, Dart, Xamarin to replace it?

Now Scala is not for replacing Java as it's not so compatible with existing frameworks for Java and it requires a lot of tuning to use it like that. Instead it has it's own purpose and frameworks. Groovy is like easy language for JVM. It has less strict rules than Java and frameworks like GORM do a lot of nice stuff so you have to type less.

On the other hand there's GraalVM. It allows devs to write a lot of stuff in different languages and connect them easily - at least that's what their aiming for. So what will be the effect on JVM?

Outro

Just wanted to get some opinions. Please to inform me about my poor writing skills as this is my first blog post so I can update this poem.

Discussion (2)

pic
Editor guide
Collapse
jorgecc profile image
Jorge Castro • Edited

IMHO, Groovy and Kotlin are only syntax sugar, they are better than Java but not for a long margin. However, usually, we are hired for Java, not for Groovy or Kotlin. And Java is not so bad after all.

For example, people complain about EJB are evil and they are hard to program.

It is ejb:


@Stateless
public class MyEJB {
   // my code...
}

And nothing more. How is it difficulty?. It was hard (pre-Java 6), but now it is trivial to write an EJB.

Anyways, right now everything is Spring (Boot).


@Service
public class MyService {
   // my code...
}

And it is also trivial.

What I don't like of Java are the setter and getters but it is a small detail.

IMHO, Java is not hard because the language but the whole Java World is quite messy. For example, the Application Server, the artifacts, they deploy and so on.

Collapse
greenroommate profile image
Haris Secic Author • Edited

I agree.

Personally I love annotations for a lot of stuff. Currently I work as .NET Core and there you need to write something like services.AddScoped() which makes no sense as they have [Controller] annotation. Why not give [Service(scope)]. Also I love that Spring is mainly Singleton style for most stuff at least on projects I worked for like Controllers, Services, Repository. In .NET Core you need to realy think hard before using singleton as most are scoped which in spring is Request scope if I remember correctly. Also forget about @Repository and implements JpaRepository because in C# you have DbContext and try to get your head around it first week you switch from Spring. But all of this is about framework. As a language I do miss some stuff in it.

I love checked exceptions as they make me feel safer and less testing is required but I do miss ?. and ?? from C# in Java. I also miss something like initializing object and filling stuff like in C# new Stuff { a = "", b = 5...} forgot what this is called. When it comes to LINQ I like streams better. I do however still miss anonymous type while using streams. In LINQ C# you can do list.Select(x => new { Att = "", Att2 = 1}) while in java 11 it's still not that simple.

However I like Java and hope to see it get more features/syntactic sugar, but on projects that don't require too much performance why would I not now skip some stuff and use Groovy since it's faster to work with. For example you need quick small API for just simple CRUD and need to use JVM for some reason. Especially with Micronaut out, I'm more excited about it than any other thing recently.