9 ms·
The Database Inside Your Codebase
- asadawadia 6y agoI can barely read with that font colour..
- walterlb 6y agoSame. Reading mode in Firefox was a quick fix
- TimWolla 6y agoI found it perfectly readable and checked with Firefox' accessibility tools: The contrast of the main text is a 12.19 and thus meets the WCAG AAA standards for accessible text. [1] is the documentation Firefox links to. [1] https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable/Color_contrast https://developer.mozilla.org/en-US/docs/Web/Accessibility/U...
- D13Fd 6y agoI find this response hilarious, because you jumped to a standard to make your argument without considering that what you are seeing may not match what others are seeing. The page is super hard to read with the white background it has in Firefox, but fine with the dark background it has in Chrome. I.e., the problem is that the website sometimes renders with a white background and very light pink text.
- anamexis 6y agoJust because you find it readable does not mean others can; also, color contrast is not the only thing that affects readability. In this case, the issue is font weight. Here's some discussion on the issue: https://github.com/w3c/wcag/issues/665 https://github.com/w3c/wcag/issues/665
- n0w 6y agoThe page has a different (lighter) text colour for dark mode but the background colour doesn't change on dark mode, making it nearly unreadable. The Firefox tools tell me it has a contrast of 1.43
- feifan 6y agoYep, that's it. Turns out, Safari/Chrome change the page background automatically based on your OS setting. FF seems not to.
- mplewis 6y agoOh, word? Mine's at 1.43. https://imgur.com/a/AVQxh20 https://imgur.com/a/AVQxh20
- eyelidlessness 6y agoThis is why metrics versus real world measurement are at odds. Sure, measure the luminance all you want; sure ignore the fact that color spaces and visual impairment aren't evenly distributed. But don't tell someone they can see something they can't.
- TimWolla 6y agoI was not telling anyone that they must be able to see this properly. I was saying that I was able to see this properly and I was saying that according to an established standard it should be as readable as it gets. Sure, the standard might be lacking, but then the standard should be fixed. As a website author you need something to refer to when you don't experience these issues yourself.
- eyelidlessness 6y ago> Sure, the standard might be lacking, but then the standard should be fixed. As a website author you need something to refer to when you don't experience these issues yourself. The problem is that it’s the wrong standard that’s lacking. WCAG does the best it can with the web specs, but it can’t just impose a perceptual color space on HTML/CSS, and it would be impossible for mere mortals to evaluate a perceptual contrast standard on RGB/HSL. But you can easily find A11y articles pointing out where the contrast ratios which pass or fail are very flawed for even people with good vision.
- jspash 6y agoContrast isn't the only indicator of readability. The font choice here is IMHO terrible for screen. It's much too thin. Taking this to the logical extreme - just for fun - imagine a the perfect contrast score of Vantablack™ on Spectralon white. It wouldn't matter if the typeface stroke widths were only a micron wide. It would still be unreadable.
- patrickcteng 6y agoI found it hard to read too.
- skunkworker 6y agoIt's just the right amount of contrast to allow you to read a word or two easily, but it's difficult to scan the article. I used Dark Reader and tweaked the contrast, and made it much easier to read.
- feifan 6y agoHey, author here — sorry about that. I don't use/didn't test with Firefox, but it looks like it's not setting the page background properly in dark mode. I'll get that fixed!
- 5560675260 6y agoConsider also testing "-webkit-font-smoothing: antialiased;" on non-retina screens. When removed text became somewhat thicker and significantly more readable.
- feifan 6y agoI'll try that tonight! Any suggestions for testing/seeing how the anti-aliasing works when I don't physically have non-retina screens?
- feifan 6y agoDone — I think antialiasing looks better on Retina screens in dark mode so I kept it only for that case (removed it for non-dark mode or non-Retina).
- feifan 6y agoI think I fixed for Firefox — let me know if you're still seeing 1.4 contrast/super-light text.
- ducharmdev 6y agoGeez, have you heard of a contrast checker before? https://webaim.org/resources/contrastchecker/ https://webaim.org/resources/contrastchecker/
- TimWolla 6y agoThe contrast is fine, see: https://news.ycombinator.com/item?id=26160608 https://news.ycombinator.com/item?id=26160608
- idreyn 6y agoI (presumably along with GP) am using Firefox where the background shows up white and the contrast ratio weighs in at 1.43:1. But it looks fine on Chrome.
- waiseristy 6y agoWhat's funny, is chrome renders the page worst out of the 3 browsers installed on my machine https://imgur.com/a/fh0BAzV https://imgur.com/a/fh0BAzV E: Edge F: Firefox C: Chrome
- eyelidlessness 6y agoBelieve it or not, just because a tool says the contrast is fine doesn't mean that it is. Even assuming a "normal" human range of color spectrum vision, many of these tools measure contrast ratios in color spaces that aren't even representative of that "normal" spectrum. All of the color spaces in native use on the web are not proportional to "normal" perception of color. Of course that gets even more complicated when different vision conditions are introduced. Don't just quote some automated tool at people who very clearly experience something else.
- true_religion 6y agoThis seems like a hard job then. If we adjust the site to make it accessible for you, then we might make it less accessible for me. Maybe that’s why CSS was originally made to be overridden client side, so everyone can make their own choices about font and background.
- simonw 6y agoI've been playing with some ideas for creating a SQLite database of classes, functions and suchlike found in Python code, so I can analyze my codebases with SQL queries. I've had some good initial results with https://github.com/davidhalter/jedi https://github.com/davidhalter/jedi - which is the Python introspection library that powers various editor autocomplete implementations. I have a prototype which uses that to create a SQL database of functions, classes and places that they are used. I've also been playing with https://github.com/github/semantic https://github.com/github/semantic - it can parse Python, JavaScript and other languages and offers a --json-symbols option which dumps out a JSON object showing the symbols (functions, variables etc) found in the code.
- samcodes 6y agodo you have a repo? this sounds cool
- feifan 6y agoOh this sounds cool! When I was writing this post I was thinking about ASTs and transforming them into domain-specific semantic graphs. E.g. that `run_config` example would be a generic "method call" node in an AST, but a domain-specific AST crawler could recognize that a "method call node whose name is `run_config`" should be replaced with a semantically-meaningful `run_config` node. And maybe that would be an interesting way to build up a conceptual graph of a codebase?
- lstamour 6y agoI'm with you on this one. I'd actually suggest https://github.com/CoatiSoftware/Sourcetrail https://github.com/CoatiSoftware/Sourcetrail could be extended to do this, though I haven't found the time yet for my own codebases. For example https://github.com/CoatiSoftware/SourcetrailPythonIndexer https://github.com/CoatiSoftware/SourcetrailPythonIndexer and under the hood the file format is SQLite: https://github.com/CoatiSoftware/SourcetrailDB https://github.com/CoatiSoftware/SourcetrailDB
- gitrog 6y agoAlthough I understand what we're trying to achieve here is easier code navigation and manipulation on a much broader scale with preferably a single tool, I couldn't shake the feeling that some of the examples you gave have existing solutions. The `run_config` one stood out the most. Isn't it perfectly feasible to have a `jobs` and a related `run_configs` table, instead of them only being objects? You could even put them in a separate database, much like one does with the auditing tables in a Rails application, or with reporting tables that need to be accessible by the likes of PowerBI. That separate database could have it's own light-weight GUI, something that just plugs your data structure into the interface, like Django's admin back-end.
- corban1 6y agoUgh, the site is giving me an eye sore. Bad font or bad color choice?
- jeremyis 6y agoReally interesting piece. I like how it discusses various seemingly disparate issues and ties them together. > In our codebase, we have hundreds of these jobs, each with their own run_config. If you look at this codebase as a database, you can imagine these jobs being rows in a jobs table, where the fields on each row correspond to the parameters provided to the RunConfig class. > Wouldn’t it be great to be able to browse all these jobs in a table? I know the article suggests a database / table, and that could work but I feel like there are a suite of things you'd want on top of that that aren't given for free -- JSON validation, history, libraries with caching, namespaces, etc. For this exact subproblem, I created www.config.ly .
- aszen 6y agoI had this realisation too, after spending countless hours searching the code bases with regexes to try to extract valuable information. Right now we have ide's that provide rich language support but they only expose extremely basic traversals over language symbols, for example I can't semantically query for all the deprecated classes in a particular package that have 3 or more instances. Right now we have to resort to grep and other text finding tool's to achieve the same functionality which is for all reasons not efficient or reliable. Once we can semantically query our code bases using a rich expressive language then we could visualise the system and gain richer understanding. Some of these idea's are being implemented in https://gtoolkit.com/ https://gtoolkit.com/, it's a fantastic tool built on one simple yet powerful idea that each object can be represented in multiple forms not just syntactic code.
- tudorgirba 6y agoThis is one succinct summary of what Glamorous Toolkit is!
- lumost 6y agoIt feels like DB technology is catching up to the cloud era. Back in the 2000s it was common for entire products to effectively be written as stored procedures, which carried a lot of benefits when it came to data consistency and performance. I'd bet good money that if Oracle didn't charge a C round, and it was easy to scale out RDBMSs with HA in the cloud that this era wouldn't have ended. Now that we have managed, fast distributed SQL DBs, with high availability - I wouldn't be surprised to see companies moving more logic back to the DB.
- chris_st 6y agoI remember learning AspectJ, and finally deciding it was a query language for your code.
- peterkelly 6y agoSomewhat related: https://www.unisonweb.org/ https://www.unisonweb.org/
- feifan 6y agoYep, I had a brief chat with one of their engineers a few days ago: https://twitter.com/FeifanZ/status/1361392018514010116 https://twitter.com/FeifanZ/status/1361392018514010116
- oftenwrong 6y agoThat reminds me of https://blog.darklang.com/how-dark-deploys-code-in-50ms/ https://blog.darklang.com/how-dark-deploys-code-in-50ms/
- erichanson 6y agoCheck out Aquameta, a web dev stack built entirely in PostgreSQL (self-plug): http://github.com/aquametalabs/aquameta http://github.com/aquametalabs/aquameta There's a ton down this rabbit hole. One of the great anomalies of our industry is that we've used the database to bring coherence to countless "user domains", but never applied the same principles to our own stack. The benefits of doing so compound exponentially.
- madhadron 6y agoLucid put C++ into a database back in the day. Didn't catch on, sadly.
- dimitrios1 6y agoDudes and dudettes let me tell you about this sweet technology called Oracle Forms.
- nerdponx 6y agoThis is wild and ridiculous and I am genuinely excited to try it in a project.
- feifan 6y agoWhoa, this project looks really cool. I'm trying to read the docs though, and there's a lot of broken links — e.g. all the "Backend Documentation" links here: https://github.com/aquametalabs/aquameta/tree/master/docs https://github.com/aquametalabs/aquameta/tree/master/docs
- deleted 6y ago[deleted]
- erichanson 6y agoYes, sorry. It's in a state of major upheaval. I'll get it cleaned up ASAP. Nice to see there's actually some interest in this direction from others!
- brundolf 6y agoI think you could drop the first "base" and just say "the data inside your codebase" Generally speaking if declarative data can be factored out of part of my code, I try and do that (in practice I'm usually doing this in JS, which is well-suited to that style). This makes it less opinionated about when and where it gets executed, or even how. It is simply information. It also allows for some neat reflective stuff as the author describes. Incidentally this has always been the calling card of Lisp: "code as data". I don't love Lisp as a whole, personally, but this is a powerful benefit of it
- nadagast 6y agoThis brings back thoughts I've had that we should be working with normalized data in code, rather than thick objects. I think the main reason we don't is because there's a lack of tooling around it in our languages. I think a system/language/library designed around this could solve some of the problems in the article as well. First class support for having only one value for a given domain specific id, relations, declaratively describing constraints, and strong querying seem like they would be very helpful to lots of programming problems in complex apps.
- jonahbenton 6y agoGood piece, tho not new ideas. Ton of references, two recent that immediately come to mind https://github.com/src-d/guide https://github.com/src-d/guide https://github.com/Datomic/codeq https://github.com/Datomic/codeq But work here goes back at least to the 1970s.
- feifan 6y agoThe future's already here, just not evenly distributed :) I wrote this in part to surface these ideas to new people!
- wiz21c 6y agoI'm pretty sure Eclipse or IntelliJ build a meaningful index of my code base... What about that ?
- jonahbenton 6y agoThey do but those aren't made available to you like a database, just through their search tool and indirectly through their contextual lookups. See also tools that build databases from code history, like https://www.adamtornhill.com/articles/crimescene/codeascrimescene.htm https://www.adamtornhill.com/articles/crimescene/codeascrime...
- polishdude20 6y agoThe article shows Blush and the visualization chart it can produce. Is there something like this for JavaScript already?
- polishdude20 6y ago*BlueJ
- jierenchen 6y agoGreat post. I see two big challenges. 1. How do you do this without changing the way we program? The most amount of value I would get from this kind of tool is being able to spelunk in a huge codebase with lots of legacy gunk. The cost of entry for this cannot be "rewrite all the codes." 2. What does the query language look like and how do you expose this to the user? This is especially challenging because the query language needs to serve so many different roles. I'm excited to see what comes of this as I see this problem as a blocker for the next generation of software development. We've more or less solved infrastructure, yet taming complexity still eludes us. Shameless plug, with a bit of fortuitous timing: I just released an alpha CLI for my project SourceScape. It's a tool that indexes your Typescript and Javascript code (Ruby coming soon.) You can then query your code by code structure instead of just raw text. As a trivial example, you can search for all classes with a render method that returns a jsx element with name div. Install instructions here: https://github.com/sourcescapeio/sourcescape-cli#install https://github.com/sourcescapeio/sourcescape-cli#install Marketing materials (a bit outdated, but looks pretty): https://sourcescape.io https://sourcescape.io
- tabtab 6y agoRe: "How do you do this without changing the way we program?" Let's change the way we program. If we outgrow trees, we've outgrown trees. I don't know if existing code will be easy to convert. It's kind of like when OOP IDE's fell out of favor for web stacks: the old OOP classes couldn't be reshaped for web because the web is state-poor and OOP is state-rich. We had to dump OOP libraries and stacks into the trash. Re: "What does the query language look like and how do you expose this to the user? This is especially challenging because the query language needs to serve so many different roles." I suggest using existing RDBMS and SQL. There's no reason to reinvent the wheel unless inherent flaws can be found in RDBMS for code management purposes. I haven't found any yet in my little experiments in "table oriented programming". I take that back a bit. Different UI components/widgets will have different attribute structures. It's hard to change the schema every time a new widget type is added. Possible solutions include Dynamic Relational, or a Windows-Registry-like "attribute tree" for UI models. Attributes of UI widgets then could be accessed like: setAttrib("screenX.widgetY.maxHeight", 37); // context-based shortcut: setAttrib("currentWidget.maxHeight", 37); The second form is handy because instead of writing explicit loops, event triggers may be used traverse and customize per-widget behavior. The traversal mechanism will create a reference to the "current" item per behind-the-scenes looping to simplify path references. More samples: // sequence control (display order): setAttrib("screenX.widgetY.sequence", 47.5); // deactivate: setAttrib("screenX.widgetY.active", false); // alternative: setAttrib("screenX.widgetY.status", "inactive"); // more uses of "status" attrib: setAttrib("screenX.widgetY.status", "hidden"); // Grid samples: setAttrib("screenX.grid4.row.7.col.9.value", "foo"); setAttrib("screenX.grid4.row.7.backGroundColor", "green"); Helper API's would probably simplify grid path management.
- mkl95 6y agoThis seems like a GNU Global use case https://www.gnu.org/software/global/ https://www.gnu.org/software/global/
- underyx 6y agoAt r2c, we've been using our own https://semgrep.dev/ https://semgrep.dev/ to search across our repositories and take inventory of certain things. For instance, we have a Semgrep rule that finds and extracts API routes and whether they require authentication. See page 27 for a visualization (PDF warning): https://owasp.org/www-chapter-dorset/assets/presentations/2020-10/OWASP%20Dorset%202020-10-08.pdf https://owasp.org/www-chapter-dorset/assets/presentations/20...
- Dirlewanger 6y agoAh, BlueJ...takes me back to Intro to CS where an entire class was spent on getting that program alone to run on everyone's computer.
- codeulike 6y agoC# and Visual Studio just does the whole 'Where is this used?' thing out of the box. And one of the intentions of the Roslyn compiler was to open up code analysis to the IDE even more, I believe.
- nsm 6y agoI am really glad they mentioned Smalltalk! I recently had a chance to experience Smalltalk and it was just mind blowing. Check out a video demo of the code introspection and visualization at minute 17 in https://m.youtube.com/watch?v=baxtyeFVn3w https://m.youtube.com/watch?v=baxtyeFVn3w
- tudorgirba 6y agoThat was a nice demo, indeed. If you liked that one, you might want to take a look at gtoolkit.com, too.
- DemocracyFTW 6y agoIt's really a shame the database is not at the base of what we're doing. We're inventing and re-inventing tons of file formats and ways to persist data without using the database, we have to eternally worry about race conditions in the file system and stuff, and all the while most of our concerns would be well served by an RDBMS. To be sure we still need file formats and persisting data to files so we can conceptually, read, understand, and pass around our data but when we work on it, when we deal with data, we should most of the time do that with a database. Except we don't. Just look at the mess that querying installation data from APT is. Startup time, functionality and search time of the synaptic GUI are abysmal.
- tabtab 6y agoFor a while I've been saying our stacks are outgrowing hierarchical file systems. Hierarchies force one trait to have more power than another, even though each may be very important at different times. There may still be inherent hierarchical patterns to the code, but that doesn't have to be our only view. Further, during compilation a file hierarchy may still be needed, but the IDE doesn't necessarily have to force that view during the normal course of dev work. It's mostly to make the compiler happy, not the developer. Related ideas: https://www.reddit.com/r/AskProgramming/comments/j6uivx/crud_frameworks_or_languages_that_are_flexible/ https://www.reddit.com/r/AskProgramming/comments/j6uivx/crud... I'm glad to see experiments along that line. I doubt anybody will get it right the first time, but technology often requires experimentation to make it practical. I just know that hierarchies are too constraining for non-trivial code bases. Typical CRUD stacks can be viewed as a big pile of event handlers. How all these events are listed, sorted, searched, filtered, etc. should be based on RDBMS or RDBMS-like tools to give as-needed views via queries and query-like interfaces, such as Query-By-Example.