Hacker News new | ask | show | jobs
by teraflop 4044 days ago
Sure, but if the headline was "CSS can be used to implement a lookup table", it would be much less eye-catching.

More to the point, Boolean expressions and truth tables are not equivalent representations that should be treated on an equal footing; there's an exponential blowup involved when converting from one to the other. Just try extending that 4-bit adder to 16 or 32 bits. The functions that can be tractably represented using this scheme are a strict (very small) subset of the functions that can be computed by true Boolean circuits.

2 comments

The difficulting in actually creating some of these larger lookup tables is, of course, very true. That doesn't mean that sometimes, depending on the problem you're solving, lookup tables can still be a useful (or preferred) implementation method.

It is the programmer's job to decide what point on the "using storage"<->"using CPU time" continuum is appropriate for the current problem. Obviously, larger chained adders at 16 or 32-bits would be crazy. (of course, at that point you would want to implement a carry lookahead anyway to avoid the horrible propagation delay in the last carry bit)

Yes, but this time it is disappointing. If the website was a tool for learning logic gates, it would be perfectly acceptable and quite clever. However, since the website is saying that it has implemented logic gates in CSS, a natural, if not necessary expectation is that these gates should be composeable, which they are not. Logic gates that can't be fed into each other really strain the definition of a logic gate (its part of the reason that circuits are interesting while a piece of paper with a truth table is not)

Edit: Just to clarify, the disappointment is from being excited that something like this could be wired up the way we initially thought. The result remains cool and clever all the same.

Not wanting to be negative here, but I don't get the point of these CSS projects.

CSS isn't Turing complete. It's a (poorly designed) markup tool, not a general symbol processing language. So there's a whole world of stuff it just can't do in any useful way.

Any attempt to make it do this stuff is either going to have to fake it with limited sleight-of-mind, or is simply not going to work.

So "I made s Haskell compiler out of pure CSS" is always going to be disappointing. (If you could make real logic gates, you certainly could make a Haskell compiler. Although it's possible it wouldn't be fast enough for production code.)

I built this for fun, and to remind people that CSS can do more than you think. (it should also be a nice tool to help teach adders)

While I would obviously never do something this insane in a real product, I have used CSS for surprisingly much actual logic in real code (empty states for lists, hiding controls that the user cannot use, etc).

See also http://stackoverflow.com/a/5239256/34397

Exactly.