It’s time to show off my java hello world with 7 errors on line 34
I don’t know what I did wrong, but the bug must be somewhere in
HelloWorldExampleClassForTutorialBuilderFactory.HelloWorldExampleClassForTutorialBuilderFactory(StringBuilderFactory myHelloWorldExampleClassForTutorialStringBuilder, int numberOfTimesToDisplayHelloWorld)
Man if I were in the US I’d apply for that job in a heartbeat, looks like that was written by a head dev who actually knows what he’s talking about rather than some recruiter
This thread reminds me that most “developers” are terrible and don’t take the time to understand the language.
All of these Java developers you guys hate is the result of schools pushing out idiots. It’s not the language but rather the type of people you hire. These people will suck at writing in any language regardless of what order they try.
Agreed, good tools can be used badly. Over the years I’ve written Java, C++, and PHP professionally, and I’ve seen excellent and horrible impls in each. Today, I mostly use Java and this thread is reminding me that I need to learn a new for-fun language.
Learn kotlin, it’s awesome and runs on literally everything.
Kotlin won’t save your skin if the code you wrote should be performant but you layered it into a heap of abstract classes, interfaces, factories, etc and, realistically, no one else would use or expand on that
Sure, but nobody codes like that in kotlin (or in modern Java for that matter)
When I was in the military, the shooting instructors said they preferred training females because they haven’t been trained poorly by somebody else.
EDIT: Designating recruits as male and female is the way the military does things. I don’t use the terms male and female when referring to groups of humans. I felt the need to clarify since somebody already took offense.
they preferred training females
It’s “women”.
deleted by creator
Perhaps because people aren’t going around calling others “males” to demean them?
These are not difficult concepts if you turn on your brain.
You’ve obviously never been in the military, because it’s definitely “females”.
I’m from a country with mandatory conscription for men, so yes, I’ve been in the military and I’ve seen the misogyny (among countless other varieties of bigotry) rampant in that system from front row seats. We had a handful of female volunteer conscripts, as well as one of my NCOs was a woman, and it was blatantly obvious they were not recieving the same treatment as the majority of us who were men (and not in a good way, if there was any room for confusion).
Experiences like that are among the key reasons I’m not happy to see people keep perpetuating that kind of behavior, especially in other traditionally male-centric contexts like the IT industry and even here on this forum.
In French, the literal translation of female and male, are only used for animals in the common language, but I have been taught that in English it is ok to use those for humans in common language. Is it not the case in your region?
deleted by creator
I don’t really see a problem with saying things like “my female friends” or “my female colleagues”, when it’s used as an adjective.
No one claimed it is, when used as an adjective :)
Adjective is fine! As a noun it’s creepy and makes you sound like an incel
This, people just being weird about terms
I, too, would like the winter winds to teach me about Rust.
OOP does things to a person
a PersonImpl, you mean? :P
The horror of the single inheritance that forces you to use composition instead.
The boredom of knowledge which exception every method throws.
The narrowness of generics that don’t allow duck typing.
The oppression of monads and pattern matching.
The poverty of a central package repository and only 2 package managers.
The pressure of choice between dozens of garbage collectors for different workloads.
The promiscuity of the single platform that interconnects various programming languages and allows all of them to use features like state-of-the-art profile-guided optimizations.The horrible world of Java.
I know the guy meant it as a joke but in my team I see the damage “academic” OOP/UML courses do to a programmer. In a library that’s supposed to be high-performance code in C++ and does stuff like solving certain PDEs and performing heavy Monte-Carlo simulations, the guys with OOP/UML background tend to abuse dynamic polymorphism (they put on a pikachu face when you show them that there’s also static polymorphism) and write a lot of bad code with lots of indirections and many of them aren’t aware of the fact that virtual functions and
dynamic_cast
’s have a price and an especially ugly one if you use them at every step of your iterative algorithm. They’re usually used to garbage collectors and when they switch to C++ they become paranoiac and abuseshared_ptr
’s because it gives them peace of mind as the resource will be guaranteed to be freed when it’s not needed anymore and they don’t have to care about when that is the case, they obviously ignore that under the hood there are atomics when incrementing the ref counter (I removed the shared pointers of a dev who did this in our team and our code became twice as fast). Like the guy in the screenshot I certainly wouldn’t want to have someone in my team who was molded by Java and UML diagrams.Depends on the requirements. Writing the code in a natural and readable way should be number one.
Then you benchmark and find out what actually takes time; and then optimize from there.
At least thats my approach when working with mostly functional languages. No need obsess over the performance of something thats ran only a dozen times per second.
I do hate over engineered abstractions though. But not for performance reasons.
You need to me careful about benchmarking to find performance problems after the fact. You can get stuck in a local maxima where there is no particular cost center buts it’s all just slow.
If performance specifically is a goal there should probably at least be a theory of how it will be achieved and then that can be refined with benchmarks and profiling.
Writing the code in a natural and readable way should be number one.
I mean, even there it depends what you’re doing. A small matrix multiplication library should be fast even if it makes the code uglier. For most coders you’re right, though.
In my experience we all go through a stage at the Designed-Developer level of, having discovered things like Design Patterns, overengineering the design of the software to the point of making it near unmaintainable (for others or for ourselves 6 months down the line).
The next stage is to discover the joys of KISS and, like you described, refraining from premature optimization.
I think many academic courses are stuck with old OOP theories from the 90s, while the rest of the industry have learned from its failures long time ago and moved on with more refined OOP practices. Turns out inheritance is one of the worst ways to achieve OOP.
I think a lot of academic oop adds inheritance for the heck of it. Like they’re more interested in creating a tree of life for programming than they are in creating a maintainable understandable program.
deleted by creator
OOP can be good. The problem is that in Java 101 courses it’s often taught by heavily using inheritance.
I think inheritance is a bad representation of how stuff is actually built. Let’s say you want to build a house. With the inheritance way of thinking you’re imagining all possible types of buildings you can make. There’s houses, apartment buildings, warehouses, offices, mansions, bunkers etc… Then you imagine how all these buildings are related to each other and start to draw a hierarchy.
In the end you’re not really building a house. You’re just thinking about buildings as an abstract concept. You’re tasked to build a basic house, but you are dreaming about mansions instead. It’s just a curious pastime for computer science professors.
A more direct way of building houses is to think about all the parts it’s composed of and how they interact with each other. These are the objects in an OOP system. Ideally the objects should be as independent as possible.
This concept is called composition over inheritance.
For example, you don’t need to understand all the internals of the toilet to use it. The toilet doesn’t need to be aware of the entire plumbing system for it to work. The plumbing system shouldn’t be designed for one particular toilet either. You should be allowed to install a new improved toilet if you so wish. As long the toilet is compatible with your plumbing system. The fridge should still work even if there’s no toilet in the house.
If you do it right you should also be able to test the toilet individually without connecting it to a real house. Now you suddenly have a unit testable system.
If you ever need polymorphism, you should use interfaces.
This was a nice analogy, thanks for the write-up.
That’s the problem, a lot of CS professors never worked in the industry or did anything outside academia so they never learned those lessons…or the last time they did work was back in the 90s lol.
Doesn’t help that most universities don’t seem to offer “software engineering” degrees and so everyone takes “computer science” even if they don’t want to be a computer scientist.
There’s an alternative system where this doesn’t happen: pay university professors less than a living wage.
You do that, and you’ll get professors who work in the industry (they have to) and who love teaching (why else would they teach).
I studied CS in country where public university is free and the state doesn’t fund it appropriately. Which obviously isn’t great, but I got amazing teachers with real world experience.
My son just finished CS in a country with paid and well funded university, and some of the professors were terrible teachers (I watched some of his remote classes during covid) and completely out of touch with the industry. His course on AI was all about Prolog. Not even a mention of neural networks, even while GPT3 was all the rage.
I have been writing code professionally for 6ish years now and have no idea what you said
That’s wild that shared ptr is so inefficient. I thought everyone was moving towards those because they were universally better. No one mentions the performance hit.
Atomic instructions are quite slow and if they run a lot… Rust has two types of reference counted pointer for that reason. One that has atomic reference counting for multithreaded code and one non-atomic for single threaded. Reference counting is usually overkill in the first place and can be a sign that your code doesn’t have proper ownership.
I actually have a ton of professional Java experience and have done a lot of microcontroller stuff of late (for fun mainly) and if you go at doing software for ARM Cortex-M microcontrollers the Java way you’re going to end with overengineered bloatware.
It’s however not a Java-only thing: most of those things have too little memory and processing resources for designing the whole software in a pure OO way, plus you’re pretty much coding directly on the low-level (with at most a thin Hardware Abstraction Layer between your code and direct register manipulation) so only ever having used high-level OO languages isn’t really good preparation for it, something which applies not only for people with only Java experience but also for those whose entire experience is with things like C#.Net as well as all smartphone frameworks and languages (Objective-C, Kotlin, Swift).
I used to write a lot of performance-critical Java (oxymoron I know) for wearables, and one time I got a code reviewer who only did server-side Java, and the differences in our philosophies were staggering.
He wanted me to convert all my code to functional style, using optionals and streams instead of simple null checks and array iterations. When explained that those things are slower and take more memory it was like I was speaking an alien language. He never even had to consider that code would be running on a system with limited RAM and CPU cycles, didn’t even understand how that was possible.
This may be an unpopular opinion, but I like some of the ideas behind functional programming.
An excellent example would be where you have a stream of data that you need to process. With streams, filters, maps, and (to a lesser extent) reduction functions, you’re encouraged to write maintainable code. As long as everything isn’t horribly coupled and lambdas are replaced with named functions, you end up with a nicely readable pipeline that describes what happens at each stage. Having a bunch of smaller functions is great for unit testing, too!
But in Java… yeah, no. Java, the JVM and Java bytecode is not optimized for that style of programming.
As far as the language itself goes, the lack of suffix functions hurts readability. If we have code to do some specific, common operation over streams, we’re stuck with nesting. For instance,
var result = sortAndSumEveryNthValue(2, data.stream() .map(parseData) .filter(ParsedData::isValid) .map(ParsedData::getValue) ) .map(value -> value / 2) ...
That would be much easier to read at a glance if we had a pipeline operator or something like Kotlin extension functions.
var result = data.stream() .map(parseData) .filter(ParsedData::isValid) .map(ParsedData::getValue) .sortAndSumEveryNthValue(2) // suffix form .map(value -> value / 2) ...
Even JavaScript added a pipeline operator to solve this kind of nesting problem.
And then we have the issues caused by the implementation of the language. Everything except primitives are an object, and only objects can be passed into generic functions.
Lambda functions? Short-lived instances of anonymous classes that implement some interface.
Generics over a primitive type (e.g.
HashMap<Integer, String>
)? Short-lived boxed primitives that automatically desugar to the primitive type.If I wanted my functional code to be as fast as writing everything in an imperative style, I would have to trust that the JIT performs appropriate optimizations. Unfortunately, I don’t. There’s a lot that needs to be optimized:
- Inlining lambdas and small functions.
- Recognizing boxed primitives and replacing them with raw primitives.
- Escape analysis and avoiding heap memory allocations for temporary objects.
- Avoiding unnecessary copying by constructing object fields in-place.
- Converting the stream to a loop.
I’m sure some of those are implemented, but as far as benchmarks have shown, Streams are still slower in Java 17. That’s not to say that Java’s functional programming APIs should be avoided at all costs—that’s premature optimization. But in hot loops or places where performance is critical, they are not the optimal choice.
Outside of Java but still within the JVM ecosystem, Kotlin actually has the capability to inline functions passed to higher-order functions at compile time.
/rant
In most programming I have done, we treat the users as the dumb mofos. In Java, the programmers are treated as the dumb mofos. As a dumb mofo, I have a great dislike toward Java’s standard development ecosystems.
That’s really interesting. Maybe it’s like @nxtsuda@lemmy.world said. For a lot of folks, OOP was the way we learned and operated for years
Could they have just asked it differently? Or do they just have Java hate.
It’s obviously an embedded role. Java and its developers are notorious for throwing memory and compute usage out the window.