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/

[Programming] Reinventing equality, one language at a time

19192949697100

Posts

  • EchoEcho ski-bap ba-dapModerator mod
    It's very handy for working with tree structures.

  • LD50LD50 Registered User regular
    Echo wrote: »
    It's very handy for working with tree structures.

    But what happens when your production data grows larger than your max stack depth?

  • electricitylikesmeelectricitylikesme Registered User regular
    LD50 wrote: »
    I feel like using recursion in production is a legit bad idea and it shouldn't get past a code review.

    In my comp sci labs I had this problem constantly. I was in that class well after I'd been playing with Arduino's with very limited stacks, so my go to for literally everything was to find the non-recursive solution.

  • EchoEcho ski-bap ba-dapModerator mod
    LD50 wrote: »
    Echo wrote: »
    It's very handy for working with tree structures.

    But what happens when your production data grows larger than your max stack depth?

    Go's stack depth is effectively infinite, only limited by memory.

    Answer A: ¯\_(ツ)_/¯

    Answer B: if a tree has the possibility of being that large I assume we know what we're doing and anticipate it and handle it non-recursively.

    Answer C: throw more memory at it if it really has to be recursive. Otherwise, see B.

  • LD50LD50 Registered User regular
    Echo wrote: »
    LD50 wrote: »
    Echo wrote: »
    It's very handy for working with tree structures.

    But what happens when your production data grows larger than your max stack depth?

    Go's stack depth is effectively infinite, only limited by memory.

    Answer A: ¯\_(ツ)_/¯

    Answer B: if a tree has the possibility of being that large I assume we know what we're doing and anticipate it and handle it non-recursively.

    Answer C: throw more memory at it if it really has to be recursive. Otherwise, see B.

    The problem with B is that what we think are requirements are when we write the program are going to be different than what they actually are 5 years from now. The problem with C is that not all languages have an easy way to increase the max stack depth, especially not if a program is already compiled.

    The biggest problem is that if you do indeed hit whatever the max stack depth is, you're going to find out about it by whatever program it is crashing and burning in what will be an effectively unrecoverable way (at least until an emergency fix is deployed).

  • OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    Every so often I have to break out the template metaprogramming or constexpr to evaluate/construct something so...

    it's fine in the right context and with the appropriate safeguards

  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    I feel like recursion is elegant when done right, but some folks find it harder to understand, and without tail call optimization it can be kind of slow, so I tend to avoid it in practice.

    Sometimes if I have the time I'll write and test a recursive implementation of something, just to prove to myself I could... then I go back and rewrite it with loops anyway.

    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • templewulftemplewulf The Team Chump USARegistered User regular
    Speaking of doing things in an elegant way, even when other ways are more comprehensible, is there a functional LINQ-style way to divide a list into groups in C# based on whether they match values from another list?
    List<SomeType> listOfValues = aListQuery.GetList(); // large list, don't know what's in it
    List<Definition> listOfDefinitions = ProgramSettings.StaticList(); // small list, never changes
    
    foreach (var definition in listOfDefinitions)
    {
        foreach(var value in listOfValues.Where(v => definition.IsValidValue(v)))
        {
            // Do things
        }
    }
    

    My current process above grows O(n) with the size of the definitions. It's an extremely small list right now, so it's totally fine, but I feel like the GroupBy series might be more performant on larger lists. It's just not obvious to me what the most idiomatic way would be to marry IsValidValue() into the GroupBy arrangement.

    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • MugsleyMugsley DelawareRegistered User regular
    Programmers: Is the new Humble Bundle legit worth? Just on a cursory glance, it seems at least the BtA tier is good just for general knowledge (I know I've asked you guys about other bundles in the past but I've been gunshy about grabbing; this one includes videos so I'm giving it heavier consideration).

    I've programmed in FORTRAN and I've watched some videos of a guy teaching how to program in C++.

  • InfidelInfidel Heretic Registered User regular
    templewulf wrote: »
    Speaking of doing things in an elegant way, even when other ways are more comprehensible, is there a functional LINQ-style way to divide a list into groups in C# based on whether they match values from another list?
    List<SomeType> listOfValues = aListQuery.GetList(); // large list, don't know what's in it
    List<Definition> listOfDefinitions = ProgramSettings.StaticList(); // small list, never changes
    
    foreach (var definition in listOfDefinitions)
    {
        foreach(var value in listOfValues.Where(v => definition.IsValidValue(v)))
        {
            // Do things
        }
    }
    

    My current process above grows O(n) with the size of the definitions. It's an extremely small list right now, so it's totally fine, but I feel like the GroupBy series might be more performant on larger lists. It's just not obvious to me what the most idiomatic way would be to marry IsValidValue() into the GroupBy arrangement.

    Your current implementation is vague on if you're truly splitting the list up (everything can only exist in one sublist) or if the same item can be valid twice+.

    Without any additional constraints, you might see a small performance gain by flipping the loops around, but you'll need to test all N items against M predicates either way.

    If you are actually working with a list that can be categorized as one distinct type, then you can do that categorization N times and then group by that yes.

    OrokosPA.png
  • templewulftemplewulf The Team Chump USARegistered User regular
    Infidel wrote: »
    templewulf wrote: »
    Speaking of doing things in an elegant way, even when other ways are more comprehensible, is there a functional LINQ-style way to divide a list into groups in C# based on whether they match values from another list?
    List<SomeType> listOfValues = aListQuery.GetList(); // large list, don't know what's in it
    List<Definition> listOfDefinitions = ProgramSettings.StaticList(); // small list, never changes
    
    foreach (var definition in listOfDefinitions)
    {
        foreach(var value in listOfValues.Where(v => definition.IsValidValue(v)))
        {
            // Do things
        }
    }
    

    My current process above grows O(n) with the size of the definitions. It's an extremely small list right now, so it's totally fine, but I feel like the GroupBy series might be more performant on larger lists. It's just not obvious to me what the most idiomatic way would be to marry IsValidValue() into the GroupBy arrangement.

    Your current implementation is vague on if you're truly splitting the list up (everything can only exist in one sublist) or if the same item can be valid twice+.

    Without any additional constraints, you might see a small performance gain by flipping the loops around, but you'll need to test all N items against M predicates either way.

    If you are actually working with a list that can be categorized as one distinct type, then you can do that categorization N times and then group by that yes.

    Oh, good catch, I have an extra break that I forgot to include when I turned it into pseudo code.

    I get the rest conceptually, and I can build up a combined dictionary in a conventional imperative way. I was more wondering if there's a style that might be more idiomatic to the linq functional approach.

    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    Mugsley wrote: »
    Programmers: Is the new Humble Bundle legit worth? Just on a cursory glance, it seems at least the BtA tier is good just for general knowledge (I know I've asked you guys about other bundles in the past but I've been gunshy about grabbing; this one includes videos so I'm giving it heavier consideration).

    I've programmed in FORTRAN and I've watched some videos of a guy teaching how to program in C++.

    I'd need to see more of the curriculum and how it's taught to say anything useful about the courses. The course outlines don't seem terrible, though they do seem centered around the frameworks you're intended to use, which does make me look askance at them.

    The price is cheap enough that if they suck it's not the end of the world.

  • InfidelInfidel Heretic Registered User regular
    templewulf wrote: »
    Infidel wrote: »
    templewulf wrote: »
    Speaking of doing things in an elegant way, even when other ways are more comprehensible, is there a functional LINQ-style way to divide a list into groups in C# based on whether they match values from another list?
    List<SomeType> listOfValues = aListQuery.GetList(); // large list, don't know what's in it
    List<Definition> listOfDefinitions = ProgramSettings.StaticList(); // small list, never changes
    
    foreach (var definition in listOfDefinitions)
    {
        foreach(var value in listOfValues.Where(v => definition.IsValidValue(v)))
        {
            // Do things
        }
    }
    

    My current process above grows O(n) with the size of the definitions. It's an extremely small list right now, so it's totally fine, but I feel like the GroupBy series might be more performant on larger lists. It's just not obvious to me what the most idiomatic way would be to marry IsValidValue() into the GroupBy arrangement.

    Your current implementation is vague on if you're truly splitting the list up (everything can only exist in one sublist) or if the same item can be valid twice+.

    Without any additional constraints, you might see a small performance gain by flipping the loops around, but you'll need to test all N items against M predicates either way.

    If you are actually working with a list that can be categorized as one distinct type, then you can do that categorization N times and then group by that yes.

    Oh, good catch, I have an extra break that I forgot to include when I turned it into pseudo code.

    I get the rest conceptually, and I can build up a combined dictionary in a conventional imperative way. I was more wondering if there's a style that might be more idiomatic to the linq functional approach.

    Again hard to say without a concrete example but maybe try "select new ..." calculated column type stuff? Turn your "short static list" into a calculated field output and then group by that?

    OrokosPA.png
  • bowenbowen How you doin'? Registered User regular
    Mugsley wrote: »
    Programmers: Is the new Humble Bundle legit worth? Just on a cursory glance, it seems at least the BtA tier is good just for general knowledge (I know I've asked you guys about other bundles in the past but I've been gunshy about grabbing; this one includes videos so I'm giving it heavier consideration).

    I've programmed in FORTRAN and I've watched some videos of a guy teaching how to program in C++.

    I mean for probably $25 you can get some more knowledge I wouldn't say it's not worth it. It's a good deal and there's probably some info you can gleam from it.

    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
    There's probably nothing in there you can't find elsewhere on the internet for free, but having a curated version all in one place is worth something

  • KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    Ultimately it comes down to will you be motivated enough to work through the material? And is it something you're interested in?

  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited February 2019
    has anyone ever experienced a situation in Docker where your service logs seem to stop or otherwise become detached from reality?

    I have a high uptime service on Docker that's been running without a restart for proooobably about a month, and I just did a deployment and noticed my logs don't seem to be updating anymore (docker serivce logs [service name])

    I reaaaaally don't want to restart the service during business hours, wondering if this is a common thing than can be remedied through commands

    Jasconius on
  • jaziekjaziek Bad at everything And mad about it.Registered User regular
    doing this latest round of job interviews I'm discovering that I really struggle to program under pressure. Tasks which I usually find incredibly simple, I struggle to do with someone watching my screen while I do it. I'm fine with every other bit of interviewing, its just the coding exercises that are letting me down, and I know that I'm perfectly capable of doing the tasks, it's the setting that is tripping me up.

    Does anyone have some decent resources for working on this?

    Steam ||| SC2 - Jaziek.377 on EU & NA. ||| Twitch Stream
  • SpawnbrokerSpawnbroker Registered User regular
    jaziek wrote: »
    doing this latest round of job interviews I'm discovering that I really struggle to program under pressure. Tasks which I usually find incredibly simple, I struggle to do with someone watching my screen while I do it. I'm fine with every other bit of interviewing, its just the coding exercises that are letting me down, and I know that I'm perfectly capable of doing the tasks, it's the setting that is tripping me up.

    Does anyone have some decent resources for working on this?

    It's really just practice. I do interviews at my company when we need a new person, and I've seen nerves completely shut a person down. Someone who I know can program can no longer write a loop, their mind just blanks. The only thing that helps is to try and make the person less nervous. And the only thing YOU can do to help that is to put yourself in the interview situation so many times that you become less nervous about it.

    When I see someone freezing up like that, I usually take the white board marker and run them through a system design question of my own making where I am drawing on the white board and they are answering questions that I'm asking while I do it. It works reasonably well since it's an open-ended question and I'm in the driver seat. Then if they look less nervous I can go back to my standard questions I brought.

    If you're interested, here's how I do my interview:
    At the phone screen, I ask them basic trivia questions about HTML/CSS/javascript. Like what does == versus === mean, basic stuff that I'd expect a front end developer to know if they've done ANY javascript coding. I don't ask them to code anything, just try to get a sense of where they're at with the .NET stack.

    When they get to the in-person interview, first question I ask them is FizzBuzz. I know, it's incredibly stupid and insultingly easy. But I give them a lot of hints, like if they don't remember the modulo operator I tell them there's an operator for that. Usually they're nervous, so there is a mistake or two here; I use that as an opportunity to see if the person will admit they made a mistake and correct it immediately. If they do, no problem, we move on.

    Second set of questions is a series of 4 or 5 methods that I pulled from our code base. Methods that are slightly tricky to navigate or have some hidden deeper meaning to them that are not apparently obvious. One is a VERY advanced SharePoint-specific question that I have only seen one other developer answer correctly and I told my boss to hire her immediately.

    If we have time, or if the interviewee is doing poorly or looks too nervous, I get up, pick up the marker, and ask them my favorite question: "Describe to me, in detail, how SharePoint works." This question can take either 5 minutes or 45 minutes, depending on how much the person knows about SharePoint. I don't really care one way or another for the hiring decision, but my team does almost exclusively SharePoint coding, so the more you know about this, the better score I personally will give you because I'm more likely to want you on my team. If the other questions are answered and the person knows how to code and doesn't seem like a dick, I give the candidate a thumbs up.

    I don't ask any algorithm questions except for FizzBuzz, and you would not believe the amount of people the above process weeds out. I've also never hired someone that I regret hiring.

    Steam: Spawnbroker
  • bowenbowen How you doin'? Registered User regular
    jaziek wrote: »
    doing this latest round of job interviews I'm discovering that I really struggle to program under pressure. Tasks which I usually find incredibly simple, I struggle to do with someone watching my screen while I do it. I'm fine with every other bit of interviewing, its just the coding exercises that are letting me down, and I know that I'm perfectly capable of doing the tasks, it's the setting that is tripping me up.

    Does anyone have some decent resources for working on this?

    I always say "I don't really have a ton of time blocked off for a hour+ coding exercise, can I send you a solution tonight?"

    90% of them are okay with it, 10% get all pissy and think I'm going to have someone do it for me or "cheat" and look at stack overflow, which I occasionally do anyways so probably don't want to work for those places.

    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
  • KhavallKhavall British ColumbiaRegistered User regular
    Honestly if someone gets shitty about using stack overflow for coding solutions then you probably don't want to work for them anyways. Because they'll 100% want extremely difficult things in extremely unreasonable timeframes with extremely unreasonable expectations.

    Like what do you think the actual job is going to entail if not borrowing resources whenever it's the correct thing to do? Hire people who can do that, not people who can work out a problem that they'll never see in ways that they'll never have to.

  • SpawnbrokerSpawnbroker Registered User regular
    That's why I don't tend to focus on coding solutions. I tend to give them code that my team has written and ask them to tell me what it does. Nothing replaces good old-fashioned face to face explanations of things, in my opinion. It's very obvious when someone doesn't know the answer and is trying to bullshit me, and it's an instant no-hire from me if someone does that.

    Steam: Spawnbroker
  • DrovekDrovek Registered User regular
    That's why I don't tend to focus on coding solutions. I tend to give them code that my team has written and ask them to tell me what it does. Nothing replaces good old-fashioned face to face explanations of things, in my opinion. It's very obvious when someone doesn't know the answer and is trying to bullshit me, and it's an instant no-hire from me if someone does that.

    Plus side of this is that the candidate can see what kind of code you expect him to output.

    (Which gives him the ability to run away screaming in case of eldritch horrors.)

    steam_sig.png( < . . .
  • AngelHedgieAngelHedgie Registered User regular
    Drovek wrote: »
    That's why I don't tend to focus on coding solutions. I tend to give them code that my team has written and ask them to tell me what it does. Nothing replaces good old-fashioned face to face explanations of things, in my opinion. It's very obvious when someone doesn't know the answer and is trying to bullshit me, and it's an instant no-hire from me if someone does that.

    Plus side of this is that the candidate can see what kind of code you expect him to output.

    (Which gives him the ability to run away screaming in case of eldritch horrors.)

    "Um, is the fabric of reality supposed to be moving like that?"

    XBL: Nox Aeternum / PSN: NoxAeternum / NN:NoxAeternum / Steam: noxaeternum
  • EchoEcho ski-bap ba-dapModerator mod
    bowen wrote: »
    I always say "I don't really have a ton of time blocked off for a hour+ coding exercise, can I send you a solution tonight?"

    90% of them are okay with it, 10% get all pissy and think I'm going to have someone do it for me or "cheat" and look at stack overflow, which I occasionally do anyways so probably don't want to work for those places.

    We do "Here's an exercise, get back to us in a week." If you're an experienced dev, you can get it done in an afternoon.

    We're well familiar with the common "found on StackOverflow/GitHub" solutions by now.

  • jaziekjaziek Bad at everything And mad about it.Registered User regular
    edited February 2019
    The question I stumbled on today was

    "Reverse order of the words in a string, in place, but keep the punctuation marks in place."

    String manipulation like that is interview questions 101, but the addition of having to keep only certain characters in their original position threw me.

    jaziek on
    Steam ||| SC2 - Jaziek.377 on EU & NA. ||| Twitch Stream
  • OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    jaziek wrote: »
    The question I stumbled on today was

    "Reverse order of the words in a string, in place, but keep the punctuation marks in place."

    String manipulation like that is interview questions 101, but the addition of having to keep only certain characters in their original position threw me.

    That seems mean for an interview question. Maybe it's meant for the folks that have seen the trick to the reverse-the-order-of-the-words question.

  • bowenbowen How you doin'? Registered User regular
    gosh that's a really annoying one

    not that most of us couldn't do it but it's like not even something you run across practically in day to day outside of someone like ethea or ecco

    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
  • OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    bowen wrote: »
    gosh that's a really annoying one

    not that most of us couldn't do it but it's like not even something you run across practically in day to day outside of someone like ethea or ecco

    It's readily doable, but unless you figure out the trick to reverse-the-words, just special casing is going to take all the time you've set aside for the coding portion of the interview. Now you're adding another layer of special casing on top of that? Come on.

    Either that or it's a 90 minute coding interview or something.

  • bowenbowen How you doin'? Registered User regular
    am I underthinking it then?

    - split by space to an array of substrings
    - reverse the array
    - if there's punctuation at the beginning or end of the substring, flip it to the other side (this may not be necessary??)
    - join by space with the reversed array

    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
  • bowenbowen How you doin'? Registered User regular
    it's just one of those "ugh" code things where I absolutely do not want to do it until the last possible minute

    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
  • OrcaOrca Also known as Espressosaurus WrexRegistered User regular
    I'm looking at this from a C/C++ interview question where you need to do things like write the code to split the array, and then I'll tell you to do everything in place.

  • bowenbowen How you doin'? Registered User regular
    C has strtok though so it's not exactly that much more complicated?

    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
  • djmitchelladjmitchella Registered User regular
    edited February 2019
    Also, what defines "a word"? Is "This is,an annoying example!" four or five words?

    (edit: or less unnaturally phrased: "this is a super-annoying example!" And in either case, which word does the punctuation stick to?)

    djmitchella on
  • dporowskidporowski Registered User regular
    I like questions like "Here's a thing we had to do. How would you do it?" Then as they go, add the restrictions, issues, or other bumps you hit along the way to see how they respond. I misspell my own damn name on a whiteboard, like I'm going to get syntax correct?

  • LD50LD50 Registered User regular
    jaziek wrote: »
    The question I stumbled on today was

    "Reverse order of the words in a string, in place, but keep the punctuation marks in place."

    String manipulation like that is interview questions 101, but the addition of having to keep only certain characters in their original position threw me.

    First you have to figure out what the systems word size is...

  • jaziekjaziek Bad at everything And mad about it.Registered User regular
    bowen wrote: »
    am I underthinking it then?

    - split by space to an array of substrings
    - reverse the array
    - if there's punctuation at the beginning or end of the substring, flip it to the other side (this may not be necessary??)
    - join by space with the reversed array

    yeah I did the splitting and reversing fine, but fumbled on finding an elegant way to keep the punctuation in the right place.

    it was like... "if the fifth word has a question mark, then once the words are reversed, the new fifth word should still have a question mark" not "index i of the string is a question mark, once the words are reversed, index i of the string should still be a question mark" which I would have found considerably easier, really.

    Also, yeah, I think I wasn't supposed to use split, or any other string functions, and was supposed to use only array manipulation to get it done.

    Steam ||| SC2 - Jaziek.377 on EU & NA. ||| Twitch Stream
  • LD50LD50 Registered User regular
    I feel like if you ever spit or reverse a string without using the built in string functions you should be fired.

  • bowenbowen How you doin'? Registered User regular
    I mean sure I can build a function that replicates split and join if I really need to, but I'm not going to just drop those function's code in-situ either.

    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
  • SpoitSpoit *twitch twitch* Registered User regular
    Orca wrote: »
    Mugsley wrote: »
    Programmers: Is the new Humble Bundle legit worth? Just on a cursory glance, it seems at least the BtA tier is good just for general knowledge (I know I've asked you guys about other bundles in the past but I've been gunshy about grabbing; this one includes videos so I'm giving it heavier consideration).

    I've programmed in FORTRAN and I've watched some videos of a guy teaching how to program in C++.

    I'd need to see more of the curriculum and how it's taught to say anything useful about the courses. The course outlines don't seem terrible, though they do seem centered around the frameworks you're intended to use, which does make me look askance at them.

    The price is cheap enough that if they suck it's not the end of the world.

    How about the O'reilly cookbook bundle?

    steam_sig.png
This discussion has been closed.