Live data from Hacker News

Silon – Adders and Logic Gates in Pure CSS

silon.slaks.net

11–20 of 40 posts

Re: Silon – Adders and Logic Gates in Pure CSS

#12
post #5

In case you're wondering what makes it tick: https://github.com/SLaks/Silon/blob/gh-pages/styles/basic-ga...

Aww, after seeing that I'm a little disappointed. Each CSS file is basically just a giant truth table that describes which state each bit should be in under all possible combinations of inputs.

It makes for a cool demo of how simple Boolean circuits work, but you can't really say it's "doing computation" in CSS when all of the actual computation has been done ahead of time.

Still, it's clever.

Re: Silon – Adders and Logic Gates in Pure CSS

#13
post #5

In case you're wondering what makes it tick: https://github.com/SLaks/Silon/blob/gh-pages/styles/basic-ga...

Aww, after seeing that I'm a little disappointed. Each CSS file is basically just a giant truth table that describes which state each bit should be in under all possible combinations of inputs. It makes for a cool demo of how simple Boolean circuits work , but you can't really say it's "doing computation" in CSS when all of the actual computation has been done ahead of time. Still, it's clever.

Using a lookup table is a valid way to implement something. It is used often for precalculating expensive functions. (trig tables are very common). This is just one extreme of the runtime-vs-memory trade-off.

Re: Silon – Adders and Logic Gates in Pure CSS

#14
post #13

Earlier quoted context omitted.

Aww, after seeing that I'm a little disappointed. Each CSS file is basically just a giant truth table that describes which state each bit should be in under all possible combinations of inputs. It makes for a cool demo of how simple Boolean circuits work , but you can't really say it's "doing computation" in CSS when all of the actual computation has been done ahead of time. Still, it's clever.

Using a lookup table is a valid way to implement something. It is used often for precalculating expensive functions. (trig tables are very common). This is just one extreme of the runtime-vs-memory trade-off.

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.

Re: Silon – Adders and Logic Gates in Pure CSS

#15
post #13

Earlier quoted context omitted.

Aww, after seeing that I'm a little disappointed. Each CSS file is basically just a giant truth table that describes which state each bit should be in under all possible combinations of inputs. It makes for a cool demo of how simple Boolean circuits work , but you can't really say it's "doing computation" in CSS when all of the actual computation has been done ahead of time. Still, it's clever.

Using a lookup table is a valid way to implement something. It is used often for precalculating expensive functions. (trig tables are very common). This is just one extreme of the runtime-vs-memory trade-off.

Lookup tables get very large as the number of potentially valid outputs increases and can do only so much (no way to incorporate state with a lookup table).

Re: Silon – Adders and Logic Gates in Pure CSS

#16
post #13

Earlier quoted context omitted.

Using a lookup table is a valid way to implement something. It is used often for precalculating expensive functions. (trig tables are very common). This is just one extreme of the runtime-vs-memory trade-off.

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 repr…

Exactly.

Re: Silon – Adders and Logic Gates in Pure CSS

#17
post #4

You can implement an adder in CSS? Somehow this reminds me of C++ templates. These things seem to gain power and have new features until they become turing-complete. And beyond...

It's not really any surprise that templates (or CSS) could be Turing complete, as all the lambda() function does is the same thing a template does - replacing the macros in a template with an argument.

This is actually an important lesson that is often missed: if the app you're writing gives the anonymous users any kind of find/replace macro capability, you're giving them a fully Turing complete language (though it's probably not easy, but that rarely stops anyone) and all the potential problems that can bring.

Re: Silon – Adders and Logic Gates in Pure CSS

#18
post #13

Earlier quoted context omitted.

Using a lookup table is a valid way to implement something. It is used often for precalculating expensive functions. (trig tables are very common). This is just one extreme of the runtime-vs-memory trade-off.

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 repr…

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)

Re: Silon – Adders and Logic Gates in Pure CSS

#19
post #4

You can implement an adder in CSS? Somehow this reminds me of C++ templates. These things seem to gain power and have new features until they become turing-complete. And beyond...

haha, thats a funny thought. I like CSS. I would love for it to have variables so I could consolidate changes and edit them via JS. Sorta like all the CSS-libraries. o.o am i doing it??

I highly recommend checking out LESS -- even if you ignore all of it's features, being able to define variables alone is worth it :)

Re: Silon – Adders and Logic Gates in Pure CSS

#20
post #13

Earlier quoted context omitted.

Aww, after seeing that I'm a little disappointed. Each CSS file is basically just a giant truth table that describes which state each bit should be in under all possible combinations of inputs. It makes for a cool demo of how simple Boolean circuits work , but you can't really say it's "doing computation" in CSS when all of the actual computation has been done ahead of time. Still, it's clever.

Using a lookup table is a valid way to implement something. It is used often for precalculating expensive functions. (trig tables are very common). This is just one extreme of the runtime-vs-memory trade-off.

On FPGAs, it's actually how most logic functions are implemented. FPGAs are a big grid of SRAM-based lookup tables, some latches and fixed function blocks, and a whole ton of interconnections.
Post reply on HN