15 ms·
I'm becoming a stronger and stronger advocate of teaching command-line interfaces to even programmers at the novice level...it's easier in many ways to think of
by danso 12y ago
I'm becoming a stronger and stronger advocate of teaching command-line interfaces to even programmers at the novice level...it's easier in many ways to think of how data is being worked on by "filters" and "pipes"...and more importantly, every time you try a step, something happens...making it much easier to interactively iterate through a process.
That it also happens to very fast and powerful (when memory isn't a limiting factor) is nice icing on the cake. I moved over to doing much more on CLI after realizing that doing something as simple as "head -n 1 massive.csv" to inspect headers of corrupt multi-gb CSV files made my data-munging life substantially more enjoyable than opening them up in Sublime Text.
- hanoz 12y agoYour CSV peeking epiphany was in essence a matter of code vs. tools though rather than necessarily CLI vs. GUI. On Windows you might just as well have discovered you could fire up Linqpad and enter File.ReadLines("massive.csv").First() for example.
- Someone 12y agoRunning a shell in a GUI doesn't make it lose its "I am a CLI" property. That is a CLI.
- eropple 12y agoI disagree. It's a REPL, but a REPL is not always a CLI. (Frankly, most REPLs are smarter than shells. I go to irb way more than I do bash, these days.)
- hueving 12y agoDo you not see the horrific syntax of what you just suggested as simple?
- mc808 12y agoIt's pretty clear what it does. It's also C#, so building up to a less trivial task will be much less horrific than find . -type f -name '*.pgn' -print0 | xargs -0 -n4 -P4 mawk '/Result/ { split($0, a, "-"); res = substr(a[1], length(a[1]), 1); if (res == 1) white++; if (res == 0) black++; if (res == 2) draw++ } END { print white+black+draw, white, black, draw }' | mawk '{games += $1; white += $2; black += $3; draw += $4; } END { print games, white, black, draw }'
- kevin_thibedeau 12y agoIn a real production environment that command line would be put into a script parametrized with named variables and the embedded awk scripts would be changed to here-docs.
- peterhunt 12y agoAre you arguing that shell scripts scale to larger applications better than C#?
- mc808 12y agoSounds good although at that point it's just programming, and there are tools that are cleaner and faster and more robust than piping semi-structured strings around from a command line. The one real benefit that can be argued is ubiquity (on *ix). Not every system has Perl, Python, or Ruby installed - or Hadoop for that matter - but there's usually a programmable shell and some variant of the standard utilities that will get something done in a pinch. If it happens to be 200x faster than some enormous framework, so much the better.
- TylerE 12y agoOr just use vim or any other editor smart enough not to try to slurp the whole file in one go.
- eru 12y agoActually, mmapping the file should Just Work (tm)?
- alrs 12y agoThe example was a multi-gigabyte CSV file. You just sucked the whole thing off the disk into RAM so that you could shave off the first line. If you're unlucky, you started swapping out to disk about halfway through.
- chrishynes 12y agoWrong. ReadLines returns an IEnumerable<string> and lets you read line by line without loading the entire file into memory: http://msdn.microsoft.com/en-us/library/dd383503%28v=vs.110%29.aspx http://msdn.microsoft.com/en-us/library/dd383503%28v=vs.110%....
- recursive 12y agoThat code you're replying about was carefully and correctly written. You just replied as if you know how it works just so you could look like you know what you're talking about. If you're unlucky, someone who actually knows how File.ReadLines() works will show up in an hour or two and explain that it's lazily evaluated.
- alrs 12y ago:) touche
- Spooky23 12y agoA few years ago between projects, my coworkers cooked up some satirical amazing Web 2.0 data science tools. They used git, did a screencast and distributed it internally. It was basically a few compiled perl scripts and some obfuscated shell scripts with a layer of glitz. People actually used it and LOVED it... It was supposedly better than the real tools some groups were using. It was one of the more epic work trolls I've ever seen!
- jefftk 12y agoMaybe I'm misreading you, but it sounds like you're saying "my coworkers made something with a really great UI and people loved it!"