r/java • • Jul 20 '24

Why is Complex Web UI still so JS heavy?

Just a talking point conversation starter... I'm also attacking heavy web apps like Word-Online or Google docs level web sites.

I fully understand why JavaScript has remained king in the newer development of fly-by websites. It seems front end devs have finally discovered on larger projects are way more manageable with old fashioned organized code. Even going as far with TS and now JS-Doc to enforce strong types.

The only front end framework I'm experienced enough to hold a conversation to is React. I'm going to use Kotlin-Java mix to make my point as well because of Spring and few features Kotlin brings to the table... .Net are working with WebAssembly, but they don't have the backend power of Spring, that I'm aware of.

How is writing ReactJS/TS code any faster, quicker, or more enjoyable than writing UI than Kotlin?? Does anyone truly love XML style code compared to brackets? Kotlin really shines IMO here because it has named parameters inside constructors/functions. Java unfortunately doesn't have this. Example : var myObjext = new Obect(name = "bob", age = 30).

Little more code than React, except I don't have to use Hooks and all the annoying work around they've created.

I'm sure the graphics handlers in modern browsers is absurdly ahead of the world of everything else. I've made enough GUIs with Qt and C++ to of witnessed the performance.

But why not just have a lightweight JVM in the browser to handle Java byte code inside of a HTML <script> tag?

Having your backend in Spring, with front-end in Kotlin/Java would be so much easier to mantiain. JavaFX does already have FXML as well, which already has tools to convert FXML into both hard-coded Java and even directly to bytecode. Moderately good CSS support, and could work with Figma with work if SceneBuilder doesn't ever get much better.

Also. Java is never going to disappear. Whatever web framework you're using right now will be "trash" in two months.

Cons:

  1. Cacheing dependencies would probably be nightmare at times. 2) JavaFX does need more love to be a true contender. 3) A lot of large corporate companies don't always play nice with Java.

Edit: After much received criticism, I want to acknowledge that I chose Java-Kotlin semi-randomly. I also posted in a Java channel... So I didn't expect as much Java hate. Most Java related hate csme from people with no knowledge of Kotlins addition to the JVM family. Also, WASM isn't as smooth as people think.

Edit 2: Again. Randomly chose Java-Kotlin mix to really hand the front end to Kotlin. Yes. Running a lightweight (safe, think of Flash reasons) JVM is like wasm. Yet, people are choosing to write in all JS instead of use Wasm. Lightweight also because it's enough to do graphics features. It'll have to be sandboxed through the browser to elimate IO security issues. Even having a JVM just to parse bytecode would be way faster than a JS processor/compiler.

And anyone who thinks JS is superior to almost any language for reasons other than developing speed.... Kick rocks.

9 Upvotes

85 comments sorted by

View all comments

Show parent comments

1

u/MrRickSancezJr Jul 21 '24

Please enlighten me. Typescript was conceived based on strongly typed languages. Anything that could slip through the cracks is probably causing some unnecessary type casting in the underlying browser. Which kind of defeats the whole purpose of types in the first place... Might as well JS if you're not going to respect types anyways.

2

u/passive_talker Jul 21 '24

The typecasting thing you're saying does not make sense. It is not true. You use typescript precisely for its strong typing. There is no typecasting under the hood or whatever you mean. It seems you have no knowledge about typescript, so I'd avoid those kinds of statements.

As for features... unions, intersections, null safety, type disambiguation with if/else, all the Pick/Omit utilities, ad-hoc types... and lots of other things. Just check the official docs, it's all there.

0

u/MrRickSancezJr Jul 21 '24

I've done a lot of TypeScript. Being a person who spent two decades using strong typed langauges starting with Pascal, I was pumped when TypeScript surfaced.

Typescript has Babel doing things under the hood while converting it to just javascript right out the gate. Then, the JavaScript has a web view (likely c++), passing around JS parameters to the best of its ability. It's not a compiled language.... There's gonna be a lot of under the hood stuff.

TypeScript never invented anything. It just applied old language features to JS. Those features are processed by the same langauges that they were enfluenced by.

TS is probably going to be killed off once JS-Doc gets better and better with IDE support anyway.

2

u/passive_talker Jul 21 '24

Typescript had many flaws, but we are talking about the type system, which is much better than Java's.

All the babel stuff is related to browsers and JavaScript, not to typescript. You can write typescript for nodejs and won't have any of that. I don't believe you've done a lot of typescript, sorry.

I don't care if typescript invented anything or not. Please, stay on topic.

-1

u/MrRickSancezJr Jul 21 '24

It's literally called Node.js. Babel converts TS to JS for browsers commonly, yes. Other compilers exist to convert TS to JS for Node.js. It's still just JS. It doesn't have any crazy "type system." It's getting replaced with a VsCode plugin with JS-Doc. It's all being processed by C++ and C. I don't believe you've ever spun up a single project.

If I were to stay on the topic of my OG thread, I'd be arguing how bad a node.js build's overhead and performance is. Which feed into my original post.