Chapter 27: New Project: Molly Tool No. 1

Reborn in 2010: The AI in My Brain Is Too Powerful! by yangxxxxxx

A few more days passed, and backpropagation in DeepFlow finally ran stably.

But Chen Yiran ran into a problem, and he'd reached his limit with it.

Namely, TextMate froze while he typed.

Not every time, but more and more often. He'd be flying along with both hands, working straight off Molly's knowledge, and then the cursor would inexplicably lock up, and it would take a second or two before the characters finally popped out. By then his fingers had already moved on, and sometimes keystrokes got swallowed and the whole line came out scrambled.

It felt, to Chen Yiran, like playing Audition, hitting the spacebar right in the groove, and then having the music suddenly cut out.

At first he assumed the file was too big. The DeepFlow code was already over a thousand lines. But surely that shouldn't matter? A normal Word document had way more characters than that.

Then he assumed it was memory. But a maxed-out 17-inch MacBook Pro with 8GB of RAM was hardly a weak machine in 2010.

"Molly, is our hardware just not up to it?"

Open Activity Monitor and check the resource usage.

Chen Yiran obediently opened Activity Monitor and took a look. TextMate was using under two hundred megabytes, the CPU occasionally spiked into the low teens percent, and most of the time it just sat there quietly.

Looks like a software problem. Shall we try a different editor?

Apple's bundled Vim and Nano were even harder to use — otherwise Chen Yiran wouldn't have shelled out for TextMate in the first place. A full fifty bucks, that had cost him.

Chen Yiran opened Google and searched for code editors on the Mac. The options in 2010 weren't exactly plentiful. He'd searched before: TextMate was the mainstream choice, but not the only one.

He tried Sublime Text first. The editor had come out in 2008, and it was genuinely fast — files opened almost instantly, with none of TextMate's stuttering. But it was far too bare-bones. It didn't even have code snippets, let alone autocomplete.

Writing Python in it meant managing your own indentation. Compared to TextMate, it was like trading a sedan for a motorcycle. Fast, yes, but extremely unfriendly to a human typewriter like Chen Yiran.

Then he tried BBEdit, the grand old man of Mac editors, around since 1992, with even more features than TextMate. But the interface was hideous beyond belief, like software from the last century, and its strengths were HTML and text processing. Writing Python in it was a miserable experience. It supported syntax highlighting for plenty of languages, sure, but code completion was essentially nonexistent.

He worked through the whole list and not one of them satisfied him. Either fast but featureless, or feature-rich but slow and ugly. In the end he went back to TextMate. Plenty of forums were buzzing about TextMate 2.0, but supposedly the author hadn't shown his face in ages. Everyone was guessing that 2.0 was stuck in development hell, if not outright dead.

So it was back to TextMate — and it froze again not long after he opened it.

"Molly, think of something, come on. Isn't there some simple way to optimize this?"

TextMate 1.x's text rendering engine is inefficient with large files, and it gets messier as fragmentation increases. There's no fixing that from the outside.

Remembering the little page-turning script Molly had written earlier, Chen Yiran thought: maybe it was time for a new project.

TextMate froze, Sublime lacked features, BBEdit was ugly, and he couldn't use Vim.

And their capabilities were mediocre anyway. When Chen Yiran made a typo, not one of these editors warned him. Other programmers didn't have a Molly running in the background flagging things for them — they'd type something wrong, carry the error all the way to the end, then have to backtrack and hunt down the misspelling.

In Chen Yiran's admittedly shallow understanding, this feature shouldn't be hard. Any typing software of the future had some kind of error correction, right?

And then there were rookie mistakes like unmatched brackets, which he committed two or three times a day minimum. Molly reminded him about a missing closing parenthesis who knew how many times a day. Ordinary programmers worrying about this stuff day in and day out — no wonder they went bald.

"Molly, you can get automatic correction when you're writing an essay. Type a word wrong in Word and it draws a red squiggle under it. Why is there nothing like that for programming?"

Error checking in code is far more complex than in natural language; it requires understanding the semantics of the code. BBEdit's feature list actually does claim error flagging — you just never triggered it, and it's presumably based on regular expressions plus the current file's cache. Which makes it fairly useless.
To implement the feature properly, you need an abstract syntax tree so the tool can read the structure of the entire project. TextMate currently doesn't support plugins. But — we could build our own editor?

"Exactly, that's what I meant. We can pull that off, right?"

In theory, yes. But it's not a small undertaking.

"Will it need a certain amount of inference computation and so on?"

Yes. I've given it a quick think. I can design a partial dirty-flag propagation algorithm, and we'll also need a mathematical model for incremental parsing, which is what keeps the footprint lightweight. We can write a code analysis process in pure C, and with Objective-C and the Cocoa framework we should be able to build a text rendering engine that handles unlimited line counts without stuttering.

Chen Yiran walked to the fridge and pulled two athletic ice packs out of the freezer — they'd only arrived a few days ago. He stuck one on his forehead and laid the other across the back of his neck, then grabbed two ice creams while he was at it.

He took out his phone and ordered three bowls of udon from Mayflower. From the snack shelf beside him he fished out a bag of Oreos and two energy bars, piling everything on the desk.

"Go, Molly! Fire it up! Just do it!"

He ate and browsed the web while waiting on Molly. Might as well survey the market first.

Over on Reddit, r/programming had another thread cursing out TextMate 2.0's endless delays, and someone down in the comments had written, "TextMate is dead."

Someone else had replied, "I love TextMate's simplicity, but the lack of real-time error checking is killing me. I have to compile just to find a typo. In 2010."

Well said. It was 2010 already — even Word could draw a red squiggle.

A few minutes in, Chen Yiran felt his body was no longer in any condition to keep reading web pages. All he could do was lie there like a corpse.

Every five minutes, Molly prompted him to take his temperature, so he didn't accidentally cook himself to death.

Fortunately, it stayed at a low-grade fever the whole time. Molly's earlier hypothesis — that the body had a self-protection mechanism, and that she'd start stuttering herself if his temperature got too high — seemed to be true.

But did that mean that if he ever actually came down with a fever, Molly would run badly?

He was drifting along on that thought when the delivery arrived. After three bowls of noodles left his little belly stretched taut and round, Molly spoke up.

The approach is basically worked out. I still didn't dare run inference too aggressively, so we'll need to do a little trial and error during actual implementation. But overall there's no problem.

"I probably won't understand it, but tell me anyway."

There are two core ideas. First, run the interface and the code analysis in separate processes. TextMate freezes because interface rendering and syntax analysis are crammed into the same thread — the moment analysis stalls, the interface stalls with it. Once they're separated, analysis can be as slow as it likes without affecting your typing.

"That's pretty much what browsers do, isn't it? Chrome makes every tab its own process."

Same principle. Second, code analysis can't just be regex matching; it has to genuinely understand code structure. That means a semantic analysis engine that parses the abstract syntax tree in real time, builds a symbol table, and tracks variable definitions and references. With that in place, you get real-time error detection and intelligent completion.
Not just recoloring keywords, but actually comprehending what you wrote. Where a variable was defined, whether you misspelled it, whether the brackets match, whether the function arguments are correct. Type something wrong and it gets flagged on the spot — no need to run it first.

"So we write it in Python?"

Semantic analysis requires traversing the entire syntax tree of the code, and Python isn't fast enough. It also can't interface seamlessly with the operating system's low-level application binary interface. The core framework needs to be written in C++ — only C++ offers both extremely high abstraction capability and lossless compilation down to machine code.
The .NET ecosystem has a mature metadata system and XML documentation, and we can use the Mono runtime for cross-platform support. We'll build C# support first, validate that the architecture works, then extend to other languages.

"And what's Mono?"

The open-source cross-platform implementation of .NET. Microsoft's .NET only runs on Windows; Mono lets C# programs run on Mac and Linux. If our compiler turns out well, it should be able to replace Mono — ours would be better, and it could support .NET directly.

"Molly, if we build this, will anyone buy it?"

Based on forum feedback, the demand for a better code editor is real. TextMate 2.0's delays have driven a large number of users to look for alternatives, and right now there isn't a single Mac editor that is simultaneously fast, full-featured, and capable of real-time error detection.
If our tool can do all of that, there's commercial potential. And since we'd also support .NET, there should be a market.

"Then we do this first. DeepFlow isn't urgent. Get the tooling sorted out and everything after that goes faster."

Understood. Project code name?

"Project code name: Molly Tool No. 1."

Understood. Project Molly Tool No. 1 is now underway.

This reader needs a modern browser to display fully. If you are using one, there may be network issues.