News for hackers. Stuff that matters.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by water8 on Sunday April 25, 2021 @02:50AM (#26930817)
The ratio of importance placed on these algorithm design in interviews vs the amount of times they actually come up in real world problems seems skewed IMO.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by Bancakes on Sunday April 25, 2021 @06:44AM (#26931751)
It's not just the algorithm, but the frame of mind to consider an optimisation. I guess it's a rare sight in the age of electron apps and cloud startups.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by DaiPlusPlus on Sunday April 25, 2021 @08:25AM (#26932193)
Oh c'mon...

Electron apps aren't slow, bloated, and awkward because the new junior SWE on the team used a O(n^2) tree-walking algorithm for the app's search feature - they're like that because it's inherent in using a general-purpose web-browser engine for your desktop GUI.

Micro-optimizing application software programs by implementing different algorithms is completely detached from the big engineering choices made at the very start of a project where the application's substrate and platform are chosen - and those decisions are made not with a view towards program computational efficiency, but primarily towards developer-productivity. Thanks to Electron someone who grew-up making websites as a teenager with little to no exposure to the horrendously unproductive and beginner-hostile world of MFC, GTK, and Qt can make an engaging and appropriate cross-platform desktop UI in under a day.

-----

If we want to see the Electron "problem" fixed, then the best solution is for the Electron team to figure out how to cut down their build of Chromium to remove all of the features unnecessary for trusted desktop applications (no, we don't need process isolation!). I'd love to see a build of Electron+Chromium with all of the JavaScript removed, so that it's a bare-bones HTML+CSS layout and rendering system, and have it wired-up to some OOP application binary (be it Java, .NET, C/C++, etc) which manipulates the DOM - I don't see why that should need more than a few dozen MB RAM and run in a single process.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by jorl17 on Sunday April 25, 2021 @08:56AM (#26932337)
People in these arguments always talk about the algorithms, but I think that entirely misses the point. It rarely is about the algorithms themselves, but, rather, it's about the data structures.

One is obviously tied to the other, but what I mean is that many slow apps are slow because the people just used the wrong data structure. Sometimes it's as simple and silly as using a list and constantly iterating over it instead of using a dictionary/KV-map. I think the idea with having people know about "algorithms" is to get them in a state of mind where they will automatically pick more appropriate data structures. I really don't remember how to implement RB-trees or AVL-trees, nor do I really know their pros and cons against each other at this moment (I have a very very faint idea), but I know they exist and I certainly have a better idea of when to use a tree versus a list, versus whatever.

Would I fail these interviews? Probably, unless I studied a bit, but do I think that the concepts that they ask about are pointless? No, not at all. I've looked at my fair share of legacy code bases built by subpar developers and the one thing that always pops up is the bad data structures chosen. Once we fix that, usually everything else automatically falls into place.

EDIT: To be clear, what I mean is that in most cases, just picking the right data structure, among the most basic and elementary data structures given to you by the language, is more than enough. Only in rare cases does one then have to go beyond that and carefully engineer a more precise algorithm. The data structures are way more than half the problem, in nearly every application.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by water8 on Sunday April 25, 2021 @10:43AM (#26933080)
I think you hit the nail on the head. Data structures are so much more important than throwing more threads at the problem. Someone could write beautiful lock-free code but choose a ring buffer (lock free queue) instead of a concurrent set and it's all for not.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by Apocryphon on Sunday April 25, 2021 @04:36PM (#26936439)
> Sometimes it's as simple and silly as using a list and constantly iterating over it instead of using a dictionary/KV-map.

It's pretty easy to walk away from an algorithms course with the very basic intuitive understanding that "dictionaries trump all other data structures." Certainly that misses out on all of the cases when hash maps are a liability, e.g. when dealing with sequential data, but most questions end up being pro-dictionaries anyway.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by DaiPlusPlus on Sunday April 25, 2021 @07:36PM (#26937776)
A dictionary is an interface, not a structure.

Hashmaps, priority-queues/heap-trees, and others are all wildly different approaches of implementing a dictionary - all with their own different Big-O characteristics.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by sidpatil on Sunday April 25, 2021 @10:18AM (#26932873)
"Bad programmers worry about the code. Good programmers worry about data structures and their relationships." —Linus Torvalds
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by fpoling on Sunday April 25, 2021 @02:56PM (#26935474)
If one implements a low-level code, then one has freedom to pick good data structures. But when writing GUI apps there is simply no such freedom as data structures are already defined by libraries.

For example, a GUI framework typically uses a notion of widget tree that is fundamental to the library design. But the end user UI does not look as an arbitrary tree with deep nesting. It is easy to see that using a tree for this leads to extreme denormalization of data. Normalizing that to a relational form should remove a lot of duplication and code (often hidden) to synchronize that duplicated state. But try that with a popular framework. It is not doable in practice. So one sticks with tree architecture and its inefficiencies.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by fpoling on Sunday April 25, 2021 @02:38PM (#26935299)
Chromium supports a single process switch at least to use for development of Chromium itself. While it does reduce memory consumption, it does not help much. All data structures in Chromium are tailored for multi-process case with no memory sharing. Replacing processes with threads do not change that.

As for removing V8 JS engine from blink I guess it is possible. But again, blink is tailored for accessing from JS and the layout and rendering code is huge so one does not save much.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by zozbot234 on Sunday April 25, 2021 @09:42AM (#26932639)
> Electron apps aren't slow, bloated, and awkward because the new junior SWE on the team used a O(n^2) tree-walking algorithm for the app's search feature - they're like that because it's inherent in using a general-purpose web-browser engine for your desktop GUI.

¿Por qué no los dos? If we're going to implement a desktop GUI via a general-purpose web browser, it should at least be as fast as a generic webpage.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by thrower123 on Sunday April 25, 2021 @08:31AM (#26932228)
Software interviewing tends to be selecting for neurosurgeons, and then the job is putting them in a rickety ambulance with some steristrips and a shot of narcan.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by mightymercado on Sunday April 25, 2021 @03:05AM (#26930889)
I would argue that it's a pretty good measure of programming and CS problem solving skill with weak alternatives.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by wst_ on Sunday April 25, 2021 @04:45AM (#26931281)
It's much better to give a candidate a simplified version of your typical daily task. Give them enough time so they can google and learn if needed. That usually means very simple task that you could solve in hour or two at your leisure at home.

Now, I do get that there's a lot of people who don't like spending time at home for interview tasks but when you think about AND it's not skewed to extreme (say, big task 8 working hours worth) then, in terms of time wasted, it's not such a big difference. Interviewer can then see the code quality, can talk about it with candidate, clarify some missing pieces or pitfalls found, etc.

IMHO most important is not if the candidate knows how to solve some hard or even medium problem when I speak to them and they are stressed enough already. What is important is if they're willing to learn, if they know how to search for stuff they may not know and if they can produce performant enough, but excellent to read, code.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by globular-toast on Sunday April 25, 2021 @04:57AM (#26931335)
It depends what you're looking for. If you want someone who can turn the handle on your typical daily task then, sure, test them on your typical daily task. But if you want someone capable of developing solutions to brand new problems then it's not so easy and testing fundamental computer science theory is important.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by slumpt_ on Sunday April 25, 2021 @05:11AM (#26931385)
It’s not. Theory can be referenced. People do not work in a vacuum.

Interviewing in eng is broken, but afaict its a “worst solution save all others” kind of scenario.

But let us not begin to deem these intrinsically important.

Some of the most creative and productive coworkers I’ve had struggled with leetcode style interviews. They’re a bad tool for anyone who isnt a new grad, and even then.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by globular-toast on Sunday April 25, 2021 @06:54AM (#26931805)
When you apply for jobs do you simply look for "engineering" positions? Why am I always applying for software engineering and not electrical engineering? It's all engineering, and theory can be referenced, right? In fact, why doesn't everyone just buy a book and become a top engineer?

The point is not (or shouldn't be) to recite a textbook. The point is you can navigate your way around the textbooks. I've got both The Art of Computer Programming and The Art of Electronics on my shelf. I could find the sections to help sorting a list in seconds. As for the latter, I have no idea why the majority of that book even exists. I can't call myself an electrical engineer, even though all the theory I need is within arm's reach.

I assume you're arguing against the "recite the textbook" approach. I would agree that this is not the way to do things. But equally, "throw the textbooks out" is not the right way either. We need to evaluate a high-level grasp of the literature/theory but don't punish for forgetting minutiae. I might ask a candidate to talk about choice of sorting algorithms. There is, of course, no perfect answer, but what I'll be expecting is general evaluation of algorithms: time/memory tradeoffs, probing for more domain knowledge (e.g. does the data often come in sorted or random), platform constraints etc. I won't even expect a name drop of an actual sorting algorithm as that's not really the point. What they're telling me is they know why Knuth has a whole chapter on sorting. That's the important thing.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by piva00 on Sunday April 25, 2021 @08:28AM (#26932209)
This is a false dichotomy. Specific theory that is hard (and useless) to memorise all details can be easily referenced if you are knowledgeable enough in a field, if you know about a red-black tree, the gist of its properties you can easily Google usage cases if you've forgotten, examples of it and algorithms related to it (rebalancing, how it relates to search, etc.), if you had never studied, used or seen one there is no way to reference to these properties easily.

I'd much rather hire and work with someone who has the skill to easily assess a situation and use referencing to rebuild knowledge than someone who memorised how to implement tree balancing, so why do we test for the latter rather than the former?

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by fpoling on Sunday April 25, 2021 @03:05PM (#26935574)
Some companies want to test if a person spent time preparing for the interview. So asking all those quiz questions does make sense even if they are no relevant. At least it shows that the person knows the rules of the game and is willing to invest substantial efforts to follow them even if the rules are arbitrary and irrelevant for day-to-day activities.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by slumpt_ on Monday April 26, 2021 @02:49AM (#26939949)
Okay. So arbitrary preparation - when nearly any other professional interview requires little preparation beyond updating your resume - has merit because... rules of the game?

Stop supporting baseless metrics for assessment just because some old person used them before you showed up. We can and should do better.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by fpoling on Monday April 26, 2021 @03:17AM (#26940108)
This is how it is with IT companies paying well above average. Given that they are able to pay such salaries this interview strategy is compatible with big profits.

It could be that by changing interview strategy to look more similar to other professions that profit can be increased even farther, but nobody is risking it.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by piva00 on Monday April 26, 2021 @06:09PM (#26948906)
I can use your argument to push to another side: wouldn't this strategy also tell us a huge bias that it is selecting for and presenting itself in tech companies? With that I mean the bias of "learning to play the game", selecting for people that are going to conform to arbitrary rules for their promotions, caring about playing the game instead of analysing the impact of their work?

And I can ask that given the recent issues with data privacy and data abuse by the tech giants, would we be in this place if the interview processes had selected for more holistic engineers, technically able but that refuse to play the game just for the sake of playing the game, that are opinionated and don't conform to something just for the sake of money?

I know that I might be creating a false dichotomy but I would like to think about what kind of pressure this selection process creates, what biases arises from it? How can we make it better?

Because your argument is the most conservative and pro-establishment one: it works so don't touch it and just emulate.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by fpoling on Tuesday April 27, 2021 @03:29AM (#26953090)
I was not arguing for these types of interviews. My point was that one can rationally explain apparently useless quiz questions. And yes, this is a strong selection bias to pick people that agree to play by arbitrary rules without questioning them.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by slumpt_ on Monday April 26, 2021 @09:25AM (#26942262)
I’ve worked at several shops paying well above average with interview processes that hinged on more representative work.

Not everyone is playing the absurdly doofy “game,” just most.

Local maximum that laziness has us trapped in. Nothing to do with merit.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by slumpt_ on Monday April 26, 2021 @02:51AM (#26939964)
Being able to refresh one’s memory / reference previously learned approaches is not akin to learning them from scratch. Your opener is preposterous.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by EvilEy3 on Sunday April 25, 2021 @08:25AM (#26932190)
> It’s not.

Yes it is.

> Theory can be referenced

How do you know that the person is even able to comprehend theory?

> Interviewing in eng is broken, but afaict its a “worst solution save all others” kind of scenario.

That's your opinion.

> Some of the most creative and productive coworkers I’ve had struggled with leetcode style interviews.

Good for you. But "slumpt_'s most creative and productive coworkers" is not a good metric for hiring.

> They’re a bad tool for anyone who isnt a new grad, and even then.

Again, that's your opinion. I'm not a pro in those interviews, but studying DS and algos opened up and pushed my mind to its limits like nothing else. Your whole thinking process changes when you start working on this, you start thinking about constraints, performance implications, pro and cons of different approaches. It is called Computer SCIENCE for a reason.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by water8 on Sunday April 25, 2021 @10:32AM (#26932993)
The person who's going to come up with new idea's isnt spending their time memorizing old ones. They learn to index where to retrieve knowledge when necessary in order to allow them to cover a wider breadth of knowledge. And this will allow themand to pick the best one for the job at hand as opposed to the tool they are an expert in. Sometimes you need a handyman instead of a master plumber because they are better able to see the big picture beyond all the shit.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by slumpt_ on Monday April 26, 2021 @02:46AM (#26939937)
My best coworkers is about as good of a metric as things that “stretched your mind to its limits.”

The point is neither is demonstrated to bear any relationship to jack shit

Interviewing is and has been broken, even with the changes we’ve made over the years.

If you’re holding onto leetcode challenges that make you think hard as representative of engineering prowess we’re never going to have a reasonable conversation.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by nicoburns on Sunday April 25, 2021 @06:40AM (#26931732)
There are plenty of people who have a fantastic knowledge of CS theory and are pretty useless at solving real world problems.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by globular-toast on Sunday April 25, 2021 @07:02AM (#26931847)
Again, it depends what you're looking for. If the real world problem is "we need a fast optimising compiler that runs on our embedded platform" then hiring someone who is great solving problems but knows nothing of compiler theory is going to be very inefficient.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by EvilEy3 on Sunday April 25, 2021 @08:26AM (#26932202)
> solving real world problems

Define this first.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by slt2021 on Sunday April 25, 2021 @09:25AM (#26932515)
changing color of a button in an Electron app, or moving JSONs back and forth (from backend to frontend)
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by water8 on Sunday April 25, 2021 @03:52AM (#26931073)
Most of these types of algorithms already have tons of research available online as people try to figure out what the lower bound of optimization is. It's far more telling to just talk about previous projects the person has worked on to gauge their level of competence. Asking them to explain why they made the choice they did vs trying to see how much they can memorize tests two different skill sets. The person who makes better choices is the one you want to hire.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by fakename11 on Sunday April 25, 2021 @04:10AM (#26931130)
How does someone talking tell you if they can actually do basic programming... I think you would be surprised at the number of people that apply for software engineering jobs but barely know how to program.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by saagarjha on Sunday April 25, 2021 @04:17AM (#26931158)
To be fair, I know a fair number of people who are good at competitive programming but are absolutely awful at writing maintainable code.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by qsort on Sunday April 25, 2021 @04:41AM (#26931264)
Yeah, those competitions are not really representative of actual skill.

I was into competitive math as a teenager and was somewhat successful, but I actually kind of suck at math.

Similarly, I'm a professional developer but I'm really bad at competitive programming: what usually happens is that I know how to solve the problems but the time limit is too low (for me, at least).

I'd say success in competitions is a good indicator of dedication and perseverance, but not sufficient to spot someone who's good at the job.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by Flex247A on Sunday April 25, 2021 @04:23AM (#26931186)
Yeah, competitive programming forces you to use short variable names and write makeshift code which is fast enough to pass all the test cases ...
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by water8 on Sunday April 25, 2021 @10:37AM (#26933029)
Because you can determine if they organize and test things in a repeatable and maintainable way or do they have trouble organizing structures and make questionable performance decisions. Are they clear on the hasA vs isA. Do they know what a mutex or static scope is? These are the things that will cause huge debugging nightmares. Syntax issues are no where close to as problematic so why use whiteboards vs an actual computer? In my experience of interviewing, questions about Security and Threading(performance / micro-opts) are good for separating the wheat from the chaff.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by pjmlp on Sunday April 25, 2021 @04:32AM (#26931218)
By the same way we have doctors do surgery in place, construction workers do a toy house, teachers give a class for free, cooks spend one day serving meals for free,...
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by beforeolives on Sunday April 25, 2021 @04:25AM (#26931197)
Are these mutually exclusive? I've never been through an interview that didn't ask questions about previous work regardless of how the technical test was structured.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by tekkk on Sunday April 25, 2021 @04:40AM (#26931257)
You'd think so, but from my experience the folk that are very interested in algorithmic design and so forth produce highly abstract and hard to understand solutions to simple problems, which, in the end, are the majority in the regular dev work.

Sure if you're applying for a job that really demands algorithmic design skills it should be a great asset but in general the most valuable skills any programmer has is producing simple and robust code that works and others can continue building on. I don't deny that knowing algorithmic design skills well helps a lot but it does seem to feed the egos of the programmers to produce overly complicated solutions.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by teachingassist on Sunday April 25, 2021 @06:32AM (#26931689)
This is a nice point -

I'd answer this type of algorithm question in truth by identifying the relevant library wherever possible, not by coding it myself, and I'd strongly expect anyone I was working with to do the same.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by water8 on Sunday April 25, 2021 @10:46AM (#26933115)
"I always code my own AES libraries because I'm an expert" - said no expert ever.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by paraph1n on Sunday April 25, 2021 @04:47AM (#26931285)
It's a much better measure of how many leetcode DP problems you solved while grinding interview prep. I'd argue it's a pretty poor measure of software engineering ability.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by aliceryhl on Sunday April 25, 2021 @03:53AM (#26931077)
Yeah, interviews should really be asking more questions about graph algorithms instead. Those are so much more useful.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by tarsinge on Sunday April 25, 2021 @05:50AM (#26931529)
I do mostly not too sophisticated web apps and binary search and minimum edit distance do come up regularly. I agree you don't have to remember the implementation details, but you have to know they exist and which problems they solve.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by philips4350 on Sunday April 25, 2021 @06:24AM (#26931652)
But that doesn't mean you need to be able to implement them though. Shouldn't having a high level knowledge about these problem be enough if all you are doing is building apps.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by kryptiskt on Sunday April 25, 2021 @07:01AM (#26931841)
I disagree. There are so much code out there that nest loops and become accidentally quadratic, where a little knowledge would have helped make it perform well at scale. Knowledge about the time complexity of algorithms isn't valuable only for people implementing libraries. Every single time you iterate over things or partition things by a predicate you are using the building blocks of algorithms to make a new custom algorithm, and knowledge of the theory will help you avoid bad performance.

All nested loops are harbingers of algorithmic doom, and should be treated as such, and they come up all the time in real code.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by lifthrasiir on Sunday April 25, 2021 @08:16AM (#26932152)
There are only a few useful parts of the algorithm theory in practice. The time complexity is surely one of them, but it is still overvalued in a sense that the actual performance on the real hardware and realistic input distribution is more important. And when you actually need algorithms, you always have a luxury of existing literatures and implementations. Real-time algorithm design in the interview is very unrealistic and in most cases only exists to detect interviewee's signaling.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by EvilEy3 on Sunday April 25, 2021 @08:29AM (#26932220)
> And when you actually need algorithms, you always have a luxury of existing literatures and implementations.

And how well that works in practice? How will candidate even know where to look at if he has no idea what he needs to find?

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by lifthrasiir on Sunday April 25, 2021 @09:10AM (#26932420)
> How will candidate even know where to look at if he has no idea what he needs to find?

That happens all the time, not just for algorithms. I don't expect candidates to know every possible algorithm (as I surely don't), I expect candidates to identify and learn what's required for the task. A knowledge of the specific algorithm is not of much value. The ability to learn and possibly implement algorithms is.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by EvilEy3 on Sunday April 25, 2021 @09:23AM (#26932501)
> I expect candidates to identify and learn what's required for the task

And that comes for free in people who spent time on Algorithms and Data Structures.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by lifthrasiir on Sunday April 25, 2021 @09:31AM (#26932563)
Yes, I haven't said that you should not learn algorithms. The best way to learn that skill is to learn (some) algorithms; DP is particularly worthwhile to learn because it is pretty hard to invent by one's own. But as an interviewer I would spend more time to check the general ability to adapt than the algorithmic knowledge.
Re:Dynamic Programming vs. Divide-and-Conquer (2018) by specialist on Sunday April 25, 2021 @10:46AM (#26933113)
Then shouldn't the interview focus on identifying and mitigating those problematic nested loops?

For day jobs, I've done very little computer science relevant work. Instead, it's communication, coordination, code maintenance, infrastructure, verification, managing upwards, ad nauseum.

That includes greenfield development, when I invented entirely new solutions to old problems. Even during the bursts of hardest parts (creatively), the algorithms and such were maybe 5% of the effort.

Re:Dynamic Programming vs. Divide-and-Conquer (2018) by waynesonfire on Sunday April 25, 2021 @03:07AM (#26930902)
i believe the claim is the ability to understand these algorithms vs understand business problems is not.