Live data from Hacker News

Offer HN: I'll answer your javascript questions

news.ycombinator.com

31–40 of 45 posts

Re: Offer HN: I'll answer your javascript questions

#31

Earlier quoted context omitted.

Coffeescript is great in theory. The problem is that when debugging stuff in the browser, you're going to be looking at Javascript in Chrome Developer Tools or Firebug. You can hopefully do an inverse mapping from generated JS to the corresponding line in Coffeescript...but that's kind of a pain, especially because it's not a line for line conversion. Short of patching Chrome Dev Tools to support stepping through Cof…

That's a pretty lame excuse. There also isn't a simple line for line relationship between C code and x86 code or C# code and MSIL code. But there's a standard solution to this problem when debugging: let the compilers generate mapping information. For something like CoffeeScript, you'd probably have a debug compilation mode where each line of generated code is annotated with comments containing line numbers or full l…

As far as I'm aware, there is no such debugging mode for CoffeeScript. The current method of debugging really is to look in the JS and then find the corresponding CS code. They do make this easier by keeping the JS code as readable as possible.

Re: Offer HN: I'll answer your javascript questions

#32

Earlier quoted context omitted.

Coffeescript is great in theory. The problem is that when debugging stuff in the browser, you're going to be looking at Javascript in Chrome Developer Tools or Firebug. You can hopefully do an inverse mapping from generated JS to the corresponding line in Coffeescript...but that's kind of a pain, especially because it's not a line for line conversion. Short of patching Chrome Dev Tools to support stepping through Cof…

That's a pretty lame excuse. There also isn't a simple line for line relationship between C code and x86 code or C# code and MSIL code. But there's a standard solution to this problem when debugging: let the compilers generate mapping information. For something like CoffeeScript, you'd probably have a debug compilation mode where each line of generated code is annotated with comments containing line numbers or full l…

[deleted]

Re: Offer HN: I'll answer your javascript questions

#33

Have you tried CoffeeScript and what are your thoughts on it? It's clearly not 'done' yet but I found it really helps clean up my scripts, reduce the amount of typing and avoid a lot of tricky JavaScript mistakes.

Coffeescript is great in theory. The problem is that when debugging stuff in the browser, you're going to be looking at Javascript in Chrome Developer Tools or Firebug. You can hopefully do an inverse mapping from generated JS to the corresponding line in Coffeescript...but that's kind of a pain, especially because it's not a line for line conversion. Short of patching Chrome Dev Tools to support stepping through Cof…

The truth, (and a big part of the reason why we haven't already tried to solve this), is that it hasn't posed a problem for folks who are building apps in CoffeeScript. The transformation is straightforward enough that by glancing at the line number mentioned in the JavaScript, it's immediately obvious where the problem is in the CoffeeScript.

That said, I'd love to have a true solid debugger. The browser vendors (starting as soon as Firefox 4, perhaps) have plans to add better support for compile-to-JavaScript languages.

https://bugzilla.mozilla.org/show_bug.cgi?id=618650

http://intertwingly.net/blog/2010/11/25/Hobgoblin-of-Little-...

Re: Offer HN: I'll answer your javascript questions

#34
post #23

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?

You don't even need to learn javascript for web dev, checkout a project called Coffeescript.

I'm a big CoffeeScript fan, but I would never say just learn CoffeeScript and skip JavaScript. CoffeeScript is really just syntax and abstraction on top of JavaScript.

Re: Offer HN: I'll answer your javascript questions

#35

Earlier quoted context omitted.

That's a pretty lame excuse. There also isn't a simple line for line relationship between C code and x86 code or C# code and MSIL code. But there's a standard solution to this problem when debugging: let the compilers generate mapping information. For something like CoffeeScript, you'd probably have a debug compilation mode where each line of generated code is annotated with comments containing line numbers or full l…

As far as I'm aware, there is no such debugging mode for CoffeeScript. The current method of debugging really is to look in the JS and then find the corresponding CS code. They do make this easier by keeping the JS code as readable as possible.

Oh, I know. I was saying that it would be doable to implement.

Re: Offer HN: I'll answer your javascript questions

#36

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?

I feel in all cases of this questions (say RoR vs Ruby) the answer must ALWAYS be "learn the language first, then learn the framework". If you don't you will do the following: a) Write bad code (you barely know the syntax) b) Get really confused, and thus either start hating it, or simply not able to take full advantage of the framework. c) Do roundabout ways to solve a problem when there is a very simple solution, b…

However to note: jQuery makes dom manipulation fairly easy. It is in no way a replacement to javascript, only the browser's dom lib calls. You just wind up not writing a bunch of utility functions to handle the different ways to get at the same information in the browser. Plus I like the syntax.

Right, browser based JavaScript is kind of a special cases, the reality is that it can be a frustrating experience to even learn JavaScript without the aid of something like jQuery to smooth out the DOM.

My personal recommendation would be either learn JavaScript outside of the browser, chose only one browser to learn it in, or get "the Good Parts" as recommended, but start with jQuery and use "the Good Parts" to make sure you are doing it right while using jQuery.

The fact of the matter is, if you are doing browser work, which most doing JavaScript are, you are going to use a toolkit like jQuery in almost every project. So to me, it becomes almost part of learning the language. JavaScript toolkit are a little different from frameworks on the server side. They are more like language enhancers than a frameworks. So they are in kind of a "chicken and the egg" problem when it comes to making recommendations on which to start with.

Re: Offer HN: I'll answer your javascript questions

#37
post #29
post #6

Earlier quoted context omitted.

jQuery is just the de facto DOM API; learn them concurrently.

I wouldn't agree with this 100%. I principally use jQuery unless I am working on something that has to very lightweight. However, there are lots of libraries and different reasons people and companies use them. That's why it's important to know the language in detail so that you can switch between libraries as needed.

Right, there is also Dojo hanging out there for large browser Apps. There is a point in which you can outgrow jQuery due to the size and complexity of an application. Dojo kind of fills that upper end so while it is a smaller segment of the market, there are still other toolkits that hold their share of the market for what they are tailored for. In saying that, there are some newer, complementary projects like backbone that are trying to make large web app development in jQuery less painful, but as of right now Dojo owns that space and it remains to be seen if that will change.

Re: Offer HN: I'll answer your javascript questions

#38
Say i have a bookmarklet with the following code

javascript:(function(){q=document.getElementById("question-title").getElementsByTagName("b")[0].innerHTML.split(" ",3);})();

That is only a snippet of the code but you get the idea.

Is it possible to repeat the code every 3-5 seconds in a bookmarklet?

Re: Offer HN: I'll answer your javascript questions

#39
post #9

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)

PHP is not the best language anymore for most web development.

Ruby or python is probably the best choice, and I personally favor python.

Re: Offer HN: I'll answer your javascript questions

#40
post #37
post #29

Earlier quoted context omitted.

I wouldn't agree with this 100%. I principally use jQuery unless I am working on something that has to very lightweight. However, there are lots of libraries and different reasons people and companies use them. That's why it's important to know the language in detail so that you can switch between libraries as needed.

Right, there is also Dojo hanging out there for large browser Apps. There is a point in which you can outgrow jQuery due to the size and complexity of an application. Dojo kind of fills that upper end so while it is a smaller segment of the market, there are still other toolkits that hold their share of the market for what they are tailored for. In saying that, there are some newer, complementary projects like backbo…

http://www.dojotoolkit.org/
Post reply on HN