19 ms·
TLDR: The author independently re-discovered what you may know as Old Code Syndrome. I think that's because mathematical papers place too much value on tersen
by csense 11y ago
TLDR: The author independently re-discovered what you may know as Old Code Syndrome.
I think that's because mathematical papers place too much value on terseness and abstraction over exposition and intuition.
This guy's basically in the position of a fairly new developer who's just been asked to do non-trivial update of his own code for the first time. All those clever one-liners he put into his code made him feel smart and got the job done at the time. But he's now beginning to realize that if he keeps doing that, he's going to be cursed by his future self when he pulls up the code a few months later (never mind five years!) and has zero memory of how it actually works.
I'm not intending to disparage the author; I've been there, and if you've been a software developer for a while you've likely been there too.
Any decent programmer with enough experience will tell you the fix is to add some comments (more expository text than "it is obvious that..." or "the reader will quickly see..."), unit tests (concrete examples of abstract concepts), give variables and procedures descriptive names (The Wave Decomposition Lemma instead of Lemma 4.16), etc.
- bbcbasic 11y agoKind of old code syndrome. I would say it is more like changing from Java to Ruby on Rails full time, and looking at your old Java code which is now a rusty language, with rusty memories of the class libraries and frameworks you used. Even with beautiful code it will be a struggle.
- gjulianm 11y ago> I think that's because mathematical papers place too much value on terseness and abstraction over exposition and intuition. If it only happened on mathematical papers... It is all over the place, in books, classes, etc. Few professors tell you what are they doing and why; they just throw formulas, theorems and symbols at you. Intuition is not given its necessary importance, first because it's hard to grasp some concepts, and second because sometimes there's no easy intution behind them unless you have deeper knowledge in the subject. Regarding "unit tests", or descriptive names... That's very difficult once you get into advanced math. Examples are probably going to be trivial or too contrived to be useful. And if you have to give a name to a theorem or lemma, you'll end up describing its full contents.
- rjzzleep 11y agoIn Germany you get to your advanced courses for the last two years of High school. I picked Math and Physics. We did a bunch of linear regression(with maple?) i believe. And some manual differential equations. I was one of the best in that class, but when I asked what we need this stuff for the other people in the class looked at me and said the following: "if you ask this question you're in the wrong class" I went on to study engineering, and i guarantee you the other two still don't know what that stuff is good for. They learned the formulas by heart and then went on with their lives. I mean it was fun for me, it was basically a coding exercise. And I was happy because I was faster than everyone else, but I didn't get why we were doing it. The same actually bothered my about the studies. Just one example: folding is a fairly easy concept. But for some reason they first want to drill it into your head, you learn a bunch of techniques and then if you're lucky and you stick with it, eventually it clicks and you'll realize why in a completely unrelated class. Why can't we just provide a simple real life example first and then go on explaining the details? Aren't things easier to grasp when you can have a real understanding/connection to it? Isn't that precisely why people that learn coding at home tend to be better than those that just studied it, because they were told it's a solid profession to study? I think with a good example and visual representation you can probably teach most of the stuff that's taught in Uni to young kids. But then you would be forced to admit that you wasted a lot of time during your own life, who'd want to admit such a thing.
- brachi 11y ago> Why can't we just provide a simple real life example first and then go on explaining the details? This. People learn differently, in my case, if I can't get the 'Why' first, I'm not that excited to learn it. I guess making 'simple' real life examples in many cases is hard. I also tend to learn things much better if they came from a real problem/need I have. There was a good discussion about a 'project based university' here: https://news.ycombinator.com/item?id=10989341 https://news.ycombinator.com/item?id=10989341
- joslin01 11y agoI actually think you're in the norm. The "why" helps create a belief; a belief is something that ignites action. Without it, someone's belief as to why they should learn [X] is too often defined as "to get a good grade."
- WalterBright 11y ago> never mind five years! Some bits of the DMD compiler back end go back 32, 33 years!
- vinceguidry 11y agoI started taking readability very seriously once I started going back to extend old code and finding I couldn't immediately understand what it was doing. Now, if I have that problem, it's now two problems. The original problem, and the readability problem. The readability problem is solved first, and the original problem can only be solved afterward. I don't see comments helping me, I could spend the time better by making better method names, better local variable names, extracting methods, ensuring that lines do not run off of the screen. Maintaining my old code got significantly easier after I started doing this.
- cname 11y ago> I don't see comments helping me... I don't know why people say this type of thing, as if there's some choice you have to make between good names and comments. You can have both, and there are absolutely times when comments are necessary. Too many comments may be a "smell", but code that doesn't require any comments at all is very unlikely.
- vinceguidry 11y ago> there are absolutely times when comments are necessary. I'll have to take your word for it, because I've yet to run into that situation.
- work-on-828 11y agoI find that sometimes I am diving into a codebase and wish I had a higher-level map of where things are.
- javajosh 11y agoA good marker for when comments are going to be useful is when something stumps you, and then you fix it and/or figure it out. Chances are, when you read the code again it will stump you again - or on re-reading you might not even realize there was an issue. So I comment the change. It's usually something simple like, "This cast avoids a special case in method X", or along those lines. The comment is the "why" where the code is the "what".
- ridgeguy 11y agoNot just code. When you design anything - a rocket engine, an immunoassay product, whatever - it should be part of the work to document the assumptions, calculations, and rationale for the design to a degree that somebody skilled in the art could follow your work when you're gone.
- quietplatypus 11y agoAnd a lot of it comes from trying to sound smart instead of readable. Sorry, but if I was this guy's advisor, I'd keep his ass in school until he took away his pretentious "it is obvious from ___ that"'s. Ph. D education just isn't what it used to be.
- argonaut 11y agoMathematics papers (dissertations included) are meant for active researchers. Perhaps that implication really is obvious to an active researcher in the field. The fact that it is not obvious to someone outside of its intended audience is not a mark against the paper. If I said to someone in machine learning that by assuming zero-mean Gaussian priors for the coefficients, we are encouraging small values of the coefficients, that would be really really obvious to someone in ML/stats/data science (I've restated a really basic statistical learning concept), but not to a random educated person.
- EGreg 11y agoI am curious, how would you assess the readability of my code: http://github.com/EGreg/Platform http://github.com/EGreg/Platform I kind of developed that style organically as I went along, in both PHP and JS. I tried to make the output readable as well. I've seen many frameworks output a bunch of gibberish, but with today's bandwidth it's not such a big deal to add a little bit of whitespace and make everything readable. Here's a fairly complex application, you can view the source of any page: http://qbixstaging.com/Groups/ http://qbixstaging.com/Groups/
- akamaozu 11y agoThere's a bunch of directories where you keep the PHP and JS files in the same directory, like this one: https://github.com/EGreg/Platform/tree/master/platform/plugins/Awards/classes/Awards https://github.com/EGreg/Platform/tree/master/platform/plugi... Any special rationale behind that approach?
- Domenic_S 11y agoI can give you some feedback since I tend to write a lot of PHP. Mostly, code style is about consistency. You can have infinite arguments about whether opening braces should go on the same line as the operator/function, but at the end of the day as long as you stay consistent it doesn't really matter. Here are some consistency issues I found. Your function declarations put the opening brace on the following line, but flow controls open on the same lines. Ex: https://github.com/EGreg/Platform/blob/master/platform/plugins/Metrics/classes/Metrics.php#L115-L117 https://github.com/EGreg/Platform/blob/master/platform/plugi... In the same vein, commenting seems inconsistent - this file's docblock opens with /* */ style comments, but then you switch to // style. Ex: https://github.com/EGreg/Platform/blob/master/platform/Q.php#L24-L26 https://github.com/EGreg/Platform/blob/master/platform/Q.php... Further down, you use two styles of if(), one with braces and one without, right next to each other: https://github.com/EGreg/Platform/blob/master/platform/Q.php#L71-L77 https://github.com/EGreg/Platform/blob/master/platform/Q.php... I much prefer 2 space indents to tabs. To me, it's much more readable. I noticed your HTML output is also tabbed, which (arguably) needlessly increases the horizontal width you need to see a page of code, especially with modern deeply-nested structures. Overall the project looks well thought out, and you may have valid reasons for any/all of the above. Just throwing in my initial reactions as a project outsider. Also, dunno if you know about PSR, but here it's a good starting point that many people (potential contributors) are familiar with: http://www.php-fig.org/psr/psr-2/ http://www.php-fig.org/psr/psr-2/
- johnhattan 11y agoOh that's good to hear. I was getting a distinct "Flowers For Algernon" vibe from the title :)
- rebootthesystem 11y agoThe one thing that has always bugged me about lots (most?) open source software is the almost total lack of comments. I consider that bad programming. I have projects dating back 15 years in both FPGA's and software that I've had to go back into and maintain or borrow from. Comments, for me, has always been part and parcel of code writing. I sort of have a conversation with myself as I document code where I tell myself why something needs to be done and, if necessary, how. As a result of this anyone can go into my code for any project at any time and find their way around. In fact, they don't even have to be domain experts to understand domain-specific code because I often take the time to document such thing pretending I am just learning about it (to a point).
- alistproducer2 11y agoI'm recently picked up an Angular-like JavaScript framework I built from scratch after about 9 months (working on it now actually) so I know exactly what you're talking about. Over the years, I've stopped and started about 3 pretty major personal projects and through that I progressively got better at writing and documenting code in a way that make it easy to pick back up after a long break.
- wfo 11y agoIt would be really nice if all it took to understand difficult mathematics were some easy programming tricks. The problem with looking at old code is you forget what is going on or what the purpose of different components are. The problem with looking at old mathematics is that it is genuinely very difficult to understand. You work very hard to be an expert in a field and get to a level where you can read a cutting-edge research paper. Then if you let that knowledge atrophy, you won't be able to understand it without a lot of re-learning when you look at it again. Unfortunately cute tricks like comments and concrete examples won't save you here (if concrete examples even exist -- oftentimes their constructions are so convoluted the abstract theorem is far easier to understand, and often times they are misleading. The theorem covers all cases, but all of the easily understandable concrete examples are completely trivial and don't require the theorem at all.) Programming has existed for, say, 50-100 years. We have recorded mathematical history going back thousands, with contributions from most of the most brilliant human beings to ever exist. Do you think perhaps there's a reason why a simple and easy trick like commenting and renaming lemmas has been discovered and solidified as standard practice in programming, but hasn't been adopted in mathematics? Are mathematicians really just SO dumb? The answer is those tricks just aren't good enough. Mathematicians do exposition. They do plenty of explaining. Any textbook and even many research papers spend a huge amount of time explaining what is going on as clearly as is possible. As it turns out the explanation helps, but the material is just plain hard.
- akie 11y ago> Do you think perhaps there's a reason why a simple and easy trick like commenting and renaming lemmas has been discovered and solidified as standard practice in programming, but hasn't been adopted in mathematics? Are mathematicians really just SO dumb? No, they aren't, but the example in question would have been easier to understand if he had tried to explain what was going on, instead of just saying "it is trivial that this or that follows". I think the comparison with "old code syndrome" is pretty much spot on, to be honest.
- conceit 11y ago... especially if code is to be considered in the terms of information theory. Context is important and context can't be encoded without raising the entropy. Also, speech and to a large degree mathematical symbolism are sequential, so multi dimensional problems would have to be broken down into one sequential dimension, raising the entropy exponentially or whatever or loosing information. Can't help it.
- wbl 11y agoThat doesn't help. Arthur has written a very nice hundred page introduction to the trace formula. You can read that, and it won't tell you why you should care about the trace formula. But if you know Langlands-Tunnels and how it was proven, or how Jacquet-Langlands was proven, you already know to care about the trace formula because you know that it will prove similar results. The abstraction is necessary: you cannot do algebraic geometry with varieties alone. But while the core of the subject is a multithousand page jewel of abstraction, Vakil is a perfectly readable, example filled introduction to algebraic geometry, covering most of the contents of the glory that is EGA. Only the rare lemmas are intrinsically interesting. Most often it's the theorems that are worth knowing as steps on the path to understanding something much more. Those lemmas that get used again and again are named, often descriptively.
- ignoramous 11y agoCompletely agree. "Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?" -Brian W. Kernighan I read a book by Brian Kernighan a few years back, "The Elements of Programming Style" and for me it has so much good advice. The book may not be as relevant in the days of Ruby, C99 and the like, but valuable advice nevertheless. I wonder if reading the literature (countless books written by the early adopters and renowned engineers) would mould the programmers to do things differently. For instance, reading "JavaScript: The Good Parts" completely changed the perspective with which I look at the language. It made me fall in love with it.
- stevenhuang 11y agoI've just started playing around with JavaScript and I'm definitely gonna check this book out now, thanks.
- blablabla123 11y agoIronically my professor advices me during my thesis not to add all of my source code to the appendix. Yay, let's make things not reproducible :D
- skywhopper 11y agoI think you missed the point of the article, which was that students, parents, standards-setters, educational theorists, and legislators have a distorted idea about what education is for and why certain subjects are taught. We don't teach history so that children can recite the years in which various battles happened. We don't teach algebra in order that everyone in society knows how to factor a simple polynomial. The author can no longer understand his dissertation, but that doesn't mean he failed, or that the educational system failed by granting him a PhD for the work. Rather, the dissertation was about proving to the system and himself that he had learned how to tackle a complex problem and generate a solution that would pass muster with his academic mentors. In the process he learned many skills indirectly, became a more effective problem-solver in general, and had fun, all of which are far more valuable and far more important than the topic of his dissertation and whether or not he still understands it.
- DyslexicAtheist 11y ago>> of a fairly new developer who's just been asked to do non-trivial update of his own code for the first time fairly new has nothing to do with it. I'm struggling to read my own code since 1998 and constantly in battle with myself to strategically place comments at the right places. I doubt that I'll ever correctly estimate my own ability to comprehend my sh1t no matter how many years of experience I have. In fact it seems to have gotten worse with experience. The more I know the less I can trust myself. Not sure if I'm alone with that.
- foobarge 11y agoI've been writing code professionally for 25 years. You're not alone. It does get worse. Junior programmers just don't get it and jump into management before they have a chance to.
- nilkn 11y agoI've brought up this issue in mathematical circles before and have encountered incredible resistance. The culture is very deeply entrenched, and the current stakeholders are not going to allow it to be changed. Just to briefly establish that I have some qualifications here, while I do not have a PhD and am not nor have I ever been a professional mathematician, I did have a lot of success in mathematics as an undergraduate, publishing research in the intersection of algebraic topology, differential geometry, and analysis with a professor at an Ivy League university. I was myself a practitioner of the school of It Is Clear That..., until I realized that my mentor for the above research, a famed professor and former Putnam Fellow who even has inequalities named after himself, didn't follow some of the stuff I'd written in some notes I showed him. And if he didn't follow it, then I knew that meant I probably didn't understand it as well as I thought I did. It wasn't a big surprise to me then that, after a few weeks of effort, I was completely unable to take my approach further. His approach, of course, worked. He represents one of few mathematicians I've personally known who emphasized clarity just as much as correctness and technical depth, and he had no desire to appear smart. But at this point in time he already had his career mostly behind him. There was nobody left for him to impress. Part of the problem, ultimately, is that phrases like "it is trivial that..." do serve a purpose when used appropriately. As a result, it's hard to argue that they should categorically be excluded from mathematical writing. But that then opens them up to abuse, and in a culture so obsessed with appearing smart, that abuse can be quite extreme sometimes. Because instances of abuse are often motivated out of appearing smart rather than legitimate economical concerns of space, bringing up the issue with the author amounts to a moral accusation against them, which makes their defense of the phrases even more impassioned. They're not going to admit that they're just trying to puff up their ego. The worst part is that, in some circles, if you criticize this sort of writing you'll just be greeted by a bunch of people who are proud to exclaim that, of course, they are smart enough to fill in the blanks, and if only you were too then you surely couldn't possibly still have any objections to it. For me, transitioning from mathematics to software development was a huge breath of fresh air, as the culture is (generally) the exact opposite. Nearly every good programmer I've met has valued clarity and maintainability equally alongside correctness.