optimal java experience

https://lemmy.ml/post/2105561

optimal java experience - Lemmy

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)
Ool about it. Where does the java hate come from?

OOP is fine. It’s particularly Java culture that’s terrible.

I never want to see the word Factory in a class name ever again.

When a Java dev writes in any other language, you can tell. Too many layers of abstraction is a key indicator. They make simple problems complex.

I once inherited a C# website project from a Java dev. I couldn’t even figure out how to modify the CSS. And I’m a C# dev.

Factories can be good in moderation. If you make factories for every class, maybe you need to rethink your practices.

I was part of a fun era at my university where they switched from C++, which is what I took in intro to programming, to java. So by the time I was doing some group projects senior year, I was working in C# with people who had only done Java.

They wanted to abstract everything. Everything had to be a class. Any time they repeated 2 lines of code it got put into a helper class.

We ran into an issue where the code just would not run no matter how hard we tried and of course no one on the project but me bothered to use git (they would literally send me the zipped up project on discord and I had to copy and paste everything into the actual code). I ended up rewriting the entire project overnight. It actually wasn’t that bad once I got into the flow of things. Turns out none of them knew how to program without being explicitly told how.

Still not the worst college group project though. Maybe top 5.

I’ve worked with Java for decades (kid you not: learned it from reading the Java Language Specification 1.0 back when it came out) and there’s definitivelly a stage (often a long one) in one’s career when one thinks him/herself so great at OO and just overengineers every single software design way (way, WAY) beyond the actual objective of behind the whole OO design concept (maintenability and bug reduction), actually achieving the opposite objectives (an unmaintainable POS, riddled with hard to track bugs because of way too many unnessary details having overwhelmed the developer’s ability to keep track of it all).

Eventually you learn KISS design and Refactoring as sort of housekeeping practice for code and design.

But yeah, as a freelancer I’ve very commonly landed in the middle of maintenance-stage projects with existing code bases that were clearly done by somebody at that oh-so-special stage in their career, and often it’s better to just reverse engineer the business requirements from the application and redo the whole thing (in the process cutting the codebase size to a small fraction of what it was).

OOP does things to a person
a PersonImpl, you mean? :P

That’s really interesting. Maybe it’s like @[email protected] 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.
If all I knew about java was some of the garbage projects I’ve inherited over the years I might hate it too.
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 and write a lot of bad code with lots of indirections and many of them aren’t aware of the fact that virtual methods and dynamic_cast’s have a price and an especially ugly one if you use them at every step of your iterative algorithm. Like the guy in the meme 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 probably right, though.

Even then you can take some effort to make easier to parse for humans.
Oh, absolutely. It’s just the second most important thing.

You can add tons of explanatory comments with zero performance cost.

Also in programming in general (so, outside stuff like being a Quant) the fraction of the code made which has high performance as the top priority is miniscule (and I say this having actually designed high-performance software systems for a living) - as explained earlier by @ForegoneConclusion, you don’t optimize upfront, you optimized when you figure out it’s actually needed.

Thinking about it, if you’re designing your own small matrix multiplication library (i.e. reinventing the wheel) you’re probably failing at a software design level: as long as the licensing is compatible, it’s usually better to get something that already exists, is performance oriented and has been in use for decades than making your own (almost certainly inferior and with fresh new bugs) thing.

Thinking about it, if you’re designing your own small matrix multiplication library (i.e. reinventing the wheel)

I mentioned this example because a fundamental improvement was actually made with the help of AI recently. 4x4 in specific was improved noticeably IIRC, and if you know a bit about matrix multiplication, that ripples out to large matrix algorithms.

PS: Not a personal critical

I would not actually try this unless I had a reason to think I could do better, but I come from a maths background and do have a tendency to worry about efficiency unnecessarily.

I think in most cases (matrix multiplication being probably the biggest exception) there is a way to write an algorithm that’s easy to read, especially with comments where needed, and still approaches the problem the best way. Whether it’s worth the time trying to build that is another question.

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.

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.

@einsteinx2 @magic_lobster_party

This is most definitely my experience with a lot of CS professors unfortunately.

The Design Patterns book itself (for many an OO-Bible) spends the first 70 something pages going all about general good OO programming advice, including (repeatedly emphasised) that OO design should favour delegation over inheritance.

Personally for me (who started programming professionally in the 90s), that first part of the book is at least as important the rest of it.

However a lot of people seemed to have learn Patterns as fad (popularized by oh-so-many people who never read a proper book about it and seem to be at the end of a long chinese-whispers chain on what those things are all about), rather than as a set of tools to use if and when it’s appropriate.

(Ditto for Agile, where so many seem to have learned loose practices from it as recipes, without understanding their actual purpose and applicability)

I’ll stop ranting now ;)

I fully agree about the damage done at universities. I also fully agree about the teaching professors being out of the game too long or never having been at a level which would be worth teaching to other people. A term which I heard from William Kenned first is ‘mechanical sympathy’. IMHO this is the big missing thing in modern CS education. (Ok, add to that the missing parts about proper OOP, proper functional programming and literally anything taught to CS grads but relational/automata theory and mathematics (summary: mathematics) :-P). In the end I wouldn’t trust anyone who cannot write Assembler, C and knows about Compiler Construction to write useful low level code or even tackle C++/Rust.

OOP/UML courses

Luckily, i had only one, and the crack who code-golfes in assembler did the work of us three.

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 have been writing code professionally for 6ish years now and have no idea what you said
When I was in the military, the shooting instructors said they preferred training females because they haven’t been trained poorly by somebody else.

they preferred training females

It’s “women”.

“They said”

“They said”

If only there was some generally agreed upon symbol to denote direct quotes as opposed to paraphrasing and idea in your own words. If only…

If only there were fewer dickheads looking for a fight online. If only.
I don’t understand what you’re saying
They already gave you a downvote lol. Redditism has arrived.
You sound like a miserable person
I’d rather sound miserable than incel.
Really? You sound both miserable and incel. You failed.
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.

Whether or not you personally agree with the military’s choice of language is not relevant to the story. You’re assuming the trainer agrees with your political views, but you weren’t there, so you have no idea what they said or didn’t say.
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?

It’s technically grammatically correct, but outside of a medical context, it has in recent years been heavily associated with incels and other creepy kinds of people. So in effect no, it’s not generally considered good to refer to women as “female” in day-to-day speech.

Examples:

“Females simply don’t have the emotional capacity that men do, which is why they’re so quick to cheat and betray” - typical incel line

“Today on the train I saw a beautiful female with silky hair and clear skin” - kinda sounds like a serial killer

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.
This, people just being weird about terms
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
Female/male are used in English as adjectives when describing humans, but as nouns they only refer to animals. “She is a woman” and “She is a female programmer” are both okay but calling women “females” is purposefully demeaning and sexist. I do not believe there is any regional difference in this, nor should we really care about such since there are no regions when we’re on a global forum.
Bevor Sie zur Google Suche weitergehen

nor should we really care about such since there are no regions when we’re on a global forum

English being a third language for me, I’m actually interested in understanding the differences coming from different cultures that I may not be aware of. I find global forum to be nice for this reason, although they are generally dominated by the Northern American culture.

I can’t speak with certainty, but I can speak subjectively on this -

I have family and friends all over the US (I’m only missing someone from both Dakotas to complete the collection), so I’ve heard damn near every accent, regional dialect, language, etc that there is to hear in the US, including some near dead native languages and Pennsylvania Dutch.

The only people I know that use “females” instead of women are either in the military like OP or they’re sexist. Sometimes it’s blatantly misogynistic, sometimes they’re casually sexist.

Or they’re both. It’s frequently both.

No one gets this upset over male lol
“Males” sounds just as awkward in such a context.

Perhaps because people aren’t going around calling others “males” to demean them?

These are not difficult concepts if you turn on your brain.

Nah. In the military, you aren’t “men and women” you are “soldiers” (or sailors, Marines, or airmen). If you are referring specifically to a specific gender such as a “female” soldier, then that’s what you call them.

No one says “women soldiers” except maybe a civilian.

No one says “women soldiers” except maybe a civilian.

And I’m not telling you to, stop putting words in my mouth. Female as an adjective is fine, “female soldier” is fine, calling a group of human women “females”, as in a noun, is demeaning and incel lingo.