As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
We're funding a new Acquisitions Incorporated series on Kickstarter right now! Check it out at https://www.kickstarter.com/projects/pennyarcade/acquisitions-incorporated-the-series-2

[Programming] Mirror, mirror, on the wall, show the git diff for them all

17677798182100

Posts

  • InfidelInfidel Heretic Registered User regular
    Grrr getting a seemingly impossible array out of bounds error on this report.
    The same report I was asking about a few pages ago. I had to restructure a lot of the code the contractor who originally put this together did because some hidden inner joins among a pile of outer joins (which she'd also done in a many years old, terrible performance, all current training from the vendor says "Don't do it this way. It's not needed anymore and it's bad.") was causing some information to be dropped that was required. So I rewrite it in a more explicit way.
    One of the things I had to do when modifying it, was use a function they provide to look up the index of a value in a list inside a record structure. Somehow, it's giving me an index 1 larger than the size of the list.

    Is that just how they signal "not in the list"?

    -1 is a better sentinel since it doesn't, you know, vary with your data. But "I'm pointing to the end of the list because I got there, you should know that means I didn't find it" is logical, if not the most practical.

    OrokosPA.png
  • TofystedethTofystedeth Registered User regular
    edited March 2016
    Mystery solved!
    I was referencing the wrong list! One that was very similar, but subtly different in such a way that it only failed near the end instead of way early on.
    Infidel wrote: »
    Grrr getting a seemingly impossible array out of bounds error on this report.
    The same report I was asking about a few pages ago. I had to restructure a lot of the code the contractor who originally put this together did because some hidden inner joins among a pile of outer joins (which she'd also done in a many years old, terrible performance, all current training from the vendor says "Don't do it this way. It's not needed anymore and it's bad.") was causing some information to be dropped that was required. So I rewrite it in a more explicit way.
    One of the things I had to do when modifying it, was use a function they provide to look up the index of a value in a list inside a record structure. Somehow, it's giving me an index 1 larger than the size of the list.

    Is that just how they signal "not in the list"?

    -1 is a better sentinel since it doesn't, you know, vary with your data. But "I'm pointing to the end of the list because I got there, you should know that means I didn't find it" is logical, if not the most practical.
    No, they use 0 or a negative number depending on the way in which it was not found (smaller than the smallest item, bigger than the biggest item, etc). It's a somewhat surprising instance of them doing something a sensible way.

    Tofystedeth on
    steam_sig.png
  • EchoEcho ski-bap ba-dapModerator mod
    LD50 wrote: »
    The gratuitous packaging makes some sense though. It's really a symptom of JS's standard library being barebones. In the rest of the programming world we'd just put together some sort of kitchen-sink type standard library replacement ala boost, but that's not a good option in the browser world because the library would be too big to send every time someone visits a web page.

    Yeah, I understand why you have very tiny specific packages like "is this a positive int?" when you're going to bundle it up into a minified JS file anyway, but it still feels pretty silly to look at.

  • EchoEcho ski-bap ba-dapModerator mod
    I don't know what I should get annoyed at first, Node or Windows.

    CeQyeOIWEAEEvcU.jpg:large

    Infidelgavindel
  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    It's pretty rare for modules to be nested that deep if you're running NPM 3, which is bundled with Node 5. It's been nothing but stable for me, so maybe give that a try.

    borb_sig.png
    Nogs
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    edited March 2016
    Jasconius wrote: »
    everything about modern JS and Node and NPM just looks like a bunch of dumbass teenagers tried to reimplement the C / GNU / *NIX universe of open source software and did the worst conceivable job of it

    Turns out it's really fuckin' hard to update a language that depends on a minimum of three different implementations to agree on (Chrome, Firefox, IE, arguably Safari, Opera, mobile browsers...) in order for it to function correctly in production. And when you can't update your language you have to implement those features in packages instead.
    Echo wrote: »
    I don't know what I should get annoyed at first, Node or Windows.

    CeQyeOIWEAEEvcU.jpg:large

    This one's easy -- character limits on paths in an operating system in 2016 are a fucking joke.

    That said, npm 3 flattened dependencies so you should update if you can.

    admanb on
  • ecco the dolphinecco the dolphin Registered User regular
    Echo wrote: »
    I don't know what I should get annoyed at first, Node or Windows.

    CeQyeOIWEAEEvcU.jpg:large

    You can technically support path lengths of up to 32k in Windows by using the "\\?\" prefix, if you're using the Unicode API.

    Is node using the Unicode API?

    I don't know.

    Penny Arcade Developers at PADev.net.
    crimsoncoyote
  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    Also yeah that's about 90% Windows' fault. The rest goes to NPM for ever building a package system without tree flattening.

    borb_sig.png
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    Node and npm will work with those paths all day, but if you have to manipulate anything using .NET or Windows...

  • hippofanthippofant ティンク Registered User regular
    Saeris wrote: »
    Also yeah that's about 90% Windows' fault. The rest goes to NPM for ever building a package system without tree flattening.

    There's a maximum file path length in Windows?

    I feel like such a n00b.

  • ecco the dolphinecco the dolphin Registered User regular
    hippofant wrote: »
    Saeris wrote: »
    Also yeah that's about 90% Windows' fault. The rest goes to NPM for ever building a package system without tree flattening.

    There's a maximum file path length in Windows?

    I feel like such a n00b.

    It's present on a lot of platforms. Linux/Unix has one, BSD has one as well, I think.

    They're a bit bigger than the 260 ANSI Windows limitation, but typically around 1-4k, I think.

    Unfortunately, once someone defined MAX_PATH as 260 for Windows, there was no real good way to change it without some serious binary magick to keep things compatible.

    Penny Arcade Developers at PADev.net.
    a5ehren
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    hippofant wrote: »
    Saeris wrote: »
    Also yeah that's about 90% Windows' fault. The rest goes to NPM for ever building a package system without tree flattening.

    There's a maximum file path length in Windows?

    I feel like such a n00b.

    There is a maximum path length of 256 characters when using ANSI APIs (due to the definition of the MAX_PATH macro and for compatibility it cannot change)
    Unicode versions of the APIs can accept up to 32k characters (though you may need the \\?\ prefix? Not sure)
    Linux has one around 4k

    ecco the dolphincrimsoncoyote
  • TofystedethTofystedeth Registered User regular
    Infidel wrote: »
    Grrr getting a seemingly impossible array out of bounds error on this report.
    The same report I was asking about a few pages ago. I had to restructure a lot of the code the contractor who originally put this together did because some hidden inner joins among a pile of outer joins (which she'd also done in a many years old, terrible performance, all current training from the vendor says "Don't do it this way. It's not needed anymore and it's bad.") was causing some information to be dropped that was required. So I rewrite it in a more explicit way.
    One of the things I had to do when modifying it, was use a function they provide to look up the index of a value in a list inside a record structure. Somehow, it's giving me an index 1 larger than the size of the list.

    Is that just how they signal "not in the list"?

    -1 is a better sentinel since it doesn't, you know, vary with your data. But "I'm pointing to the end of the list because I got there, you should know that means I didn't find it" is logical, if not the most practical.
    hippofant wrote: »
    Saeris wrote: »
    Also yeah that's about 90% Windows' fault. The rest goes to NPM for ever building a package system without tree flattening.

    There's a maximum file path length in Windows?

    I feel like such a n00b.

    Yeah, you won't come across much in normal circumstances.

    steam_sig.png
    crimsoncoyote
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Of course, if you want to get clever about it,
    d:\dev\redux-~1\node_m~1\babel-~1\node_m~1\babel-~1\node_m~1\babel-~1\node_m~1\babel-~1\node_m~1\babel-~1\lib\path\infere~1\inferer-reference.js is probably a valid path due to the short name thing

    bowen
  • EchoEcho ski-bap ba-dapModerator mod
    edited March 2016
    I'm using Chocolatey as a package manager for stuff in Windows, turns out it has npm 1.4.9.
    This package uses an older NPM which is no longer offered as a standalone package separately from NodeJS. It is recommended that you uninstall this package and the package nodejs.commandline in favor of nodejs.install (which nodejs package now points to).

    This version of npm is known to have issues on Windows.

    *recombobulates*

    edit: there, uninstalled the npm package and now it uses the one that apparently came with the nodejs package, which is 3.something.

    Echo on
  • InfidelInfidel Heretic Registered User regular
    Echo wrote: »
    turns out it has npm 1.4.9.

    Oh my glob, I'm crying over here.

    OrokosPA.png
    Echo
  • EndEnd Registered User regular
    Echo wrote: »
    I'd just like to know how that need for a distinct package is rationalized.

    CeM4s4XXEAAQWLb.jpg:large

    a) what the fuck

    b)

    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpgsteam~tinythumb.png
    htmecco the dolphinInfidelEchoa5ehren
  • EchoEcho ski-bap ba-dapModerator mod
  • crimsoncoyotecrimsoncoyote Registered User regular
    So can we blame spoilers breaking on NPM? :P

    ecco the dolphinTofystedethDisruptedCapitalistPolaritie
  • bowenbowen How you doin'? Registered User regular
    Echo wrote: »
    ebdtj4vyqnvk.png

    https://github.com/kevva/is-positive/commits/master

    for those that are interested in this crazy journey

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Basically, v2 stopped considering 0 as positive and v3 returned false on non-numbers vs throwing...

    Oh and if you want to consider 0 as positive good news! Yet another module will do that... https://github.com/sindresorhus/positive-zero

    crimsoncoyotebowenDelmain
  • urahonkyurahonky Registered User regular
    I guess I'm not seeing the problem here. "Dumb people use a tool incorrectly" is hardly new news at this point.

  • ecco the dolphinecco the dolphin Registered User regular
    edited March 2016
    Hey so um forgive the JavaScript n00b here but what is the purpose of the package?

    Why isn't it as simple as a >= 0?

    Is this something akin to type traits in C++?

    Edit: oh I see that the code does contain a > 0 comparison. So is it handling the type system of JavaScript?

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • bowenbowen How you doin'? Registered User regular
    What gets me is, after @ethea posted a link, I did a little research:

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign

    There's already a mostly built in function for this.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • TofystedethTofystedeth Registered User regular
    Hey so um forgive the JavaScript n00b here but what is the purpose of the package?

    Why isn't it as simple as a >= 0?

    Is this something akin to type traits in C++?

    I haven't looked at it but maybe the integer part? Like, it checks both sign and integerness.

    steam_sig.png
  • DelmainDelmain Registered User regular
    Hey so um forgive the JavaScript n00b here but what is the purpose of the package?

    Why isn't it as simple as a >= 0?

    Is this something akin to type traits in C++?

    Edit: oh I see that the code does contain a > 0 comparison. So is it handling the type system of JavaScript?

    You got it, but yeah, it's probably a bunch of stuff to go "is it actually a number, are we sure of it's sign, etc" before it does "val > 0"

  • djmitchelladjmitchella Registered User regular
    Yes and no -- it does those checks, but even with that it is still not very much code:
    'use strict';
    module.exports = function (n) {
    	return toString.call(n) === '[object Number]' && n > 0;
    };
    

  • NogsNogs Crap, crap, mega crap. Crap, crap, mega crap.Registered User regular
    i have absolutely no problem including small micro packages that do things like that in my apps or whatever.

    hell, I use https://www.npmjs.com/package/slash all the time because i develop on windows. This is the entire codebase:
    'use strict';
    module.exports = function (str) {
    	var isExtendedLengthPath = /^\\\\\?\\/.test(str);
    	var hasNonAscii = /[^\x00-\x80]+/.test(str);
    
    	if (isExtendedLengthPath || hasNonAscii) {
    		return str;
    	}
    
    	return str.replace(/\\/g, '/');
    };
    

    Could I write my own for every project? sure, but...why? why waste even the smallest amount of time or effort in doing that when someone has already proven a stable, efficient version that covers every use-case?

    With an ecosystem like the Browser, and then also bringing in operating system compatibility stuff now with node, I don't want to think or worry about "well, i know it should just be this one regex thing, but what about NonAscii characters or the ExtendedLengthPath check? Would I have just thought of those use cases the 1st time i hand implemented it, or would I have had to wait until someone filed an issue and then go fix it?

    These micro packages also have the ability to evolve as the system and technologies evolve, thus potentially updating automatically if say a new browser (hello https://www.brave.com/ ) or javascript engine ( hello https://github.com/Microsoft/ChakraCore ) handles these use cases differently. And I don't have to worry about it.

    I'm focused on building a product, not stupid shit like having to hand write regex to fix my slashes. Same thing with left-pad and million other micro modules out there.

    rotate.jpg
    PARKER, YOU'RE FIRED! <-- My comic book podcast! Satan look here!
  • InfidelInfidel Heretic Registered User regular
    Is-positive package isn't a joke package? :rotate:

    OrokosPA.png
    ecco the dolphin
  • InfidelInfidel Heretic Registered User regular
    edited March 2016
    npm i -D double-post

    Infidel on
    OrokosPA.png
  • NogsNogs Crap, crap, mega crap. Crap, crap, mega crap.Registered User regular
    speaking of jokes:

    http://left-pad.io/

    rotate.jpg
    PARKER, YOU'RE FIRED! <-- My comic book podcast! Satan look here!
    crimsoncoyoteecco the dolphinPolaritie
  • PolaritiePolaritie Sleepy Registered User regular
    admanb wrote: »
    Jasconius wrote: »
    everything about modern JS and Node and NPM just looks like a bunch of dumbass teenagers tried to reimplement the C / GNU / *NIX universe of open source software and did the worst conceivable job of it

    Turns out it's really fuckin' hard to update a language that depends on a minimum of three different implementations to agree on (Chrome, Firefox, IE, arguably Safari, Opera, mobile browsers...) in order for it to function correctly in production. And when you can't update your language you have to implement those features in packages instead.

    Ugh. Yeah, I've been banging my head on that a few times this month - there's a perfect function for what I want to do in ES6 or whatever, except whoops I have to have multiple browser compatibility and one of them hasn't bothered to implement it.

    Hell, Promise only got added to mobile Safari with iOS 9 iirc.

    Steam: Polaritie
    3DS: 0473-8507-2652
    Switch: SW-5185-4991-5118
    PSN: AbEntropy
  • TofystedethTofystedeth Registered User regular
    I was waiting for someone to make a fizzbuzz joke but i Don't know JS and was unable to do so myself.

    steam_sig.png
  • gavindelgavindel The reason all your software is brokenRegistered User regular
    My favorite comment of the week as I prepare to log a new bug and check the source code:
    // This can never happen.

    Angels, innovations, and the hubris of tiny things: my book now free on Royal Road! Seraphim
    Grape ApecrimsoncoyoteBaron Dirigibletemplewulf
  • TofystedethTofystedeth Registered User regular
    Needing to move a couple fields around on this ASP.net site I maintain. Can't figure out why it breaks complaining that it can't generate a control because one of label fields on it is already used in another control.
    Turns out when I commented it out ,instead of ASP comments
    <%-- stuff -->
    
    I used HTML/XML style comments
    <!-- stuff -->
    

    which Visual Studio "helpfully" syntax highlights as comments (because I guess the page is still technically HTML) but if there's ASP type stuff inside it has to have ASP comments or it will still try and generate it.
    Had to have a coworker point it out to me because I so rarely work in the ASP world.

    steam_sig.png
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    gavindel wrote: »
    My favorite comment of the week as I prepare to log a new bug and check the source code:
    // This can never happen.

    I would never write a comment like that.
    // This should never happen.

    See?

    bowenmightyjongyoecco the dolphincrimsoncoyoteDelmainEchoNaphtaliPolaritiereplacewythy
  • bowenbowen How you doin'? Registered User regular
    //oh god, I'm so sorry

    is one of my "this shouldn't happen" comments

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
    ecco the dolphin
  • mightyjongyomightyjongyo Sour Crrm East Bay, CaliforniaRegistered User regular
    There's one in some legacy code we have:

    // we're fucked if we get here, just exit

    ecco the dolphinbowen
  • DelmainDelmain Registered User regular
    There's one in some legacy code we have:

    // we're fucked if we get here, just exit

    I have written almost exactly that comment before in ancient code I was trying to debug

    like, "I have no fucking clue how this state occurs, but it does sometimes and it fucks everything up, so just error out"

    bowen
This discussion has been closed.