Live data from Hacker News

Competitive programming is useless

kislayverma.com

111–120 of 157 posts

Re: Competitive programming is useless

#111

Earlier quoted context omitted.

> Almost everything you will ever need is already implemented in a library for you to reuse, and even reaching for that library is pretty rare. Developers who have no interest towards algorithms will not even have the skills required to identify opportunities where algorithms should be used, much less the skills required to identify which algorithm should be used. For example, I had a conversation here on HN a few we…

>And that's how you end up with 5-minute load times for GTA. was it actually the reason?

Different game, different problems, but I've spent a fair amount of time looking at the source for Civ IV's core game DLL (released by Firaxis for modding).

It was fairly simple to get significant performance gains (without changing AI behavior or results) just by applying straight forward changes. Eliminating macro's hiding chained method calls. Saving the result of nested calls, e.g. save a pointer to the game map instead of making the same call repeatedly in a tight loop.

There's a huge difference between "premature optimization" and just sloppy coding. Too many take the idea too far that the (C++) optimizer is better than you'll ever be and that you should let it do it's job. Yes, the optimizer is/can be very good and can make surprising and unintuitive changes to make code faster. But, it's not a miracle worker. Optimizers work best on clear, concise, code with minimal data dependencies.

FWIW, back on my Core I2 Duo, a single late-game turn on a huge map could take upwards of 30 minutes to complete, most of that spent in AI's turns. I was able to get it down to about 5 minutes without too much effort. Along the way, RAM usage also plummeted. If I had full access to the source, I could have made even greater gains that would have broken the DLL ABI...

Sadly, I never released my changes anywhere (and I only had local SVN at the time), and they haven't survived my PC upgrades since.

Re: Competitive programming is useless

#112
post #10

Earlier quoted context omitted.

According to Peter Norvig, the correlation is actually negative! https://www.youtube.com/watch?v=DdmyUZCl75s

I believe Norvig later clarified that the negative correlation was untrue or statistical noise.

Correct: https://news.ycombinator.com/item?id=25426329

Re: Competitive programming is useless

#113
post #67

Earlier quoted context omitted.

Writing foundational algorithms/data-structures libraries (e.g. language-runtime stdlibs like libc) is usually treated as a sort of sacred ritual in programming—something where it’s “obvious” that it should be done slowly, carefully, and without distraction, with each change audited carefully by many peers before accepting a merge. It’s not often that you’re writing such code “in anger”, under time-pressure to ship t…

> Writing foundational algorithms/data-structures libraries (e.g. language-runtime stdlibs like libc) is usually treated as a sort of sacred ritual in programming—something where it’s “obvious” that it should be done slowly, carefully, and without distraction, with each change audited carefully by many peers before accepting a merge. I'll be honest, I think you're vastly overestimating how well these things are actua…

What I really meant, without the fancy language, is that stdlib programmers are crotchety greybeards who don't like change-for-change-sake and so default-deny rather than default-accept random patches. That by itself creates a very different level of stability in these projects, where things only ever change if they really need to to fix a specific bug—and even then, the change is pared down to have as little architectural effect as possible.

Re: Competitive programming is useless

#114

Earlier quoted context omitted.

To me competitive programming doesn't make you a good software engineer. It will teach you bad practices, like abusing of dangerous programming constructs or data structures to optimized the code or just save some typing while writing the code (like one letter variable names, macros, etc), global variables and state in the program, not using common design patterns, not using OOP, not documenting the code and in gener…

Not using design patterns seems like pure upside. I don't think it's reasonable to use a library for most things one implements in competitive programming, because the work of getting your problem instance in and out of the library is probably greater than the work of writing the solution yourself, in code length and in runtime. As an example, the only time I ever needed to use A* was on a state space that was larger…

It's not. Because then someone else has to maintain the code you written, and if he cannot see any common pattern in your code he will make 10x the effort to understand the code, that means wasting time and thus loosing money for the company.

Re: Competitive programming is useless

#115
post #83
post #45

Earlier quoted context omitted.

you obviously have a pretty strong bias. I didn't say its a requirement, I said they would have a higher percentage of gifted students. Also the requirements are not "above average", a math SAT of 750 is in the 95% percentile of SAT takers, which is already below average for MIT. Even then, the "average" student isn't even taking a college readiness test. You are grossly overestimating what average is.

Can you clarify how this can't be prepped for, and is a marker of intelligence instead of also being explained by average intelligence, coupled with means ($$) and drive? I attended a top school. I can assure you my classmates weren't on the whole more intelligent. They did have more drive, better study habits, more external forces (parents) pushing them. Some were extraordinary, but not the average. I would have tro…

I really don't think I am making that claim. As far as I've read SAT scores before the age of 10 are a good marker of intelligence. Of course you can prep a large extent to get into a good school as a high school student.

I attended a small state school for undergrad, and a top school for grad school. There were no extraordinary students at the small state school. I was top of the class. When I went to grad school I was quickly humbled as very much average in that selected group. Everyone studied/research all day long in grad school, it wasn't really a matter of who was more driven, everyone was driven.

All my point is and has been, is that extraordinary people self select to go to good schools. That brings up the average overall compared to low rank state schools.

Re: Competitive programming is useless

#116
The article leaves out one very important skill: teamwork.

Teamwork is tested very well by contests like the ACM ICPC programming competition: teams of 3 people, one computer, and 7 or so problems to solve in 5 hours.

Speaking from first hand experience, my team won the ICPC (many years ago...) based totally on coaching on our teamwork. Essentially, we arrived in the competition city 5 days early and somehow got adopted by the coach of another country's team (which said they didn't need her help). She spent those 5 days observing us approach each phase of the contest, and gave feedback on every aspect on how we worked together: triaging the problems in the first minutes of the contest, who to allocate which problems to, optimising sharing the single computer, when to switch when stuck, helping each other debug, etc, etc. Right down to how to lay out our stationery and stack our working notes on the table.

After doing 2-3 prior competition problem sets a day for 5 days, we became an amazingly efficient machine. Not because we were individually better problem solvers (thought there was some improvement there). But because we all instinctively did the right things in the right order, there was no dead time, no miscommunication, and no stress about our performance versus others.

Thanks to Raewyn's coaching, we converted probably a 5th place into a convincing 1st place. And she'd already won 1st place with her own country's team two years earlier.

So the focus on teamwork paid off. Both in our contest, and in work situations subsequently...

Re: Competitive programming is useless

#117

Earlier quoted context omitted.

No they weren't using bubble sort. When parsing JSON, they were calling sscanf (which internally was calling strlen). In addition, those parsed objects were stored in an array which was iterated through on each insert to check for duplicates. There was an article [0] and subsequent discussion on HN [1] about reverse engineering and patching the binaries. [0] https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-time…

No? If you check your own sources, you will find that this is precisely the type of case where a developer is using an O(n^2) algorithm out of ignorance when they should have been using a faster algorithm, and that the high load time was caused by this mistake. The time complexity for bubble sort is also O(n^2), compared to O(nlogn) for reasonable sort algorithms. I don't really understand how you take all this infor…

The way accidental O(N²) comes about isn't "I'm intentionally using an algorithm that's O(N²)" (e.g., bubble sort), but "this method that I think is O(1) is actually O(N)" (whether because it's badly designed or just badly documented).

It's really not in the same vein as using bubblesort instead of a mergesort: failures aren't in algorithm design but in the actual mechanics of the implementation that is ancillary to the algorithm itself.

Re: Competitive programming is useless

#118

Competitive programming is useless, but most things are useless! And here "useful" only means useful in the context of building and evaluating skills for industry. But my friends who do competitive programming do it because it's fun, and some of them don't even want to work in tech when they graduate! There is a kind of pleasure in connecting the pipes and optimizing the loops and building a sick dynamic programming…

Agree completely, it's really fun. It's unfortunate it's factors so heavily into some hiring processes though.

Re: Competitive programming is useless

#119
post #86

Competitive programming is fun. It’s amazing that some people seem to think everything is about career path optimization. Are we not allowed to do things for fun or just to pass the time anymore without someone writing that we’re wasting our time since it isn’t boosting our career?

Debugging is fun (at least for me). We should replace programming tests with debugging tests in interviews.

Re: Competitive programming is useless

#120

I'd disagree with this assessment. In my own experience, I've found that competitive programming is useful in teaching a few skills. However, the apparent point of competitive programming--building up a good repertoire of advanced algorithms and data structures--is pretty close to useless. In my professional career, the most complex algorithm I've ever had to code myself is ... union-find (on like two occasions), wit…

> Almost everything you will ever need is already implemented in a library for you to reuse, and even reaching for that library is pretty rare. Developers who have no interest towards algorithms will not even have the skills required to identify opportunities where algorithms should be used, much less the skills required to identify which algorithm should be used. For example, I had a conversation here on HN a few we…

> somebody said that they will not need to learn anything about sort algorithms, because they can just google bubble sort and copypaste it if they need sorting at work

In this example, the missing skillset is not memorizing a book of algorithms as you seem to imply.

If performance isn't good for the use case, they should be profiling the code for root causes. Which will lead them to identifying the sort operation as a problem. At which point they can search for faster sorting algorithms which will quickly lead them to a better solution and libraries containing them (or even how to implement, if they're operating in a constrained environment where no libraries exist).

I don't want to hire software engineers who have memorized the algorithm book, that's not useful to me. I want to hire those who can apply discipline to the work, such as (in this example) be aware of performance and know how to analyze it and find solutions.

Post reply on HN