Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. I'm new to using Ruby and this tickled me pink

I'm new to using Ruby and this tickled me pink

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
68 Posts 47 Posters 3 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R [email protected]

    365.25, surely

    B This user is from outside of this forum
    B This user is from outside of this forum
    [email protected]
    wrote last edited by
    #36

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

    1 Reply Last reply
    5
    • cm0002@lemmy.worldC [email protected]
      This post did not contain any content.
      M This user is from outside of this forum
      M This user is from outside of this forum
      [email protected]
      wrote last edited by
      #37

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

      1 Reply Last reply
      1
      • cm0002@lemmy.worldC [email protected]
        This post did not contain any content.
        _ This user is from outside of this forum
        _ This user is from outside of this forum
        [email protected]
        wrote last edited by [email protected]
        #38

        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.

        ripcord@lemmy.worldR R 2 Replies Last reply
        17
        • bleistift2@sopuli.xyzB [email protected]

          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!

          _ This user is from outside of this forum
          _ This user is from outside of this forum
          [email protected]
          wrote last edited by [email protected]
          #39

          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 😁

          1 Reply Last reply
          0
          • R [email protected]

            365.25, surely

            B This user is from outside of this forum
            B This user is from outside of this forum
            [email protected]
            wrote last edited by
            #40

            365.2425

            heythisisnttheymca@lemmy.worldH 1 Reply Last reply
            3
            • W [email protected]

              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.

              eager_eagle@lemmy.worldE This user is from outside of this forum
              eager_eagle@lemmy.worldE This user is from outside of this forum
              [email protected]
              wrote last edited by
              #41

              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.

              1 Reply Last reply
              3
              • _ [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.

                ripcord@lemmy.worldR This user is from outside of this forum
                ripcord@lemmy.worldR This user is from outside of this forum
                [email protected]
                wrote last edited by [email protected]
                #42

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

                _ 1 Reply Last reply
                2
                • diplomjodler3@lemmy.worldD [email protected]

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

                  eager_eagle@lemmy.worldE This user is from outside of this forum
                  eager_eagle@lemmy.worldE This user is from outside of this forum
                  [email protected]
                  wrote last edited by [email protected]
                  #43

                  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)?

                  1 Reply Last reply
                  5
                  • S [email protected]

                    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.

                    M This user is from outside of this forum
                    M This user is from outside of this forum
                    [email protected]
                    wrote last edited by
                    #44

                    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

                    1 Reply Last reply
                    0
                    • ripcord@lemmy.worldR [email protected]

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

                      _ This user is from outside of this forum
                      _ This user is from outside of this forum
                      [email protected]
                      wrote last edited by
                      #45

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

                      1 Reply Last reply
                      1
                      • B [email protected]

                        365.2425

                        heythisisnttheymca@lemmy.worldH This user is from outside of this forum
                        heythisisnttheymca@lemmy.worldH This user is from outside of this forum
                        [email protected]
                        wrote last edited by
                        #46

                        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.

                        B 1 Reply Last reply
                        0
                        • R [email protected]

                          365.25, surely

                          blackmist@feddit.ukB This user is from outside of this forum
                          blackmist@feddit.ukB This user is from outside of this forum
                          [email protected]
                          wrote last edited by
                          #47

                          Sure, if you want things at midday instead of midnight.

                          1 Reply Last reply
                          0
                          • diplomjodler3@lemmy.worldD [email protected]

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

                            blackmist@feddit.ukB This user is from outside of this forum
                            blackmist@feddit.ukB This user is from outside of this forum
                            [email protected]
                            wrote last edited by
                            #48

                            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

                            1 Reply Last reply
                            2
                            • S [email protected]

                              I just started a new php gig

                              blackmist@feddit.ukB This user is from outside of this forum
                              blackmist@feddit.ukB This user is from outside of this forum
                              [email protected]
                              wrote last edited by
                              #49

                              I work with Delphi.

                              1 Reply Last reply
                              2
                              • cm0002@lemmy.worldC [email protected]
                                This post did not contain any content.
                                omegalemmy@discuss.onlineO This user is from outside of this forum
                                omegalemmy@discuss.onlineO This user is from outside of this forum
                                [email protected]
                                wrote last edited by
                                #50

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

                                1 Reply Last reply
                                3
                                • heythisisnttheymca@lemmy.worldH [email protected]

                                  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.

                                  B This user is from outside of this forum
                                  B This user is from outside of this forum
                                  [email protected]
                                  wrote last edited by
                                  #51

                                  That kind of thing happens surprisingly often.

                                  https://en.wikipedia.org/wiki/Leap_second

                                  1 Reply Last reply
                                  1
                                  • _ [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.

                                    R This user is from outside of this forum
                                    R This user is from outside of this forum
                                    [email protected]
                                    wrote last edited by
                                    #52

                                    Obligatory Tom Scott video

                                    alaknar@sopuli.xyzA 1 Reply Last reply
                                    2
                                    • V [email protected]

                                      I like Fish Shell better than python, not gonna lie. Easier to read and write. Especially if you already live in the terminal.

                                      A This user is from outside of this forum
                                      A This user is from outside of this forum
                                      [email protected]
                                      wrote last edited by
                                      #53

                                      Python is more system agnostic though.

                                      V 1 Reply Last reply
                                      0
                                      • R [email protected]

                                        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.

                                        R This user is from outside of this forum
                                        R This user is from outside of this forum
                                        [email protected]
                                        wrote last edited by
                                        #54

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

                                        1 Reply Last reply
                                        0
                                        • cm0002@lemmy.worldC [email protected]
                                          This post did not contain any content.
                                          U This user is from outside of this forum
                                          U This user is from outside of this forum
                                          [email protected]
                                          wrote last edited by
                                          #55

                                          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.

                                          1 Reply Last reply
                                          3
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups