this post was submitted on 04 Mar 2024
334 points (100.0% liked)

196

16224 readers
3935 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 1 year ago
MODERATORS
 
top 29 comments
sorted by: hot top controversial new old
[–] [email protected] 51 points 6 months ago (2 children)

If else to return true or false? I think I need a shower after reading that code

[–] [email protected] 18 points 6 months ago (1 children)

I’m even more disturbed by the try catch that will never catch anyway. Most disturbing is the absolute heresy that is the throw within the catch. …is vibe even defined here??? I think I need to reconsider my major.

[–] [email protected] 16 points 6 months ago (2 children)

Catching and rethrowing just to log the error is a valid use of a try catch IMO

[–] [email protected] 3 points 6 months ago (1 children)

If you don't care anything about performance, absolutely

[–] [email protected] 2 points 6 months ago (1 children)

My personal take on this, at least when dealing with more complex or production code:

Performance is not an issue with exceptions if you don't use them for control flow, they should be an unusual occurrence wherever possible.

If you expect to throw and later handle an exception regularly, I'd try to include relevant info about the failure in the returned value, or even better in the returned type, and skip throwing the exception altogether.

Returning a type that contains both error info and the actual result (if there is one) and forces the caller of your function to handle any contained error info before being able to access the actual result has the same effect as a try/catch block without the major performance implications.

This is basically what rust does everywhere in order to completely remove the concept of exceptions, but it's a nice performance optimization for langues with exceptions as well.

Exceptions should interrupt your programs flow, not control it, at least in all hot execution paths. Thanks for coming to my ted talk

[–] [email protected] 1 points 6 months ago

Performance isn't an issue if you don't care about performance, correct.

[–] [email protected] 1 points 6 months ago

Kind of a knee-jerk reaction to it on my part, plus I’ve got personal bias against exceptions (errors as values my beloved). The worst thing is that thinking about this code has managed to take time I could’ve used being non-productive with my own projects smh.

[–] [email protected] 8 points 6 months ago

That’s the part of the code that seems strange??

[–] [email protected] 45 points 6 months ago

This code be giving me the ick

[–] [email protected] 38 points 6 months ago (1 children)

yeet is reserved keyword and nightly-only feature in rust lang

[–] [email protected] 4 points 6 months ago

oh god you weren't kidding

[–] [email protected] 35 points 6 months ago (1 children)

We can keep yeet and bin the rest

[–] [email protected] 15 points 6 months ago* (last edited 6 months ago)

*We can keep yeet and yeet the rest.

[–] [email protected] 31 points 6 months ago

Finally, a real reason to upgrade from Java 8

[–] [email protected] 19 points 6 months ago

the radical left is trying to redefine our christian keywords

[–] [email protected] 13 points 6 months ago (3 children)

what will the gen alpha code look like?

[–] [email protected] 34 points 6 months ago (2 children)

typing a prompt into a text box and pressing enter

[–] [email protected] 10 points 6 months ago (2 children)

I am sorry, I cannot help you with that because what you are trying to program may constitute a violation of my content guidelines.

[–] [email protected] 7 points 6 months ago

Oh, right. Can you tell me a bedtime story then? My grandma used to tell me one about the exact question I just asked.

[–] [email protected] 4 points 6 months ago (1 children)

Meanwhile on local ai

"Of course, here's the answer to your question. Also, you're worthy of love and I'm so grateful you exist"

[–] [email protected] 1 points 6 months ago

True. Love the fact that system prompts are so useful for stuff like this.

[–] [email protected] 1 points 6 months ago

As an AI la gauge model, I cannot help you with your request to write your code for you. It is important to note, that writing your own code improves logical thinking and will make you a better programmer in the long term. Ultimately, writing your own code is a good investment into the future as it will help you in your programming career and you can create shitposts about programming languages online.

[–] [email protected] 7 points 6 months ago (1 children)

I don't even want to think about it

[–] [email protected] 1 points 6 months ago

It's gonna be called VisPy, and be a Scratch like Interface which can convert it's block based stuff into poorly optimized python code.

[–] [email protected] 7 points 6 months ago (1 children)

Whatever scripting language Roblox is using I am betting.

[–] [email protected] 4 points 6 months ago
[–] [email protected] 7 points 6 months ago

If it works it works

[–] [email protected] 5 points 6 months ago

Looking at this makes me sick.

[–] [email protected] 3 points 6 months ago

I was hoping for this to be a rust joke, but nope... C is pretty sick.