Wednesday, August 22, 2012

Playing with javascript

I find myself facing a wall with javascript/node.js.

I went through the basics of javascript today. Except for the syntax (grammar) and a few differences in how processes are made, they are pretty much the same. Almost.

I decided to test what I have learned by following a python tutorial on how to create games. In the first chapter, there was a line in the script where the program asks for user input.

With ruby, we use gets.chomp. In javascript, there is ,code>prompt, but I couldn't find a way to use prompt with console.log.

I could have used alert or something that's similar, but I did not want to have to run the script through a web browser. That's what node.js was for, so I can run javascript without a browser.

I found a module called prompt, but it's a few lines long, and I'd have to install the module so I can run it. Why can't I just ask for user input through the node.js REPL?



I found a nodejs web framework that seems to be similar to ruby's Sinatra.

Here too, I found myself facing a wall. It wasn't that easy to work as Sinatra was. Maybe it's because nodejs is low-level(-ish) type of language... not like C or C++, but surely not like python or ruby. I did find a few tutorials on how to create a simple blog.

No comments:

Post a Comment