2012-05-01

Languages I’m Concentrating On

I’ve kind of decided that this year I’m going to concentrate on languages with a C derived syntax. So for the moment that means I’m focusing on the following languages…

  • C
  • C++
  • Awk
  • JavaScript
  • PHP

I’m haven’t decided if Java, C# or Perl fit the class of C derived syntax.


Node . Async File Reads

I figured out how to change my basic hello world blog server to read the blog file in a non-blocking fashion.

Basically instead of calling response.end with the file as an argument, you call file read, with a callback function that sends the data to response.end.

So it’s

fs.readFile('<filename>', '<encoding>', function (err, data) {
    response.end(data);
});

instead of

response.end(fs.readFileSync('<filename>', '<encoding>'));

It doesn’t matter because I’m using the http-server package which I assume already does that non-blocking, but I will check the code now that I’m thinking about it.

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s