Live data from Hacker News

Is abstraction overrated in programming? Chess, interviews and OOP

quora.com

11–20 of 149 posts

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#11

I have no idea what abstraction actually is. It seems to me it's never abstraction unless it leads to complicated designs for the simplest problems. I've been accused of hating abstraction because I wrote in C instead and programmed out my own concepts -- instead of just using a ready-made framework with ill-fitting ones (Qt in that case). A much better term than abstraction to me is "semantic compression" (got that…

IMO, the key issue is to differentiate between abstractions in language-space and abstractions in problem-space. Turning a chess board into an object is language-space, since it affects vocabulary; writing a function to count the pawns is problem-space, since it defines a step towards the problem one wants to solve.

Nobody programs without problem-space abstractions any more; this is effectively what you get with functions and libraries. When someone uses a prebuilt tangent function, that's working in problem-space.

Language-space abstractions don't pull the same weight. If they did, Haskell programmers would be so much higher productivity than C programmers that the latter would be simply competed out of the market. Instead we see marginal benefits against marginal costs, and the gamut of C, C++, Go, Haskell, Python, Javascript, etc. are, if not equally good, at least sufficiently similar that there is genuine debate.

If in doubt, abstract the problem. If you do an abstraction and don't have less work to do afterwards, maybe you've abstracted the wrong thing.

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#12
The class-based solution provides more information about the developer's approach than the single struct for the BitBoard.

For example, where would the equivalent of "findMoves" be declared in the latter case? Is the bitmath abstracted out into a set of helpers, or is it done in one big function?

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#14

I have no idea what abstraction actually is. It seems to me it's never abstraction unless it leads to complicated designs for the simplest problems. I've been accused of hating abstraction because I wrote in C instead and programmed out my own concepts -- instead of just using a ready-made framework with ill-fitting ones (Qt in that case). A much better term than abstraction to me is "semantic compression" (got that…

what about just calling it "slang"?

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#15
post #13

The OP has translated the interviewers question of "design a readable and maintainable abstraction for a chessboard" into "design the most space-optimized chessboard possible", then wonders why the interviewer doesn't like his solution.

Or maybe the OP understood that everyone who has ever implemented a chessboard are also building chess engines where memory efficiency and speed actually matter a lot.

It's the interviewers who are ignorant here, they took a real problem and translated it badly into a toy problem. Then they failed to realize what they did.

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#17
post #13

The OP has translated the interviewers question of "design a readable and maintainable abstraction for a chessboard" into "design the most space-optimized chessboard possible", then wonders why the interviewer doesn't like his solution.

The OP specifically addressed your objection. Write some helper functions if you're worried about maintainability.

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#18

I have no idea what abstraction actually is. It seems to me it's never abstraction unless it leads to complicated designs for the simplest problems. I've been accused of hating abstraction because I wrote in C instead and programmed out my own concepts -- instead of just using a ready-made framework with ill-fitting ones (Qt in that case). A much better term than abstraction to me is "semantic compression" (got that…

Well, I think the lack of a definition for what is meant by abstract or abstraction is critical. For example there is some discussion of an abstract base class but the article keeps missing that in Object Oriented Programming the term abstract class exists. It describes an 'incomplete' class which cannot be used to instantiate objects but can be used to hold common behavior.

http://www.javacoffeebreak.com/faq/faq0084.html

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#19
in case anyone was curious how a bitboard chess engine works, I wrote one from scratch in python and included a writeup describing my general approach (mostly focused on the move generation aspect):

https://github.com/cglouch/snakefish

(I cheated a little by not implementing castling / en-passant since it's a pain, and my engine is still really slow, but hey it works!)

Re: Is abstraction overrated in programming? Chess, interviews and OOP

#20
post #13

The OP has translated the interviewers question of "design a readable and maintainable abstraction for a chessboard" into "design the most space-optimized chessboard possible", then wonders why the interviewer doesn't like his solution.

That is entirely subjective. I am more comfortable reasoning with bits than with object.

I also think optimization matters, if you can reduce the memory consumption with a simple and elegant solution, why not ?

Post reply on HN