‹ BackHN Continuity

Thread

My temporary PHP fix from 2014 has nearly 20M installs. Today I'm deprecating it

341 points · 107 comments · jakeasmith

  1. jakeasmith · · focus · HN ↗
    Author here, happy to answer any questions. I never imagined a polyfill for http_build_url would gain so much traction. After 12 years, deprecating it feels like the right move, especially given the new options from the community and PHP itself.
    1. HackerThemAll · · focus · HN ↗
      The JavaScript world is littered with stuff comparing to which your patch seems like a complex project. See those examples:

      <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-odd" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-odd

      <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-even" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-even

      <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;left-pad" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;left-pad

      <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-whitespace-character" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;is-whitespace-character

      <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;isarray" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;isarray

      1. JaggerJo · · focus · HN ↗
        what a broken ecosystem.. The crazy thing is not that the package exists, but that it is used by JS devs.
        1. junon · · focus · HN ↗
          I feel like I have to remind people of this quite often, but the history is such that npm was lightweight at one point, bundling wasn&#x27;t a thing, and while `isodd`&#x2F;`iseven` are of course silly, things like `isarray` were not functions that existed back then (we didn&#x27;t have Array.isArray). `typeof [] === &#x27;object&#x27;` in JS, so e.g. my package `is-arrayish` checked for a similar structure to an array (whereas Id guess `isarray` checked for the prototype). `isarray` failed for the `arguments` keyword, which was needed for variadics before argument spreads were added to the language I believe in ES5.

          So of course they don&#x27;t make sense now. But they were created for a reason. Before even Markov chains were a fad - let alone LLMs - we were trying to be as efficient as possible and maximize code reuse I stead of writing the same helper functions over and over again. That&#x27;s what you&#x27;re seeing.

          1. b112 · · focus · HN ↗

            [dead]

            1. junon · · focus · HN ↗
              I think a lot of things end up that way, just at different timescales. Best we can do is learn from them and start again, IMO - however that looks.
            2. toyg · · focus · HN ↗
              &quot;The road to Hell is paved with good intentions&quot;. Still true, probably thousands of years after the sentence was coined.
          2. zarzavat · · focus · HN ↗
            Yes and the critical issue was tree shaking. Nowadays we have tree shaking so it doesn&#x27;t matter as much but in the past people preferred small single function packages because they had less impact on the download size.
          3. ChiperSoft · · focus · HN ↗
            Additional Context: for about two years functional programming was REALLY popular in the Node community. It was a fad to chain tons of tiny functions together, and thus lots of people wrote tons of tiny functions. This is why lodash&#x2F;fp exists.
          4. wat10000 · · focus · HN ↗
            I don’t think it ever made sense. Code reuse improves efficiency when the code can be shared in memory, or when it needs to be updated and you only have to change it in one place. JS packages don’t give you sharing beyond what you’d get from copying the code. And these little things don’t need to be updated, and in fact you probably don’t want them to be.

            It’s a case of doing something without understanding why it’s done. Packages are good, code sharing is good, so use it for everything. But it misses why they’re good.

            1. junon · · focus · HN ↗
              This is all very easy to say in hindsight. It&#x27;s missing the context of having been there, I think. Things were just different.

              Also, way more fun.

              1. wat10000 · · focus · HN ↗
                I was definitely saying it at the time. But I wasn&#x27;t embedded in the ecosystem, it was very much &quot;those JavaScript guys are nuts, why would they do this?&quot;
          5. IncreasePosts · · focus · HN ↗
            You want to implement your own is-odd in your code - simple, right? isOdd = (x) =&gt; x % 2 == 1

            Ut oh, your code is broken for negative numbers now since % isn&#x27;t a true modulo operator...

            Fine then, isOdd = (x) =&gt; x % 2 != 0

            Ut oh, your code is broken because isOdd(&quot;hi&quot;) returns true now...

            Fine then, isOdd = (x) =&gt; if(!isNumber(x)) throw... else return x%2 != 0

            Ut oh, your code is now broken because isOdd(2^55+1) returns true now...

            1. rtkwe · · focus · HN ↗
              Ut oh? I&#x27;ve never seen that, is it variant on uh oh or something else?
              1. IncreasePosts · · focus · HN ↗
                It&#x27;s something I&#x27;m fighting for in my own little way.

                Everyone does a glottal stop between the &quot;uh&quot; and &quot;oh&quot;, so I&#x27;m trying to align the spelling

                Unlike the guy on him who writes all years with 5 digits like 02026, I have good reasons for my idiosyncracies.

                1. luplex · · focus · HN ↗
                  Hm, I would not spell it with a &quot;t&quot; then, but maybe with an apostrophe instead.

                  &quot;Uh&#x27;oh&quot; is more readable in my opinion and won&#x27;t be mispronou in ced

            2. Dylan16807 · · focus · HN ↗
              &gt; Ut oh, your code is now broken because isOdd(2^55+1) returns true now...

              I think you messed up this example. Whether I literally use &quot;2^55&quot; with XOR or replace it with &quot;2*55&quot;, that version of isOdd returns false.

              False for isOdd(58) is obviously correct. (Also thanks C for permanently screwing up the precedence of bitwise operations because you didn&#x27;t want to break some existing programs in 1972.)

              False for isOdd(36028797018963970) is also correct, and if you expected to send in a different number the bug is in the &quot;+1&quot; not the isOdd.

              1. IncreasePosts · · focus · HN ↗
                Sorry, it&#x27;s supposed to be power. So 2**55 in JavaScript

                2 to the 55th power is obviously even, so that +1 is obviously odd, but ((2*55) +1) % 2 == 0 in JavaScript.

                1. Dylan16807 · · focus · HN ↗
                  But there&#x27;s no bug in isOdd. You&#x27;re sending the number 36028797018963970 into it, which is clearly even.

                  Putting extra code between the parentheses of the function call doesn&#x27;t make it the function&#x27;s responsibility. As nice as it would be for debugging if you could stuff your entire program inside of isNaN((function(){ &#x2F;* your code here *&#x2F; })()) and force your browser vendor to fix all problems.

                  1. IncreasePosts · · focus · HN ↗
                    You should check the math on a real calculator.

                    Despite what most JavaScript implementations will tell you, 2 to the 55th power is 36028797018963968, and adding one to that value is 36028797018963969. That&#x27;s clearly odd.

                    There is no extra code between the parens. I just put them there so there wouldn&#x27;t be any question as to operator precedence. I do see now that hn ate my double star, but I think you know what I mean since you told me the value that is spits out when you do the exponentiation

                    1. Dylan16807 · · focus · HN ↗
                      &gt; There is no extra code between the parens.

                      You have a plus and an exponentiation in there. That&#x27;s code.

                        var n = 2**55 + 1
                        console.log(n)
                        isOdd(n)
                      
                      n is 36028797018963970. isOdd(n) is giving you the right answer. Putting the +1 inside the parentheses and talking about calculators is a sleight of hand that lets you pretend isOdd gets an odd number, but it doesn&#x27;t. No odd numbers are around by the time isOdd actually does anything.

                      The problems are in + and&#x2F;or our expectations of +. It does not output 36028797018963969, and we must acknowledge that.

          6. bigstrat2003 · · focus · HN ↗
            IsOdd and IsEven never made sense. They were a badge of shame that said &quot;I have no idea how to program&quot;.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.