←back to thread

-2000 Lines of code

(www.folklore.org)
506 points xeonmc | 4 comments | | HN request time: 0.003s | source
Show context
impostervt ◴[] No.44386164[source]
About 1.5 years ago I inherited a project with ~ 250,000 lines of code - in just the web UI (not counting back end).

The developer who wrote it was a smart guy, but he had never worked on any other JS project. All state was stored in the DOM in custom attributes, .addEventListeners EVERYWHERE... I joke that it was as if you took a monk, gave him a book about javascript, and then locked him in a cell for 10 years.

I started refactoring pieces into web components, and after about 6 months had removed 50k lines of code. Now knowing enough about the app, I started a complete rewrite. The rewrite is about 80% feature parity, and is around 17k lines of code (not counting libraries like Vue/pinia/etc).

So, soon, I shall have removed over 200,000 loc from the project. I feel like then I should retire as I will never top that.

replies(2): >>44386217 #>>44386712 #
1. motorest ◴[] No.44386217[source]
> The rewrite is about 80% feature parity, and is around 17k lines of code (not counting libraries like Vue/pinia/etc).

This is exactly where these comparisons break down. Obviously you don't need as much code to get passable implementations of a fraction of all the features.

replies(3): >>44386293 #>>44386392 #>>44387307 #
2. sshine ◴[] No.44386293[source]
>> is about 80% feature parity, and is around 17k lines of code

You make a fair point that a basic framework can be expressed with much less code.

And that the remaining 20% probably contains more edge cases with proportionally more code.

But do you think the last 20% will eventually make up anywhere near 233k lines of code?

The real save here comes from rewriting: seeing all the common denominators and knowing what's ahead.

3. Philip-J-Fry ◴[] No.44386392[source]
It's definitely a good argument for not reinventing the wheel though.

I'd rather have 250,000 lines of code but 230,000 of that is in battle tested libraries. And of which only 20,000 lines are what we ever need to read/write.

4. williamdclt ◴[] No.44387307[source]
I mean, you can get basic implementations of Vue and state management libs in a few hundred (maybe thousand?) LOCs (lots of examples on the interweb) that are probably less "toyish" than whatever this person had handrolled