Page 21 of 21 FirstFirst ... 11192021
Results 201 to 207 of 207

Thread: Programmer's Den

  1. #201
    Senior Member
    Type
    intp
    Join Date
    Dec 2013
    Posts
    1,452
    Quote Originally Posted by Hephaestus View Post
    That's too bad. My experience with it has beeen hit and miss as to whether it would function for me. Though some of the jank is coming from plugging code into an existing page that may or may not even permit use of the console for debugging--ironically for verification purposes.
    Debugging page jank? Try the techniques here https://developers.google.com/web/to...e-performance/

  2. #202
    Meae Musae Servus Hephaestus's Avatar
    Type
    INTP
    Join Date
    Dec 2013
    Location
    Ceti Alpha V
    Posts
    13,577
    INTPx Award Winner
    Quote Originally Posted by scarydoor View Post
    Debugging page jank? Try the techniques here https://developers.google.com/web/to...e-performance/
    Definitely worth a bookmark--but not going to resolve the issue.

    Right now I'm working through problem sets on HackerRank. They provide driver code and you fill out the stub to perform the task. They're set up to use a variety of languages, including Javascript--Node.

    There are two problems, both manageable, just not as I would have liked.

    The first problem is wrangling and isolating the parser box. Can't just copy paste into a friendlier space without rewriting all of their code because of hidden dependencies on their web page. I've more or less resigned myself to doing that, but then I run into the occasional issue of not knowing for certain what they are actually passing me, which means some guesswork in the end as it's a bit inconsistent what you get from language to language.

    As an example, the problem descriptions usually describe passing arrays as two lines, one of the array length, and the other the array contents. In some languages that's what you get. In Javascript, you usually only get the second line--but you have to figure it out on your own based on whether or not it worked. Of course, there's lots of reasons something might not work, and if there is any other reason your code is incorrect, you can spend quite some time chasing rabbits because of the second problem.

    The second problem is that some of the problems are solved by writing the answer to stdout. As long as the problem wants a function that returns something to be handled by main, I can plop out all the logs I need to figure out where things are going awry. But if the problem wants me to print to stdout, in JS, that's the console, so my messages become errors and I don't even get to see the output. I just have a generic failure message. Sometimes I get useful information like, somehow I'm returning NaN so I can specifically look for places I might be assigning the wrong thing to a var. Usually though, once I've sorted all the minor syntax issues (for which their parser gives excellent feedback), all I get is "Wrong Answer", then they tell me the expected answer, and maybe half the time, the answer they received.

    I can work around most of these problems in various ways--the problems specifically for JS are so far well behaved, and when things get too frustrating in the other problem sets, or if the problem is complex enough I know I'll need to send debug info, I switch to Python and work things out in IDLE. Either way, I've just resigned myself to rewriting the driving function.

    If that's what needs doing, so be it. It's certainly not worse than debugging in IDLE, and I'm fine with that most of the time.


    That said... their code is still indubitably better than what I'm doing.

    And I am learning new things hand over fist from the fight.
    Most of time, when people ask why something terrible happened, they don't realize they are looking for someone to blame.

    --Meditations on Uncertainty Vol ξ(x)

  3. #203
    Senior Member
    Type
    intp
    Join Date
    Dec 2013
    Posts
    1,452
    Quote Originally Posted by Hephaestus View Post
    Definitely worth a ...
    Hmmmm. What's the site? I'm interested to take a look.

    Generally though, chrome dev tools is very excellent in regards to debugging javascript/web related stuff. It's very much worth diving in.

  4. #204
    Meae Musae Servus Hephaestus's Avatar
    Type
    INTP
    Join Date
    Dec 2013
    Location
    Ceti Alpha V
    Posts
    13,577
    INTPx Award Winner
    Quote Originally Posted by scarydoor View Post
    Hmmmm. What's the site? I'm interested to take a look.

    Generally though, chrome dev tools is very excellent in regards to debugging javascript/web related stuff. It's very much worth diving in.
    Meant to respond earlier, but, things.

    HackerRank.com

    They've got a ton of little programming puzzles, most of them pretty easy. I've gained more traction on them and to some extent things seem better behaved in that I'm now getting my console.log messages reporting as desired--for the most part. There's still some frustration built-in in their model though. I think they plan on or planned on monetizing through their "hackos" scheme, but haven't implemented a microtransaction system yet, and I hope it's because they realized how deplorable that idea was.

    The model involves having a couple open test cases you can actively plunk with and get feedback from, then you submit your working (presumably) code and they run about 10 more test cases. But they don't tell you what they are or what the result was other than pass or fail, unless you "buy" that privilege with "hackos" that are earned by successfully completing challenges.

    Unfortunately, I ran up against that with my programming test via them, and couldn't use my massive store of hackos to find out what the problem cases were. I'm reasonably certain my algorithm is correct and I just didn't sanitize the input test cases sufficiently, but not knowing what test cases are failing means I end up spending way too much time verifying my algorithm is accurate for any "correct" inputs. I still don't know why the cases that failed failed and I ran out of time before I could get an answer--all because they didn't show me the bloody test cases.

    Maybe I'm just naive, but when I was writing bug reports, part of the bug report was a repro to tell the programmers what I did that broke, and how often it broke. Even if it was a test case that had been given me that failed, I couldn't just say "Failed" I had to write a report that detailed what I did to do the test case--and even if I didn't, even if I just said it failed and didn't explain how I attempted to perform the case, they'd still know what the fucking test case that failed was. But maybe it is common practice to test things and not explain what inputs resulted in the failure and just leave it to the programmer to grope blindly for a way to stop it.

    Still, I'm glad to have learned of it as it does have some interesting little problems and I have learned quite a bit poking around in with it.

    Bad experiences can still be good experience.
    Most of time, when people ask why something terrible happened, they don't realize they are looking for someone to blame.

    --Meditations on Uncertainty Vol ξ(x)

  5. #205
    Senior Member
    Type
    intp
    Join Date
    Dec 2013
    Posts
    1,452
    Oh yeah. So the javascript is going to be executed on the back end, most likely. Therefore the chrome dev tools aren't going to give you anything, because it can only work with what it has (javascript loaded into the client side).

    Reading the faq briefly, they mention you could debug by using `console.error`. Real world, you would prefer to not debug like that. But they're trying to make sure you know your shit.

    Quote Originally Posted by website
    How do I debug my code?

    You can debug on your computer using any tool that you like. When coding in our online editor, anything printed to STDOUT will be matched against the challenge's Expected Output (so printing debug statements there could cause you to fail the challenge). If your submission language supports printing to STDERR (e.g., cerr for C++, System.err.println for Java, console.error for JavaScript, etc.), you can send your debug output there and it will show up in a separate Error box underneath the challenge's Expected Output.

    Can my code write to a file?

    Check out the Writing State Information to a File tab on our Environment page.

    What happens after I submit my code?

    We run your code against hidden test cases. Depending on the output your code produced, you can get the following verdicts:

    Accepted. Congratulations, your code passed all the test cases! It's time to solve a new challenge!
    Wrong Answer. The output your code produced didn't match the output expected by the test case. Rethink your approach and think about whether you misunderstood the problem or missed a corner case.
    Terminated due to timeout. Your code doesn't solve the problem efficiently enough! If you write a O(2n) solution when n = 100, it will surely time out and you're going to need to optimize your algorithm. The time limits are different for each language (some languages are slower than others), and you can see the limits for all the languages we support at our Environment page.
    Runtime error/Segmentation Fault. Your code terminated unexpectedly. Did you overrun your array? Is your code trying to divide by zero?
    Abort Called. Are you using too many resources? Maybe an array you created is too large and exceeds the memory limit, or an assert statement in your code is failing.
    After you submit your code, hover your mouse cursor over the icon for each test case to view the verdicts and runtime for each test case your code was tested against.

  6. #206
    Meae Musae Servus Hephaestus's Avatar
    Type
    INTP
    Join Date
    Dec 2013
    Location
    Ceti Alpha V
    Posts
    13,577
    INTPx Award Winner
    Quote Originally Posted by scarydoor View Post
    Oh yeah. So the javascript is going to be executed on the back end, most likely. Therefore the chrome dev tools aren't going to give you anything, because it can only work with what it has (javascript loaded into the client side).

    Reading the faq briefly, they mention you could debug by using `console.error`. Real world, you would prefer to not debug like that. But they're trying to make sure you know your shit.
    Yep. That's what I ultimately worked out. I understand not coding to test, or think I do, but find this approach ridiculous and a bit antididactic. No worries. It's a reminder my error checking and testing skills still have a lot of room for improvement.
    Most of time, when people ask why something terrible happened, they don't realize they are looking for someone to blame.

    --Meditations on Uncertainty Vol ξ(x)

  7. #207
    Meae Musae Servus Hephaestus's Avatar
    Type
    INTP
    Join Date
    Dec 2013
    Location
    Ceti Alpha V
    Posts
    13,577
    INTPx Award Winner
    I got the interview. Interesting.
    Most of time, when people ask why something terrible happened, they don't realize they are looking for someone to blame.

    --Meditations on Uncertainty Vol ξ(x)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •