setTimeout drives me crazy. How can I implement "sleep" without going insane?
If you really, really wanted to you could create a busy wait sleep function, but it's an awful idea and you should never do it.
11–20 of 45 posts
setTimeout drives me crazy. How can I implement "sleep" without going insane?
If you really, really wanted to you could create a busy wait sleep function, but it's an awful idea and you should never do it.
What's your opinion of technologies like Node, WebGL, MooTools, and GWT? All are interesting to me but I'm not sure where to invest my time.
WebGL is something I haven't played with much, mainly due to small market share yet. With so much out there, I've had to prioritize on what to learn and when. I recommend http://learningwebgl.com/ to get started.
MooTools is mainly a client-side library. I've found that its syntax, like that of YUI and Prototype are excessive and limited. While you can use any library to get the same work done, I've stuck with jQuery because its just more natural for me to work with it. Its syntax, features, and widespread support are all positive reasons to use jQuery over other libraries.
GWT was designed to let Java engineers write javascript in Java. That's just a bad, bad idea. The resulting javascript code doesn't really take advantage of the language the way it was designed. It helps Java engineers feel like they can write web stuff, but really the end result is not often very pretty.
setTimeout drives me crazy. How can I implement "sleep" without going insane?
But, to answer your question:
// some code runs here
var continue = function(data){ //more code runs in here after sleep }
setTimeout(function(){ continue(data); },2000);
A different pattern:
var obj = { sleep: function(fn, time){ setTimeout(fn, time ); }, func1: function(data){ console.log('Continuing'); }, init: function(data){
console.log('Starting');
obj.sleep(obj.func1, 2000);
}
}
obj.init()I'm a desktop application developer still finding my feet on the web. Should I bother learning "pure" JavaScript or should I just learn a library like JQuery?
If you're a desktop guy, and MS based, learn some silverlight, it's very nice and also a MS-win7 phone. If you're not, Javascript + JQuery is the way to learn for the client side stuff, you also need a server side language (python, ruby, etc).
So what to do you? Do you even code javascript now or you use coffeescript and it's object creation strats (or do you use clojure, or whatever).
And another question: Do you use JSLint or something similar? What about if you want to validate javascriopt 1.7/1.8 syntax.
Earlier quoted context omitted.
If you're a desktop guy, and MS based, learn some silverlight, it's very nice and also a MS-win7 phone. If you're not, Javascript + JQuery is the way to learn for the client side stuff, you also need a server side language (python, ruby, etc).
If possible can you throw some light on which would be good for starters on server side language Python (which I am currently learning) from http://learnpythonthehardway.org/static/LearnPythonTheHardWa... OR PHP (which I already know)
In a browser, what framework do you use to handle file dependencies? As in I have foo.js which will only run if bar.js is loaded, I don't want to specify in my page: 1) load bar.js, 2) load foo.js 3) order matters... rather I want to say load foo.js (and implicitly it loads bar.js first)
Earlier quoted context omitted.
If possible can you throw some light on which would be good for starters on server side language Python (which I am currently learning) from http://learnpythonthehardway.org/static/LearnPythonTheHardWa... OR PHP (which I already know)
Python is generally considered to be the stronger language and certainly the one I would recommend.