11 ms·
Yes, I can connect to a DB in CSS
- superkuh 5y agoCommitStrip, a IT themed comic strip, predicted this in 2019: https://www.commitstrip.com/en/2019/03/15/css-css-everywhere/ https://www.commitstrip.com/en/2019/03/15/css-css-everywhere...
- SamBam 5y agoSo we can write Javascript in CSS. Previously we could write CSS in Javascript. If I write a React template that embeds the CSS that embeds this Javascript, whose job is it to untangle my mess when I leave the company?
- ljm 5y agoYou could write HTML inside your CSS and then use your PaintWorklet to render that HTML onto a canvas. Start with HTML 1.0 so you don't have to support CSS inside that HTML.
- trollied 5y agoNot really. It uses lots of JavaScript.
- Waterluvian 5y agoThis is accurate. But it’s also not: any time anything is done in any language we can just point at the language below it. But yeah, this is probably more charitably described as “A CSS interface for SQL written in Javascript.”
- deleted 5y ago[deleted]
- pests 5y agoOkay, but why not call every database extension for a language just "A [language] interface for SQL written in [driver language]." "ext/mysqli is just a PHP interface for SQL written in C" What is the difference
- JasonFruit 5y agoStill clever, though.
- omgmajk 5y agoAn V8 is written in C++ so...
- TameAntelope 5y agoThe challenge isn't to only use CSS, it's to "connect to a DB in CSS", which this does with `--sql-query: SELECT name FROM test;`. So, in the strictest sense, "yes really".
- cush 5y agoEven without Houdini, we could have always written a piece of JS to read all the CSS on a page, and if it contains an SQL query, execute it. This implementation has nothing to do with CSS, but is obfuscated behind a new fancy api.
- gavinray 5y agoTitle is very misleading It's just JavaScript that interacts with SQLite and uses CSS API's to render the results
- bryanrasmussen 5y agowhen a recruiter asks you to connect to a db with css is it really wrong to mislead them in this way though?
- rodamaral 5y agoWhen a recruiter asks you to connect to a db with css, you leave immediately to never return.
- deleted 5y ago[deleted]
- oldsecondhand 5y agoOr write a strong AI with regular expressions that solves the problem for you.
- mindcrime 5y agoI feel like there's a variation of jwz's famous quote waiting to be coined: "Sometimes, when a programmer confronts a problem, ze thinks 'I know, I'll use strong AI', now ze __________." * has 2 problems? * has 3 problems? * has infinite problems? * has a death wish?
- bryanrasmussen 5y agobut the quote was already wrapped in the parent posters idea, since they were writing Strong AI with regular expressions! If you have two problems when using regular expressions and you have X problems with Strong AI how will the combination of your problems be calculated?
- c-linkage 5y agoMaybe it's time for me to switch to a text-only browser. When CSS becomes Turing-complete it seems that even NoScript won't help me from nefarious web pages.
- robin_reala 5y agoCSS is already Turing-complete if you set up an execution environment of some checkboxes and require user interaction to ‘advance the tape’: https://stackoverflow.com/a/5239256/453783 https://stackoverflow.com/a/5239256/453783
- jhoelzel 5y agowe have come full circle! you should now browse websites with the terminal just to be secure. but then you get blocked for not having the right headers....
- catfishx 5y agoI wonder if there are any vulnerabilities in terminals which could be exploited
- deleted 5y ago[deleted]
- charcircuit 5y agoWhat does Turing completeness have to do with anything? Physical computers aren't even Turing complete themselves.
- colejohnson66 5y agoUnder what definition is a physical computer not Turing Complete? The lack of infinite memory? That requirement would preclude literally everything but theoretical computers. It’s a lot more logical to talk in terms of “if there was infinite tape, would this thing Turing Complete?” Brainf** is famously Turing Complete and can be executed on any desktop you can think of. That alone is enough to prove that your desktop itself is Turing Complete.
- varelaz 5y agoTechnically you could do any web requests which contain SQL in query paramaters even before with images/backgrounds and return data to the page. The thing is that it cannot work just between CSS and DB.
- searchableguy 5y agoTIL CSS Paint worklet. Someone could use that to hook in a utility css framework.
- d--b 5y agoAt some point we need to ask who's asking for these CSS features? Unless it's coming from the NSA who just wants more attack surface, I don't see the point...
- bgdam 5y agoIf it doesn't work without Javascript enabled, then it's not a CSS solution. I was quite excited by the title, but alas the project doesn't live up to the title.
- 3np 5y agoA more old-school but no-JS solution would be point image/font URLs to endpoints that queries a DB on GET requests. With enough contortions and breaking GET idempotency you could probably do a whole CRUD app with just that.
- danbruc 5y agoIn which case you are connecting to a web server that connects to a database, you are not connecting to a database.
- falcor84 5y agoTo be pedantic here, you're never connecting directly to a database, but rather to a DBMS, and it's nowhere set in stone that the DBMS must not offer a web interface.
- BeefWellington 5y agoThat's not entirely true. You can absolutely load underlying data structures into your own application, and in fact this is how a lot of older database tech used to be. Stuff like dBase, Access, etc., used to be literally "load database into program memory" or "read database format from file" - similar to what SQLite does now. I wonder if CSS could implement sqlite...
- danbruc 5y agoBut even in that case you are - at least usually - still interacting with some kind of DBMS. I am not really familiar with the examples you named but with SQL Server Compact you are essentially just loading and running the DBMS in your process. But as I said in my other reply, at some point the distinctions become blurry.
- kkjjkgjjgg 5y ago"A new set of APIs affectionately known as Houdini" - love it :-) I suppose because they provide so many means for escaping the browser sandbox?
- rvz 5y agoAs many have pointed out, it is still using Javascript. > As the name might suggest, this is how you connect to a database using CSS. It only works in Chrome, unfortunately. Now we know why Firefox isn't widely used for more advanced websites and why tons of Chrome-based browsers exist.
- kwhitefoot 5y agoSounds like another reason to avoid Chrome.
- udbhavs 5y agoFantastic. The next step is to create a declarative query model using CSS, complete with the built in CSS selector model. (Eg. if a div of class .a is inside a div of class .b, all the query parameters of .b get applied to .a). Then someone can create a Tailwind-like utility library for that and we're back to SQL
- prvak 5y agoUgh. Thanks I hate it.
- beepbooptheory 5y agoLove this just because I empathize with struggling with js worklets!
- virgilp 5y agoThe connection itself has nothing to do with CSS. This is not "connecting to database", it at best "writing SQL queries in CSS".
- pests 5y agoEh, I think it counts. I mean, aren't most database extensions for programming languages not written in the language its targeting? When I use mysql_query in PHP, aren't I just "writing SQL queries in PHP" and the underlying C driver is the one doing it? But we still say PHP can connect to databases. Its just a driver for CSS written in the host language (JS).
- virgilp 5y agohttps://www.w3schools.com/php/php_mysql_connect.asp https://www.w3schools.com/php/php_mysql_connect.asp There's nothing similar in this CSS example, unless I missed it. (I do believe it can be done, the idea is "there" - you need to invent a syntax to declare connection details, error handling, etc; and then you can indeed argue that the .js part is just the "driver")
- ljm 5y agoAuthor here. While it's true that this depends on JS to work (because of the various new CSS Object Model APIs in the browser), I think there's enough doubt about my technique here that I can submit this for YC2023 and make bank in maybe a decade or so. After all, I remember what everyone said about Dropbox...
- cookiengineer 5y agoJust FYI the paint worklets are also available (at least) in WebKit nightly since around August 2021. So I'd guess that your implementation could work with a few modifications on iOS, as the worklets aren't hidden behind a compile time feature flag. Kudos to you, this is exactly why I removed the worklets from my retrokit fork :)
- ljm 5y agoSadly I don't have any iOS/MacOS devices... maybe I can re-host the source on GitHub and engage a community around the project.
- ghiotion 5y agoOld school quality shit posting all the way down. I appreciate you man.
- anon_123g987 5y agoIf you want to impress Hacker News, you have to write a browser in CSS, too, because currently your work depends on C++.
- pulse7 5y agoIf CSS property value is not limited in length, you could actually put the whole browser source code in it... :-)
- anon_123g987 5y agoGreat! Now all we need is a pure CSS operating system, and we're ready to go.
- unlog 5y agoI believe the purpose of the article is to expose the paint API, rather than trying to claim that has been done with CSS alone. Which in some part is true, as CSS is allowing this at all in the first place.
- deleted 5y ago[deleted]
- echan00 5y agoHilarious to the max
- numlock86 5y agoOne of the many reasons why you should use SRI and other security measures even on CSS resources and not just <script>s.
- 58x14 5y agoHere's an actual CSS-only implementation of a chat app that I happened to stumble across yesterday while tinkering: https://github.com/kkuchta/css-only-chat https://github.com/kkuchta/css-only-chat
- a9h74j 5y agoNeed to justify your disk quota? Now your tables can expand to fit the available space. Who said table-based layout was passe.
- ivan_gammel 5y agoThe first question that naturally comes out of it is when we should expect an exploit, because it does look like a rich source of vulnerabilities.
- testplzignore 5y agoI'm not satisfied until I see a quine.
- simias 5y agoIs CSS turing complete? If it were you could cross-compile SQLite into it. You'll probably want to have it run Doom first though.
- goldsteinq 5y agoCSS is kinda Turing-complete, but you need an external tick. And running SQLite compiled to CSS would probably be unusably slow.
- zekenie 5y agoYou’re hired
- simonw 5y agoI built something a tiny bit similar to this (but not nearly as clever) a while ago - my trick is to return the results of a SQL query as CSS variables so you can use CSS generated content to display them on a page: https://simonwillison.net/2021/Jan/7/css-apis-no-javascript/ https://simonwillison.net/2021/Jan/7/css-apis-no-javascript/
- s5806533 5y agoAnd yet another example of feature creep in today's browsers. Now one can extend CSS with JavaScript.
- gmiller123456 5y agoThe requirement is "connect to the database using CSS", which is incredibly vague and ambiguous. It does not bar the use of other dependencies, so, IMHO, he complied with the requirements. The client could only claim it does not comply by adding new requirements.
- cush 5y agoThe title reads like a zero-day attack vector
- webmaven 5y agoBut do mauve SQL databases have the most RAM?
- dzhiurgis 5y agoReminds me The Expert and 7 perpendicular lines - https://www.youtube.com/watch?v=B7MIJP90biM https://www.youtube.com/watch?v=B7MIJP90biM