Live data from Hacker News

FizzleFade

fabiensanglard.net

151–160 of 182 posts

Re: FizzleFade

#151
post #68

Earlier quoted context omitted.

Why? I mean if you look at the majority of work that programmers do today - frontend/backend web development and apps, there is no need to have knowledge about bits. In fact, if I see someone using binary operators in languages such as Java,JS,Ruby etc... I'll immediately consider it bad code, regardless of context - it's just not the right tool for the level of abstraction in these languages. The fact is that in the…

> In fact, if I see someone using binary operators in languages such as Java,JS,Ruby etc... I'll immediately consider it bad code, regardless of context - it's just not the right tool for the level of abstraction in these languages. Clojure is written in java (and clojure). It uses bit operations to implement Software Transactional Memory and persistent collections. Is it a bad code? You seem to think a programmer sh…

> It uses bit operations to implement Software Transactional Memory and persistent collections. Is it a bad code?

I don't know anything about clojure, but it sounds like you're clobbering in the suggestion that because bitwise operations are bad in high level business code, they must also be bad in low level language implemention code. At best you're not paying attention, at worst that's an intellectually dishonest counter argument.

Re: FizzleFade

#152

Earlier quoted context omitted.

So many simple things are only easy if you know bits. Interpreting a packet capture, poking at memory, designing cache friendly data structures, ... It is like second nature to me. If it isn't required (obviously it isn't, it must at least be a strong competitive advantage). I am not that old. I don't have get off my lawn moments. I grew up (really learned at least) on a processor (P133) where bits started mattering…

Never needed to interpret a packet, I intercept communications at the 7th layer to troubleshoot things - namely http connections. I don't poke at memory, I use a profiler that tells me what every piece of code and variables I use take in memory. I don't design cache friendly data structures, I use redis. I would wager that my experience is closer to the development situation and needs of the majority of programmers.…

These are good points. At some point architecture and systems like Redis will become the only tools that can reliably implement these behaviors if no one ever learns about bits. Similar to how hard it can be to outperform compilers in many areas when writing assembly by hand.

Then again there are programming disciplines where you have to know all of this and more. It ultimately comes back to those capable of implementing the tools/frameworks/compilers and those that just use them. Safe crypto libraries are impossible without bit wrangling.

I will still argue that having these skills has at times saved order of magnitudes of time for me. Maybe it wasn't worth all the effort I spent if it only saves time once in a while. Then again I haven't been a full time developer in like 11 years, now I break other peoples software for a living and bang bits together on a weekly basis :)

Re: FizzleFade

#153

Earlier quoted context omitted.

What are some good resources to learn about bits?

There are some quite good pages, I don't remember the exact titles, but the first results are quite ok: https://www.google.de/search?q=bit%20hacks

You can write mostly C code. Each processor will have different quirks.

https://en.wikipedia.org/wiki/CPU_cache

https://www.akkadia.org/drepper/cpumemory.pdf

These are great places to start.

Especially Ulrich Drepper's PDF on memory.

edit: even simple things like looping can require knowledge of "bits" and "memory layout" and "CPU cache" to write the fastest code. Most people don't need to write the fastest code though.

Re: FizzleFade

#155
post #34
post #18

Earlier quoted context omitted.

OP said "a lot of", not all. Which is probably true, because you needed to know it in the past, and now you don't. Chill out.

> You needed to know it in the past, and now you don't Well, that's not a very interesting statement by itself, though? We used to need to know how to use clubs back when we lived in caves, but I don't see myself practicing with one any time in the near future :)

Yes, I don't know why you seem to think I would disagree.

A lot of people needed to know how to ride a horse back in the day to get from place to place. Now, in the west, you may just learn to ride a horse for pleasure and nothing else. It doesn't mean you should take offense to someone stating that fact though. Really, one just comes off as insecure when doing that.

Re: FizzleFade

#156
post #100

i am interested to know the particulars of any routines people have for reading and reviewing a codebase, as the author talks about doing in his spare time. do you take notes? add comments? step through with a debugger?

Given you are a seasoned programmer, most of the code written in familiar language should be obvious just by skimming it. But when it comes to a short and "smart" algorithms, especially including bit manipulations, I still find pen&paper the best tool to find out what's really happening.

Pencil/pen, paper, flow charts, and in some cases one of those TI scientific calculators can come in real handy.

This being said, I've never gone much away from C/C++/Pascal/Assembly/COBOL/FORTRAN and various forms of BASIC where what I mentioned helps immensely (I work on legacy systems in my spare time, CS isn't my primary field), although Python, Haskell, Rust and GO have piqued my curiosity.

Re: FizzleFade

#158
post #68

Earlier quoted context omitted.

> In fact, if I see someone using binary operators in languages such as Java,JS,Ruby etc... I'll immediately consider it bad code, regardless of context - it's just not the right tool for the level of abstraction in these languages. Clojure is written in java (and clojure). It uses bit operations to implement Software Transactional Memory and persistent collections. Is it a bad code? You seem to think a programmer sh…

I don't know enough about Clojure, but I think you are saying that Clojure itself is using bit operations behind the hood - of course it's ok for a language implementation to use bit operations. But if any of your Java code for applications or libraries used bit operations, I'll call it bad code.

Conway's Game of Life can be implemented naively in C/C++/Java/etc, using a boolean for every cell's state (on/off). This will require at least n*m bytes (probably more in Java). Using bits to store that data will require 8 times less, which will most likely greatly increase the performance because of the data locality and the amount of data that will fit into a CPU cache.

Re: FizzleFade

#159

Earlier quoted context omitted.

I don't know enough about Clojure, but I think you are saying that Clojure itself is using bit operations behind the hood - of course it's ok for a language implementation to use bit operations. But if any of your Java code for applications or libraries used bit operations, I'll call it bad code.

Conway's Game of Life can be implemented naively in C/C++/Java/etc, using a boolean for every cell's state (on/off). This will require at least n*m bytes (probably more in Java). Using bits to store that data will require 8 times less, which will most likely greatly increase the performance because of the data locality and the amount of data that will fit into a CPU cache.

Conway's game of life is at best school homework, it does not correlate to any programming done in a real job.

Re: FizzleFade

#160
post #68

Earlier quoted context omitted.

> In fact, if I see someone using binary operators in languages such as Java,JS,Ruby etc... I'll immediately consider it bad code, regardless of context - it's just not the right tool for the level of abstraction in these languages. Clojure is written in java (and clojure). It uses bit operations to implement Software Transactional Memory and persistent collections. Is it a bad code? You seem to think a programmer sh…

I don't know enough about Clojure, but I think you are saying that Clojure itself is using bit operations behind the hood - of course it's ok for a language implementation to use bit operations. But if any of your Java code for applications or libraries used bit operations, I'll call it bad code.

But clojure is a java application, and its libraries (written in java) are also java libraries, you can use them from java (and some people do).

There's nothing wrong with writing your own library implemented using bit operations.

Post reply on HN