3 ms·
Here's another tip for juniors: Avoid Golden Hammer syndrome. Developers do deep work with a framework which ties them to a specific language and the accompany
by CaptArmchair 7y ago
Here's another tip for juniors: Avoid Golden Hammer syndrome.
Developers do deep work with a framework which ties them to a specific language and the accompanying ecosystem. So, what you see is the "not invented here" syndrome, and how already solved problems are tackled again in that specific ecosystem.
Many solstices ago, I was a PHP developer. If you'd ask me to split a 2.55 Gb CSV file in several CSV files as a one-off request, I would have fiddled with a PHP script, because that was my bread and butter. Probably would have taken something like https://csv.thephpleague.com/ https://csv.thephpleague.com/ off the shelf to get the job done.
Well, no, you can do exactly that in a single line with tail, head, split and cat.
Since I moved away from PHP, I have come to find a new, deep respect for the already existing general purpose commands which are part of the Unix spec. And reflecting on my earlier work, I realize that I could have solved some challenges a lot quicker.
Now, this is not a stab at clean code or PHP. Both are valuable tools.
Rather, a big lesson for young developers is that the cleanest code out there... is the code you didn't write at all, as you leverage what's already there.
- burntsushi 7y ago> Well, no, you can do exactly that in a single line with tail, head, split and cat. You can't, because csv records may span multiple lines. So dicing them with standard tools may subtly break them. Unless you know your particular CSV data only has single line records. (I take your broader point though. It's just that CSV is a bad example, because you usually wind up needing specialized tools to deal with them. It's likely that your PHP script would actually be more correct!)
- mynegation 7y agoThank you for xsv and other things, Andrew. To GP: also - CSV headers. Still possible in one line of shell, but it is starting to get unwieldy.
- CaptArmchair 7y agoThanks for clarifying that overlooked detail. I should have mentioned another lesson for junior developers: learn to understand the structure of your data and avoid making assumptions about formatting.