4 ms·
I can't imagine what one would do with thousands of lines of awk, so that seems a little extreme. Awk is a pretty terse language, and that gives you plenty of
by rspeer 8y ago
I can't imagine what one would do with thousands of lines of awk, so that seems a little extreme.
Awk is a pretty terse language, and that gives you plenty of room to put in whitespace and comments and still have something short and sweet. I think that the idea of writing code to be nicely readable by your collaborators, or your future self, might not have been around in the early days of UNIX.
("But it's just a one-off thing I'm never going to do again, why should I save it to a file?", you may ask. Is what you do important? Then you'll probably have to do something like it again.)
- msingle 8y agoone could write an assembler - http://doc.cat-v.org/henry_spencer/amazing_awk_assembler/ http://doc.cat-v.org/henry_spencer/amazing_awk_assembler/
- rspeer 8y ago"aaa" is a fitting name because that's what I said out loud when I followed the link.
- eckza 8y agoI have a little repo called “cleversql”. It’s full of little scripts that represent hard problems that I’ve had to solve, clearly-named and well-documented. I fall back on it often, when I remember that I’ve solved a certain kind of problem before, but I cannot recall exactly how. It’s an invaluable asset and saves me tons of time on a regular basis. I’d rather search my OWN hard drive for an example of my OWN code for how to - for instance - use a CTE to recursively populate a date dimension table, than to search Google and see someone else’s code, to refresh my memory.
- Pamar 8y agoHave you considered making it (or part of it) publicly available?
- QasimK 8y agoI suspect a huge amount of the value of it is because it is personal, I.e. based heavily on his past experience. It means he is always just refreshing his memory rather than looking at something new. It’s why my Programmer’s Compendium [0] may only ever be useful to me. If you try looking at some of the more complete pages there, you might think they’re useless, but they’re, in fact, all that I need to write down. However, mine is public, and there’s not much harm in these things being public, because perhaps it can be useful to someone else one day. I would encourage people to share knowledge by default. So while I also think making it public is a good idea, I would also say never be under pressure to make it accessible to others! What’s good for learning is almost never good for reference. [0] https://qasimk.gitbooks.io/programmers-compendium/content/ https://qasimk.gitbooks.io/programmers-compendium/content/
- Pamar 8y agoWhat’s good for learning is almost never good for reference Maybe. But stuff like The Perl Cookbook helped me a lot in the past.
- vram22 8y agoThe Perl Cookbook is just great. IIRC I have it, though not looked at it lately. (Had read most of it earlier, though.) I also have the Python Cookbook for Python 2 [1] and for Python 3 [2]. Both those are great too. All three are by O'Reilly Media. It's not only that you get ready-made recipes that you can use; you get to learn a lot about language and library features and software design too, from such books. [1] The chapter on iterators and generators is excellent, and full of useful ideas and code snippets you can reuse and build upon. I think a large part of that chapter was written by Raymond Hettinger, who also has designed and implemented much of those features in Python, IIRC. This book is written by many contributors, for the different sections and recipes. [2] Interestingly, the Cookbook for Python 3 takes a somewhat different approach. It still has recipes, of course, but they are presented without too much discussion. The authors expect you to (and say so explicitly up front) use more of your time and thinking to figure out how they work (and to read the relevant Python and external library docs for the background information needed), rather than giving detailed explanations (not that the explanations in the previous edition are very detailed, but they are there). David Beazley and Brian Jones are the main authors of this one, IIRC. Both models have their merits, IMO. In fact, overall, I think the approach of the Python 3 Cookbook may be better, at least for experienced programmers, because it makes you think and do more on your own (using the book as a base), from which you grow more as a programmer.