Slashdot Mirror


Hacker's Delight

Ben Olmstead writes with the review below of Henry S. Warren's Hacker's Delight, which is not about tricking folks into providing sensitive information, but rather about how to cleverly manipulate computers into doing more work on their part with less work on yours. Read on for his brief review. Hacker's Delight author Henry S. Warren Jr. pages 320 publisher Addison Wesley Professional rating Excellent reviewer Ben Olmstead ISBN 0201914654 summary Collected Tips & Tricks for Programmers

Hacker's Delight is an impressive compendium of clever tricks for programmers. Warren concentrates on micro-optimizations -- few of the tricks in this book operate on more than 3 or 4 words of memory -- and he displays an impressive knowledge of diverse computer systems in the process.

Who Should Read This Book

Hacker's Delight is hardcore in its presentation and subject matter. I would not recommend this for a beginning programmer -- to fully understand the material requires at least some knowledge of concepts such as Assembly and Machine languages. However, anyone who writes performance-critical software should read this book, even if they do not plan to write Assembly code, both to learn the tricks given, and to learn the concepts behind them.

What's Good

The book is organized into chapters where Warren presents related tricks. In each chapter, he presents a few tricks which perform related tasks -- for example, in Chapter 3, he presents tricks for rounding (up or down) to the next power of 2, rounding to a multiple of a known power of 2, and detecting power-of-2 boundary crossings (i.e., checking for page faults). For each trick, he discusses why it works, whether the technique is generally applicable, related tricks which might be better in specific situations, and where a trick might be used in the real world.

Warren keeps his discussion architecture-neutral, while noting optimizations and problems for specific architectures for specific tricks -- in the process, he displays a vast array of knowledge about specific processors, from 1960's mainframes to x86, MIPS, PPC, Alpha, and others. He also skims the surface of hardware-design issues in a few places -- for example, he devotes a page or two to explaining why computers use base 2 for arithmetic, and why this is the most efficient choice.

What's Bad

This is an extremely dense book, and there are sections which are difficult to understand. Furthermore, there are many tricks which, while interesting, would be difficult to apply to real-world applications, and use of these tricks does violate the Keep It Simple, Clock Cycles Are Cheap And Someone May Have To Understand Your Code philosophy which is harped upon so heavily (not without reason) in modern software design. However, someone writing a compiler or high-performance code may feel that the benefit outweighs the potential risk.

The Summary

If you want a better understanding of the hardware on which your code runs, or you need to squeeze clock cycles, or you just enjoy seeing clever tricks, this is an excellent book. If you primarily use high-level languages such as VB, perl, python, etc., this may not be the right book for you. Be prepared for very dense material.

You can purchase Hacker's Delight from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

178 comments

  1. Sounds like an interesting read... by Gortbusters.org · · Score: 5, Funny

    Almost as interesting as those lovely discrete math textbooks were. This sounds more like 'Optimizer's Delight.'

    To be honest, 'Hacker's Delight' sounded more like a cookbook title.

    --
    --------
    Free your mind.
    1. Re:Sounds like an interesting read... by swordboy · · Score: 1, Funny

      It also sounds like an interesting song:

      I said a hip hop the hippie the hippie
      to the hip hip hop, a you dont stop
      the hack it to the bang bang boogie say up jumped the boogie to the rhythm of the boogie, the beat

      --

      Life is the leading cause of death in America.
    2. Re:Sounds like an interesting read... by Alcohol+Fueled · · Score: 1
      "To be honest, 'Hacker's Delight' sounded more like a cookbook title."

      It'll only be a cookbook title if the hacker's doing something to tweak an AMD processor, and manages to deep fry something in the computer. :)

      --
      Ah am not a crook! (\(-__-)/)
    3. Re:Sounds like an interesting read... by Bob+McCown · · Score: 1
      To be honest, 'Hacker's Delight' sounded more like a cookbook title.

      By Jeffrey Dahmer?

    4. Re:Sounds like an interesting read... by iloveprotoss · · Score: 2, Informative
      Much of the basic material in this book was formerly published in 1996 under the more mundane title of:
      The PowerPC Compiler Writer's Guide
      ISBN 0-9649654-0-2
      edited by Steve Hoxey, Faraydon Karim, Bill Hay and Hank Warren.

      That book obviously had no qualms about targeting a narrow audience and it served its purpose well.

      When Sun was awarded patent #6,073,150 it had a familiar ring. Sure enough: figure 3-25 on page 50 of "PowerPC Compiler Writer's Guide". Only the patent was awarded in 2000 and the Guide was published in 1996. That was about where I lost respect for the patent process.

  2. omg by Anonymous Coward · · Score: 1, Funny


    i said a hip hop a hippie the hippie
    to the hip hip hop, a you dont stop
    a rock to the bang bang boogy say upchuck the boogy,
    to the rhythm of the boogity beat.

    now what you hear is not a test, i'm hacking to the motherfuckin beat
    and me, rob malda, and the rest are gonna try and move your feet
    see i am timothy and i'd like to say hello
    to the ACs, freaks, and logged-in kooks, and all the goatse trolls
    but first i gotta bang bang the boogie to the boogie
    say up jump the boogie to the bang bang boogie
    let's rock, you dont stop
    rock the rhythm that will make your body rock
    well so far youve heard my voice but i brought two friends along
    and next on the mike's my man hemos
    come on, hem, sing that song

    1. Re:omg by FireballFreddy · · Score: 2, Funny

      Don't worry bud, I agree with you. That's funny shit. :) I'll stand by your side. Bring it on, you mod-punks with no sense of humor!

      You know, the post was offtopic but funny... shouldn't that average out to "Neutral +0"?

      -FF

      --
      SQUEAK, the Death of Rats explained.
    2. Re:omg by Gordonjcp · · Score: 1

      Possibly, but I prefer replies to karma.

    3. Re:omg by zapfie · · Score: 1

      Nono, you're supposed to call me a smartass now. ;)

      --
      slashdot!=valid HTML
    4. Re:omg by Wakko+Warner · · Score: 1

      If I'd posted it as myself it'd probably be at +5 by now. But I thought it was too lame to bother with... I actually was trying to post it fast enough for it to be first, so I didn't spend much time on it.

      - A.P.

      --
      "Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
    5. Re:omg by dracocat · · Score: 1

      Bring it on. I'll blow some Karma here.. This looks fun.

  3. Dubious value? by SuperMario666 · · Score: 5, Insightful

    Furthermore, there are many tricks which, while interesting, would be difficult to apply to real-world applications.

    Maybe you should break open the old CS textbook instead. IMO, learning general principles would be a much better use of your time.

    1. Re:Dubious value? by KDan · · Score: 5, Insightful

      Seriously depends what you're doing. If you're writing the next entreprise application, sure, optimization tricks are not really your main concern... If you're writing a game engine, though...

      I remember back when I was younger and had much more free time (*longing sigh*) I spent most of a term and a summer writing a 3D wolfenstein-like engine, mostly under the careful instruction of a book: Tricks of the game programming gurus. The book was great, and though it gave some optimizing ideas here and there the resulting engine was very slow (esp. compared to the wolf3d engine, which was so perfectly smooth... and the engine I made didn't even do monsters and doors and items). So then I turned to another book I had, called "PC Interdit", which was written in french and oriented towards Pascal rather than C which I was using, but explained a number of optimization tricks which made all the difference (examples: page flipping in mode X instead of double-buffering in mode 13h, basics of coding fast assembler functions to optimize C functions, etc). Before using that book's advice, my engine would run at something like 10 fps or so on my 486DX4 100Mhz in turbo mode, and 1fps more or less without turbo mode... After the optimizations, it ran very smoothly in turbo mode and at least 5-6fps in non-turbo.

      So if you're programming a game engine, those books are really really useful. Or in fact if you're programming anything where squeezing every tiny bit of performance is critical. If you're programming a J2EE servlet engine, though, then for sure, it's a waste of your time.

      Daniel

      --
      Carpe Diem
    2. Re:Dubious value? by First_In_Hell · · Score: 0, Offtopic
      Well said. I noticed that hackers/virus authors make horrible IT personel in the workplace. All they have learned is from fooling around, and there is no strong foundation in place.

      My company hired this guy who said he had a lot of computer expierence. He confessed to me that he had written viruses and hacked into other people's computers in his spare time. Suffice to say, the guy was a complete tool. He could not program for sh*t, and was constantly bothering me to give him work. I gave him nothing because;

      I did not trust him

      He had no foundation, everything he did was a kludge.

      Also there is no real-world application for hacking. Anyone who says that deserves to be butt-raped in jail.

    3. Re:Dubious value? by KDan · · Score: 1

      Not everyone writes entreprise applications where performance doesn't matter that much. If you were programming games (well, at least back a few years ago) you'd have found that you had to do everything you have to do now, but better and all at the same time in real time. That's when you need the kind of person who can "kludge" it and somehow miraculously get it to work fast without everyone fully understand how exactly he did that.

      Not that this means that the particular guy you hired was any good.

      Daniel

      --
      Carpe Diem
    4. Re:Dubious value? by Anonymous Coward · · Score: 0

      Also there is no real-world application for hacking.

      Also you have no clue what in the hell you are talking about and you are an asshat to boot!

      Please FOAD sir!!!

    5. Re:Dubious value? by HR · · Score: 1

      Sorry man but did you even read that review? The book has nothing to do with cracking or virus writing, making the whole rant about your poor employee, well, beside the point.

      I agree that without a good foundation, you're not likely to produce good code. However, it sounds to me that you can't even get the most benefit from the book in question without having such a foundation. That is, you can use the book like a cookbook but you probably won't understand why the recipe works. Disclaimer: I have not read the book, only this review. As many others have pointed out, if you're working on something which must be highly optimized, or are working on an optimizer, such a book can help you squeeze that bit of extra performance out of your code. Nothing wrong with that.

    6. Re:Dubious value? by leshert · · Score: 1

      You're using the wrong sense of hacker. Most security hackers won't have much use for the tricks in this book, either.

      The hacker referenced in the book's title is this one.

      Also there is no real-world application for hacking. Anyone who says that deserves to be butt-raped in jail.

      Tell that to anyone who's ever worked on a tiger team (or opfor, in military terms).

    7. Re:Dubious value? by hughk · · Score: 1
      Not really. I worked on several "Enterprise" applications whereby shaving time off algorithms was vital to the competitiveness of the application. Graphics tricks are somewhat more specialised, but look inside a real flight simulator, and you will see how the programmers try to get everything to work as fast as possible (they work at the limits of the hardware).

      The real problem for commercial users is that this level of optimisation is dirty, i.e., difficult to test and maintain. However, it is usually only need for a very small percentage of the application.

      --
      See my journal, I write things there
    8. Re:Dubious value? by onepoint · · Score: 1

      Ahh it's good to see the old great habit's still alive. I had a c-64 and would rewrite part's of Ea's graphic routines to increase the spead of them. then I would work on cool stuff for the c-64.

      To the outside viewer, code optimizing is most likely to be viewed as magic than anything else. Very few people I know could reduce code on the 6502 like myself. And those few I met back then ( 1983 (84 maybe ) onwards were highly gifted and they made optimizing code seem like magic.

      Onepoint

      --
      if you see me, smile and say hello.
    9. Re:Dubious value? by darxyde · · Score: 0

      If you're programming a J2EE servlet engine, though, then for sure, it's a waste of your time.

      Its good to see there are still old school coders out there, I often reminisce of my days with TASM, the torn and coffee-stained copy of 'PC Programmers Guide to Low Level Functions and Interrupts', and 'The Big Red Book that won't fit on a shelf' (now in retirement)... but things have changed.

      Unless you are writing the latest and greatest compiler (recently wrote one which will interface Java/corba over parellel port to pre-486 relics to steal some processor power for nasty threads... my 100 hour optimisations weren't worth it, Java is still as slow as shite ;) ) there isn't much use.

      People have had to learn to live with bloated code and OS's (thanks Mr Gates for your valued contribution!). The course I did at University doesn't even teach assembly as a core requisite anymore. Guess my point is, developers don't seem to mind churning out chunky kludge, coding isn't academic anymore and to most people its just a job (that they do rather poorly), it's easier to market the product with higher hardware specs, yes?

      anyway, might be interesting, but the guy is living in the past if he thinks he will make some green with this title.

      --
      Hey relax fella, you need a rest, guy.
  4. The author.. by J+x · · Score: 5, Informative

    I know the author well. Here's some background for you slashdotters who may doubt his expertise:

    Henry S. Warren, Jr., has had a forty-year career with IBM, spanning from the IBM 704 to the PowerPC. He has worked on various military command and control systems and on the SETL project under Jack Schwartz at New York University. Since 1973 he has been with IBM's Research Division, focusing on compilers and computer architectures. Hank currently works on the Blue Gene petaflop computer project. He received his Ph.D. in computer science from the Courant Institute at New York University.

    1. Re:The author.. by Anonymous Coward · · Score: 0, Interesting

      Where did you copy'n'paste this information from? Have your heard of plagiarism? You shouldn't try to pass that paragraph as your own. People like make me sick, it just encourages entities like Disney to lobby for their extensions of their copyrights because people LIKE YOU, will abuse it.

      Get a clue.

    2. Re:The author.. by derch · · Score: 2, Flamebait

      Dude, you ripped that background from the BN site.

      If you really know him, write up your own background.

    3. Re:The author.. by theDEFT · · Score: 0

      but he can't beat me in quake, coming at me with that weak shiznit, i'll have to put the smack down and 0wn3rz dat @55!

    4. Re:The author.. by Gailin · · Score: 1

      If you are meaning Barnes & Noble descriptions, then I'm confused as to what exactly the reviewer plagiarized.
      G

      --
      I wish there was a fscking blue pill
    5. Re:The author.. by jwinter1 · · Score: 1

      Scroll down to Accreditation.

      --
      Anything you can do, I can do meta.
    6. Re:The author.. by FCP · · Score: 1

      Get a grip.

      That's fair use if I ever saw it. Besides, that
      piece of text is probably from the author's
      resume, passed along to the publisher for the
      dust cover bio, and copied by B&N for the website.

      Probably only the first transfer in that chain
      was even marginally interesting from a copyright
      law standpoint.

      But I agree with derch, it's ironic to say you
      "know" Hank S. Warren, and then copy his bio
      verbatim. At least add something we don't know:
      he wears ugly bowties/cheats at chess/designs
      almost-perpetual-motion machines ...

      --
      .plan: file not found
  5. Hacker delight.... by Jethro+On+Deathrow · · Score: 4, Funny

    ...is the exact oposite of afternoon delight, I would imagine.

    1. Re:Hacker delight.... by Lt+Razak · · Score: 2, Funny

      True. When you see a hacker at work at 7 a.m., it's not because he came in early. It's because he hasn't left work yet.

    2. Re:Hacker delight.... by Anonymous Coward · · Score: 0

      Um, what exactly is an "afternoon delight"?

    3. Re:Hacker delight.... by Jethro+On+Deathrow · · Score: 1

      Exactly... thanks for proving my point.

      (sex)

  6. Sugar Hill Gang, anyone? by dasmegabyte · · Score: 5, Funny

    I said a hip, hop, hippy, hippy to the hip hop hacking you don't stop a hacking until the bang bin boogie said backslash the boogie to the rhythm of the boogity beat..

    What you hear is not a test, I'm hacking to the beat. And me, the compiler, and my code are gonna start to move your screen.

    See, I am das MB and I'd like to say hello
    To the linux loners and the mac fairys and the losers on windows.

    But first I gotta..bang slash bin slash P E R L said hack kernel yes hack hack the kernel until the whole machine runs like hell.

    Proper.

    --
    Hey freaks: now you're ju
    1. Re:Sugar Hill Gang, anyone? by dasmegabyte · · Score: 0, Offtopic

      Offtopic? I think not. You can't review a book called "Hacker's Delight" and not have somebody do a bad parody of "Rapper's Delight." It's a given.

      But I suppose I can't expect your average slashdot moderator to understand the great works of old school hip hop.

      --
      Hey freaks: now you're ju
    2. Re:Sugar Hill Gang, anyone? by incripshin · · Score: 1
      From dasmegabyte:
      Offtopic? I think not. You can't review a book called "Hacker's Delight" and not have somebody do a bad parody of "Rapper's Delight." It's a given.

      But I suppose I can't expect your average slashdot moderator to understand the great works of old school hip hop.

      Yeah! and I thought it was pretty good ... but then they up and made your post offtopic as well. That doesn't make any sense either. These moderators are relentless ... or maybe it's just one moderator who just can't stand to see anything about that song. Damn them youngsters with their foul-mouthed rap music! Why back in my day...

    3. Re:Sugar Hill Gang, anyone? by Anonymous Coward · · Score: 0

      a million bucks says these relentless downmods are being done by one particular nazi slashdot editor, michael. he has no problem abusing his moderation privileges in order to get himself off.

    4. Re:Sugar Hill Gang, anyone? by sdcharle · · Score: 1

      For real, I was gonna go for the obvious goof on Rapper's Delight myself but saw it had been done, pretty well too, I dug it.

    5. Re:Sugar Hill Gang, anyone? by Anonymous Coward · · Score: 0

      Oh ... ooo .. mmm another -1. Oh! Oh! o00000 ...

      eww!

      hey another one ... -1

      oh! oh!

    6. Re:Sugar Hill Gang, anyone? by Anonymous Coward · · Score: 0

      damn, you beat me to the punch. Funny as hell though

    7. Re:Sugar Hill Gang, anyone? by Pseudonym · · Score: 1
      Damn them youngsters with their foul-mouthed rap music! Why back in my day...

      The ironic thing is the same moderator probably listens to Las Ketchup.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    8. Re:Sugar Hill Gang, anyone? by solferino · · Score: 1
      love the reference

      know it's not in th spirit of rapping (to revise) but how 'bout a slight change to make a better rhyme in the second line

      What you hear is not a test, I'm hacking to the beat. And me, the compiler, and my code are gonna give your cpu some heat
    9. Re:Sugar Hill Gang, anyone? by dasmegabyte · · Score: 1

      Wack.

      --
      Hey freaks: now you're ju
  7. Refreshingly different for the CS bookshelves by Anonymous Coward · · Score: 1, Insightful

    This is a great book for those looking to expand thier minds beyond the usual low-level-phobic computer science pulp. I do not employ any of the book's teqniques in my code, but I'm glad to know of them.

  8. Sounds cool by photon317 · · Score: 3, Interesting


    Sounds like he knows his stuff. The world needs more asm-aware programmers. High level languages and all the trickery that is "keep the source simple, waste the abundant cycles" and all are important things. The problem IMHO is that these are techniques to be applied by a fully-fledged programmer, who is capable of doing it the hard way in C or even asm - but too many modern programmers have only ever know the world of OO languages. The Leaky Abstractions paper applies here too.

    --
    11*43+456^2
    1. Re:Sounds cool by johnnyb · · Score: 2, Interesting

      You should check out the book I'm writing - Programming from the Ground Up - http://savannah.nongnu.org/projects/pgubook/

  9. If you like this idea.. by stevey · · Score: 5, Informative

    If you like this topic you may well appreciate this Assembly Language Gems Page

    It's a little biased towards x86 assembly, but there are some neat tricks there, and some stunningly lovely code.

  10. Recommended by Anonymous Coward · · Score: 3, Informative

    I got this a couple of months ago and found it rather good -- If you are looking to shave a couple of cycles off you implementation of integer logarithms then have a look at it. I'd agree with the reviewer that it is rather dense, and you'll need to be numerate (graduate maths or C/S) to understand the algorithms, but not to find it useful. There are also quite a few amusing anecdotes from the author's time at IBM. Worth the cover price.

    Jim Green

  11. Base 2 by micromoog · · Score: 1
    ...he devotes a page or two to explaining why computers use base 2 for arithmetic, and why this is the most efficient choice.

    Why is that? I always figgered it had something to do with it being easier/cheaper to build hardware that only needs to store and detect 2 states (on/off) than multiple intermediate states.

    1. Re:Base 2 by KDan · · Score: 5, Informative

      Well, I remember when I was reading a book about assembler they expressed it beautifully by saying that if school taught kids binary numbers instead of the decimal system, the entire mathematics syllabus could be taught in a couple of months with time to spare.

      Binary maths make many integer operations ridiculously simple, and while the fact that it's cheaper and more feasible to detect 2 states than 10 is true, there's also a certain simplicity that you can get to by coding everything with binary logical gates which wouldn't quite be there if you used some sort of decimal logical gates...

      Basically, binary arithmetic is really simple so can be optimized really well and is much more universal, in the wider philosophical sense, than decimal arithmetic. Everything in the universe seems to revolve around a binary concept, rather than a decimal one... matter/antimatter, existence/non-existence, quantum spin states, etc.

      Daniel

      --
      Carpe Diem
    2. Re:Base 2 by Anonymous Coward · · Score: 0

      Jesus fucking christ... what a load of bullshit...

    3. Re:Base 2 by Grab · · Score: 1

      Simple answer is that states are represented by voltage ranges. If a voltage is in one range, the state is TRUE. If it's in another range, it's FALSE.

      The neat thing with that is that it can only be TRUE or FALSE. There may be an indeterminate state in the middle which is neither, but at that point the receiving chip will hold the current state until the input voltage goes to TRUE or FALSE.

      Now consider that you have three states. Say one state is 0-1V, another state is 2-3V and the third is 4-5V. It's impossible to go from the first state to the third state without passing through the second state. So how does your receiving chip know whether you really wanted the second state, or whether you're just en route to the third state? Simple answer is that it can't, so you'd need to have some requirement like staying in a state for some length of time before the state's confirmed. This would be a complete pain in the arse, so no-one ever tried doing this.

      There's also a compatibility issue. Electronics derived from relay logic, and relays can only be on or off, so there was a bunch of legacy material already on Boolean logic.

      Grab.

    4. Re:Base 2 by Bob(TM) · · Score: 1

      Basically, binary arithmetic is really simple so can be optimized really well and is much more universal, in the wider philosophical sense, than decimal arithmetic. Everything in the universe seems to revolve around a binary concept, rather than a decimal one... matter/antimatter, existence/non-existence, quantum spin states, etc.

      You know, there are two types of people in the world ...

      --

      The little guy just ain't getting it, is he?
    5. Re:Base 2 by Anonymous Coward · · Score: 0
      ...he devotes a page or two to explaining why computers use base 2 for arithmetic, and why this is the most efficient choice.

      It is faster to drive a transistor into cutoff or saturation. In addition to the reasons listed by others.

      Base 2 is faster for addition and subtraction, not so good for multiplication and division (except for specials like powers of 2). Base 3 is faster for multiplication and division but really horrid for addition and subtraction. As far as I know, the USSR built the only trinary computer.

    6. Re:Base 2 by Anonymous Coward · · Score: 0

      Oh Lord you are on crack. Binary math isn't easier or harder than any other kind. It's all the same damn thing. Multiplying numbers is multiplying numbers, no matter how you represent them.

    7. Re:Base 2 by Anonymous Coward · · Score: 0

      try roman numerals then, you obnoxious troll

    8. Re:Base 2 by low-k · · Score: 1

      Actually, it doesn't matter that much whether you can get from the `zero' state to the `two' state with or without going through the `one' state first. Even in current processors, interference (inductive coupling), ground bounce, and other effects may cause what should be a `zero' to bounce up into the voltage range that would make it a `one'. That's one reason why the processor uses a clock. It doesn't matter what states the signal goes through so long as it has settled down to the correct voltage by the time the clock ticks and you sample the voltage (well, less the setup time of the latch...).

      As mentioned by a comment a few posts down, they used to use base ten in machines (BCD = binary coded decimal), where each base-10 digit was encoded with a 4-bit binary value. Besides the increased complexity of base-10 arithmetic circuits, since each digit uses four bits, there's 6 possible states that aren't utilized. So for example, with two BCD digits, you can represent from 0-99 in BCD, but if you used those same eight bits in binary, you could represent 0-255. I think that's what people may be talking about when they say binary is more "efficient" than BCD. Otherwise from an information theoretic perspective, I don't think one unit is any better than the other (it would be like saying using "kilograms" is more efficient than "grams" or "milligrams" or even "slugs").

  12. Definition of "Hacker" by RT+Alec · · Score: 4, Insightful

    I am pleased to see the correct use of the term "hacker". Now if we could just work on the folks at CNN...

    1. Re:Definition of "Hacker" by Q+Who · · Score: 1

      I am pleased to see the correct use of the term "hacker". Now if we could just work on the folks at CNN...

      Use defines language.

      Get over it.

    2. Re:Definition of "Hacker" by Anonymous Coward · · Score: 0

      And if we don't like how it's being used, what's wrong with trying to change it?

      Most people who misuse the word "hacker" do so merely out of ignorance. If you tell them the right meaning, many will use it.

      People say "literally" when they mean "figuratively", but you can bet your ass I call them on it. You can't just start arbitrarily swapping meanings of words or nobody will be able to communicate.

      "Can you define 'sex' your honor?"
      -- Bill Clinton

    3. Re:Definition of "Hacker" by Anonymous Coward · · Score: 0

      Wow! You sound like quite the fucking douchebag!
      plsfxkthxbye!

    4. Re:Definition of "Hacker" by Anonymous Coward · · Score: 0

      I hear ya buddy. I've also discovered that many people also arbitrarily swap "obsolete" and "redundant", thinking "redundant" is a symonym for "obsolete" rather than "surplus".

    5. Re:Definition of "Hacker" by Anonymous Coward · · Score: 0

      Really? I find just the opposite. You must be one of those dirty hackers.

  13. Definitions, Titles, and Categorization by _Sprocket_ · · Score: 4, Interesting

    I noticed this book at the local Barnes and Noble. Unfortuately, it was (and still is) mis-catagorized and firmly stuck in the "Security" area of the technical / computer section.

    Now I know that I'm toying with the usual hacker/cracker jihad. None the less, it seems the definition of "hacker" associated with secuirty is so engrained in to society that it manages to overcome even the content of the book itself. I would have thought the B&N folks, being in the book profession, would manage to catch this. Judging a book by its cover and all that (makes me wonder where a book called 'Pinky Fuzzy Bunnies' that studies furry erotica would land).

    Of course, B&N are not the definitive measure of language. Where they stick a book doesn't go much beyond acknowledging one use of our much-flamed word. It doesn't negate the history of the word nor offer final proof of its popular definition. But it does show the power of that popular definition despite the obvious intent of the book's author.

    Be it for good or not - there it is.

    1. Re:Definitions, Titles, and Categorization by Anonymous Coward · · Score: 0

      It seems to me that most book stores don't actually consult any domain experts when they classify computer books. At all the local bookstores in my area, they place all coputer books dealing with "Bioinformatics" in the computer security section.

      No one ever bothered to find the destinction between "Bioinformatics" and "Biometrics". It's ridiculous.

  14. Efficiency != Portability (or overall goodness) by shoppa · · Score: 3, Insightful
    This sort of subject has been around for years, and gets rediscovered every so often, by a "new" generation of hackers. (Look, for instance, at the big deal made about Duff's Device when C came along.) The problem is, that implementations of these ideas are often non-portable. (To other architectures, languages, or even the next version of the compiler.)

    That's not to say that I don't enjoy reading about these clever things; there is a lot to be learned by studying this stuff. But implementing them is usually a mistake these days, if for no other reason than because there's already a portable way to do it which is probably more efficient. To go back to the Duff's Device example, almost all compilers will implement loop unrolling already. And that's a C-language trick, supposedly already a high-level language. Note I said supposedly! :-)

    1. Re:Efficiency != Portability (or overall goodness) by Anonymous Coward · · Score: 0

      Bah. If you know anything about principles of Comp Programming, you can have it both ways.

      Factor out and encapsulate your "trick", so that if you want portability or longevity, all you have to do is re-code the half-a-screenful of code that is the "trick". While the 95% of your code that executes 1% of the time remains perfectly maintainable.

    2. Re:Efficiency != Portability (or overall goodness) by raytracer · · Score: 1

      This sort of subject has been around for years, and gets rediscovered every so often, by a "new" generation of hackers. (Look, for instance, at the big deal made about Duff's Device [tuxedo.org] when C came along.) The problem is, that implementations of these ideas are often non-portable. (To other architectures, languages, or even the next version of the compiler.)

      I'm not sure why you mentioned Duff's device. Duff's device is portable. If I had an ANSI C spec in front of me, I could quote you chapter and verse that explicitly allows it.

      I think it is a damn spiffy idiom. It is relatively obvious what it means (at least after you've seen it once) and why you would use it. Yes, modern C compilers may do loop unrolling, so it is probably not something that is worth expending a lot of time on. As Tom Duff told me:

      I did it once. I haven't done it since. I don't recommend you do it.

      I too believe that code can be too clever, but increasingly I see code written with very little regard to either space or time behavior. Gratuitously inefficient code should not be tolerated, and understanding idioms like Duff's device puts one in a mindset of where such inefficiences are revealed more often.

    3. Re:Efficiency != Portability (or overall goodness) by jejones · · Score: 1

      Duff's Device had its reason for being, but Duff is right; don't do it now. Can you say "irreducible flow graph"? Sure, I knew you could. Modern compilers will get themselves out of the pickle Duff's Device and analogous code schemata put them in, if they do at all, by replicating code, thus undoing one of the things people think clever about it.

  15. Be Wary by OldStash · · Score: 4, Funny

    manipulate computers into doing more work on their part with less work on yours

    To paraphrase the great Terry Pratchet: "Beware labour saving devices which are smaller than their manuals".

  16. It's digital. by Anonymous Coward · · Score: 0

    You douche, the switch is either on or off. It's not a dimmer switch!

    But in your case, maybe it is a dimmer switch.

    1. Re:It's digital. by micromoog · · Score: 1

      By "it's digital" I assume you mean "it's binary". Which is the whole point. Binary hardware is cheaper/easier to build than other options ("dimmer switches" as it were).

  17. My computer won't work hard enough by Toe,+The · · Score: 2, Funny
    I tried all kinds of tricks to get my computer to work harder. And whaddya know, one night it patched its speech software into the modem and called the union on me.

    Ingrate! If it weren't for me, it'd be running gene sequences all day and night. Computers have no sense of perspective.

  18. the most important thing by pummer · · Score: 1, Funny

    will it teach me how to hack Windows ME??? It's so hard -- I can't figure it out!

    1. Re:the most important thing by Anonymous Coward · · Score: 0

      how does lame humor make this a troll???????? read this journal

  19. Lesson learned by Anonymous Coward · · Score: 0

    There's an important lesson here: Don't leave your computer on overnight.

  20. oh please by tps12 · · Score: 2, Interesting

    For 99% of people, these kinds of unreadable but "neat" optimizations are going to have no impact on execution time whatsoever. Good algorithm design and efficient architecture -- and yes, optimization, once you've profiled and located a bottleneck -- are worth far more than stupid bit shifting tricks, and your code will actually end up maintainable. If you follow the advice in this book, you're liable to produce code that looks like the Linux kernel.

    --

    Karma: Good (despite my invention of the Karma: sig)
    1. Re:oh please by Pseudonym · · Score: 2, Insightful
      For 99% of people, these kinds of unreadable but "neat" optimizations are going to have no impact on execution time whatsoever.

      So? Most technical books are useless for 99% of people. I personally have no use for The Black Art of C# in 21 Days For Idiots. For my part, I used to write compilers. This book would have been invaluable for me. I guess I was in the 1%.

      The only danger in this kind of book is that people will use the techniques in it blindly, in which case they arguably shouldn't be writing software anyway (or at the very least should have it thorougly reviewed before committing).

      If you follow the advice in this book, you're liable to produce code that looks like the Linux kernel.

      So if you have to produce code like the Linux kernel, it sounds like the book for you.

      Incidentally, the Linux kernel is that way for several reasons, some of which are valid (e.g. profiling or back-of-the-envelope calculations showed that something was going to be a bottleneck) and some of which made sense at the time. For an example fo the latter, see do_pipe() in fs/pipe.c. If starting the kernel again today, it would make a lot more sense to use C++ which would make all those gotos unnecessary, but it's a bit late now.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    2. Re:oh please by Anonymous Coward · · Score: 0

      The problem is that the book is being marketed, and reviewed, as a book for "hackers," that is, anyone who programs. Young people, of which there are hundreds on this site, get the impression that to be a "hacker," you need to write weird, bit-fiddly code that's impossible to understand, much less maintain a few months down the line. This is the stuff that kills many projects before they even get started, and can doom Open Source projects as soon as the original maintainer loses interest.

      Oh, also, YHBT about Linux, which is actually a great example of keeping a large system readable and maintainable.

      -tps12

    3. Re:oh please by Pseudonym · · Score: 1
      The problem is that the book is being marketed, and reviewed, as a book for "hackers," that is, anyone who programs. Young people, of which there are hundreds on this site, get the impression that to be a "hacker," you need to write weird, bit-fiddly code that's impossible to understand, much less maintain a few months down the line.

      You clearly have a different definition of "hacker" than I do. "Anyone who programs" is not even close.

      I could equally argue that Knuth's The Art of Computer Programming is marketed to "programmers" which gives people the mistaken impression that to be a "programmer" you need to be able to implement a Patricia trie or solve nonlinear recurrences by hand. These are useful skills, but then so is the ability to write weird, bit-fiddly code.

      Oh, also, YHBT about Linux, which is actually a great example of keeping a large system readable and maintainable.

      You clearly have a different definition of "readable" than I do.

      You do have a point on the "maintainable" aspect, but that's only because there are a small number of people who understand Linux well and are willing to review patches thoroughly before accepting them. It's got little to do with any inherent clarity in the code and everything to do with the process.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    4. Re:oh please by Anonymous Coward · · Score: 0

      Knuth is far more important than these simple tricks. TAOCP is about algorithmic efficiency, not intricacies of C or x86 instructions or anything else. Absorbing Knuth will make you a better programmer, period. Absorbing this tripe may make you a wanker with some flashy tricks.

      As for Linux, it strikes me as pretty clear. I don't think of myself as incredibly bright, but I managed to understand how the scheduler, the memory management (the last one; haven't checked out the current one yet), and filesystems work. It's better than the dinosaur book (though it's a good companion), and better than the BSD source, I can tell you that.

  21. Efficiency of base 2 arithmetic by The+Variable+Man · · Score: 1
    explaining why computers use base 2 for arithmetic, and why this is the most efficient choice

    I always thought that ternary computers were theoretically more efficient, from a mathmatical point of view.

  22. Behold mere programmer, I give you 'left shift' by Anonymous Coward · · Score: 0

    Chapter 3, he presents tricks for rounding (up or down) to the next power of 2, rounding to a multiple of a known power of 2, and detecting power-of-2 boundary crossings

    Since when has the C operator been advanced programming techniques ?

  23. Commodore 8-bit by MagerValp · · Score: 0, Troll
    As I mainly write C for my C= machines (C64, C128, and Plus/4), would this book be of any use to me or is it mainly aimed at larger platforms? So far I've just been looking at the generated assembly code.

    cc65 is an ANSI C compiler for 6502 machines. It's sweet.

    --

    READY.
    #
    1. Re:Commodore 8-bit by FuzzyBad-Mofo · · Score: 1

      Whoever modded this as a troll should be slapped. It is a legitimate question.

  24. Hard to understand? by cperciva · · Score: 5, Interesting
    use of these tricks does violate the Keep It Simple, Clock Cycles Are Cheap And Someone May Have To Understand Your Code philosophy

    In some cases, this may be true, but not always. If you want to increment a multiple-precision value, the textbook method is
    int i, carry=1;
    for(i=0;icarry+=x[i];
    x[i]=carry;
    carr y/=radix;
    };
    while the "cute trick" method is
    int i=0;
    while(++x[i]==0) i++;

    The textbook method takes a while to recognize, just because it's very similar to many other loops; but the second is distinctive and can be recognized immediately. If I'm maintaining someon else's code, I'd much prefer to see the second.
    1. Re:Hard to understand? by Anonymous Coward · · Score: 0

      This is great if you're a dickhead who thinks that leaving out all whitespace and putting everything on one line is better code - hooray, yuo R a real hax0r!

      Try formatting so it is easy for others to read. Then if someone is maintaining your code they won't complain about you over lunch.

    2. Re:Hard to understand? by Anonymous Coward · · Score: 0

      Try formatting so it is easy for others to read.

      Easier said than done, on slashdot.

    3. Re:Hard to understand? by stratjakt · · Score: 3, Insightful

      Many times the 'tricks' method is less readable, and nothing more.

      A good compiler will recognize produce the same optimized byte code for different code blocks. It should unroll shorter fixed lenth loops and automatically inline function calls when it determines that it's not worth the overhead of popping the caller onto the stack.

      In the end it's the design as a whole that will determine efficiency. For instance, recursion. As soon as it's learned, a coder has a tendency to use the 'cute trick' of recursion everywhere, and doesn't realize that it's rarely the optimal solution to a problem.

      Personally, I loathe the 'cute-ass cryptic trick' coding philosophy. I constantly battle with all the bad habits I picked up having been born and raised on the Commodore 64. Unconditional branches (goto), cramming all the code you can onto one line, one or two letter variable names, functions longer than a chapter of the bible. Blech.

      --
      I don't need no instructions to know how to rock!!!!
    4. Re:Hard to understand? by miu · · Score: 2, Interesting
      But those distinctive shortcuts that everyone recognizes can cause you to "label" the code and move on while reviewing code that is due for maintenance.

      Everyone recognizes what:

      while (*dst++ = *src++) ;
      is supposed to be doing, but I recently cleared a mystery bug in a very old routine that used such code. The problem had been missed for years because people "recognized" the code and moved on - despite the fact that there were several problems with it.
      --

      [Set Cain on fire and steal his lute.]
    5. Re:Hard to understand? by Anonymous Coward · · Score: 0

      if its harder to recognize, there should be a quick comment. tricks are good/bad because they might be hard to *understand*

    6. Re:Hard to understand? by Anonymous Coward · · Score: 0

      Compilers can't do everything -- although they are pretty good! Have you never thought that the compiler writer uses the very same optimization techniques that you loathe? There will always be specialized applications for which the compiler's generated code will not be optimum. These techniques come in handy for those times -- unless, of course, you have your very own compiler writers on hand to create compilers which generate code tailored to your specific application domain.

  25. Redundant and proud of it by Chocolate+Teapot · · Score: 2, Interesting
    In principal, I like the sound of this book. However, I have a shelf full of so-called 'secrets of the masters' books, each weighing in at around half a ton, containing 800 pages all stating the obvious. I look forward to hearing comments from those who have actually bought the thing.
    If you want a better understanding of the hardware on which your code runs, or you need to squeeze clock cycles, or you just enjoy seeing clever tricks, this is an excellent book. If you primarily use high-level languages such as VB, perl, python, etc., this may not be the right book for you.
    Time for me to state the obvious... I have worked on many applications that run uneccessarily slowly as a result of an accumulation of inefficient code. Sure, it is often better to sacrifice raw performance for portability, maintainabilty and plain readability, but code does not need to be obcure to be efficient. Optimisers take much of the hard work out of achieving this, but taking the time to examine compiler output once in a while will help you write high-level code in such a way as to give the optimiser room to strut it's stuff. If anything, there is often more to be gained by programs written in high-level languages (VB, perl, python, etc) if the coder takes time to examine the structure of his code and attempts to eliminate bottlenecks. Inefficiency is not a function of the development tools, it's a function of laziness.
    --
    Modest doubt is called the beacon of the wise. - William Shakespeare
  26. Hacker's Delight? by Tofino · · Score: 0, Redundant

    I said a hick, hack, the hacker, the hacker To the hick hick hack, a you don't stop! The hack it to the bang bang hacker say up hacked the hacker The the ryhthm of the hacker, the hack! Old school!

    1. Re:Hacker's Delight? by Anonymous Coward · · Score: 0

      I said uh, U-nix, Lin-ux, Mac O-S X!
      And if you do it right it feels almost as good as sex!

  27. Whoa! by mschoolbus · · Score: 2, Funny

    3313 bytes in body

    I almost thought that was 31337 or something!

  28. Hackers Delight? by dr_dank · · Score: 0, Redundant

    What you hear is not a test, I'm hacking to the beat.

    --
    Where does the school board find them and why do they keep sending them to ME?
  29. And all this time by MrScience · · Score: 1

    I thought that hacking was how to cleverly manipulate computers into doing more work on their part with way too much work on yours. Just get out of the house and fricken buy a skillet... no need to hack one up.

    --

    You quitting proves that the karma kap worked. The most annoying of the whores shut up. --CmdrTaco

  30. Re:I've read this book by ryanr · · Score: 1

    So, who are you? Rosie or Mike Blaszczak?

    http://www.amazon.com/exec/obidos/tg/detail/-/0201 914654/

  31. Doofus! by Chocolate+Teapot · · Score: 1

    Left shift multiplies by a power of two - it doesn't round anything.

    --
    Modest doubt is called the beacon of the wise. - William Shakespeare
    1. Re:Doofus! by Anonymous Coward · · Score: 0

      Must he spell it all out for you (Guess so)...

      try using and AND mask Doofuck

  32. Re:Base 2 vs. the wonderful IBM 1401 by Anonymous Coward · · Score: 0

    Hi, you gotta remember the author is a long time IBM'er. IBM started creating mainframes at the dawn of the computer age. My first IBM was a 1401. It used BASE 10 and you had to write your own bootstrap to power up and load your application. BASE 2 came along later when it became clear that on/off pairs of core memory might as well be binary arithmetic. (If I remember right you had to write your own subtract, multiply, and divide routines for the 1401)

  33. Punish the slackard! by Anonymous Coward · · Score: 0

    Install Access on it. I cant think of a worse punishment.

  34. HACKMEM by ctrimble · · Score: 5, Interesting
    HACKMEM is a document from the Elder Days at the MIT AI lab. It's not about optimisation, like Hacker's Delight, but it's full of lots of cool math/comp sci tidbits. I first discovered it back in the 80s when I was a script kiddie looking for cracking info (I hadn't understood the distinction between hacking and cracking at the time) and discarded it as lame. I revisited it about five years later after spending some time in the CS department and realised what a gem it really is.

    Here's a sample:

    ITEM 63 (Schroeppel, etc.):
    The joys of 239 are as follows:

    * pi = 16 arctan (1/5) - 4 arctan(1/239),
    * which is related to the fact that 2 * 13^4 - 1 = 239^2,
    * which is why 239/169 is an approximant (the 7th) of sqrt(2).
    * arctan(1/239) = arctan(1/70) - arctan(1/99) = arctan(1/408) + arctan(1/577)
    * 239 needs 4 squares (the maximum) to express it.
    * 239 needs 9 cubes (the maximum, shared only with 23) to express it.
    * 239 needs 19 fourth powers (the maximum) to express it.
    * (Although 239 doesn't need the maximum number of fifth powers.)
    * 1/239 = .00418410041841..., which is related to the fact that
    * 1,111,111 = 239 * 4,649.
    * The 239th Mersenne number, 2^239 - 1, is known composite, but no factors are known.
    * 239 = 11101111 base 2.
    * 239 = 22212 base 3.
    * 239 = 3233 base 4.
    * There are 239 primes < 1500.
    * K239 is Mozart's only work for 2 orchestras.
    * Guess what memo this is.
    * And 239 is prime, of course.
    HACKMEM
    1. Re:HACKMEM by cperciva · · Score: 1

      The 239th Mersenne number, 2^239 - 1, is known composite, but no factors are known.

      Not true. It wasn't even true when it was written: It takes only about a minute with pencil and paper to discover that 2^239 - 1 is a multiple of 479.

    2. Re:HACKMEM by Servants · · Score: 1

      It takes only about a minute with pencil and paper to discover that 2^239 - 1 is a multiple of 479.

      If you have a minute, then, how does that work?

    3. Re:HACKMEM by legerde · · Score: 2, Informative

      Im no math wizard, but bc is a nice tool...

      scale=6
      ((2^239)-1)/479
      1844308000812509738604 6946771846748599451815207469 92649396248644355553.000000

      seems to be without a remainder, but this does not equal a proof.

    4. Re:HACKMEM by cperciva · · Score: 3, Interesting

      If you have a minute, then, how does that work?

      All prime factors of 2^p-1 are of the form 2kp+1 for some k. If we're looking for a factor, the obvious place to start is with k=1, which tells us that we should look at 2*239+1 = 479.

      Now, 2^7 = 128, so
      2^14 mod 479 = 98,
      2^29 mod 479 = 2*98^2 = 48
      2^59 mod 479 = 2*48^2 = 297
      2^119 mod 479 = 2*297^2 = 146
      2^239 mod 479 = 2*146^2 = 1

      so 2^239-1 is a multiple of 479.

    5. Re:HACKMEM by Anonymous Coward · · Score: 0

      re: * The 239th Mersenne number, 2^239 - 1, is known composite, but no factors are known

      Not true, see below:

      2^239-1
      = 88342353238919216479164875037145925791374194843780 9479060803100646309887

      = 479 *
      1913 * 5737 * 176383 * 134000609 * 7110008717824458123105014279253754096863768062879

      - by James Bond

    6. Re:HACKMEM by Anonymous Coward · · Score: 0

      Sorry, but most people are incapable of modular squaring 3-digit numbers in "about" 15 seconds each.

  35. Premature optimisation is the root of all evil by Ella+the+Cat · · Score: 4, Interesting

    I've not read the book yet, but I do have a general worry, that optimisation isn't always done in the right context or for the right reasons. Code that runs faster in a small test program can break when part of a larger program (by thrashing the cache for example). What's the point of optimising something that's seldom invoked, in other words, always ask an enthusiastic optimiser to show you their profiling results.

    My favourite hacks are Jim Blinn's floating point tricks - 10% accurate square roots and reciprocals that blow away a floating point unit and are just what you need in graphics and games.

    1. Re:Premature optimisation is the root of all evil by Anonymous Coward · · Score: 0

      Even Knuth, who is the source of the statement "Premature optimization is the root of all evil.", will be covering these topics (known as "bit fiddling") in his upcoming volume 4A. Until that volume is published, which may be quite a while from now, I'd say Hacker's Delight covers the topic very well.

  36. Karma: Excellent? Oh please by Anonymous Coward · · Score: 0

    You say your karma is excellent and even claim to have invented the Karma sig? Oh please. I see that your comments have averaged a score of less than 1 recently. I seriously doubt with all those -1's you've racked up that your Karma is Excellent.

  37. Re:Karma: Excellent? Oh please by Anonymous Coward · · Score: 0

    Yeah, I just passed the Excellent -> Good threshold. I'll update the sig. Thx.

  38. Re:I've read this book by pnot · · Score: 1

    If you actually have read this book, why are you plagiarizing Mike Blaszczak's Amazon review in a fairly unsubtle manner?

    OK, it's good Slashdot Karma, but think what this is doing to your *real* karma -- much more of this and you're heading for reincarnation as a nematode worm ;-).

  39. Re:Greetings by Anonymous Coward · · Score: 0

    Being a one armed, Taiwanese child myself, yes.

  40. Re:Base 2 - Because you can add by comparing... by Rick.C · · Score: 0

    If you compare two bits, the sum is zero if they're the same (both zero or both one). If they are different, the sum is one. This simple comparison (which is also an addition) can be performed by a single XOR gate, which is like, four transistors.

    Yes, you also have to include carry-out and carry-in, but that just amounts to a few more gates. A 1-bit full-adder circuit uses only about ten or so transistors.

    That's why silicon computers use base-2: the simple math can be implemented in simple logic gates.

    Rick.C

    --
    You were 80% angel, 10% demon. The rest was hard to explain. - Over The Rhine
    "Math in a song is good."-Linford
  41. Duff's Device by spakka · · Score: 1

    there's already a portable way to do it which is probably more efficient.

    Nitpick: Duff's device is portable

    To go back to the Duff's Device example, almost all compilers will implement loop unrolling already

    Even where the number of iterations is not known until runtime, as in Duff's Device?

    1. Re:Duff's Device by Anonymous Coward · · Score: 0
      Nitpick: Duff's device is portable
      Double nitpick: only certain forms of Duff's device are portable. The form in which it first came to fame was not portable.
    2. Re:Duff's Device by spakka · · Score: 1

      Double nitpick: only certain forms of Duff's device are portable. The form in which it first came to fame was not portable.

      Triple nitpick: It is portable. It just doesn't do very much on implementations where the destination address isn't magic

    3. Re:Duff's Device by shoppa · · Score: 1
      Nitpick: Duff's device is portable

      But you've got to be sure that you don't unroll the loop so much that you go out of your processor's I-cache...

      And a programming trick that works *only* in C is hardly a portable one.

      Even where the number of iterations is not known until runtime, as in Duff's Device?

      Yes. Unrolling a loop is *not* rocket science. Any compiler from the last decade will know how to do it better than you can.

  42. This goes next to Knuth for me by Anonymous Coward · · Score: 0


    I read Hacker's Delight a few months ago over a few good cigars and found it fascinating in its thoroughness, a la Knuth. I may not use ever use it daily, but it added to my knowledge, and I so recommend it at $40 US.

    One interesting theorem on p.12 is "A function mapping words to words can be implemented with word-parallel add, subtract, and, or and not instructions if and only if each bit of the result depends only on bits at and to the right of each input operand."

    This tells you, for instance, that there is no magic bit masking trick which will turn off the leftmost 1-bit in a word. If that interests you, you'll probably enjoy the book.

    ~Matt

  43. Re:First Post by Anonymous Coward · · Score: 0

    "Tastes like poo!"

    Vivian, from _The Young Ones_

  44. Re:I agree, but... by Anonymous Coward · · Score: 0

    Aww, c'mon! The moderators are smoking that $5 crack.

  45. con.* files on NT or 2K, won't let you, try it by lugonn · · Score: 1
    I just discovered the weirdest bug ever. I've tested it with NT4sp6 and win2Ksp2.

    Try creating or renaming any file or your system to con.* * could be anything like .html .jpg .txt. The OS won't let you, it'll give an error. NT and 2K give different error mesasages. Under NT it just says the name is used already. Under 2K it says it's a reserved device name.

    1. Re:con.* files on NT or 2K, won't let you, try it by tricops · · Score: 1

      Well, it's actually not really a bug. "con" *is* a reserved device name. It's the device name for console, in the same vein that "prn" is the device name for the parallel port printer. (Or whatever it's been redirected to?)

      --
      (\(\
      (^v^)
      (")")
      This is the cute vorpal bunny virus, copy to your sig or runaway, runaway in fear!
    2. Re:con.* files on NT or 2K, won't let you, try it by tom.allender · · Score: 1

      Well yeah, you can completely lock Win98 with file:///c:\con\con link click.

    3. Re:con.* files on NT or 2K, won't let you, try it by tom.allender · · Score: 1

      Hey did I just discover a bug in Slashcode?

      Backslashs in links are replaced with '5C' not '%5C'.

      Ho hum. Diliberate or not?

    4. Re:con.* files on NT or 2K, won't let you, try it by Anonymous Coward · · Score: 0

      Can not create con.* under ME either.

  46. Karma whoring by cerebralsugar · · Score: 1

    I found some copies here. I might get one.

    --
    Easy guys, I put my pants on one leg at a time. The difference is after I put on my pants I make gold records!
  47. Re:Efficiency of base 2 arithmetic by Anonymous Coward · · Score: 0

    Technically, I believe base "e" (2.718...etc.) is the most efficent encoding scheme for numbers...... in terms of the overall tradeoffs between number-of-states-per-digit, vs. number-of-digits-required-to-encode. Good luck implementing this ;)

  48. Base 10 was on more recent computers too... by hughk · · Score: 1

    Converting decimal to binary and back again was relatively expensive so many commercial computers could work in decimal mode. The computer kept working in binary, it was just the numeric representation used. All that it meant was that the bytes were divided into two BCD nibbles, and numbers were represented as strings of 4-bit BCD digits.

    --
    See my journal, I write things there
  49. Actual non-existence? by BorgCopyeditor · · Score: 1
    Everything in the universe seems to revolve around a binary concept, rather than a decimal one... matter/antimatter, existence/non-existence, quantum spin states, etc.

    Please explain in what sense non-existence is something "in the universe."

    --
    Shop as usual. And avoid panic buying.
    1. Re:Actual non-existence? by KDan · · Score: 1

      There's about two billion examples I could point out. Here's one:

      In semiconductors, you may have heard of "holes" that carry charge. They can be treated as particles when you do the maths, as if they really existed. Yet all they are is electrons that are missing from filled conduction bands. So in this case, lack of existence IS most definitely something. If it wasn't computers would not exist.

      But that's a trivial example. On the more philosophical side, existence is defined by non-existence. If there were electrons everywhere, it would be meaningless to say that there are electrons somewhere. Just like at the moment, because there is spacetime everywhere that is somewhere, it's meaningless to say that there's a bit of spacetime here or there. Anywhere which exists is spacetime. However the discreteness of the existence of particles in that spacetime is a core concept to understand the universe.

      Of course, if you dig a bit deeper it all gets a whole lot more confusing when you find that those "discrete" particles are probability distributions smeared out across the entire universe. Still, I don't think that diminishes in any way the importance of non-existence.

      That's the sense in which I thought of it when I posted the previous post.

      Daniel

      --
      Carpe Diem
  50. Performance Critical by Giggles+Of+Doom · · Score: 1

    Shouldn't all software be built with performance in mind? Personally, I think that many developers have taken a love to today's high speed CPUs as it allows them to practically ignore performance issues. While it is true that in some areas performance tweaking is still vital, such as server software and high-end gaming, it seems that most mundane software, such as office tools and other nominal is over bloated and slow. Granted, it isn't as important, perhaps, but its still annoying when on my Dual Athlon machine I have speed issues, like when moving my media player causes the movie to stall and skip. I still chuckle at the popularity of Phoenix, an apparently slimmed down and tweaked browser. Even with fewer features then Mozilla, it stands on its own just because its fast. Does anyone else feel that programming in general today has been sloppy and aimed more at getting more features then having a fast, stable program?

    --
    "A coward dies a thousand deaths, the brave but one."
    1. Re:Performance Critical by Servants · · Score: 2, Insightful

      aimed more at getting more features then having a fast, stable program

      As I understand it, "stable" is kind of in opposition to both "fast" and "features". The reviewer's point is that super-optimized code tends to have strange tricks in it that are difficult to read and understand. That makes the code hard to maintain and increases the likelihood of bugs, so performance tweaking isn't a great idea unless speed is really important to an application.

    2. Re:Performance Critical by Lucas+Membrane · · Score: 2, Informative

      Do the math. As a first approximation, optimization of software running on a desktop machine has to save the users as much or more time than it takes the developer to produce and support the optimization. This means that if the statements you are optimizing will not be executed hundreds of millions of times, it's not worth worrying about. OTOH, if MS could shave one second off the start-up time for Word or IE, that would be worth tens of millions of dollars annually in additional productivity for the US economy overall.

  51. Hey, that's one of my Christmas gifts! by carambola5 · · Score: 2, Informative

    The reviewer speaks truth about this book. It is quite dense and, in many cases, violates the "Code should be easily decoded by future programmers" rule.

    I got this book for Christmas because I specifically asked for it. My mom was a bit put off by the title, though. The title refers to the original definition of "hacker," so don't get excited if you're all about computer security. There's nothing in there for you.

    One of my favorite concepts in this book is the author's use of non-breaking code. As many of you know, the mechanism for sending instructions to the CPU requires a bit of quasi-premonition. Riddle your code with many if-, while-, and (the hideous) goto-statements, and you will end up with slow code due to the seemingly random jumps inside memory. Use some of the methods in this book, however, and you will end up with more efficient code in the longrun. Need I remind you of the speedup generated when you use non-breaking code within a lengthy while loop?

    --
    IWARS.
    People, in general, disappoint me. Politicians even more so.
  52. Re:I've read this book by Asprin · · Score: 0, Offtopic


    Whoever you are, you sure get around.

    --
    "Lawyers are for sucks."
    - Doug McKenzie
  53. Try this more up to date page by Ninja+Programmer · · Score: 1

    That page is old, and not kept up to date. Try this one for some more exotic, well explained and up to date stuff.

  54. Re:Efficiency of base 2 arithmetic by mad.frog · · Score: 1

    Yep, that's what the book points out (that e is the most efficient base). However, he goes on to analyze the difference in efficiency between base 2 and bases 3 and e, and concludes that base 2 is more costly only by a factor of 1.062. (Yes, I have the book open in front of me as I type :-) It's a nice book... most of the information only of practical use to people doing serious code tweaking, but of interest to anyone who codes.

  55. Re:Karma: Excellent? Oh please by Anonymous Coward · · Score: 0

    Just you watch, as soon as he gets - he will start sucking the asses of eveyone to get back up.

    I say keep the troll where they belong.

  56. a reference 20 years late !! by Anonymous Coward · · Score: 0

    Truthfully - in today's world of cheap computing where there is more unused memory and idle CPU cycles than most users know what to do with, this book is much more a novelty than a practical guide. After all, how many programmers do bit-tweaking in Java these days? There may be the odd tidbit scattered throughout the book that may be truly useful but mostly one should savor the book for the mathematical insights and "tricks of the trade" the author lays out, undoubtedly accumulated from his many decades working with computers (From the days of "Real programmers" no doubt - and I don't mean the Pascal users ...)

  57. Made with Twinkies by Anonymous Coward · · Score: 0

    I actually saw a recipe, and some of the young ladies where I work baked it, of a confection called Hacker's Delight. Twinkies with marshmallows, caramel, & chocolate melted together in a microwave. So sweet it made you gag.

  58. Hacker culture by The+OPTiCIAN · · Score: 2, Informative

    I have come to despise the whole hacker culture based on the use of the sort of tricks the review illustrated. I comment my code like crazy, avoid confusing booleans, put null on the lhs of code, etc.

    But unfortunately, the other people on my team do none of that, and it would only be more painful if they were trying the sort of stunts this book focuses on.

    --


    Believe with me, my saplings.
  59. Do not berate by Anonymous Coward · · Score: 0

    It is not polite to undermine the opinion of one that is so passionate about plagiarism. If dismiss it so easily it must be because you deep inside nurture some feelings of promoting piracy of copyrighted works.

    And stop typing your messages from your VIC20. In the modern world we have at least 80 chars per line.

  60. I know him as well by Anonymous Coward · · Score: 0

    And just to show you, I will quote a random block of text that has nothing to do with him/it:

    "The team will comprise of a range of inexperts taken from former staff at Jensen, Strathcarron and Marcos. Their collective expertise in the field of failure will be co-ordinated by beardy inventionator Sir Clive Sinclair. We rang Sir Clive for further comment but he had invented a new phone system for his house based around washing machine motors and squelchy rubber keys and it didn't seem to work properly. "

  61. Shouldn't my compiler be reading this book? by dracocat · · Score: 1

    I may be missing the point here... but, in todays software world, shouldn't I be worried about coding reliable, and easily read code?

    And then let my compiler read through my code and determine the most efficient way to turn it into assembly? I mean, I would rather be multiplying by 2 rather than bitshifting; and then let my compiler turn it into whatever it needs to in order to run the fastest.

    In fact, I really wouldn't be surprised if many of the better compilers already do most of these tricks for us, and we don't even know it.
    But then again, I can't say for sure, since I have not read the book

    1. Re:Shouldn't my compiler be reading this book? by Anonymous Coward · · Score: 0

      It does however help know what your compiler is
      doing.. and remember, someone had to write the
      compiler also.

      --
      Silvio

    2. Re:Shouldn't my compiler be reading this book? by that+_evil+_gleek · · Score: 1

      Of course, it may be doing other tricks we don't know about.
      I once tracked a bug to the compiler optimizing away a whole branch. Neat, but it wasn't an if ( 1==0) branch, it should have been reachable. Very confusing even in a debugger, just seemed to jump over lines of C code... only when I compared the assembler output files, between optimized and nonoptimized did I notice what happened. Of course, having some assembler knowledge did help.
      It was a major unix vendor and their compiler.