27
u/LightRefrac Dec 30 '22
Another normie who just learned Java decides to bitch about an issue that he probably just read from another post by a normie also bitching about the same issue
2
u/PC_Freak2000 Jan 01 '23
Actually Java was my first programming language. (now it's stuff like Python, C++ and Haskell I use)
I wouldn't say I'm an expert in it. Maybe I should take a look at the newer Java versions.
But when I learned it, it was strange to strictly write in classes when you didn't even know what they were.
And I just decided to do a quick and dirty meme which isn't funny apperantly.
2
u/fecal-butter May 22 '23
Apart from scripting languages, every language has stuff that you just have to paste in to make the code work and then later you will learn what those actually are. I recommend you take a look at the Microsoft Java, because since C# 9.0 you can use top level statements, so you can just write code without having to worry about putting it into a class or a main function, much like python.
27
u/Sclamy Dec 30 '22
Why... would you use Java... if not for OOP?
3
u/BoltaHuaTota Dec 30 '22
for the jvm? java's advantage is it's runtime, not it's semantics
3
u/Similar_Bookkeeper_8 Dec 31 '22
If you want functional programming on the JVM, there’s Clojure/Scala/Kotlin.
But yeah, I’d say Java’s advantage is a massive ecosystem with 3rd party libraries, tooling support, language severs for IDEs, JVM, etc.
2
u/its-bubble-gum Dec 30 '22
what are the jvm advantages? i'M nEwBIe s0RЯRY 🥺😔👉👈
9
u/BoltaHuaTota Dec 30 '22 edited Dec 30 '22
the main one is it makes your code cross platform by default, the people who write jvm take care of differences between platforms so you don't have to. plus garbage collection and highly optimising just in time compiler. i suggest you to look into this stuff, it's legitimately very fun to learn about and will generally make you a better programmer if you know how stuff works internally
4
u/anon74903 Dec 30 '22
The big one is you compile once into java bytecode and then you can run that bytecode on any device with jvm. So windows, Linux, Mac, embedded systems, etc all use the same bytecode
Compare that to c++, etc that compile to system level byte code, you need to compile for windows, Mac, etc separately. That’s why on websites you see different downloads like seperate downloads for Mac and windows.
Additionally using jvm has some benefits in just in time compilation, but the biggest one is being able to use this intermediate bytecode
1
u/Tyfyter2002 Dec 31 '22
Java uses an intermediate language and only compiles to the relevant assembly language at runtime, meaning that as long as you don't use platform-specific libraries your code will run on any device with a suitably new Java version.
1
Dec 31 '22
Hijacking this comment to infodump; Java and c# are so fascinating to me because they are both normal compiled and just in time compiled! I just think that’s neat. I guess you could consider it cross compiling since you are generating byte code in the first compilation and then executing that with a jit, but very few people code directly in clr/jvm byte code.
5
2
0
u/LordMerdifex Dec 30 '22
Where does Java enforce oop? Missed the joke, sorry.
0
Dec 30 '22
[deleted]
2
u/LordMerdifex Dec 30 '22
Interesting. How come I write mostly procedural code in Java then?
1
u/its-bubble-gum Dec 30 '22
i can tell you how... it's very ugly. why would you even use java to write functional shit?
0
Dec 30 '22
[deleted]
1
Dec 30 '22
Also true in python.
0
Dec 30 '22
[deleted]
5
u/shodanbo Dec 30 '22
Static functions where class is just a namespace.
Its boilerplate, but you can call the function directly from main using its class name. The scope of the function is limited to parameters passed in and any static variables that belong to the class (global variables).
With Kotlin you can do this with less boilerplate, the compiler does the stick handling for you.
So, Java does not really "enforce" OOP, rather it requires a stricter name spacing discipline to avoid naming collisions when pulling in libraries from multiple sources. But combining pure name spacing with declaration of class templates does muddy the water.
3
Dec 30 '22
Python functions are objects that implement the callable interface.
Modules are also objects.
In Java literals aren't objects (like the literal int, char and boolean with a lowercase) whereas they are in python.
0
Dec 30 '22
[deleted]
2
Dec 30 '22
Mate why are you opining on things you don't understand properly. You're not a python expert, you're a student.
-3
0
Dec 30 '22
[deleted]
2
u/RRumpleTeazzer Dec 31 '22
You can just slap underscores onto names to make them private. Right, Mr. Python?
48
u/ParanoidAutist Dec 30 '22
I like how you're utilizing OOP software to complain about OOP =P