3 ms·
How do you know the code is right?
by godelski 1y ago
How do you know the code is right?
- ic_fly2 1y agoThe LLM generated unit tests pass. Obviously!
- dkdbejwi383 1y agoIf customers don’t complain it must be working
- godelski 1y agoYou don't hear the complaints. That's different than no complaints. Trust me, they got them. I got plenty of complaints for Apple, Google, Netflix, and everyone else. Shit that can be fixed with just a fucking regex. Here's an example: my gf is duplicated in my Apple contacts. It can't find the duplicate, despite same name, nickname, phone number, email, and birthday. Which there's three entries on my calendar for her birthday. Guess what happened when I manually merged? She now has 4(!!!!!) entries!! How the fuck does that increase! Trust me, they complain, you just don't listen
- fsloth 1y agoThe program behaves as you want. No, really - there is tons of potentially value-adding code that can be of throwaway quality just as long as it’s zero effort to write it. Design explorations, refactorings, erc etc.
- godelski 1y agoAnd how do you know it behaves like you want? This is a really hard problem when I write every line and have the whole call graph in my head. I have no clue how you think this gets easier by knowing less about the code
- theshrike79 1y agoTests pretty much. Not a silver bullet for everything, but works for many cases. Unless you're a 0.1% coder, your mental call graph can't handle every corner case perfectly anyway, so you need tests too.
- godelski 1y agoNo one is saying you shouldn't write tests. But we are saying TDD is dumb. Actually, for exactly the reasons you mention: I'm not dumb enough to believe I'm a genius. I'll always miss something. So I can't rely on my tests to ensure correctness. It takes deeper thought and careful design.
- fsloth 1y agoBy using the program? Mind you this works only for _personal_ tools where it’s intuitively obvious when something is wrong. For example ”Please create a viewer for geojson where i can select individual feature polygons and then have button ’export’ that exports the selected features to a new geojson” 1. You run it 2. It shows the json and visualizes selections 3. The exported subset looks good I have no idea how anyone could keep the callgraph of even a minimal gui application in their head. If you can then congratulations, not all of us can!
- godelski 1y agoGreat, I used my program and everything seems to be working as expected. Not great, somebody else used my program and they got root on my server... > I have no idea how anyone could keep the callgraph of even a minimal gui application in their head Practice. Lots and lots of practice. Write it down. Do things the hard way. Build the diagrams by hand and make sure you know what's going on. Trace programs. Pull out the debugger! Pull out the profiler! If you do those things, you too will gain that skill. Obviously you can't do this for a giant program but it is all about the resolution of your call graph anyways. If you are junior, this is the most important time to put in that work. You will get far more from it than you lose. If you're further along, well the second best time to plant a tree is today.