Live data from Hacker News

Poll: How many programmers don't know about bit-wise operations?

news.ycombinator.com

51–60 of 82 posts

Re: Poll: How many programmers don't know about bit-wise operations?

#51

Hackers Delight! http://www.amazon.com/Hackers-Delight-Edition-Henry-Warren/d...

Interesting book but wow $50, never seen anything so expensive, even used copies are over $25 ?

Discovered my library allows me read it for free online:

http://proquestcombo.safaribooksonline.com/9780133084993

Others can at least see the table of contents.

Re: Poll: How many programmers don't know about bit-wise operations?

#52
I guess programming languages don't really encourage using bit wise operations.

On top of it, it doesn't have many advantages. It takes much less memory, but takes more lines to write, while on the hardware, it's the opposite: more memory, not so fast processors.

What always bugged me, is that there are no real programming facilities to take advantages of bits, like encoding many variable in on 32 bit integer variable.

I guess

Re: Poll: How many programmers don't know about bit-wise operations?

#53
In the videogame industry the standard question on the phone screen interviews is what is the two power 8. It's eerie how many people cannot answer this at all or answer incorrectly.

So, if even the people who are aspiring to write "code to the metal" console games don't know binary then, I imagine, a generic programmer knows it even less.

Re: Poll: How many programmers don't know about bit-wise operations?

#54
post #50

Earlier quoted context omitted.

yes, but we don't care. A language is agnostic of the underlying system. Even the C standard is built on top of a machine that doesn't really exist. Anyhow, the point is, limitations of the underlying system aren't excuses for why this syntax isn't implemented. If I can write bitmasks, then so can a compiler, right?

There are tons of useful features that aren't supported in C. The basic feature set of C was determined by whatever operations Dennis Ritchie could easily implement on the PDP-11 when he created the earliest C compilers. (Fun fact: the bitwise operators even preceded the Boolean operators like && and ||.) If the question is "why isn't bit indexing supported" then "because processors didn't (and don't) support it" is…

arianvanp had the point of my question correct.

Re: Poll: How many programmers don't know about bit-wise operations?

#56
post #10

I use them a lot when I'm designing hardware, but I never use them when I'm doing "regular programming", there's no reason to do it if I can use more readable, higher level constructs.

When writing network protocols or de-marshalling binary data it's common to want to know which bits are set in a byte. You might do a & 4 == 4 to test the 3rd bit is set, how would you do this with 'regular programming'?

I'm guessing that writing networking protocols and even de-marshaling binary data doesn't fall under "regular programming". The vast majority of programming is business programming and marshalling and de-marshalling data is relatively troublesome (Ruby anyone?). Most of these projects are better off using a library than implementing their own.

Re: Poll: How many programmers don't know about bit-wise operations?

#57
I know them especially since I took digital electronics in university. However, I've never had to use them so far in anything I've built. I could use them if required but unless I get into some kind of video processing or high end optimization, I don't think it'll be required.

Re: Poll: How many programmers don't know about bit-wise operations?

#58

I come from full time 8/16 bit assembly (Z80 and later 68000) so I tend to use those naturally. Very powerful and fun; it's a shame most universities don't teach the basics; it saves a lot of CPU cycles.

The basics don't save CPU cycles, every decent C compiler knows that for unsigned x, x*4 == x << 2.

Re: Poll: How many programmers don't know about bit-wise operations?

#59
This question isn't exactly clear either. What constitutes "knowing" bit-wise operations? Can I do bit-wise math? Test if a bit is set? Use shift operators for some arcane purpose?

As I get older (lets just say I'm over 35), I'm baffled by older programmers who worry about this stuff. When you were a young programmer, there were likely problems that were solved that you never had to deal with that older programmers feel were super important. Bitwise operations likely stick around for the duration of digital computing, but I think it's foolhardy to think that the vast majority of developers will need to know about them in all their gory detail.

New developers will stand on the shoulders of giants so to speak, and solve the problems that are pertinent to their domain. It may or may not include bit-wise operations.

Post reply on HN