Most active commenters
  • bironran(3)

←back to thread

-2000 Lines of code

(www.folklore.org)
506 points xeonmc | 17 comments | | HN request time: 2.075s | source | bottom
Show context
bironran ◴[] No.44382555[source]
One of my best commits was removing about 60K lines of code, a whole "server" (it was early 2000's) with that had to hold all of its state in memory and replacing them with about 5k of logic that was lightweight enough to piggyback into another service and had no in-memory state at all. That was pure a algorithmic win - figuring out that a specific guided subgraph isomorphism where the target was a tree (directed, non cyclic graph with a single root) was possible by a single walk through the origin (general) directed bi-graph while emitting vertices and edges to the output graph (tree) and maintaining only a small in-process peek-able stack of steps taken from the root that can affect the current generation step (not necessarily just parent path).

I still remember the behemoth of a commit that was "-60,000 (or similar) lines of code". Best commit I ever pushed.

Those were fun times. Hadn't done anything algorithmically impressive since.

replies(13): >>44382607 #>>44383577 #>>44383660 #>>44384143 #>>44384528 #>>44384875 #>>44385261 #>>44385550 #>>44385861 #>>44386549 #>>44386714 #>>44386823 #>>44388515 #
1. ifellover ◴[] No.44384528[source]
I’m a hobby programmer and lucky enough to script a lot of things at work. I consider myself fairly adept at some parts of programming, but comments like these make it so clear to me that I have an absolutely massive universe of unknowns that I’m not sure I have enough of a lifetime left to learn about.
replies(7): >>44384974 #>>44385333 #>>44385697 #>>44385739 #>>44386666 #>>44388151 #>>44390810 #
2. PaulRobinson ◴[] No.44384974[source]
Read some good books on data structures and algorithms, and you'll be catching up with this sort of comment in no time. And then realise there will always be a universe of unknowns to you. :-) Good luck, and keep going.
replies(2): >>44385334 #>>44385463 #
3. dev0p ◴[] No.44385333[source]
I've been coding for a living for 10 years and that comment threw me for a loop as well. Gotta get to studying some graph theory I guess?
4. fuzztester ◴[] No.44385334[source]
zen comment :)

uncatchable, so I won't even try.

replies(2): >>44386177 #>>44388478 #
5. neilv ◴[] No.44385697[source]
You could've figured out this one with basic familiarity with how graphs are represented, constructed, and navigated, and just working through it.

One way to often arrive at it is to just draw some graphs, on paper/whiteboard, and manually step through examples, pointing with your finger/pen, drawing changes, and sometimes drawing a table. You'll get a better idea of what has to happen, and what the opportunities are.

This sounds "Then draw the rest of the owl," but it can work, once you get immersed.

Then code it up. And when you spot a clever opportunity, and find the right language to document your solution, it can sound like a brilliant insight that you could just pull out of the air, because you are so knowledgeable and smart in general. When you actually had to work through that specific problem, to the point you understood it, like Feynman would want you to.

I think Feynman would tell us to work through problems. And that Feynman would really f-ing hate Leetcode performance art interviews (like he was dismayed when he found students who'd rote-memorize the things to say). Don't let Leetcode asshattery make you think you're "not good at" algorithms.

replies(1): >>44390614 #
6. amake ◴[] No.44385739[source]
(More than?) half of the difficulty comes from the vocabulary. It’s very much a shibboleth—learn to talk the talk and people will assume you are a genius who walks the walk.
replies(1): >>44390764 #
7. HenryBemis ◴[] No.44386177{3}[source]
do try (so you get the joy of 'small' wins), also do know that it's untouchable (so you don't despair when you don't master quantum mechanics in one lifetime)

:)

8. Cthulhu_ ◴[] No.44386666[source]
I want to believe a lot of these algorithms will "come to you" if you're ever in a similar situation; only later will you learn that they have a name, or there's books written about it, etc.

But a lot is opportunity. Like, I had the opportunity to work on an old PHP backend, 500ms - 1 second response times (thanks in part to it writing everything to a giant XML string which was then parsed and converted to a JSON blob before being sent back over the line). Simply rewriting it in naive / best practices Go changed response times to 10 ms. In hindsight the project was far too big to rewrite on my own and I should have spent six months to a year trying to optimize and refactor it, but, hindsight.

replies(1): >>44388521 #
9. weaksauce ◴[] No.44388151[source]
it’s just graph theory nomenclature. if you study an intro to graph algorithms it would get you most of the way there.
10. rangerelf ◴[] No.44388478{3}[source]
The more you know, the more you know you don't know.
11. geon ◴[] No.44388521[source]
Yes. I invented the Trie data structure when I was 19. It was very exciting finding out it had a name, and it was indeed considered a good fit for my use case.
replies(1): >>44389189 #
12. tired-chimp ◴[] No.44389189{3}[source]
Thats so funny, I had the exact same experience. And when I was 16 I "invented" csv's because I was too lazy to setup SQL for my discord bot. I like to think I've gotten better at searching for the correct solution to things rather than just jumping in with my best guess.
replies(1): >>44389734 #
13. bhaak ◴[] No.44389734{4}[source]
LLMs are pretty good at providing names and search terms for very vague prompts.

Although that's also often an invitation for hallucinations so you have to be even more careful than usual.

replies(1): >>44390615 #
14. bironran ◴[] No.44390614[source]
I despise leetcode interviews. These days, with coding LLMs, I see them as even less relevant than they were before.

Yet, you ask someone "how do you build an efficient LFU" and get blank stares (I just LOVE the memcache solution of regions and probabilistic promotion/demotion).

15. mikepurvis ◴[] No.44390615{5}[source]
I was just going to say the same— LLMs are great for giving a name to a described concept, architecture, or phenomenon. And I would argue that hallucinations don't actually much matter for this usage as you're going to turn around and google the name anyway, once you've been told it.
16. bironran ◴[] No.44390764[source]
That! It took me a while to start. My education of graph theory wasn't much better than your average college grad. But I found that fascinating and started reading. I was also very lucky to have had two great mentors - my TL and the product's architect, the former helped me to expend my understanding of the field.
17. meistertigran ◴[] No.44390810[source]
A lot if it is just technical jargon. Which doesn't mean it's bad, one has to have a way to talk about things, but the underlying logic, I've found, is usually graspable for most people.

It's the difference between hearing a lecture from a "bad" professor in Uni and watching a lecture video by Feynman, where he tries to get rid of scientific terms, when explaining things in simple terms to the public.

As long as you get a definition for your terms, things are manageable.