this post was submitted on 15 May 2024
243 points (88.1% liked)

Programmer Humor

24785 readers
900 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 63 points 1 year ago* (last edited 1 year ago) (10 children)

Go is like that abusive partner that gives you flowers and the next day makes you feel like shit. Then another day you go to an expensive restaurant and you tell yourself that maybe it's not so bad and they still care. And the cycle continues.

Rust is an autistic partner that sometimes struggles with telling you how much they care, is often overly pedantic about technical correctness and easily gets sidetracked by details, but with some genuine effort from both sides it's very much a workable relationship.

[–] [email protected] 43 points 1 year ago (9 children)

Yeah but Go has the best error handling paradigm of any programming language ever created:

ret, err := do_thing()

if err != nil {
    return nil, err
}

Don't you just love doing that every 5 lines of code?

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago) (2 children)

I do think Zig is better for this kind of thing.

const ret = try do_thing();

if( ret ) | result | {
   do_something_with_result(result);
}

The try keyword returns any error up; the if-unwrap works with what came out of a successful call. Normally you wouldn’t have both, of course.

do_thing would be defined as a union of an error (a distinct kind of type, so it can be reasoned about with try, catch and unwrapping) and the wrapped return value.

[–] [email protected] 5 points 1 year ago (1 children)
[–] [email protected] 2 points 1 year ago

Well, different floats for different boats I suppose.

load more comments (6 replies)
load more comments (6 replies)