I would like to post an example of what I think an everyday question with answer would look like in a new SE site I would like to call Code Translation.

User knows Perl, but is new to JavaScript:

Question [Perl > JS] How do I process stdin and print a result after reading the stream?

In Perl:

$output = "";
while ($line = <STDIN>) {
  # Do something interesting here...
  $output = $output . $line;
print $output

Another user who is fluent in both Perl and JavaScript:

In JavaScript you would first create an interface that exposes stdin and register callbacks to do something when (1) each line is read, (2) when the stream is closed / done, etc.

var readline = require('readline');

var stdin = readline.createInterface({
  input: process.stdin

var output = [];

stdin.on('line', function(line){
  // Do something interesting here...

stdin.on('close', function() {

This idea was more or less inspired by Rosetta Code. I think if used correctly, it would be useful.


You can already ask questions like this on Stack Overflow. It's one of the reasons to use SO, in fact.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .