this post was submitted on 24 Aug 2025
456 points (98.9% liked)

Programmer Humor

25958 readers
724 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
 
top 50 comments
sorted by: hot top controversial new old
[–] ArcaneSlime@lemmy.dbzer0.com 2 points 10 hours ago* (last edited 10 hours ago)

There's two of these threads?! Well ok here's the same comment.

10.years.ago
On.a.cold.dark.night
There.was.someone.killed
'Neath.the.town.hall.lights
There.were.few.at.the.scene
Though.they.all.agreed
That.the.slayer.who.ran
Looked.a.lot.like.me
[–] Unpigged@lemmy.dbzer0.com 5 points 18 hours ago

I miss Ruby DSLs so much. Python is bland. It's on purpose, I know and even appreciate it.

Yet I feel like Ruby syntax magic compared to Python blandness is like comparing a steaming plate of beautiful aromatic curry to plain rice.

[–] _stranger_@lemmy.world 34 points 1 day ago* (last edited 1 day ago) (2 children)

Ok, everyone who's ever had to use datetime hates it, but not because it's insufficient, but because international date/time is such a nightmare that the library must be complicated enough to support all the edge cases I'm convinced that library has a function for traveling trough time.

For years I've wrapped datetime with custom functions that do exactly and only what I want to mitigate its all-plumbing-zero-porcelain approach to the problem.

[–] raman_klogius@ani.social 3 points 20 hours ago (1 children)
[–] Alaknar@sopuli.xyz 1 points 13 hours ago

This is exactly why I love PowerShell.

Need the [DateTime] object from 10 years ago? No biggie, just chuck (Get-Date).AddYears(-10) down your console.

Need it in a specific timezone? That one's trickier, but since PowerShell can do .Net, run this:

$TargetDateTime = (Get-Date).AddYears(-10)
$TargetTimeZone = "India Standard Time"
$tz = [TimeZoneInfo]::FindSystemTimeZoneById($TargetTimeZone)
$utcOffset = $tz.GetUtcOffset($TargetDateTime)
[DateTimeOffset]::new($TargetDateTime.Ticks, $utcOffset)

And you get a DateTimeOffset object, which is this beauty:

DateTime           : 25/08/2015 23:15:14
UtcDateTime        : 25/08/2015 17:45:14
LocalDateTime      : 25/08/2015 19:45:14
Date               : 25/08/2015 00:00:00
Day                : 25
DayOfWeek          : Tuesday
DayOfYear          : 237
Hour               : 23
Millisecond        : 421
Microsecond        : 428
Nanosecond         : 600
Minute             : 15
Month              : 8
Offset             : 05:30:00
TotalOffsetMinutes : 330
Second             : 14
Ticks              : 635761413144214286
UtcTicks           : 635761215144214286
TimeOfDay          : 23:15:14.4214286
Year               : 2015

DateTime is the time in your target timezone, UtcDateTime is, well, the UTC time, and LocalDateTime is the time on host you ran the commands on.

[–] ripcord@lemmy.world 8 points 1 day ago* (last edited 1 day ago) (1 children)

Complicated or not, the interfaces suck. And dont have to. And that's the problem.

[–] _stranger_@lemmy.world 4 points 1 day ago

exactly why I wrap the parts I need, it's like git, tons of power, zero help.

[–] OmegaLemmy@discuss.online 12 points 1 day ago

Using ruby felt weird, it felt like it shouldn't work but it does.

[–] Diplomjodler3@lemmy.world 46 points 2 days ago (4 children)

The Python won't give an accurate date here because it doesn't take into account leap years.

[–] rtxn@lemmy.world 24 points 1 day ago (2 children)

timedelta marks time in days, seconds, and microseconds. It doesn't take leap years into account because the concept of years is irrelevant to timedelta. If you need to account for leap years, you need a different API.

[–] nilloc@discuss.tchncs.de 1 points 8 hours ago

365.25*10 would at least get you closer.

[–] Randelung@lemmy.world 1 points 18 hours ago

You can subtract two dates and get the exact time difference.

[–] wols@lemmy.zip 12 points 1 day ago (2 children)

The comparison is somewhat awkward, because the rails example presumably produces a date, while the python one is referring to an interval of time.
Just from the meme it's not obvious which was the actual intended use, so labeling either as inaccurate requires us to make assumptions.

Personally, the concept of "10 years ago" is a bit nebulous to me. If today is February 29th, is ten years ago March 1st? Doesn't seem right. Or particularly useful.

[–] nilloc@discuss.tchncs.de 1 points 8 hours ago

Ruby should add 10.years.ago.today

[–] eager_eagle@lemmy.world 5 points 1 day ago

yeah, that's pretty much why timedelta doesn't have the concept of months or years, just days and smaller units. I like it better this way.

[–] eager_eagle@lemmy.world 9 points 1 day ago* (last edited 1 day ago)

Because what's accurate here depends on the context, and the Python example doesn't hide that from the programmer.

The same dilemma goes for month calculations: does "3 months ago" mean 90 days ago, 91.3 days ago, this many days into the target month, or this many days from the target month's end (e.g. to account for 28, 29, 30, and 31-day months)?

[–] Blackmist@feddit.uk 3 points 1 day ago

Does the Ruby version do that though?

I haven't got it installed to check, but seeing constants like SECONDS_PER_YEAR in the documentation makes me think it's just as bad if not worse.

https://api.rubyonrails.org/classes/ActiveSupport/Duration.html

[–] bleistift2@sopuli.xyz 18 points 1 day ago (2 children)

Fuck that. I once used a constraint solver in python where you could += a constraint to a problem. This is completely un-discoverable. In any sane language you can use IntelliSense to find that you can problem.add(constraint) and be done with it without ever touching a manual. Overloaded operators are cool, but a menace.

And while I’m ranting: Angular’s new addRouting(), withThingA(), withThingB() is complete horseshit, too. The old way of doing addRouter({ and letting the IDE tell you what you could to with the router was so much clearer!

load more comments (2 replies)
[–] CubitOom@infosec.pub 48 points 2 days ago

Yukihiro “Matz” Matsumoto has often said that he is “trying to make Ruby natural, not simple,” in a way that mirrors life.

https://www.ruby-lang.org/en/about/

[–] marsza@lemmy.cafe 37 points 2 days ago (6 children)
[–] Sinthesis@lemmy.today 2 points 11 hours ago (1 children)
[–] marsza@lemmy.cafe 1 points 5 hours ago

That explains a lot about how GitHub works… or doesn’t.

[–] sfxrlz@lemmy.dbzer0.com 29 points 2 days ago (2 children)

I just started a new php gig

[–] marsza@lemmy.cafe 22 points 2 days ago (4 children)

I fucking love PHP. I know I probably sound crazy to most developers, but PHP 8+ is freaking dope.

load more comments (4 replies)
[–] Blackmist@feddit.uk 4 points 1 day ago

I work with Delphi.

I had a coworker choose RoR for a major project despite the fact that he didn't know it, nobody on his team knew it, nobody at our company knew it, and nobody in the entire state knew it. It ended as one would expect, after three years and millions of dollars spent, with the only revenue it generated being $50K from the original client that had to be refunded to avoid a lawsuit.

[–] LedgeDrop@lemmy.zip 11 points 2 days ago (2 children)

The handful of us have moved onto Crystal Lang. It's a statically type checked and compiled dialect of Ruby. Crystal is fun to write code, but the compiler is slower (compared to go-lang/rust)... because... well it's a ruby dialect (with DSL's)... and the 3rd party libraries are limited.

load more comments (2 replies)
load more comments (1 replies)
[–] rizzothesmall@sh.itjust.works 13 points 1 day ago (3 children)

Never use numbers when calculating dates. Use the data formats and constants the calendar library provides.

[–] brianary@lemmy.zip 8 points 1 day ago (2 children)
load more comments (2 replies)
load more comments (1 replies)
[–] etchinghillside@reddthat.com 24 points 2 days ago* (last edited 2 days ago) (6 children)

LLM is saying this is a feature of Rails and not particularly Ruby.

I was surprised Python didn’t have a years parameter but learned about

relativedelta(years=10)

[–] noxypaws@pawb.social 1 points 15 hours ago (1 children)

LLM is saying...

Stop. Nothing at all past those three words is worth a damn.

[–] etchinghillside@reddthat.com 0 points 14 hours ago (1 children)

What is the purpose of this comment.

[–] noxypaws@pawb.social 1 points 12 hours ago (1 children)

You didn't seem to be ashamed of admitting to asking an LLM a question as if it was helpful, wise, or respectable for you to have done. You should be.

[–] etchinghillside@reddthat.com 0 points 12 hours ago

This is a poor perspective to have on things towards a stranger on the internet. I hope you’re just having a bad day and that things get better.

[–] mesamunefire@piefed.social 30 points 2 days ago (1 children)

Yeah its a rails only thing. Rubys biggest issue is its much too intelligent for its own good. Its implicit rather than pythons explicit. Most of the time. That and it's hard to find out where Ruby starts and rails ends.

That being said I made a ton of good money on rails back about 15 or so years ago. Still excellent for starting out.

[–] tyler@programming.dev 1 points 5 hours ago

Ruby’s biggest issue is rails. Ruby is such a beautiful and highly functional language and yet everyone’s experience with it is rails’ horrific metaprogramming magic. I’ve had numerous people tell me they hate Ruby, and yet when I dig deeper I find out that they don’t actually understand where Ruby ends and rails starts and all of their problems lies on rails side. The majority of people I’ve shown that have come to actually like Ruby where they hated it before.

load more comments (4 replies)
[–] friend_of_satan@lemmy.world 17 points 2 days ago* (last edited 2 days ago) (1 children)

This implies that integers in ROR are complex objects with properties that would be unhelpful in the majority of scenarios. Is that right?

[–] myotheraccount@lemmy.world 16 points 2 days ago

Integers are just integers in ruby, with no structure backing them. They behave like objects, but only in some respects. You can call methods on them, but you can't extend individual numbers with properties for example (which would require them to have structure).

[–] goatinspace@feddit.org 20 points 2 days ago (1 children)
[–] m33@lemmy.zip 4 points 1 day ago

I'm surprised this post hasn't summoned perl devs yet... 🤨

load more comments
view more: next ›