I'm new to using Ruby and this tickled me pink
-
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 canproblem.
…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 doingaddRouter({
and letting the IDE tell you what you could to with the router was so much clearer!Any good inline help would run dir into your variable and discover it overloads that operator. It's a fault of your tools.
-
365.25, surely
Never use numbers when calculating dates. Use the data formats and constants the calendar library provides.
-
This post did not contain any content.
I'm surprised this post hasn't summoned perl devs yet... 🤨
-
This post did not contain any content.wrote last edited by [email protected]
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.
-
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 canproblem.
…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 doingaddRouter({
and letting the IDE tell you what you could to with the router was so much clearer!wrote last edited by [email protected]I'll take overloaded operators over overloaded functions any day of the week, and I also hate overloaded operators.
Python's optional typing has come a very long way in the past few years, you might be able to mitigate this with some creative application of typing.
Edit: I read your post closer, I'm not sure typing would help with the overloaded operator issue and now I have something fun to try out later
-
365.25, surely
365.2425
-
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.
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.
-
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.
wrote last edited by [email protected]Complicated or not, the interfaces suck. And dont have to. And that's the problem.
-
The Python won't give an accurate date here because it doesn't take into account leap years.
wrote last edited by [email protected]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)?
-
I haven’t used php before and I am not that far into it yet, so I don’t really know what’s gotten better but I like how it handles arrays and it has loads of little functions that make life easier.
It’s best not to think about what PHP used to be. It will make you sick. Just know that it is very mature at this point. It is not as Serverless friendly as some of the other languages, but if you were running a VPS with a more traditional LAMP style set up, you can’t go wrong with PHP
-
Complicated or not, the interfaces suck. And dont have to. And that's the problem.
exactly why I wrap the parts I need, it's like git, tons of power, zero help.
-
365.2425
didn't we gain or lose 0.00000001ish of a day recently? Like from tonga exploding or antarctica melting or something i can't remember.
-
365.25, surely
Sure, if you want things at midday instead of midnight.
-
The Python won't give an accurate date here because it doesn't take into account leap years.
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
-
I just started a new php gig
I work with Delphi.
-
This post did not contain any content.
Using ruby felt weird, it felt like it shouldn't work but it does.
-
didn't we gain or lose 0.00000001ish of a day recently? Like from tonga exploding or antarctica melting or something i can't remember.
That kind of thing happens surprisingly often.
-
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.
-
I like Fish Shell better than python, not gonna lie. Easier to read and write. Especially if you already live in the terminal.
Python is more system agnostic though.
-
timedelta
marks time in days, seconds, and microseconds. It doesn't take leap years into account because the concept of years is irrelevant totimedelta
. If you need to account for leap years, you need a different API.You can subtract two dates and get the exact time difference.