Live data from Hacker News

I no longer understand my PhD dissertation

medium.com

131–140 of 281 posts

Re: I no longer understand my PhD dissertation

#131

Earlier quoted context omitted.

I've recently taken a calculus problem (multidimensional real optimization) I guess for the first time since I was an student. While your description has some merit, there's a huge amount of trivia in the format of "I can do X, I just have to do Y first", "X has no known solution, try something else", and "operation X is very useful, try it". That goes away, and everything gets way harder.

I've always felt that if I had done all of my calculus with Mathematica I would have left college with an excellent grasp on how to use higher level functions provided by Mathematica that would have largely abstracted away all of this. Of course, the higher level functions might get covered in cobwebs - but I suspect not the same way; I would have kept these higher level skills up to date because: - I recently went t…

That's roughly what I did, and it worked out about as well you predict. As soon as I understood what was going on with some kind of math, I'd use whatever tools I had to automate it: calculators at first, then computer algebra systems, numpy, whatever. No regrets; it was a great time-saver with very few drawbacks, and I made good educational use of the time it freed up.

Re: I no longer understand my PhD dissertation

#132
post #108

Earlier quoted context omitted.

> 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.

Comments are not for how or what, the code does that just fine. Comments are for why . Sometimes the why is obvious, then you don't need a comment. The rest of the time, add that comment. Even if it's something like "Steve in accounting asked me to put this in."

Good comments do frequently answer the why question and, sometimes, the non-obvious what.

It's generally true that the code expresses the what, but it's also true that it can take the reader time to discern. A simple comment here and there can be a shortcut to this discernment which, over thousands of lines of code can save serious time.

Re: I no longer understand my PhD dissertation

#133
post #91

Earlier quoted context omitted.

I 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 m…

I'm fixing someone else’s code right now and a few single line comments would have saved my client thousands of dollars. Today I put in a log statement to see why the code deletes data from the database if there is no new temperature data for the time period. The cron job has been running all day and so far every time it attempts to delete the data, there is no data to delete. Another line runs a different script if…

I'll go one better: I've got servers in my machine room that I don't know the purpose of. Literally in some cases the way I've found out what they do is shut them off and wait for someone to complain.

Re: I no longer understand my PhD dissertation

#134
post #91

Earlier quoted context omitted.

I 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 m…

I'm fixing someone else’s code right now and a few single line comments would have saved my client thousands of dollars. Today I put in a log statement to see why the code deletes data from the database if there is no new temperature data for the time period. The cron job has been running all day and so far every time it attempts to delete the data, there is no data to delete. Another line runs a different script if…

[deleted]

Re: I no longer understand my PhD dissertation

#135
post #64

Earlier quoted context omitted.

> 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 univers…

Yeah, teaching the basics of an abstract concept without first explaining how it fits into the bigger picture is IMO not the best way to motivate some people. I'm also a person who wants to understand why it's important instead of just trusting someone that it'll be useful "later". It'd be cool if, once you start your major, there was basically an overview class explaining why each of your courses is important and wh…

I took an automata class where the professor talked into the chalkboard and refused to explain why we were required to learn any of the material. It wasn't until later in the compilers course that we had a teacher who actually took the time to explain how all that mysterious theory actually had a place in the real world. So many light bulbs went off in my head during that class.

Re: I no longer understand my PhD dissertation

#136
> Mathematics is an excellent proxy for problem-solving

In my experience, earning a PhD in [redacted] was excellent training in problem solving. And in developing working expertise in new areas. I suspect that the choice of field is indeed irrelevant.

> Mathematics embeds character in students

I'd say that actually finishing a PhD does that.

> Mathematics is fun

Whatever you pick for your dissertation topic had better be fun ;)

Re: I no longer understand my PhD dissertation

#137
post #86

Earlier quoted context omitted.

Comments are incredibly useful for that bit of code that you spent hours trying to make it work and you couldn't figure out a way to name things well or to improve it. That's where a comment is priceless.

The downside of course is that comments aren't compiled/run - so they often become out of date. "Often" might actually be an understatement. I can't tell you how many times I've been reading a comment that runs quite contrary to what the code really does. You then end up reading the code to reason about it anyway, paying two taxes. After too many of those experiences, you just end up going straight to the code as the…

Names for classes, methods, parameters, and variables all suffer from this same problem. I think the solution to align code and comments is code reviews. Not writing comments also works but fails to solve related issues.

Re: I no longer understand my PhD dissertation

#138
post #86

Earlier quoted context omitted.

Comments are incredibly useful for that bit of code that you spent hours trying to make it work and you couldn't figure out a way to name things well or to improve it. That's where a comment is priceless.

Maybe it's because I write in Ruby, and so never have to do any tricky optimizing, but if solving a particular problem starts to run over a half hour, I look to re-architect the project, either by reaching for a gem or telling my boss that X is too hard and we should do Y instead. My patience for going down rabbit holes has mostly gone over the last year. Also, again perhaps because I use Ruby, it never takes me more…

I don't see how Ruby saves you from optimising (to my limited knowledge, it's not exactly a fast language), but I agree with you that naming stuff sensibly and extracting functions (which you can then name sensibly) is most important for maintainability and can make "in-code" comments unnecessary in many cases. However I strive to always document what a function does if its not obvious -- though I'd call that "documentation" and not "comment".

Example for obvious: Int add(Int x, Int y) in a typed language. Example for not obvious: add(x, y) in an untyped (or "dynamically typed") language (Does it auto-coerce? How? Can it add complex numbers? In my particular representation? ...).

Someone mentioned that sometimes comments are useful e.g. to document a quirk/bug in library function you call, and I have some examples of that in my own code. But most often you should be able to rectify that by wrapping said function in your own one that omits the problem.

If a function seems impossible to give it a sensible name that isn't ridiculously long, split it up. The more clear code of the individual parts and how they are combined should give a hint of what is actually computed here. Maybe it's a new concept in your business logic, in which case providing a clear and exact definition makes sense anyway (put it into the appropriate place in your documentation). This whole procedure can take a significant amount of time, but it will be worth it in maintainance!

Re: I no longer understand my PhD dissertation

#139

Earlier quoted context omitted.

> 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.

1) Vector3 computeNewtonianGravity(float massA, Vector3 positionA, float massB, Vector3 positionB); Which way does the returned force vector point? Towards mass A, or towards mass B? 2) Vector3 UnitVectorWithDirection(Vector3 originalVector); What does this function do when the magnitude (length) of originalVector is zero? 3) float ArcTan(float x); What is the allowable range of values for x? ...

The sibling comment about renaming is good - particularly with regard to the first function. However I think the other two are better suited to documentation rather than trying to make the function signature explain itself. Sooner or later you'll just remember that it takes a float, not the variable name.

Certainly calling things like "x_returnsNaNIfNot0to1" works, but I find it a bit ugly and it gets complicated if you have multiple or more complex constraints.

This is where languages with docstrings are nice. In Python all I would do is add a """ comment describing the inputs and the return values.

You then have a) a comment describing the code; and b) documentation that's standard so people can pull it up with pydoc or ? in Ipython. When I'm working in Jupyter, I often hit shift-tab to check what a function is expecting.

Post reply on HN