Related
I'm new to web development, I'm discovering javascript and all its capabilities. I'm currently learning jQuery and it made me wonder: "what really is a library ?".
From some so/internet search I understand that jQuery is a library, although some people also consider it a framework as it help/force you to change the way you code js.
For me, a library is a set of functions and classes to help the programmers on a particular point.
As I understand it jQuery doesn't seem to only add function or classes contrary to other javascript libraries such as math, for example or even other jQuery plugins like datatables etc...
To me, jQuery at its base just looks like another way of presenting js code.
So to summarise my questions are:
Is jQuery a "normal" library like Math for c++, python or even js?
How does the js engine understand jQuery? (some sort of compilation ?)
Can every js engine understand jQuery as long as they have the jQuery.js file, or is there something already embedded inside the engine for jQuery.
I also took a look at this very interesting so post on Is a jQuery compiler possible?, but it just blurred me the line between library and jQuery even more.
Any hint or link to how js/jquery combine would be helpful!
Is jQuery a "normal" library like Math for c++, python or even js?
Yes. It's just a collection of functions, etc.
How does the js engine understand jQuery? (some sort of compilation ?)
jQuery is just code written in JavaScript using the standard features of the browser (the DOM, etc.). (Well, and some non-standard ones it feature-tests for to get around browser idiosyncracies.)
Can every js engine understand jQuery as long as they have the jQuery.js file, or is there something already embedded inside the engine for jQuery.
jQuery is designed for the browser environment, so it won't work correctly in a non-browser environment without additional dependencies (a DOM library, etc.).
For the avoidance of doubt: There's nothing you can do with jQuery that you can't do without jQuery, using JavaScript's standard library, the DOM API, and other browser APIs directly. All jQuery does is provide an alternate API for doing DOM manipulation, provide some utility functions, and define a standard way to add features to extend jQuery with more functionality (e.g., "jQuery plugins").
And for completeness:
jQuery is not a language, although it's a common misconception that it is. You don't do something "in jQuery" or "in JavaScript." The correct contrast is "with jQuery" or "with the DOM" (or "without jQuery").
There are other libraries which also fill the same sort of "make the DOM easier" niche, although jQuery is by far the most successful of them.
There are entirely different approaches to handling browser-based interfaces, provided by a spectrum of projects from libraries (like KnockoutJS and many others) through light(ish) frameworks (like React and others) to full-on frameworks (like AngularJS and many others).
Its pretty simple how you understand a library and a framework when it comes to jquery its a library because it dose'nt add any additional jquery approch whatever you see in jquery is present in javascript what jquery does is shorthand your code and help you chain functions which was not that much possible in javascript and when it comes to plugin they all are also part of javascript functions
I have written some javascript which reads data in a textarea (inside a browser)
and outputs the result in a string (as innerHTML) in a div.
It's brilliant and it does its job.
I would like to port it out of the browser.
I would like to reuse the same javascript (which effectively is just a function that given a string returns another string) out of the browser.
Ideally I would like to run it a commandline tool and say read file c:\input.txt and writes the response on c:\output.txt
Can somebody suggest how best I can achieve this ?
I looked around and came across to commonjs.org (which is very interesting) and node.js
(which is interesting too) as well as other obscure projects.
Yet, I still don't know how to do this. If somebody has done something similar I would like to hear.
Many Thanks,
p.s.
I tagged this question 'server-side javascript' mainly to say that it's not a browser question.
Rhino from Mozilla is javascript interpreter written in java which might do what you need.
If your're on a windows system, you could the native c-/wscript interpreter using the FileSystemObject to read and write files. Otherwise jsdb may be an option, where you can use the Stream-object.
http://RingoJs.org
It's a thin wrapper on top of Rhino. Makes dealing with files, modules, etc a lot easier, see for example: http://ringojs.org/api/master/fs/
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Is it a good idea to learn JavaScript before learning jQuery?
I am about to start learning JavaScript. However one friend suggested me to go in for jQuery instead since he says future is jQuery. I heard that jQuery is created from JavaScript.
In short, give me one simple reason why developers like me should invest in JavaScript. What is its future?
Part of being a good programmer is having an interest in understanding how things work. You can't understand how JQuery works without knowing JavaScript.
A good programmer has a diversity of skills. Knowing both the JQuery way to do things and the JavaScript-only way makes you more versatile.
Most employers who are looking for someone who knows JQuery are probably also looking for someone who knows ordinary JavaScript.
You can never achieve true expertise in JQuery without understanding JavaScript.
Sometimes even a fairly lightweight framework is more than you need.
If you don't ever learn to do things the hard way, you won't appreciate what's so great about doing it the easy way.
Moreover, if you start by learning to do things the easier way, you'll have that much harder a time motivating yourself to learn to do it the hard way.
Learning the language first without the fancy frameworks builds character.
Who knows, maybe you'll want to make your own framework someday. Or even work on a new version of JQuery. To do that, you'll need to know the language.
jQuery is JavaScript and yes, it makes things a lot easier for you and you can use it without much JavaScript knowledge, and yes, it will probably become even more popular in the future.
BUT: Wherever is jQuery, there will be JavaScript. jQuery is "just" a tool. You still need "plain" JavaScript to solve some problems, e.g. string manipulation.
Imho: You cannot master jQuery if you don't master JavaScript.
And there will be situations where jQuery might be not the best solution, e.g. when you really need high performance.
For me, this is similar to other questions I read here on SO about web frameworks and programming languages, like: Do I have to learn/know PHP if I want to use [Zend | symfony | CodeIgniter].
Seriously: If you don't understand the basics, you cannot use a tool efficiently.
JQuery is a library, written in Javascript, the language. It is almost always the case that learning the library without learning the language is impractical if not impossible, irrespective of the library and the language in question.
jQuery will come and go.
You are a web developer, right? Javascript is huge. Think how much time people spend using a web browser. The entire time they are interfacing directly with html dom, css, and javascript. Or, less and less, flash and "actionscript" (which is basically javascript).
Learn javascript, learn css, learn the dom. Refer to ecma-262 versions 3 and 5 and publications by w3c and whatwg. Read mozdev, cross-check msdn.
After that, take a look at jQuery if you want. You will probably find that you don't need it for 99% of the stuff people use it for.
Every browser has its own implementation of Javascript ( the language ) and the DOM ( library for manipulating elements on the page ). Because of the inconsistency of each browsers Javascript + DOM with another, jQuery ( created with Javascript ) was created as a wrapper that internally deals with these inconsistencies so you can use the easy API.
Underneath the hood, most of your problems are already solved for you so you don't have to think about issues like:
invoking functionality for the DOM ready event
a consistent way of attaching event handlers for click, mouseover and other events, attaching multiple functions to the same action
returning the proper values for elements as well as viewport ( window ).
Because jQuery is a Javascript library you won't master it without mastering Javascript. See my previous answer for recommendations for learning Javascript.
You do not need to know JavaScript in order to use jQuery.
This depends what you want of course.
If you want to put together web pages and don't consider yourself the 'programming type' or you simply don't like JavaScript, then don't bother, spend your time where it will matter most.
Your also asking this question on a site where majority of users are developers so your going to get a lot of people who say you should learn JavaScript, I say learn it if it interests you.
There are pleanty of jQuery solutions out there and support so that you don't need JavaScript.
jQuery IS JavaScript. When you are writing jQuery, you are writing in javaScript. All a library like jQuery consists of is a premade collection of functions you can use in your JavaScript programs.
So, you have to know JavaScript syntax and the core language in order to use jQuery at all. A good book for that is Douglas Crockfords the Good Parts.
What you do not need to know as much about is the DOM API, since that is mainly what jQuery smooths over for you. It helps a lot to understand the concepts of the DOM, though. You still need to know what an element is, and what attributes are.
You also need to know about CSS in order to use jQuery effectively. The key concepts here are classes, IDs, positioning, visiblity and display, among others.
Yes you CAN use jQuery without knowing JavaScript. In fact, I knew very little about JavaScript originally but by using jQuery it sparked my interest to learn it and so I did. Years later I can say I am very proficient with both.
As you progress in your programmer expertise you would find that you go from library writer to library user. This is quite natural and OK. When you are starting off, all you have is the basics. You write your code in terms of those basics and over time find that you need to bunch common code in a library for easier reuse.
Sometime later you find that someone has already done just that and created a library that's even better than yours. You then switch from being library writer to library user. jQuery is one such library and you really need to know JavaScript to be able to draw a line in your head as to where jQuery is and where JavaScript is.
My advice, in light of the above, would be to learn the underlying technology before getting started with the library (which is what jQuery is). However in this case I would make an exception - skip DOM manipulation. DOM is a stupid abstraction and will have you tear your hair out in no time flat. jQuery wraps it up quite nicely, might as well get stuck into that after you understand JavaScript basics.
you can read this
edit
However one friend suggested me to go
in for jQuery instead since he says
future is jQuery.
If you go for jQuery, of course you are still learning Javascript...
You can not understand jQuery if you can not understand how Javascript works.
Some programmers learning jQuery wihtout the knowledge of javascript thought that they are learning a new programming scripting language. But they did not know that jQuery is not. They are just using jQuery as a tool. They are still coding Javascript...
If you want your Javascript codes to be cross-browser,
with less hassle, go for jQuery... but still you need the basic (or at least) knowledge of Javascript.
This question already has answers here:
Closed 13 years ago.
Duplicate:
What are some of the pros and cons of using jQuery?
Should I avoid using a JavaScript library while learning how to write AJAX client code?
I've read it so many times... "I'd learn JavaScript before learning something like jQuery" - but is this really necessary for every situation? Sure, some people like to know what's going on under the hood, but are there any serious negative side effect of heading straight for jQuery tutorials/books? I want to learn something in my spare time and I've decided on jQuery (or JavaScript if anyone can convince me strongly enough).
jQuery is a library, not a language. You've essentially said, "I am thinking of learning how to write English songs. Some people say that you should learn English first, but I'm not convinced that it's worthwhile, I just want to rock."
You can probably still pick up jQuery without learning JavaScript first, but you ultimately will understand nothing of how jQuery is actually working and likely just come to accept that it's magic. Good luck when jQuery breaks or doesn't work how you expected it and can't figure out why your code is broken.
JavaScript is a beautiful language, and worth learning in its own right. Start here: Eloquent Javascript.
The reason of the typical recommendation "learn JS before jQuery" is because you'll find yourself too many times asking yourself how some jQuery snippet works, when it's not a problem of jQuery but JS syntax / etc (e.g. closures).
Go for JS, you won't be disappointed.
That's like asking if it's worth learning learning Objective-C before using Cocoa. It's kind of a weird question, because Cocoa is in Objective-C, much the same way as jQuery is written in JavaScript. When you learn jQuery, you learn some JavaScript whether you like it or not.
I think what you're wondering is more along the lines of "should I learn the underlying JavaScript that jQuery bypasses with its core library and plugins?" It depends on the circumstance, of course; if you need code in a hurry, you're much better off learning jQuery alone. But since your goal seems to be to learn something in your spare time, I personally think it's a good idea to learn basic JavaScript before diving into jQuery:
If you ever need to figure out how the internals of jQuery works, you'll need to know core JavaScript. This is especially important given how many jQuery plugins are out there.
If you ever need to extend jQuery or plugin functionality, you may have to know more detailed JavaScript.
If all you know is jQuery, you'll find it harder to work with other frameworks and/or vanilla JavaScript if you ever find yourself in that situation.
There is no question about it. jQuery is JavaScript. You'll be handicapping yourself severely if you jump straight into jQuery. Your code will be slow and unmaintainable. jQuery is an API, it's not a language.
In fact, you could try jumping into jQuery but I doubt you'll get very far without being frustrated with hurdles that would be otherwise trivial. At the very least, you should understand the concepts in Re-introduction to JavaScript.
It's very good advice actually.
The problem is this. Javascript doesn't work the same way most of the other popular languages work. If you dive into Javascript with the idea that it is similar to Java, C#, Perl, PHP, etc, then you'll end up thinking Javascript is a bizarre, inconsistent mutant language that makes no effing sense whatsoever. This isn't because Javascript makes no sense, it's because Javascript is different at its foundations. Javascript is an object oriented language, but it isn't class based, it's prototype based. The syntax is similar enough to where you could work just fine thinking Javascript was class based up until the point where everything goes horribly wrong.
Learn Javascript first, at least the fundamentals. It's not that difficult, you don't even need a special IDE or compiler since you can just use a browser or WSH. Learning the fundamentals of Javascript will definitely pay off if you're using jQuery.
A lot of learning and using jQuery comes for free to begin with and can be motivating as it provides an immediate sense of productivity. There does come a point however, where you need to understand JavaScript in order to use jQuery effectively or any other JavaScript framework for that matter. This is particularly pertinent for example, when writing plugins and utility functions.
For the same reason VB6 programmers needed to understand the Windows API to get anything done, and VB.NET and C# programmers need to at least know what MSIL looks like, you should be familiar enough with JavaScript to understand what jQuery is doing. There's a lot of far-out stuff built into JavaScript that most people never need to use, but if you don't know it exists, you'll always overlook good solutions to your problems.
JQUERY is just a library, not a substitue for language like JAVASCRIPT. You wont be going ahead in the field of the softare developement by just learning the LIBRARY. Basic understanding of the core langauge is always the better way to go. And of course, once you have that grasp, then you can and should definitley use libary like JQUERY.
I feel rather strongly that JavaScript is a more important concept than jQuery or any of it's siblings. These libraries are wonderful, and I can hardly imagine doing anything in the client without their help, but by themselves they only provide some tools and a bit of flashy polish. To actually accomplish any real logic, you will need a good understanding of JavaScript and the objects that are available in the browser.
Short answer to your question is yes if you ever have written anything in any normal language.
If you want to know why, watch JavaScript the good parts by Douglas Crockford (JS guru).
I was wondering if anyone could point to an Open Source date utility class that is fairly robust. I find myself rolling my own when I want to do a lot of things I take for granted in C# and Java. For instance I did find a decent example of a DateDiff() function that I tore apart and another DatePart() function. Another examples would be parsing different date/time formats. I'm trying to avoid reinventing something if it's already built.
Another possibility may be a nice set of Javascript files that I can convert to ActionScript 3. So far I've found DateJS but I want to get a good idea of what is out there.
as3corelib has the DateUtil class and it should be pretty reliable since it's written by some Adobe employees. I haven't encountered any problems with it.
There is also DP_DateExtensions, though I believe DateJS is more robust.