Codebase as Database: Turning the IDE Inside Out with Datalog (2020)
It&#x27;s not a new approach but actually a very old one. The author mentions Intellij but fails to note the history of Eclipse which, via IBM&#x27;s Visual Age, you can actually trace back all the way to Smalltalk, which arguably had one of the first modern IDEs three decades ago.<p>Smalltalk programs were stored in a database. There were no .sm source files on disk anywhere. It had a refactoring browser, which was a tool that allowed you to restructure the code. This came straight out of the first research papers on refactoring. It came with a class hierarchy browser as well. It was pretty amazing for the time. Smalltalk was very clever about exposing its internals to developers. Refactoring, introspection, reflection etc. were all things that it supported out of the box. And meta programming, which is something that came out of the Lisp community, was also supported of course.<p>Visual Age was basically built around IBM&#x27;s tooling for Java, which included an incremental compiler they built. A lot of the people involved with that had a Smalltalk background (it actually also was a Smalltalk IDE). It stored code in a database. Later, they created Eclipse which dropped the database but kept a lot of the compiler internals that allowed it to be way faster at refactoring and working with Java code than Intellij ever was. I use that every day and I still miss the two orders of magnitude difference in speed that Eclipse used to have. You must think I&#x27;m exaggerating. I&#x27;m not. Eclipse would be able to compile and be ready to run your code in between key presses. We&#x27;re talking milliseconds here. In Intellij it&#x27;s never less than 4-5 seconds and usually a lot more. Even on an M1. I have one. It helps. Faster is better. But it&#x27;s still slow. It&#x27;s just architected wrong to be that fast. It would need to internalize the compiler for it to be that fast and it just never did that. It relies on external build tools running via forked processes. It mitigates with a lot of (flaky) caching. That&#x27;s why it has a top level menu option labeled &quot;Invalidate Caches&quot;. Because cache coherence is a hard problem and they have plenty of bugs related to that.<p>So, it&#x27;s an old idea and a very good idea. The ultimate version of this idea would be intentional programming (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Intentional_programming" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Intentional_programming</a>) where the core idea is that programming is manipulating abstract syntax trees and that text is a mere serialization of that syntax tree. With intentional programming, you use tools (including editors) that do things with that syntax tree. Sadly, Simonyi, the person who came up with this never really got any traction with the company he founded out of Microsoft for this.<p>However, modern compiler design is finally starting to acknowledge that there is value in being IDE friendly. A compiler necessarily has to do a lot of the same things an IDE does but with very different requirements. Simply running a compiler from and IDE is slow and leads to a lot of repeated work. A much better approach is a compiler that exposes its internals to the IDE directly and runs incrementally. Like IBM did with Java in the late nineties. The Rust community has also been working on this lately and it&#x27;s a topic that you see discussed in the context of other compilers. And with VS Code gaining popularity, a lot of languages are now supported through language servers that expose (some) basic refactoring functionality and other things. Mostly this is limited by the underlying tools; i.e. compilers and interpreters. It&#x27;s nowhere near what Intellij does but it&#x27;s better than nothing. And it&#x27;s creating some stimulus for compiler makers to do better.<p>Jetbrains took their sweet time figuring that out (given they make IDEs and a major language) but their upcoming version of the Kotlin compiler frontend takes some steps in that direction as well. Java is slow in intellij. Kotlin is slower. Because the compiler is doing a lot of work and it can easily take something like half a minute to compile our code base; which isn&#x27;t that large. I love Kotlin but I don&#x27;t like how much time it sucks out of my day waiting for stuff to happen in intellij. And it needs to re-compile things quite often. The flipside is that it&#x27;s a very good IDE that provides a lot of time saving functionality. I have a love &#x2F; hate relationship with it. Love what it does, hate how slow it is doing it.