7 ms·
I reacted to this title the way I react a new menu item at Taco Bell: a strange mixture of desire, shame, and admiration for human ingenuity.
by scop 2y ago
I reacted to this title the way I react a new menu item at Taco Bell: a strange mixture of desire, shame, and admiration for human ingenuity.
- qsort 2y agoI work a lot with databases and I've seen... stuff. It's not as bad as you might think if you know what you are doing. Most RDBMSs support recursive CTEs, it feels like writing Prolog with a slightly sadistic syntax. For something like AoC the most difficult part is probably parsing the input.
- dunham 2y agoSpeaking of parsing, back around y2k we were building an app that used XML everywhere, which was the style at the time, and our DBA wanted to write an xml parser in SQL (the api would involve sending XML to the database). That got vetoed. IMO, this kind of thing is what AoC is good for - you get to play with weird/obscure stuff without affecting your day job code.
- jamie_ca 2y agoI did something with JSON back before there was reasonable native support - it's certainly not robust, but it handled a few syntax variants for a use case where we had an extra attribute column that serialized JSON, and wanted to surface one of the fields as a proper column on the table. https://blog.tracefunc.com/2011/11/19/parsing-json-in-sql-html/ https://blog.tracefunc.com/2011/11/19/parsing-json-in-sql-ht...
- jmg_ 2y agoFunnily, I’m actively working on rewriting a stored procedure which parses an XML snippet as one of its arguments Luckily it’s not a handwritten XML parser though: https://learn.microsoft.com/en-us/sql/t-sql/functions/openxml-transact-sql?view=sql-server-ver16 https://learn.microsoft.com/en-us/sql/t-sql/functions/openxm...
- yazmeya 2y agoJust around the same time I was working at a place that used Oracle's web app extension, with CGI endpoints written completely in PL/SQL. I did end up writing an XML parser/serializer for it.
- emmelaich 2y agoThanks for that comment. I laughed aloud at "It's not as bad as you might think if you know what you are doing." ... because that pretty much describes all human activity :-)
- AdieuToLogic 2y ago> Most RDBMSs support recursive CTEs, it feels like writing Prolog with a slightly sadistic syntax. Which makes sense as both are declarative logic-based languages. IMHO, SQL and Prolog fundamentally have much in common.
- marxisttemp 2y agoI did a semester at the university of Edinburgh and took database systems and logic programming at the same time, and I definitely felt the synergy between them.
- UltraSane 2y agoA company I worked for uses Syteline ERP which heavily relies on SQL Server. But the DBA was constantly complaining about how slow the Syteline SQL was. One major issue was long running transactions taking 10 minutes locking rows/tables for too long and using a lot of memory. You would think very expensive ERP systems would have decent SQL.
- ulrikrasmussen 2y agoIt is closer to Datalog I think, or can you express cut? CTEs are fairly restricted compared to logic programmming languages though, at least for Postgres. In particular, relations cannot be mutually recursive and your rules may only be linearly recursive in themselves (i.e. can contain only one instance of themselves in the right hand side). Postgres is overly restrictive in the latter and requires at most once recursive reference over all subqueries in the UNION even though it would be safe to only restrict the number of recursive calls for each subquery (each corresponding to a separate Datalog rule for the same relation). It is possible to work around that restriction using a local WITH expression (a hack really), but then you are also on your own since it disables all checks and allows you to write rules which uses actual nonlinear recursion and will give incorrect result sets when evaluated. I really would like Postgres to have proper support for writing Datalog queries, and with better and more efficient incremental evaluation algorithms as opposed to the iterative semi-naive algorithm that is only supported now.
- harrall 2y agoHaven’t written SQL in a while (and I used to write a lot) but I think SQL Server recursive CTEs are fairly unbounded so it’s just a Postgres limitation unfortunately. (I’m a fan of MS SQL but it’s Microsoft and also hard to financially justify for many companies. But if you ever get to use it, it is a very solid RDBMS, even if the rest of your stack is open source.)
- bob1029 2y agoThe cost of MSSQL is largely controlled by how the system is designed and the complexity of the business. The model I am most familiar with is a 10-20 employee B2B SaaS startup running one "big" instance on a single vm in the cloud somewhere. If this is approximately all you require, then the cost should not be a dominating factor in your decision. I think "because Microsoft" is also really poor justification if we are being serious about the technological capabilities and pursuing high quality business outcomes. If your business is fundamentally about open source advocacy and you are operating as a non profit, I totally get it. But, this is probably not your business model.
- youerbt 2y agoI do AoC in SQL, I wish it was true. With Postgres, you have lots of regex/string manipulation functions that make it easy. For me, the biggest problem was memory. Recursive CTEs are meant to generate tables, so if you are doing some maze traversal, you have to keep every step in memory, until you are done.
- xdavidliu 2y agoparsing is most difficult for probably the first third of the problems. when you get to day 19 or so, the input is still just a grid or a bunch of ints just like day 1, but the algorithms required are considerably more challenging than the parsing part. (I've done all 25 problems in all years)
- brettgriffin 2y agoI'm as equally amazed by the solutions in this post's github repo as I am with Taco Bell's new chicken nuggets.
- upghost 2y ago⊂ •͡˘∠•͡˘ ⊃ Suspicious. Need to investigate if taco bell has interesting ANSI SQL flavored chicken nuggets or I've been taken for a fool!
- deleted 2y ago[deleted]
- larodi 2y agobut why? what would make you react at human ingenuity with shame and desire? is this something about you or something about them in particular? isnt the whole of HN about human ingenuity...? are we to feel Taco Bell menu about it all, what am I missing?
- knicholes 2y agoThis is just a guess, but if the OP's reason is similar to mine, DBMSs should be reserved for managing databases and not implementing complex logic.
- liontwist 2y agoWhy not? I think the main barrier is the programmers are not comfortable with recursion, rather than a technical limitation.
- FridgeSeal 2y agoI’d hazard a guess that quite a few devs have at one point, been lumped with a db where someone pushed too much logic into it. Probably great for the one person who wrote it, and awful for everyone else. Mystery triggers, unclear or badly managed stored procedures, opaque invariants. It’s not to say that all of these things are bad, but a certain level of DB complexity will naturally set off alarm bells for some devs.
- scop 2y agoOne of the most eye opening moments in my junior dev career was when I found a really nifty way to achieve an operation using SQL alone and brought it to our VP (start up, small company size). It wasn’t esoteric, but used some SQL features not well-trodden by web devs. I thought I was the bees knees and this would be a clear demonstration of my sizable brain. He complimented the thought behind it, but immediately vetoed it as too complex for the majority of developers who would have to touch the code down the road. In hindsight he was completely right.
- PaulHoule 2y agoWhat I can't stand about Taco Bell is the fake nacho cheese. The ordinary grated cheese that is on (say) a hard taco is OK even if it's not the best, but it takes me a strong act of suppression to choke down anything with Velveeta in it. Maybe their tablet interface can be drilled into to get ingredients but as it is it's a game of chance. (Funny there is a taco stands that has the best street tacos I've seen anywhere except LA a block from Taco bell but too often it's not open when I'm there) Seriously though, https://www.amazon.com/Joe-Celkos-SQL-Smarties-Programming-dp-0128007613/dp/0128007613/ref=dp_ob_title_bk https://www.amazon.com/Joe-Celkos-SQL-Smarties-Programming-d... is a masterclass in extreme SQLmanship.