Tuesday, September 29, 2020

Re: Why Don’t You Use Java for Programming the Client-Side Web Apps on Web Browser?

Hi Thomas,

thanks for the feedback.

This is my point of view as a Java developer 😉I did some Polyglot projects and have written my summary here from 2011: 
In the beginning I was a fan of "use the right language for the right problem" but at the end I saw the problem in maintenance and as we all know, maintenance is the hardest part of software development. Building from scratch is always easy and fun. This presentation from Netflix is also very interesting: https://youtu.be/W3HkCF0jBZA - Key message: Polyglot is expensive. As I wrote my summary in 2011 I always thought that all the problems in maintenance is because my projects were always mid-size and such a problem would not exist in Google, FB, Netflix... but the presentation from Netflix from 2018 told me something different 😁

I know and IMHO I think TypeScript is a very good language + transpiler + tooling. But today I'm very careful to introduce new programming language, new tooling, frameworks and ecosystem. If I cannot see the clear advantages I won't do it. Just because you could write the code in more compact or functional way, it won't give you the advantages you hope.

So, to come back to the discussion, yes my opinion is biased but I hope I'm not dogmatic, this should not happen in our domain or elsewhere since I hope that we could always learn new things and adapt the good things and learn from the bad things 😉

BTW. I find it also interesting that Angular offers DI and it looks really like all the patterns we had in GWT... and I found Mocking is very important, I see a lot of developers cannot "localized" the problem to fix bugs faster. In today environment with Microservices it is a very important work to make everything in "small" part / "make everything running locally" so you could enclose the problem and fix it.

Thanks,
Lofi
t.br...@gmail.com schrieb am Dienstag, 29. September 2020 um 13:45:56 UTC+2:


On Tuesday, September 29, 2020 at 12:08:36 AM UTC+2, lofid...@gmail.com wrote:
OK, now I understand you 😉

Yes, we always have to separate the Client and the Server part. This is also GWT best practice.

But if you are using JavaScript on browser you lose the advantages like:
  1. We use Java as the language

Is Java objectively the best language out there to be used as an argument that way?
 
  1. We have the best ecosystem like libraries, frameworks, build system and IDEs.

Please define in which way they're "the best".
In terms of dependency management, NPM and Yarn are probably better than Maven (but not Gradle, which looks unrivaled on that point).
In terms of build systems, I hope you're not trying to compare anything to Maven; but I also wonder how you're going to do things like PostCSS, Imagemin, SVGO, etc. do with a J2Cl toolchain. GWT does some of those (not all), but the JS frontend ecosystem is the clear winner on that point.
VS Code, and probably (I never used them for non-JVM projects) IntelliJ IDEA / WebStorm, and I suppose Visual Studio too, are absolutely great IDEs too for JS and/or TypeScript (and Go, and probably many others).
  1. We know best design patterns to make our apps maintainable like Dependency Injection, Mock Testing and many other just take a look at: http://bit.ly/DesignPatternsJava

Wow, how condescending!
BTW, as already pointed by Rodolfo, design patterns are language independent. The "GoF" Design Patterns book has all its examples in C++ and Smalltalk, not Java; and that link you give lists exactly those patterns from the book.
I do miss Dependency Injection from time to time in JS devs, but if you really want/need it, there are ways to do it (React Context for example); and Angular does DI: https://angular.io/guide/architecture-services#dependency-injection-di
Mocking is overrated, but far from impossible in JS, including for network access: https://mswjs.io/ and even though I personally rarely do automated testing of frontend devs (and that's true of GWT too), the JS ecosystem has some quite good libraries as well (testing in a browser environment with GWT is quite "outdated" in comparison: HtmlUnit or the defunct SeleniumRC, or manually launching your browser; fortunately we're doing better with J2Cl by leveraging Selenium/WebDriver).
 
  1. … and if you use Java on the server-side with Spring Framework or JavaEE you have one language through the whole stack. So, you could reuse Validation APIs, Business Rules, Business Model, etc. from server to client.

If you do need to share code, then J2Cl is for you; but that doesn't mean using Java for the whole client-side app. That's actually exactly what J2Cl was built for, in replacement for GWT inside Google: leveraging Closure for web development while being able to share code with the backend through J2Cl (and mobile native apps, through J2ObjC for iOS).

Back to your original question: 
I would like to know, what are the obstacles for you as Java developers not using Java as programming language for writing Web browser apps.

First, I don't consider myself as a "Java developer"; I'm a developer, and I'm proficient in Java (but also JavaScript and Kotlin, somewhat less in Go or Python, and I could probably still do good things in PHP if you forced me to use it).
Now let me return the question: what are the obstacles for you to use JS or TS (possibly mixed with Java through J2Cl) for frontend development?

I'm not saying you shouldn't use Java (we wouldn't be there otherwise), I'm questioning why you wouldn't use something else.
By describing yourself as a Java developer (and praising the Java language and ecosystem like you do), it looks like maybe it could be because you don't know anything else, treating Java like your golden hammer (https://en.wikipedia.org/wiki/Law_of_the_instrument)

My personal take on it is: it depends. It depends on the project (what it does, whether you need to leverage some existing Java or JS library, its size, whether you need to share code with the server and/or native mobile apps, etc.), and of course the project team and its skills.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/35e6f4dd-5a16-451b-a2d5-35d5031bbb35n%40googlegroups.com.

No comments:

Post a Comment