Live data from Hacker News

Professor solves 240 computer science exam problems in 4 hours [video]

youtube.com

171–173 of 173 posts

Re: Professor solves 240 computer science exam problems in 4 hours [video]

#171
post #123

Earlier quoted context omitted.

Here's an embedded system. It has a hardware resource. There's only one such hardware resource. A singleton to manage it is a natural. I suppose you could argue that it's still a global variable, but I think it's more fundamental than that. You use a singleton when there should be exactly one of something. Why is there exactly one? "Because there's only one in the hardware" is a fundamentally different answer than "b…

A singleton only seems natural to you because you are used to using them. Other programmers might reach for a global variable or a static variable for the same purpose in the same situation. The tradeoffs are pretty subtle. However, as I said, the main reason that I have seen singletons used is programmers who heard lectures about how bad global variables are, heard about global variables, and didn't understand that…

Not entirely true, because a singleton can implement defensive logic and maintain coordination state that is difficult with a global variable. For something like a unique hardware resource a singleton that administrates the resource can do things like enforce queueing on components that want to communicate with the hardware resource, and make decisions about which components to notify when the resource responds.

Re: Professor solves 240 computer science exam problems in 4 hours [video]

#172
post #123

Earlier quoted context omitted.

A singleton only seems natural to you because you are used to using them. Other programmers might reach for a global variable or a static variable for the same purpose in the same situation. The tradeoffs are pretty subtle. However, as I said, the main reason that I have seen singletons used is programmers who heard lectures about how bad global variables are, heard about global variables, and didn't understand that…

Not entirely true, because a singleton can implement defensive logic and maintain coordination state that is difficult with a global variable. For something like a unique hardware resource a singleton that administrates the resource can do things like enforce queueing on components that want to communicate with the hardware resource, and make decisions about which components to notify when the resource responds.

I said subtle, not non-existent.

For example you tout the advantages of enforced access rules. And indeed enforcement is good for avoiding bugs from accidental concurrent access. But said enforcement also means that bugs in releasing access at the proper time are harder to recover from. I've seen systems fail both ways, and it is unclear to me which one is better. (For example I've had more problems with Windows enforcing locking in its filesystem than with bugs in Unix's advisory only locking policy.)

Re: Professor solves 240 computer science exam problems in 4 hours [video]

#173
post #93

Earlier quoted context omitted.

I use CS theory all the time in my professional career. Automata, was the most useful class I took (the 2nd most useful was Programming Language Concepts).

I don't dispute at all that theoretical CS is practically useful, I love it myself and think it offers amazing tools for thought. But my hunch is (and I'm emphasizing that I'm speculating here) that only people who like the material end up retaining enough to see the applications. I feel like some of my fellow students, including ones that I felt were smart (but who were application-oriented learners who have trouble…

That's the thing, it is useful, so I don't blame companies for wanting people who know CS theory.

And when I hire people, even though I hate doing adversarial whiteboard coding, I will probe to find out if people understand a bit of theory.

You can get a lot of work done without theoretical knowledge, (but the end result is often not as good, and it usually takes longer). Combine that with the fact that CS theory is hard, and you get a lot of people complaining about how theoretical CS is useless outside of academia.

It's basically an extension of "no one needs to know math beyond arithmetic in the real world".

Post reply on HN