4 ms·
No we wouldn’t. Source code is notoriously hard to read if you’re not familiar with it, and optimized source code using internal APIs is even harder. If you’re
by jonathankoren 6y ago
No we wouldn’t. Source code is notoriously hard to read if you’re not familiar with it, and optimized source code using internal APIs is even harder.
If you’re learning an algorithm, just stick to pseudocode, otherwise youre stuck with MMIX bullshit.
- aidenn0 6y agoI mean Joyce is notoriously hard to read, no?
- deleted 6y ago[deleted]
- jonathankoren 6y agoWhile there is only one Joyce, please tell me how build 627252 of Windows 3.11 glonkglonk.cpp is a unique example that provides more insight into a heap, than five lines of pseudocode.
- aidenn0 6y ago"Here's 5 lines of pseudocode" "Here's a real-world implementation of the pseudocode. Note this section does not improve the asymptotic case, but has significant constant-factor advantages for small inputs." [edit] I noticed you mentioned "heap" assuming you're talking about the data-structure, that would probably be in a different class than one where you read windows source code. Just like you probably wouldn't read Joyce in a class on composing newspaper articles. I still think it's useful to dissect existing code to get an idea of how complicated it really can be. A CS undergrad may graduate without ever reading or writing a single program over 1kloc. Even from an academia perspective, having a concept that real-world software is usually 100s or 1000s of kloc is likely useful.
- philipkglass 6y agoA typical experience when I re-implement a technique from an academic paper: 1) Read the paper's high level description and pseudocode. 2) Write some test cases. 3) Write code based on the paper's pseudocode. 4) Observe that my test case results do not match what the authors show. 4a) Fiddle repeatedly with possible ambiguities in the pseudocode-to-real-code translation until test cases match publication. This involves a certain amount of mind reading and speculation. "They said argmax, but there are possible singularities... maybe argmax followed by clamping." 4b) Request source code from the authors. Upon receiving it, find that their real implementation diverges in small but significant ways from the pseudocode that was published. They have mixed actual-code algorithm outputs with incomplete pseudocode algorithm descriptions in the paper.
- sanxiyn 6y agoMMIX is not bullshit. Knuth is interested in concrete complexity as well as asymptotic complexity, e.g. why quick sort is faster than heap sort, so he needs concrete model of computation. It may be an overkill if you aren't interested in concrete complexity, but it serves a purpose.
- jonathankoren 6y agoThere’s a reason why no one explains abstract algorithms in assembly. It’s a trash idea, that obscures more than it illuminates. It’s a flex. A flex that is marginally above explaining an algorithm through a wiring diagram of thermionic valves.
- xorcist 6y agoNo one, except Donald Knuth himself, widely regarded as one of the best explainers of algorithms we have?
- jonathankoren 6y agoI don’t think agreeing that no one else on the planet writes examples in assembly is the dunk you think it is. Have you ever heard of anyone reaching out of those books, or even read all of them? He maybe heralded because of when we wrote them, but there are much better written books in 2021.
- tester34 6y agoI disagree I hate reading pseudocode because I do always have to wonder "what the person writting this had actually on their mind" an actual source code is literally what's going on.
- wassenaar10 6y agoReading source code, especially source code that you're not familiar with, is a crucial skill for any programmer. I've found annotated source code to be an extremely useful learning resource, personally.