4

[Disclosure: This question is slightly related to my previous question.]

As you can see, a few suggested that I learn JavaScript / jQuery / Node.js. From what I've read, (a) jQuery is a JS library that makes coding in JavaScript (that works across all browsers in one go) easier, (b) Node.js is a basically a server-side JavaScript environment, (c) Javascript is the root programming language of the aforementioned ones, and is client-side.

I have also read many questions regarding the same on SO, but for someone (like me) who has nil knowledge of any kind of programming, somethings aren't clear.

(1) Basically, my goal is to write a (real-time) live blogging/commenting application for my blog. This, I have learnt, requires a client-side scripting language like JavaScript. So, the question is, can I build such an application with (a) jQuery alone (b) Node.js alone?

(2) If the answer to (1) is YES: Do you think going with the server-side option - - Node.js would be better? (as jQuery definitely doesn't work on JS-disabled browsers, I don't know about Node.js.) Please advise.

(3) When I got a book for XHTML, the book got me started with HTML, and gradually took me into XHTML. So, there was no confusion between HTML and XHTML. Would that be the case with (a) jQuery and (b) Node.js too?

EDIT: (4) There's one problem with JS. Some users may have JS disabled in the browser. Is there any other client-side scripting alternative as good as JS? (Just asking)

That is, in order to learn, (a) jQuery or (b) Node.js should I first learn, JS or can I start with a beginner's jQuery or Node.js book right away? Which would be the right way?

I really need your advise here, as I am totally new to programming (and have very little time to study), and I am pretty excited of what's ahead.

(I used (a) jQuery and (b) Node.js whenever possible to denote that you consider them separately, and not think that I will be learning both. I can only choose one, at least for now.) Thanks.

DECISIONS! DECISIONS! For someone who may come here in the future searching for the same... From the answers it's clear that one can start with jQuery, and end up learning pure JS through practice (building applications, solving issues etc). It seems the learning curve, that way, would be longer?! (Because you end up having problems, keep trying to solve them, maybe lose confidence... blah! blah! blah!) Still that's good. What I've chosen is the straight forward way - JS first (until I feel like I've got some hold), and then go go jQuerying! I hope I am not wrong in my conclusion. :) {Thanks @Greg Pettit and @Pete Wilson}

Community
  • 1
  • 1
  • 1
    You _need_ to learn Javascript. You also need to learn the basics of HTTP, browsers, and client-server separation. – SLaks Oct 23 '11 at 00:37
  • I would be more than thankful if you can elaborate. (Any books). –  Oct 23 '11 at 00:41
  • hehe! Starting problem. When I am not wise enough to decide, I thought it's better to ask, and get it cleared. (:P) –  Oct 23 '11 at 01:22

5 Answers5

8

Node.js and jQuery perform two different roles. One facilitates server-side JavaScript, the other provides an abstraction library for client-side JavaScript. It's not one or the other. The question has to be branched into two directions:

  1. What server-side technologies do I want to use? Is PHP+MySQL (a known commodity) going to do what I want on the server side? Should I use something I'm already familiar with (ASP or whatever)? Or do I like the projected performance benefits and scalability of Node.js to jump into that? Does Node.js have mature enough Database classes to actually use it for my purpose?

  2. On the client-side, do I want to write everything with 'pure' JavaScript, or do I want to use a framework? If I use a framework, should I use jQuery because it seems to be the most widely-known, or do I research other frameworks that might do what I want? Furthermore, should I look into web application frameworks like Kendo UI or jQuery UI or piece it together with a JavaScript framework?

At some point, someone is going to tell you if you don't know JavaScript at all that you should start with pure JavaScript so that frameworks don't corrupt you. Me, I say phooey. You want to get stuff done. You don't want to spend your hours jumping through hoops when you could be just getting stuff done.

If you jump right into a framework (say, jQuery) instead of learning JavaScript properly, there are things that you will learn eventually anyhow. Before too long you'll realize that you didn't need to use $(this).attr('id') when you could've just used this.id. But it doesn't matter, because the former worked until you learned the better way.

I'm a former educator and very much in support of seeing results quickly, because it will propel you to learn more. Just because you start with jQuery doesn't mean you'll forever ignore 'pure' JavaScript. If you are an intelligent problem-solving kind of person, eventually 'pure' JavaScript will find you, and you'll begin to identify the right time to use it, and the right time to use a framework.

Greg Pettit
  • 10,749
  • 5
  • 53
  • 72
  • 3
    +1 for a very beautiful answer! But you should start with pure JavaScript because (1) it's easy as it's going to get and (2) if you start with Jquery you'll have to learn that **plus** pure Javascript anyway. To say nothing of the "corruption / pollution" effects :-) – Pete Wilson Oct 23 '11 at 01:08
  • 2
    Syntax-wise, yes, you'll still be doing JavaScript (jQuery IS JavaScript!). And you should know iterators other than .each(), that's for sure! I'll go halvsies with you: there's nothing stopping you from using jQuery as part of learning JavaScript. ;-) – Greg Pettit Oct 23 '11 at 01:15
  • Greg Pettit and @Pete Wilson : your answers have cleared the air for me. Thanks a lot. –  Oct 23 '11 at 01:31
  • 4
    @Greg Pettit -- "JavaScript will find you." I thought about this overnight; I dreamt about it, in fact. These four words completely encapsulate the pot of gold that every teacher (and parent) searches for. A very pretty and moving figure of speech that I won't forget. Thanks! – Pete Wilson Oct 23 '11 at 11:18
4

You should definitely start with learning Javascript first. I would read Eloquent Javascript to learn javascript at first. Then, learn jQuery and then node.js. For jQuery, I would say you should read jQuery in Action to learn jQuery.

tr4656
  • 1,298
  • 9
  • 16
1

For most web-applications, you need a server-side part. For the application you want to do, you need client-side Javascript. You'll have to do both parts.

For the server-side part, you can use whatever you please, whether it's Node.js, or PHP + the myriad PHP web frameworks, or anything else that can respond to HTTP requests.

Node.js and jQuery serve completely different purposes, it's unlikely you'll find a book that deals with both, and if you do, there's no "smooth" progression between the topics I can imagine.

jQuery does make use of certain idiosyncracies of Javascript (rebinding this), some of its nontrivial features (anonymous functions), and introduces several patterns on top (using literal objects for named/optional function arguments), so I'd recommend looking into JS at the moderately advanced level rather than just muddling though.

millimoose
  • 39,073
  • 9
  • 82
  • 134
  • two small Q. (1) I have seen many live blogging applications, like ScribbleLive (example) for [example](http://live.thisismynext.com/Event/Live_from_WWDC_2011?Page=0). It uses jQuery, right? From the page's source, I think so. (2) The problem is, some users may have JS disabled in the browser. Is there any other client-side scripting alternative as good as JS? –  Oct 23 '11 at 01:02
  • 1
    In ancient times (ten years ago) we *had* to worry about Javascript being disabled. That worry might still be justified in web pages that don't offer much user interaction. And there are still purists who insist on it. google "progressive enhancement" to see the interesting comments by these shellbacks. Nowadays imo it should not concern you: it's the rare user who does not have JavaScript enabled. Plus your job is to learn JavaScript/Jquery so please disregard this issue, at least for the time being. – Pete Wilson Oct 23 '11 at 11:34
  • 1
    @badlearner If the core functionality of your application (real-time chat) implies Javascript is (more or less) a necessity, you don't need to worry about progressive enhancement. Catering for users with Javascript disabled is mostly important for public content-based websites, where the important part is presenting the content and not the interactive functionality. – millimoose Oct 23 '11 at 11:41
  • @Pete Wilson and Inerdia: The problem is, it's not just about learning. I want to build a good opensource live blogging platform that anyone can integrate into their blog. And a live-blogging/live-commenting (aka real-time system) as this will not work on JS-disabled browsers. (I am more worried about IE7, IE8... should I be?) IMHO, this application is not about interactivity (concerning Live blogging), it's more about real-time presentation of an event to folks, without they having to refresh the page. I am probably worrying for nothing, that could be coz I am starting out. Thanks 4 chippi... –  Oct 23 '11 at 12:53
  • 1
    @badlearner In that case, "progressive enhancement" would be the part where you add new posts while the page is open. An acceptable degradation for people with Javascript disabled would be having them reload the page. An unacceptable design would be for instance loading a page with no posts, and only then loading the posts via Javascript, so that people without JS have no way of accessing the content. – millimoose Oct 23 '11 at 12:58
  • @Inerdia Have you heard of "WJS" - an enterprise JS library? Livefyre, a real-time comments system, uses it. I couldn't find any documentation at all for it. Not even on wikipedia. (I just came across it.) –  Oct 23 '11 at 18:47
  • 1
    @badlearner No, and looking at the Livefyre main page with a demo of the comment widget, I'd say they're not really using the library on Google Code, and "wjs" in URLs just means something like "widget JS". – millimoose Oct 23 '11 at 18:50
1

You should read javascript the good parts by Douglas Crockford, make a hello world with pure node.js then use express.js + socket.io or now.js. and mongodb for data persistence

nod
  • 399
  • 3
  • 3
0

Well it goes without saying to learn library of any language you need to learn the laguage first. But how you want to learn it is your choice, some people prefer to start with the library first then traverse bottom up to cover the basics of the language, while some other likes to get their hands dirty with basics of language before trying out advanced syntaxes and libraries. To add to it I should also mention jQuery and Node.js are totally different things and have different learning curve too. Node.js is more of a concept to enable javascript run at server side with asynchronus programming inbuilt. To learn node you will be learning some server level APIs like file streaming, logging, file system operations, callback etc which are typically server level tasks. Whereas to learn jQuery you would learn how javascript operate of doms and events, css , ajax etc on a webpage to alter those pages dynamically.

From application/website building point of view I would say to get started you need very little knowledge of nodejs but more knowledge of JQuery.

PS: If you are looking to build an website today in 2017 I would suggest to avoid jQuery altogether and go for client frameworks like angular/react.

ishandutta2007
  • 16,676
  • 16
  • 93
  • 129