4 ms·
I once considered teaching JavaScript as a first language, but the absence of synchronous user input made me reconsider. For example, there is no way to do thi
by tantalor 15y ago
I once considered teaching JavaScript as a first language, but the absence of synchronous user input made me reconsider.
For example, there is no way to do this in JavaScript,
> var line = read_line();
Of course you could use the prompt() function, but that only works in the browser, and it's an ugly hack.
- danmaz74 15y agoWhy is prompt() ugly? On the contrary, I think that for kids who grew up in GUIs, it is much more familiar and less intimidating than a prompt.
- tantalor 15y agoWith a standard prompt, you can see the previous output from the program and user input. But a popup window has no context, no history. Of course that's just my opinion. If it could help teach kids good programming skills then it should be used used.
- peterbraden 15y agoChrome, Firefox and Safari all have built in REPLs
- tantalor 15y agoREPL is not the same as standard streams (STDIN, STDOUT). You can build a REPL with standard streams, but you can't use a REPL like the WebKit console as standard streams. Where is your STDIN?
- danmaz74 15y agoThat's true - if your program works like a conversation. That's not always the case ;) You can give all the needed context by updating the page when needed.
- ZenPsycho 15y ago"Synchronous I/O Considered Harmful" or "I once considered teaching JavaScript as a first language, but then I found out it has no GOTO statements"
- tantalor 15y agoIt may not have GOTO statements, but JavaScript (ECMA-262 Ed. 3) does have its cousin, label-breaks, foo: if (1) { break foo; console.log("nope"); } console.log("yep"); https://developer.mozilla.org/en/JavaScript/Reference/Statements/break https://developer.mozilla.org/en/JavaScript/Reference/Statem...