vbscript is bad since it will only run in Internet Explorer. vbscript is good because it runs from the command prompt with csript progra.vbs.
javascript is good since it runs in any browser. javascript is bad since it won't run from the command prompt.
The last two days I have been working on feeding pgn files to a chess viewer. See here and here.
I first wrote a program for converting Yahoo Games chess game recording to pgn chess recording using vbscript. Why? Since I wanted to refresh my vbscript programming skills and because I wanted to create a modify a file something I did a bit of a year ago when I worked as a developer in a bank.
When I had published the vbscript program on the web page I thought it might be kind of fun to see the translation live using two text boxes and javascript.
So, the last few hours I have translated from vbscript to javascript. Quite a fun exercise!
If you are interested in checking out my translation, here are the two files: vbscript, javascript.
Who came first and why are they so different? Wikipedia reveals little on the matter: vbscript or javascript. By the way, the new guy in town is called Ajax.
This is what I thought happened:
Q: We have this meeting to come up with a scripting language. On my left a Netscape representative and on my right a Microsoft representative. Let's start with something simple. What is the smallest natural number?
N: That must be 0.
M: I hate to say this, but you are wrong. Everyone knows that 1 is the smallest natural number.
Q: So in an array called arr what is arr(1)?
M: The first element in the array.
N: The second element in the array. And it should be written arr[1] as it is not a function.
Q: OK. Now most people believe that 4 is different from 5. How should this be expressed?
M: 4 <> 5. If 4 is less than 5 or greater than 5, it is obviously different from 5.
N: 4 != 5.
Q: Let's move on. A block of code, how should that be indicated?
N: "{" at the start and "}" at the end.
M: Depends on the block. One example: "if" at the start and "end if" at the end.
Q: How do I find the third character in a string called board?
M: mid(board, 3, 1).
N: board.substring(2, 3).
Q: Quite! And the ascii value of that character?
M: asc(mid(board, 3, 1).
N: board.substring(2, 3).charCodeAt(0).
Q: And if that character is "s"?
M: instr(mid(board, 3, 1), "s") > 0.
N: board.substring(2, 3).indexOf("s") != -1
...
Here is a page that does some code comparison between the two languages.
Sunday, May 06, 2007
Subscribe to:
Posts (Atom)