Daniel_Burfoot comments on Open thread, Jan. 12 - Jan. 18, 2015 - Less Wrong Discussion
You are viewing a comment permalink. View the original post to see all comments and the full post content.
You are viewing a comment permalink. View the original post to see all comments and the full post content.
Comments (155)
I'm a programmer with a fair amount of reasonably diverse experience, e.g. C, C#, F#, Python, Racket, Clojure and I'm just now trying to learn how to write good Java. I think I understand most of the language, but I don't understand how to like it yet. Most Java programmers seem to basically not believe in many of the ways I have learned to write good software (e.g. be precise and concise, carefully encapsulate state, make small reusable modular parts which are usually pure functions, REPL-driven development, etc. etc.) or they apply them in ways that seem unfortunate to me. However, I feel foolish jumping to the popular conclusion that they are bad and wrong.
I would really like a book -- or heck, just a blog post -- which is like "Java for Functional Programmers" that bridges the gap for me and talks about how idiomatic Java differs from the style I normally consider good and readable and credibly steelmans the Java way. Most of my coworkers either don't like the Java style, only know the Java style, or just don't care very much about this kind of aesthetic stuff, so none of them have been very good at explaining to me how to think about it.
Does this book exist?
I am a Java programmer, and I believe in those principles, with some caveats:
My feeling towards Java is just that it's a very reliable old workhorse. It does what I want it to do, consistently, without many major screwups. In this sense it compares very strongly to other technology tools like MySQL (what, an ALTER TABLE is a full table copy? What if the table is very large?) and even Unix (why can't I do some variant of ls piped through cut to get just the file sizes of all the files in a directory?)
Nerd sniped. After some fiddling, the problem with
ls | cutis that cut in delimiter mode treats multiple spaces in a row as multiple delimiters. You could put cut in bytes or character mode instead, but then you have the problem that ls uses "as much as necessary" spacing, which means that if the largest file in your directory needs one more digit to represent then ls will push everything to the right one more digit.If you want to handle ls output then awk would be easier, because it collapses multiple successive delimiters [1] but normally I'd just use du [2]. Though I have a vague memory that du and ls -l define file size differently.
(This doesn't counter your point at all -- unix tools are kind of a mess -- but I was curious.)
[1] ls -l | awk '{print $5}' [2] du -hs *
Your vague memory is probably that ls -l gives file size, while du give "disk usage" - the number of blocks used. On my computer the blocksize is 4k, so du only reports multiples of this size. (In particular, the default behavior is to report units of historical blocksize, so it only reports multiples of 8.)
A huge difference that I doubt you forget is how they define the size of directories - just metadata vs recursively. But that means that du is expensive. I use it all the time, but not everywhere.