Copying stdin to stdout in Java
gist.github.com
Copying stdin to stdout in Java
1–10 of 61 posts
Re: Copying stdin to stdout in Java
#2Re: Copying stdin to stdout in Java
#3may want to link to the particular post in the gist :)
Re: Copying stdin to stdout in Java
#4Re: Copying stdin to stdout in Java
#5may want to link to the particular post in the gist :)
Yeah – what post?
Re: Copying stdin to stdout in Java
#6Earlier quoted context omitted.
Yeah – what post?
"Why I like Java" by Mark Dominus: https://news.ycombinator.com/item?id=7463671
while () {
print;
}
Still Awk is shorter: { print }
And if you are allowed change the switches of the command line to Perl for your program that Perl program can have exactly 0 bytes.Re: Copying stdin to stdout in Java
#7Re: Copying stdin to stdout in Java
#8Earlier quoted context omitted.
"Why I like Java" by Mark Dominus: https://news.ycombinator.com/item?id=7463671
Who never wrote it but assumed we know that the same program in Perl, without using command line switches is while ( ) { print; } Still Awk is shorter: { print } And if you are allowed change the switches of the command line to Perl for your program that Perl program can have exactly 0 bytes .
By default, unless you use the BEGIN block or something, awk will run your program on each line of stdlin. This is useful for programs of the type:
(/some regular expression/) { some action}
The default action if you don't specify one is "print $0" (the whole matching line). If your condition is a plain-ol' expression rather than a regular expression, and it always evaluates truthy, you thus get every line.
Re: Copying stdin to stdout in Java
#9I don't hate Java, but "Java as it is spoken" does not often get used for Unix-style piping in a chain of small programs on a command line. It also isn't the easiest tool in the drawer if you want to do light (or heavy) string processing.
Re: Copying stdin to stdout in Java
#10Earlier quoted context omitted.
"Why I like Java" by Mark Dominus: https://news.ycombinator.com/item?id=7463671
Who never wrote it but assumed we know that the same program in Perl, without using command line switches is while ( ) { print; } Still Awk is shorter: { print } And if you are allowed change the switches of the command line to Perl for your program that Perl program can have exactly 0 bytes .
Your example is very much just a special shortcut for one special condition. It's not generalizable in the same way. And let's be honest - most of today's code is not writing to standard output, it is writing to some iOS or Android GUI or outputting JSON to be used in some javascript webapp. That kind of shortcut just doesn't make sense anymore and is a relic of a different time.