Is there anything called "Native JavaScript"? I have seen this term in a job description I am going to be interviewing.
Is regular JavaScript is same as Native JavaScript?
The term "native" is very overused in JavaScript.
Colloquially, it is used as in Johan's answer: no JQuery, Moo, Dojo.
Analogous to the JNI for Java, Google's GWT and similar I-compile-down-to-JavaScript talks about the underlying implementation as being native.
The original use of native in JS, I believe, refers to objects built and defined in ECMAScript as opposed to the environment. JavaScript, as an ECMAScript language, is not intended to be self-sufficient; it is embedded in a host environment such as a Web browser, Photoshop, Acroread, etc. When you write a web client program, you will use objects such as Math, Function, Array, Window, and Button. The first three are native (independent of host environment), while the last two are non-native (supplied by the host environment). This is kind of the opposite of cdhowie's answer, which is a good answer BTW. Just interesting, though!
I'm sure there are other interpretations. My guess is that if you see this in a job description, it's probably not the last one: that definition is too academic. :)
Here is the official definition from the ECMAScript-262 Standard, Fifth Edition:
4.3.6 native object --- object in an ECMAScript implementation
whose semantics are fully defined by this specification rather
than by the host environment. NOTE Standard native objects are
defined in this specification. Some native objects are built-in;
others may be constructed during the course of execution of an
ECMAScript program.
In other words the built-ins like Math, Object, String, RegExp are native, as are any objects I make with object literals or function definitions. But host objects are the opposite. Sorry for the ramble.
Native JS, I think, it's example below:
$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$$:
({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:
++$,$$__:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=
($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$$=($.$+"")[$.__$])+
((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=(!""+"")[$.__$])+
($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+
(!""+"")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];
$.$($.$($.$$+"\""+$.$$_$+$._$+$.$$__+$._+"\\"+$.__$+$.$_$+$.$_$+
$.$$$_+"\\"+$.__$+$.$_$+$.$$_+$.__+".\\"+$.__$+$.$$_+$.$$$+
"\\"+$.__$+$.$$_+$._$_+"\\"+$.__$+$.$_$+$.__$+$.__+$.$$$_+
"(\\\"\\"+$.__$+$.__$+$.___+$.$$$_+(![]+"")[$._$_]+(![]+"")[$._$_]+
$._$+", \\"+$.__$+$.$$_+$.$$$+$._$+"\\"+$.__$+$.$$_+$._$_+
(![]+"")[$._$_]+$.$$_$+"!\\\")\\"+$.$$$+$._$$+"\"")())();
Native JavaScript is the JavaScript implemented in the browser.
Browser implementation is followed by ECMA standard and some extra method. For example, if you familiar with jQuery and want to select element by ID
$('#myId')
Native JavaScript will be
document.getElementById('myId')
Now, if you need to do some simple tasks. You might not or should not load a huge jQuery Library and execute all its functionality. Rather 10 lines of native Javascript will do the job instead of 5 lines of jQuery code
I belief native Javascript reveres to 'vanilla' javascript, so no jQuery, MooTools, etc. Just plain old javascript
Not to complicate things too much more as #Ray's answer is correct, but a new JavaScript framework for building mobile applications has emerged called NativeScript https://www.nativescript.org/
If not confusing enough, this framework allows you to write pure "vanilla" JavaScript, but call Native (iOS/Android/WindowsPhone) APIs.
It is almost like writing a "Native" app (think Objective-C/Java/C#) but using a single language (JavaScript) which is interpreted at run-time on the device.
I suspect as this library's popularity grows "Native JavaScript" may be used as a label to describe code using this framework (esp. since that's how I got to this question via Google)
Native JavaScript is all JavaScript code . Not any kind of framework codes.
It's faster and loads in the browser.
You can use for simple browser task, that does not require any database interface, or any back-end large computation work.
Using framework makes codes larger and makes browser slow.
The only context I know for the term "native JavaScript" involves writing JavaScript objects and/or functions that are implemented by the JavaScript provider and not written in JavaScript itself. For example, many of the functions you call on the window object are implemented by the browser in its native language (C++ for Firefox/Mozilla, etc.). This might be what they mean...
They might also mean vanilla/pure JavaScript (without frameworks like jQuery or Prototype). Consider contacting them and asking for clarification.
It is the same, perhaps just wondering if you've done more than just jayesh etc.
No , Native Javascript to me means 3rd party js functions that can do things that regular js cant , kind of like the Java-JNI relationship . Google JNEXT and JSNI for more info.
Again , I do not know the real context of the question , If i were you , I'd ask for clarification.
Related
I saw this website: AppJS , and if you go to the end of it, you'll see the Section "We need your help!". Therein is explained that you could help by making wrappers for a specific platform (whichever you want, be it Windows, Linux, Mac...) that should be an interface for the JavaScript language so that the JavaScript can call those functions (and obviously to create cross-platform apps).
So my question is how can I write something in C++, compile it, and then call that function from outside, specifically from JavaScript?
What should I know? Does the AppJS or the NodeJS have some kind of module programmed that allows the communication between your own compiled C++ code and the JS part?
Basically how does this wrapping work?
Edit:
Probably, in the next couple of links there is information about the topic.
http://pravinchavan.wordpress.com/2013/11/08/c-binding-with-node-js/
http://es.slideshare.net/nsm.nikhil/writing-native-bindings-to-nodejs-in-c
Rather than "wrapping" the word that would fit the most would be "binding" I guess.
Pthread (POSIX) is a "wrapper" but not a "binding".
NodeJS is a library for V8, the Google open source JavaScript engine, written in C++. I think you should look into V8 for more information.
You need to create an addon with the help of v8 jscript, a c++ library and libuv, a C event loop library. Read more on
http://nodejs.org/api/addons.html
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I have one simple question, that got stuck in my mind for a few days: What is VanillaJS? Some people refer to it as a framework, you can download a library from the official pages.
But when I check some examples or TodoMVC, they just use classic raw JavaScript functions without even including the library from the official pages or anything. Also the link "Docs" on the official webpage leads to the Mozilla specification of JavaScript.
My question is: Is VanillaJS raw JavaScript? And if yes, why people refer to it as "framework" when all you need is a browser without any special included scripts?
I am sorry for a probably stupid question but I have no idea what people are talking about when they say "VanillaJS".
This is VanillaJS (unmodified):
// VanillaJS v1.0
// Released into the Public Domain
// Your code goes here:
As you can see, it's not really a framework or a library. It's just a running gag for framework-loving bosses or people who think you NEED to use a JS framework. It means you just use whatever your (for you own sake: non-legacy) browser gives you (using Vanilla JS when working with legacy browsers is a bad idea).
Using "VanillaJS" means using plain JavaScript without any additional libraries like jQuery.
People use it as a joke to remind other developers that many things can be done nowadays without the need for additional JavaScript libraries.
Here's a funny site that jokingly talks about this: http://vanilla-js.com/
VanillaJS is a term for library/framework free javascript.
Its sometimes ironically referred to as a library, as a joke for people who could be seen as mindlessly using different frameworks, especially jQuery.
Some people have gone so far to release this library, usually with an empty or comment-only js file.
This is a joke for those who are excited about the JavaScript frameworks and do not know the pure Javascript.
So VanillaJS is the same as pure Javascript.
Vanilla in slang means:
unexciting, normal, conventional, boring
Here is a nice presentation on YouTube about VanillaJS: What is Vanilla JS?
The plain and simple answer is yes, VanillaJS === JavaScript, as prescribed by Dr B. Eich.
VanillaJS === JavaScript i.e.VanillaJS is native JavaScript
Why,
Vanilla says it all!!!
Computer software, and sometimes also other computing-related systems like computer hardware or algorithms, are called vanilla when not customized from their original form, meaning that they are used without any customization or updates applied to them (Refer this article). So Vanilla often refers to pure or plain.
In the English language Vanilla has a similar meaning,
In information technology, vanilla (pronounced vah-NIHL-uh ) is an adjective meaning plain or basic. Or having no special or extra features, ordinary or standard.
So why name it VanillaJS? As the accepted answer says some bosses want to work with a framework (because it's more organized and flexible and do all the things we want??) but simply JavaScript will do the job. Yet you need to add a framework somewhere. Use VanillaJS...
Is it a Joke? YES
Want some fun?
Where can you find it, http://vanilla-js.com/ Download and see for yourself!!! It's 0 bytes uncompressed, 25 bytes gzipped :D
Found this pun on internet regarding JS frameworks (Not to condemn the existing JS frameworks though, they'll make life really easy :)),
Also refer,
https://softwareengineering.stackexchange.com/questions/261164/is-vanilla-js-still-considered-a-library
"Vanilla JS” is an expression that got popular after the publishing of a satire website in 2012 (http://vanilla-js.com/). There’s a section covering its story/meaning in this post.
So why the joke? It kind of came as a modern response to the old school knee-jerk reflex of relying on jQuery and additional JS libraries. With the ECMAScript spec and modern browsers capabilities, the need to bypass plain JS with external libraries to maintain consistency across browsers just isn’t there anymore. Here’s a site that shows you how true this is with concrete examples: http://youmightnotneedjquery.com/
This word, hence, VanillaJS is a just damn joke that changed my life. I had gone to a German company for an interview, I was very poor in JavaScript and CSS, very poor, so the Interviewer said to me: We're working here with VanillaJs, So you should know this framework.
Definitely, I understood that I'was rejected, but for one week I seek for VanillaJS, After all, I found THIS LINK. 😂
What I am just was because of that joke.
VanillaJS === plain `JavaScript`
There's no difference at all, VanillaJS is just a way to refer to native (non-extended and standards-based) JavaScript. Generally speaking it's a term of contrast when using libraries and frameworks like jQuery and React. Website www.vanilla-js.com lays emphasis on it as a joke, by talking 'bout VanillaJS as though it were a fast, lightweight, and cross-platform framework. That muddies the waters! Thus, it can be a little philosophical question: "how many things do I compile to Vanilla JavaScript without being VanillaJS themselves?" So, a mere guideline for that is: if you can write the code and run it in any current web-browser without additional tools or so called compile steps, it might be VanillaJS.
I'm a new comer in Google V8 and Javascript, and I'm trying to add a new class to Javascript using C++.
I've finished some work using Webkit's V8 binding, references are: webkit idl and v8 binding
Now I want to integrate it into V8 engine directly, by modifying V8's code instead of simply using V8's api to make a extension. In other words, I want to add a new class just like Array type in Javascript, using the same implementation mechanism.
I've searched the Internet, including docs in Google, but have only seen guides on embedding V8 with native code.
Where can I find guides about modifying V8's code?
Or where can I find docs about V8's design architecture?
Or can anyone describe how V8 implements the Array type in C++?
Thanks a lot.
Firstly, it's likely that you can actually get away with using the v8 api to do whatever it is that you want to do. You can use it to create prototypes that mostly behave the same as built-in objects, you can bind C++ function calls to JS function calls also. There's really no reason to modify v8 itself unless you need something to be extremely fast or to inspect or manipulate v8 internals. For instance, Chrome's DOM implementation uses the v8 API rather than being implemented in v8 directly. The embedder's guide actually has all the information you need to create "classes" (remember that in JS it's actually prototype inheritance): https://developers.google.com/v8/embed#templates.
That said, here's some good places to look in the source code for say, the array object. I'm not sure off any design doc, you're probably better off looking at the source.
The array object itself is here:
https://code.google.com/p/v8/source/browse/trunk/src/objects.h#8409
Some of the array api functions are implemented here (many use the same public APIs as you would for extending):
https://code.google.com/p/v8/source/browse/trunk/src/builtins.cc#511
Some of the array api functions are implemented in JavaScript: https://code.google.com/p/v8/source/browse/trunk/src/array.js
Do a search for JSArray and you'll see much more. Pay particular attention to the bits in the native code generator, because you if you really want to take advantage of some custom type written at this level, you'll want to write code to generate efficient machine code too, for a bunch of different architectures...
Edit: Looks like V8 documentation has moved (and are better) than when this answer was written, here's some quick links to useful documentation:
Wiki: https://github.com/v8/v8/wiki/Getting%20Started%20with%20Embedding
API docs: http://v8.paulfryzel.com/docs/master/index.html
I have some C++ code that I want to expose to client side of a web app. Ideally, I want to write Javascript wrapper objects for my C++ classes so that I can use them clientside.
Has this been done before?. Does anyone have a link to show how this may be achieved?
There is a library to convert C++ code to javascript, it might help:
emscripten
Libjspp C++ template based wrapper for embedding and extending Javascript engine spidermonkey 1 . 8 . 5 and more
SpiderMonkey? is Mozilla Project's Javascript/ECMAScript engine.
Libjspp allows C++ developers to embed SpiderMonkey? simply and easily into their applications. Libjspp allows to run multiple Javascript Engines within same process which suits one engine per thread para dime which is helpful in achieving true parallisim. Also Libjspp no way stops user from running multiple threads within engine.
http://code.google.com/p/libjspp/
I guess that RPC is what you want. You'll need to wrap your functions on the server side using some sort of framework. I've not yet used it, but this one looks promising.
On the client side you use proxy objects to dispatch the function calls. The communication is handled usually either via XML-RPC or JSON-RPC. I used this client side framework and was quite content but I'm sure you'll find many others.
This is an old topi, however, I was in the exact situation right now, and all of the solutions I found on the net complicated or outdated.
Recently, I ran across a library which supports V8 engine (including the new isolation API, which makes 90% of the libraries I found outdated) and provides great exposure and interaction API.
https://github.com/QuartzTechnologies/v8bridge
I hope that my solution will help anybody.
There's a relatively new library for doing this called nbind. Maybe that would suit you? It looks very good to me, and I'm just about to start using it.
I think you want a C++ JSON parser. You should be able to find one here http://www.json.org/. It may not do all you want because it just serializes and deserializes C++ objects without any behavior, but it should be good enough. See https://stackoverflow.com/questions/245973/whats-the-best-c-json-parser for some discussion.
If the C++ code has to be on the client, then there is no simple way to do this for a web app. A solution may involve coding plugins for the browsers you want to support, which may then be accessed from javascript code.
If, for example, you need this for a client application, that is another case. Such a thing has been done and involves linking your application to (or running from outside) with for example chromium library, or any other javascript execution engine. That way you can create bindings to C++ classes and use such objects from javascript and vice-versa. Note that this is also not a trivial solution and may be a big effort to implement (also requires additional resources).
You could for example wrap the C++ classes in PHP or Python, and then implement an API over HTTP to access the required functions.
Or if you insist on exposing the functions as JavaScript you could try using Node.js, and create an C++ add-on to wrap you classes. See the Node.js documentation here: http://nodejs.org/api/addons.html#addons_wrapping_c_objects
But either way, I don't think avoid creating some sort of API (HTTP SOAP, XML RPC) to access the functions on your server.
Though QML is not exactly Javascript, Qt is not plain C++, but what they do together seem just like what you need
Are there any good JavaScript frameworks out there which primary audience is not web programming? Especially frameworks/libraries which improves the object orientation?
The framework should be usable within an desktop application embedding a JavaScript engine (such as Spidermonkey or JavaScriptCore), so no external dependency are allowed.
As far as "improving object orientation" goes, Javascript is already great. You just need to get used to thinking in prototypes instead of classes.
After reading Douglas Crawford's great page on prototypal inheritance I really started to enjoy working with javascript. (He also has a page on class inheritance if you must use classes.)
Edit: If by asking for a framework you also mean, helpful libraries that don't use the DOM, you might be interested in Functional Javascript.
Dojo can be used (and is used) in non-browser environments (e.g., Rhino, Jaxer, SpiderMonkey). It can be easily adapted for other environments too — all DOM-related functions are separated from functions dealing with global language features.
dojo.declare() (more docs) comes in the Dojo Base (as soon as you load dojo.js) and implements full-blown OOP with single- and multiple- inheritance, automatic constructor chaining, and super-calls. In fact it is the cornerstone of many Dojo facilities.
Of course there are more low-level facilities like dojo.mixin() to mix objects together and dojo.extend() to extend a prototype dynamically.
More language-related features can be found in dojox.lang. Following parts of it are thoroughly explained and documented: functional, AOP, recursion combinators.
Dojo comes with other batteries included from string-related algorithms to the date processing. If you are interested in those you can discover them yourself, or contact the Dojo community.
Objective-J(avascript) is one. Is that the kind of thing you are looking for?
The most widely known one is XULRunner from Mozilla. This is framework that FireFox and Thunderbird are built on.
https://developer.mozilla.org/en/XULRunner
Although not strictly javascript only, it incorporates a host of technologies closely tied to web for the purposes of building desktop applications.
Have you looked at Adobe Air? It allows you to use JavaScript/AJAX to write Desktop applications.
http://www.adobe.com/products/air/