• 0 Posts
  • 26 Comments
Joined 1 year ago
cake
Cake day: June 30th, 2023

help-circle



  • Yeah, I was going to mention race conditions as soon as I saw the parent comment. Though I’d guess most cases where the debugger “fixes” the issue while print statements don’t are also race conditions, just the race isn’t tight enough that that extra IO time changes the result.

    Best way to be thorough with concurrency testing IMO involves using synchronization to deliberately check the results of each potential race going either way. Of course, this is an exponential problem if you really want to be thorough (like some races could be based on thread 1 getting one specific instruction in between two specific instructions in thread 2, or maybe a race involves more than 2 threads, which would make it exponentially grow the exponential problem).

    But a trick for print statement debugging race conditions is to keep your message short. Even better if you can just send a dword to some fast logger asynchronously (though be careful to not introduce more race conditions with this!).

    This is one of the reasons why concurrency is hard even for those who understand it well.


  • Yeah, I wish C++ had function/scope epilogs and labeled loops/breaks, too. Those are the cases where the “never use goto” rule can be broken to make better code than adding all of the code that would be required to handle it the “right” way (setting up early exit flags and if statements after each level of nested loop to check the flag).



  • I think part of it is going through all those sorting methods to show quick sort is the best so that a) students who run into new sorts are better equipped to determine it most likely isn’t better than quick sort and b) to show the process used to determine quick sort is better than the rest in case you have some other algorithm options you want to pick the best of.

    And yeah, depending on what you do, some tasks never involve any of that, or when they do, they get offloaded onto a library or something that gives the solution to that step directly.

    But, for example, if you have a collection, the question of array vs linked list vs tree is still relevant, even if you’re just choosing a provided construct that is built on top of one of those. Each has their strengths and weaknesses depending on how the data is added, removed, and accessed.

    And with how slow things are these days despite how much better the hardware is, I think there’s a lot of successful software engineers and programmers who should be using that stuff from school more than they are.


  • Also big O analysis IMO should just be the starting point of maximizing efficiency. Those coefficients that just get dropped can have a huge impact. For example, any algorithm written in JavaScript or visual basic will be of the same order as that same algorithm written in C/C++ or rust, but will likely perform much slower. And the exact manner of implementation could even result in the C version being slower than the VB one.

    And on the other hand, I wouldn’t call a lot of big O analysis very advanced math. You might get a tighter bound with advanced math on some algorithms, but you can get a rough estimate just by multiplying and adding loops together. The harder question would be something like “does this early exit optimization result in an O(x³) algorithm becoming an O(log(x)*x²)?”


  • He’s got a lot of charisma. And his videos frequently give that “people doing something they should have prepared more for but pushing through anyways” entertainment where you can laugh at how they put effort into creating an illusion of professionalism but left enough gaps to make it clear it was just an illusion and he’s in way over his head, but somehow still manages to keep it going.

    It’s a weird spot where I like the guy and want to see him succeed but also don’t think he deserves that success and want to see him fail.

    Though I don’t really spend much time watching hardware enthusiast videos in general, so I probably won’t see either of those unless it goes viral like his last shitshow did.


  • Yeah, it’s one of those core components that if someone actually lists it, first assumption is that they felt like they needed to pad their resume.

    Though at the same time, it could be an attempt to say, “hey, I don’t know each of the specific languages you’ve listed, but because I know how to use a search engine, I can quickly learn any of them”.

    Like I learned python because I needed it for assignments. It wasn’t a “oh, some classes might use python, I better learn it ahead of time”, it was a “I’ve just been given an assignment that must be written in Python. It’s due in two weeks, so next week I’ll sit down with a tutorial or two to learn the basics, then I’ll just have a couple of reference tabs going while I do the assignment itself”. And I’ve done that at work for both perl and ruby.

    Out of all languages I’ve learned, the only new paradigms were things like objects, functional programming, or RTL programming with verilog. And really only that last one is a significant mindset shift. Objects are just a way to organize data and methods, functional programming is just using a new variable for each assignment, it’s all still running the same machine code on a CPU core. RTL is different because it’s designing circuitry that “runs itself”, but even that is one that I learned during one school term that I could have picked up on my own if pointed in the right direction.

    The real benefits from my schooling and experience are all harder to put on a resume. I know how to learn. I might not know everything you’d like me to know to do this job right now, but I’m confident that I can learn them quickly and competently enough to be useful in this role. I naturally gravitate towards edge cases and rule exceptions, which I find helps mature my experience quicker because debugging is more matching current behavior with a limitation I was already aware of rather than needing to discover that limitation exists. But how do I put that on a resume, especially one that needs to get passed AI filters just looking for the most matches with words from the job posting? Or as a hiring manager, what do I even look for to try to get more of those people than rigid people who happen to have a match with the current skillset I’m looking for? A university level degree is the only thing I can think of so far.




  • Olauncher is highly rated and collects/shares 0 data (at least according to the data safety section on its Google Play page, though I have no idea how reliable that is).

    I installed it yesterday. I’m not hating it but not sure if I like it. It’s very minimal. Like you don’t even see the notification bar from the home screen and are limited to putting 8 apps on there (after you adjust the setting from 4). Everything else is on an alphabetical list, which has forced me to remember the names of apps instead of just remembering the icon and position I gave it in Nova. But it might just be something I need to get used to, so I’ll give it some more time.



  • Awesome, thank you for that link. I should have guessed this was a thing but it hadn’t even occurred to me.

    And yeah, it is surprising that clang doesn’t treat mod power of 2 as a special case. It looks like I can’t type in code on mobile, does clang handle divide by power of 2 as a idiv or shift?


  • The less readable one is faster, though I’d be surprised if the compiler doesn’t generate the same code for both of those options with optimizations enabled.

    I like the regex one as another unnecessarily complicated way of doing it. It also involves a string conversion.

    The way that was being hinted at before my reply was a large series of if statements: is it 2? 4? 6? 8? And so on. It’s plausible in that I could see a beginner programmer using that method. And honestly, knowing how people can get pigeon holed into looking at a problem from some weird angle but still having the determination to figure it out, most solutions are plausible. Often when they get pointed in a better direction, it’s not so much a case of them learning something new as it is a facepalm kinda moment where they feel embarrassed at not seeing that. I’ve done it myself many times lol.

    It’s always funny seeing someone use the wrong tool for the job but still getting the job done, even when it’s me.





  • Just need to add some code that saves the base stack pointer, detects when the stack is about to run out, then saves the current number, resets the stack to the original pointer but now with the current number as x and continues on to fix the stack overflow issue. You don’t even have to restore the stack when it’s all unwinding!

    The integer overflow issue would be more complicated to solve except it isn’t really an issue because chopping off the upper bits doesn’t affect the eveness of a value.

    Oh and I thought of a quick way to verify the result of the algorithm. It should give the same result as this expression that you can use in your test suite:

    !(x & 1)
    

    Edit: um, new formatting problem… And that amp shows up in the edit box so it might even keep expanding.