Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
After learning about dplyr and ggplot2, I've decided to start coding exclusively in R. Where can I find an R-to-JavaScript compiler, so I can build extensions for Google Chrome?
I am willing to write one myself, but it would have to be in R.
R works well as a special purpose math oriented language purely because the R interpreter/JIT and runtime is highly optimized.
Not unlike MATLAB or Mathematica or even using numpy with python
If you were to transpile R code to JS, it would be quite poor in comparision and would be unable to efficiently perform all the complicated computations you would typically do in an R program (if your R code is really doing non-trivial computations)
There doesn't seem to be any project that does R to JS compilation - seems like it is not really something people would really require.
I think the ecosystem of Javascript only Chrome extensions is a poor fit for running R code in.
If you were running FireFox or IE, you could call DLLs from within extensions - using COM on IE and the FF native bridge API. Chrome doesn't support such a thing directly.
The answer is to write an NPAPI plugin - this is a bit of native code implemented as a DLL that can be accessed from JS, via an OBJECT tag. I have used this to write an extension that replaces Flash video controls with a windowless VLC player on Chrome, FF and IE.
This is the best way to do it. Write your R code, make it a DLL, expose the interface via an NPAPI plugin. In your extension, inject an OBJECT tag into the HTML, which will instantiate your native code instance - after which you can call methods on it directly as if it were a JS object.
The next best thing I can think of is - Translate R to MATLAB, convert MATLAB to C++ (which is possible) and then run the C++ as native client code in the browser.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm new to JavaScript, and just started learning about Document Object Model.
I came to an understanding that DOM is actually not a "core/default" library of JavaScript rather developed by W3.org as a programmatic model to work with HTML.
I have also learnt that JQuery is also a library built ON TOP of JavaScript just like AngularJS NodeJSN etc.
So my question is:
Does Javascript have a core library?
And is JavaScript actually useful without relying on third-party libraries in 2015?
Are there examples of programs/products that just use Javascript without any third-party libraries?
There is a set of core JavaScript functions, and a specification to detail these functions and their behaviors. This is sometimes known as ECMAScript and common support is for version 5 (aka es-5).
There are a great number of functions available to you in here, from DOM manipulation, creating/modifying arrays and even HTTP requests. Essentially every library that you see, is just a wrapper on top of the core JavaScript functionality to make your life easier.
A great example of this is http://youmightnotneedjquery.com/ which gives examples of how to do things in vanilla JavaScript. Here's a simple comparison from their site:
has class in jQuery
$(el).hasClass(className);
has class in pure JavaScript
if (el.classList)
el.classList.contains(className);
else
new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
This quite clearly shows how jQuery can make things easier, but you can also achieve what you want in pure JavaScript.
Does Javascript have a core library?
The language itself doesn't have any means of interacting with anything. It relies on being run in an environment where it can interface with something useful, for example running in a browser and interfacing with the DOM objects.
JavaScript is also used in environments completely different from a browser, like in the web server platform Node.js where the environment allows JavaScript to respond to web requests and access system resources.
Is JavaScript actually useful without relying on third-party libraries
in 2015?
Yes. You can do anything without a third party library that you can do with one, you just need to write more code yourself. Third party libraries are only used for convenience.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm diving into web development again (first time was an utter failure), and I have some pretty spectacular resources for learning both HTML5 and CSS3. What I want to begin studying next is JavaScript so I can have absolute control over my pages. But before I begin integrating JavaScript into my work, I'd like to use JavaScript solely as a programming language (with console I/O and basic programs) to familiarize myself first. What are the best tools for accomplishing this? Because thus far, I haven't found any browser/tool that approaches the simplicity of writing a source file, and clicking run like you might with a C++ program. Thanks.
Node.js is your best shot.
Node is used for:
Server-side applications (Sails, Express, Socket.io)
Various frontend-related scripting (Grunt, LESS)
You can try Node.js, that allows you to run Javascript programs from commandline. Other than that, Javascript runs in a browser.
I think JetBrains makes the best IDEs in the world. Their support of JavaScript, HTML5, and CSS3 is first-rate. I'd recommend looking at WebStorm as your IDE.
I would recommend jsfiddle.net which allows you to type and run code. I might also suggest codecademy.com which has a very good program to teach you javascript and many other languages as well. There is also a really simple part of there website called "codebits" where you can compile js, html, and css and play around. W3schools.com is also very helpful for reference.
If you are running windows, the Windows Scripting Host (WSH) can run both Visual Basic Scripting and JavaScript... with the JavaScript having full access to things.
Because Microsoft supprorted VB Script over JScript (their version of EMCAScript), it is difficult to find documentation, though it does exist. I have a fair number of admin tools written in JScript.
Because that's not how Javascript works. You can't read user input from console.
You can use any browser's development tools and write Javascript code line by line.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm working on a browser based game atm and already looking into options porting it to other platforms such as consoles or devices where playing in a web browser may not be suitable.
The game is pretty much all JavaScript with rendering done via a 2d canvas context.
What i was hoping for is that there is already a c++ library/api that will work in conjunction with maybe google's v8 engine to handle the canvas calls in JavaScript and render them with opengl or something similar
Does anyone know of a project out there that may be providing this functionality?
Otherwise how would you suppose I go about embedding my javascript in c++ with as little changes required to the javascript as possible as I don't really want to have to maintain too many differences between platforms?
Qt is a very nice C++ library compatible with LGPL licensing that among other things includes a webkit based widget with javascript support. Also as scripting language Qt uses javascript with a tight integration with C++ (it's easy to write a C++ class and and make it visible at the javascript level).
Qt is multi platform and comes with an highly sophisticated IDE.
Qt is not currently using V8 but the porting is in progress and they aim at providing a 100% backward compatible solution.
The only "problems" of Qt are IMO that:
It's huge
It's a framework, not a library. You cannot just "use" Qt easily, you should embrace the view (the documentation is however of excellent quality).
The long term prospects are a bit fuzzy (not as bad as a few months ago, tho)
I guess I'm a bit late here, but I'm searching for a similar solution. I found node-canvas and I do not know if it is feasible to hook that so it renders into something like an SDL or SFML-managed window or not.
But for my own purposes, I will port my code over to C++ and use Cairo directly with SFML and OpenGL.
Interesting idea - another possibility is using Adobe Air, and rendering the game via StageWebView and Flex 4. Here's some example code for using the thing if you're interested:
https://github.com/JustinBeckwith/frink/blob/master/frink-flex/src/controls/WebBrowser.as
An interesting Project that I have uses id FireBreath(firebreath.org). This is not exactly what you are looking for, but in some ways it would get you close. Firebreath allows the creation of browser plugins in C++. One of the features of Firebreath is it allows you to access and modify the DOM from the C++ in you browser plugin as well as create methods and properties in C++ that can be accessed from JavaScript on your page.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there a plug-in for Firefox that would allow user's Javascript code like Greasemonkey and be able to browse from page to page?
I'd like to write a script to:
Log in to a website.
Follow several links.
Make a GET request to that host periodically with given data and time intervals.
Make a POST request based on the results of the previous in-loop requests.
Now I use Python's mechanize for a browser so I'm looking for something with similar (maybe not that rich) functionality within Firefox. Do you have experience with that type of things? What should I check out?
Selenium - which has an interface for recording and running tests inside the browser but can also export tests in many languages including Python for running as a suite in the SeleniumRC tool.
Or
Chickenfoot (You'll probably need to use setTimeout for the repeating requests.)
(source: mit.edu)
You also have iMacros
The software's description on Mozilla Addons says :
Automate Firefox. Record and replay
repetitious work. If you love the
Firefox web browser, but are tired of
repetitive tasks like visiting the
same sites every days, filling out
forms, and remembering passwords, then
iMacros for Firefox is the solution
you’ve been dreaming of! Whatever you
do with Firefox, iMacros can automate
it.
(source: extjs.com)
I would recommend Selenium RC. It comes as a Java command line tool and allows you to remote-control both Firefox, IE and Safari. Although it is officially a browser based web-testing tool, it can be very useful for crawling and scraping AJAX-based web applications and for all sort of automated tasks otherwise difficult to accomplish with non graphical HTTP clients such as Curl, Hpricot and Mechanize.
Moreover, it's widely spread, has an API for most popular programming languages (including python), and allows you inject custom javascript code within web-pages.
PS:
Documentation is here
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Is there any python module for rendering a HTML page with javascript and get back a DOM object?
I want to parse a page which generates almost all of its content using javascript.
The big complication here is emulating the full browser environment outside of a browser. You can use stand alone javascript interpreters like Rhino and SpiderMonkey to run javascript code but they don't provide a complete browser like environment to full render a web page.
If I needed to solve a problem like this I would first look at how the javascript is rendering the page, it's quite possible it's fetching data via AJAX and using that to render the page. I could then use python libraries like simplejson and httplib2 to directly fetch the data and use that, negating the need to access the DOM object. However, that's only one possible situation, I don't know the exact problem you are solving.
Other options include the selenium one mentioned by Łukasz, some kind of webkit embedded craziness, some kind of IE win32 scripting craziness or, finally, a pyxpcom based solution (with added craziness). All these have the drawback of requiring pretty much a fully running web browser for python to play with, which might not be an option depending on your environment.
You can probably use python-webkit for it. Requires a running glib and GTK, but that's probably less problematic than wrapping the parts of webkit without glib.
I don't know if it does everything you need, but I guess you should give it a try.