r/JavaProgramming • u/ExtraTNT • Aug 11 '26
Why is java so fucking hard for no reason?
Uni kind of loves java, using it as the default language in every module, except modules specifically around a language.
Currently struggling building a compiler with it... focus is more on working around java and the forced oop, managing state and getting fucked by gradle.
Have tests, that refuse to exit, can't be killed by the user, as they fork infinite and need to be killed with root, then the entire tooling falls apart and needs fixing.
Also for base functions you need to transform lists to streams and back to lists. Logic gets lost in boilerplate and overly verbose code.
I normally use languages like c and haskell, everyone always tells you, that they are much harder, than java, but can't agree at all
Is java supposed to be such a cluster fuck or am I missing something?
Also any idea, why char to char comparison sometimes fails, but char to hex works always?
Is this some random java thing or just my env?
13
4
u/Syntax-Tactics Aug 11 '26
Java has to be one of the easiest "languages" around, consider a career change.
1
u/InstantCoder Aug 11 '26
It’s hard because it is not taught anymore at schools and universities. And the language gets updated quite often (each 2 year almost) which makes online tutorials often outdated.
But if you have a good grasp of the OO concept then it’s not that hard.
For learning the SDK i would recommend using the help of AI.
And there is this thing called Spring Boot. Which is quite hard to learn for beginners and it is a complex framework. As a Java veteran, Im using Quarkus and I think this might be better for beginners because it doesn’t have all this bagage and bloat that comes with SB.
1
u/ExtraTNT Aug 11 '26
We have it at uni to build compilers (yeah, not a main usecase for a language like java). But I wasn't expecting it being so bad... Uni chose it, as they don't require you to know haskell or c.
I was really struggling getting a simple lexer going (turns out, my code was working and gradle just silently crashed and executed the old code, then went into infinite forking, leaking memory, having problems with gc or just using 512mb heap for no reason...)
Everything just seems complex for no reason (I'm no OOP guy, I do FP), you have to describe more of how you want to do something, rather, than what you want to do... A problem, that I don't have in haskell and also not really in c... Java feels like cpp, but with less power...
1
u/usedtoswimfast Aug 12 '26
At my uni we used extensively java for most things, but when we were at the phase of building a semi-compiler/parser we absolutely used C for that... idk why your uni is choosing what I can argue as the wrong tool for the job to teach you something...
1
u/romulusnr Aug 12 '26
Like any compiled language, unlike most interpreted language, it tends to be syntactically strict.
struggling building a compiler with it.
It's not really suited for that, ngl. OOP in general probably isn't
as they fork infinite
That shouldn't happen, and that's not a Java thing
for base functions you need to transform lists to streams and back to lists
I mean, you don't need to, not really. But it's all just encapsulation, it's not that bad.
char to char comparison sometimes fails
You mean char or you mean Character?
1
u/ExtraTNT Aug 12 '26
yeah, somehow using a linkedlist to sum up a token to debug print it caused build gradle to fork to get stuck by fucking up lock files and then forking to infinity when trying to kill it...
for the stream part, i'm a functional guy, so i use map and fold for so many things...
8bit, not cursed object thing... i mean i think i found the issue: it was gradle doing strange shit, after removing the linkedlist i used for the debug print, it went away...
1
u/romulusnr Aug 12 '26
well that's gradle not java.
1
u/ExtraTNT Aug 12 '26
So gradle is just a clusterfuck?
What do you use for enterprise software?
I mean cabal is apparently one of the main reasons people don’t use haskell for enterprise and I don’t have issues with cabal (with the exception of looking 5min at a typo and go “huh”)1
u/romulusnr Aug 13 '26
Idk i've ever only used maven and/or ant
Idk why you're using a linkedlist anyway and not just a List, unless that's what you meant.
1
u/ExtraTNT Aug 14 '26
Linked list, as array is expensive on add depending on the implementation… and as I don’t know shit about how it’s implemented in java, i go with the safe option…
1
u/romulusnr Aug 14 '26
Most people use ArrayList. Append is lightweight. It only gets messy in inserts, but then again, so does LinkedList (traverse to find N and then repoint all links. which includes N+1 since LinkedList is double linked) whereas insert in an array is ultimately a couple memcopies.
1
u/LogCatFromNantes Aug 12 '26
Java is a good langage it’s solide it’s trusted by enterprise although it’s not easy but it’s a solid bagage to learn and to work with your carrer
1
u/ExtraTNT Aug 12 '26
I’m using it, as it’s required by the module: basically build a compiler within 8 days (4 weeks, 2d a week)
Thing is, simple lexer took me a long time, was fighting more the language and build tools, than anything else… 4h fucking around with java and like 20min of actual logic…
(Seriously considered rewriting it in haskell)
Professionally i do functional c#, some react and for my own apis and frontends i use now haskell and my own js render framework…
1
u/am_Snowie Aug 13 '26
Why can't you just try lazy tokenization, it makes your life so easy, instead of storing all tokens in a buffer ahead of time. Emit and consume tokens as you go. Also take a look at crafting interpreters book, the first half uses java to build a simple tree walking interpreter.
1
u/ExtraTNT Aug 13 '26
We got an env, that gives us a stack like structure, i summed literals up i. A list, symbols are directly tokenised…
3
u/Scary-Ad6675 Aug 11 '26
try writing anything a company would want in haskell or C (a simple CRUD service with any DB behind it), try deploying it in production and maintain it. suddenly java becomes easier. this argument that a language is "easier" or "harder" requires the context: what are you trying to build, whats the problem at hand.
1
u/FooBarBuzzBoom Aug 11 '26
If Java is hard, what do you think about fucking advanced algorithms or useless shit like that?
1
u/sozesghost Aug 11 '26
Java is verbose, or can be, and that makes it easy to read and maintain. Writing it can be a hassle at times, but I like it. I could never stomach gradle however.
1
u/jonathancast Aug 11 '26
Pretty sure it's your environment. Gradle is a tiny minority thing in my experience, but I don't know what could be causing Java tests to fork bomb except a bad Gradle config.
I also don't know what you mean by "forced OOP". Professional Java code in my experience is pretty procedural. Your professor might want you to use OOP, but Java really only wants the ceremony of wrapping your code in a class.
1
u/Pale_Height_1251 Aug 12 '26
I agree Gradle can be a pain, but the rest of it is probably you. Show an example of the char comparison that isn't working for you.
1
u/whiterhino8 Aug 17 '26
Different people has different preference .
Java is good but it's not suite to every one . Because its verbosity and OOP design .
That's OK You can find yourself more comfortable with another languages.
4
Aug 11 '26
[removed] — view removed comment
1
u/ExtraTNT Aug 11 '26
I do fp normally, so it's an absolute nightmare... java 25 doesn't allow you to do things easily and has a lot of the things I normally use not implemented... no Maybe monads, no Tuples on language level, no proper pattern match and logic seems always far apart, I write more how my code does things, rather, than what my code does...
i usually write code like this:
group :: (Eq a) => [a] -> [[a]] group [] = [] group (x : xs) = takeWhile (== x) (x : xs) : group (dropWhile (== x) xs)1
u/Scf37 Aug 12 '26
Been there, seen that. fp is an awesome toy, but toys are too fun for big boring projects.
2
u/smaratter Aug 11 '26
It would be easier to help you if you were more specifik. How are you comparing chars to chars and to ”hex”?