Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



A 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!


Maybe I'm misreading you, but it sounds like you're saying "my coworkers made something with a really great UI and people loved it!"


Your 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.


Running a shell in a GUI doesn't make it lose its "I am a CLI" property. That is a CLI.


I 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.)


Or just use vim or any other editor smart enough not to try to slurp the whole file in one go.


Actually, mmapping the file should Just Work (tm)?


Do you not see the horrific syntax of what you just suggested as simple?


It'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 }'


In 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.


Sounds 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.


Are you arguing that shell scripts scale to larger applications better than C#?


The 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.


That 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.


:) touche


Wrong. 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%....




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: