JQuery: When does a library become a language?
skuunk.com
skuunk.com
jQuery uses Javascript more deeply than what you get out of a "Learn Javascript in Ten Minutes!" tutorial, but it's still just using the language. It is a library, not a language. If Javascript didn't have closure support, jQuery would be up a creek without a paddle. (We all would; without that feature JS programming would be an order of magnitude more nightmarish.)
And if you don't understand how it is using the language, you will not be able to use jQuery to its full advantage. There's no substitute for understanding.
He wouldn't be the first... Objective-C (the big language of the moment due to its use on the iPhone) was originally designed to be a preprocessor in front of a vanilla C compiler, which reduces most of the syntax additions down to one single library call. (This makes it a strict superset of C, unlike C++, which isn't perfectly backwards compatible with C.)
Also, it's not accurate to call something a "preprocessor" just because its target language is a subset of the language it supports. It's a compiler - a source-to-source compiler, yes, but still a compiler.
This was kind of my original point. The very first version wasn't a compiler, just a collection of pre-processor macros. I didn't have the opportunity to work with the language back when the bracket syntax was still macro'ed, but there were still some design warts in ObjC when I started before gcc was modified to support more modern, Java-like extensions to the language.... (I've written code that used the macro based NS_DURING/NS_HANDLER/NS_ENDHANLDER instead of the modern compiled @try/@catch/@finally version.)
As an aside, this got me thinking about compilers that can compile multiple languages in the same source file.. a kind of linguistic pick-n-choose... has anything been done along those lines?
What does this mean exactly? No language performs "magic" at a fundamental level. When I first started with programming in the early 80's, the distinction between library and language was just as blurry as it is now. Many of the Basics and Pascals I worked with made graphics drawing primitives language keywords, even though nowadays, these would be considered part of an OS's platform specific libraries. (Logo, in particular, was almost all graphics related keywords.)
arr.each { x | ...};
at that point it would be a different language rather than a clever fluent expression happy library.
I honestly don't think jQuery differs too far from writing ordinary JavaScript. Yes, it has a nice design, but it ultimately works because it plays to JavaScript's strengths rather than its weaknesses, and many of its other design decisions are forced by the limitations of the language and good practice.
In fact, one of the reasons jQuery is so popular is because it doesn't use one of JavaScript's most powerful and most misused tools by playing with the core language, whereas Prototype and Mootools make much more sweeping changes, blurring the line of where the library end and the language starts.
arr.each(function(el){...}); in Prototype as well, and you can attach custom method to JS array accepting functor "on the fly", it will look unfamiliar to beginners, but it will be still JS.
There is a definition for what author tries to explain:
Embedded Domain Specific Language
Here is the def:
http://c2.com/cgi/wiki?EmbeddedDomainSpecificLanguage
Many powerful languages provide cool constructs for creating embedded domain specific languages that look very different from the base language, just take a look at Ruby or LISP or C++.
You can also take a look at metaprogramming (writing programs that create other programs).
I just don't get this. There aren't many differences between the browsers these days in terms of js at all. Rendering? sure. CSS? definitely. But js, and dom manipulation pretty much just works. Event handling is slightly different, but not massively.
I really do think the "Allows you to develop cross browser" is vastly overplayed.
I've never had such issues, but then I don't like the whole concept of getElementsByTagName getElementsByClassName querySelectorAll etc
If you're just using getElementByID, and the standard dom properties to navigate the tree (And make sure you don't do bad things with name= id= or use reserved words), you can't go far wrong.