A new approach to Storing code. Other tools try to recover structure from text; Unison stores code in a database. This eliminates builds, provides for instant nonbreaking renames, type-based search, and lots more.
Ask HN: Code should be stored in a database. Who has tried this?
31–40 of 51 posts
Re: Ask HN: Code should be stored in a database. Who has tried this?
#32> To me it seems obvious that code should be stored in a database rather than a hierarchical, text-based format. So, granted a filesystem does exhibit CRUD, and hierarchical relations, it's already a relational database. I take this as you are arguing about the utility of a text based format?
Re: Ask HN: Code should be stored in a database. Who has tried this?
#33There are programming languages that store code in some kind of non-hierarchical format. For example, Unison (https://www.unison-lang.org/) stores code in a database just as you suggest, and projects it down to text for editing. A more established example is probably Smalltalk, which stores the code as part of an image that is edited live in the Smalltalk environment.
On the other side, you can have filesystems that are not hierarchical, for example semantic filesystems like Tagsistant for Linux — these can be used for more flexible relationships between any kind of file, not just code.
Re: Ask HN: Code should be stored in a database. Who has tried this?
#34The folder structure reflects the subdivision of code into modules. Each module may have submodules, and each module decides the visibility of its children to other modules at the same level as itself, and to its own supermodule. This is a naturally hierarchical structure, which file systems lend themselves well to. A code database would have to replicate this structure within it somehow anyway.
A non-hierarchical tag system would help model situations where you have multiple orthogonal axes along which to organise the code (as you point out). But in these cases, which axis gets the top-level hierarchy just doesn't matter. Pick one, maybe loosely informed by organisational factors or by your problem conceptualisation.
On the flipside, in situations where a stricter hierarchy would improve modularity, the tag system might _discourage_ clean crystallisation, and cause responsibilities to bleed into each other. IMO, it's more important for there to be modules at all than for their boundaries to be perfect.
Re: Ask HN: Code should be stored in a database. Who has tried this?
#35I have been playing with the exact opposite, representing a database as a file structure where databases show up as top level folders, tables are subfolders, and each row appears as a form like file automatically generated from the schema. You can see a screenshot of such form in [1] which you can edit and save back, effectively enabling anyone familiar with Dropbox to edit data on a database as it just look like a f…
Re: Ask HN: Code should be stored in a database. Who has tried this?
#36Where are you storing code if not in a database?
> rather than a hierarchical, text-based format.
Okay, so you mean not a hierarchical database, but rather a... Relational database, I guess?
> The main way we navigate and organize code is by folder hierarchies.
Organize I can buy, I suppose. But I navigate by AST representation (as provided by an LSP in this day of age). It turns out code is a database too!
> Rather than folders and file names, everything could just be tagged in different ways.
So you are looking for WinFS? While it suffered from many technical issues, its biggest problem is that users really didn't gain much from it.
Re: Ask HN: Code should be stored in a database. Who has tried this?
#37Re: Ask HN: Code should be stored in a database. Who has tried this?
#38Yes, that's git, a filesystem, and an IDE -- and the physical layout of the code isn't the way I normally navigate it. It's useful structure for the tooling, though.
It's definitely true that "using git" or "putting our code on the filesystem" aren't ends in themselves, they are means to an end. If we found a way to meet our requirements that has fewer trade-offs to git then I'm sure we'd jump. Git and filesystems are possibly the worst options for organising code and history, except for all the other options out there :P.
Re: Ask HN: Code should be stored in a database. Who has tried this?
#39On the positive side, DevOps was a breeze - push a DB to a server and everything just worked. Pushing new code to all the DBs was a breeze. Any dev could immediately jump into an app and have a sense of where they would find elements of the app. All apps ran the same way, so it was realistic for small shops to deliver large products.
On the downside, source control was sub-optimal. That was a weakness in the platform even 25 years ago when it was modern, and never quite improved... although there are ways to import/export the code to make it work with modern source control like git. It also made each app heavier than it needed to be - instead of sharing centralized code, each app had its own copy. Your infrastructure footprint got big, fast.
For a modern take on it, I think other comments are hitting the key point - you might want to have fuzzier definitions of what a database and a file system are. At the end of the day, they are both ways of storing data to disk with different access methods. But it sounds like you are more concerned about DX. To get to your vision, I'd focus more on an IDE that lets you navigate code how you desire, while leaving the actual code storage as a DevOps exercise where they can focus on whatever solutions optimizes delivery and reliability.
Re: Ask HN: Code should be stored in a database. Who has tried this?
#40What benefits do you expect from this approach compared to the hugh number of tools that work very well with folders and text files?
Current Text based approach. 187 files changed.
Structured Data approach. Function Fobar changed to FooBar. Struct Baz field vargle changed to bargle.