8 ms·
Silon – Adders and Logic Gates in Pure CSS
- devsquid 11y agoGood job man!
- devsquid 11y agoHey heads up Steve Gibson of the Security Now podcast just shared your website. You might be getting a ton of traffic, if thats a concern
- vardump 11y agoYou 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...
- devsquid 11y agohaha, 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??
- girvo 11y agoI highly recommend checking out LESS -- even if you ignore all of it's features, being able to define variables alone is worth it :)
- devsquid 11y agoYes i have been meaning too
- robin_reala 11y agoCSS does have variables: http://www.w3.org/TR/css-variables/ http://www.w3.org/TR/css-variables/ Of course, this being the web you’re somewhat limited in browser support: http://caniuse.com/#feat=css-variables http://caniuse.com/#feat=css-variables
- yellowapple 11y agoLanguages of the future will be compiled to CSS in the same way that languages of the present are compiled to Javascript. I get shivers just thinking about all the fun I can have breaking web semantics this way.
- spartanatreyu 11y agoCSS is already turing complete: - http://stackoverflow.com/questions/2497146/is-css-turing-complete http://stackoverflow.com/questions/2497146/is-css-turing-com... This project doesn't use rule 110, it uses LESS which sorts out the logic while compiling and spits out the results in css.
- Dylan16807 11y agoI still say that doesn't count as long as you have to make the user click on all the cells. CSS by itself is capable of doing a single row of rule 110, but that's not enough.
- pdkl95 11y agoIt'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.
- jacquesm 11y agoIn case you're wondering what makes it tick: https://github.com/SLaks/Silon/blob/gh-pages/styles/basic-gates.css https://github.com/SLaks/Silon/blob/gh-pages/styles/basic-ga...
- teraflop 11y agoAww, 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.
- pdkl95 11y agoUsing 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.
- teraflop 11y agoSure, 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.
- jacquesm 11y agoExactly.
- pdkl95 11y agoThe 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)
- nickysielicki 11y agothis was the coolest thing I've ever seen in my entire life.
- pkghost 11y agodude.
- jacquesm 11y agoWhy?
- javajosh 11y agoYouth.
- nickysielicki 11y agoBecause this is hackernews, and this is a really cool CSS hack.
- jacquesm 11y agoI agree it is a cool hack. I was wondering why you thought it was the coolest thing you'd seen in your life, rather than say this week or maybe even just today.
- crimsonalucard 11y agoIt's like programming with a crayon on a dirty wall. Sure.. but why?
- tombh 11y agoVery cool :) I didn't realise you could click on them until after a good while though.