Tiny javascript implementation? [closed] - javascript

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 4 years ago.
Improve this question
I need an extremely tiny implementation of (maybe a subset of?) Javascript. Code size and memory usage are extremely important (speed isn't in the question, it can run as slow as it likes). It must be written in C (not C++), and that too, ANSI C (GCC extensions are okay). If it runs on a VM would be best, because I will have to write a compiler for it. Any suggestions?
EDIT: Both of the responses I have seem good, except:
SpiderMonkey concentrates a lot on making it faster, I don't care if its fast at all.
Quad-Wheel sounds good, except the activity on it, and code comments are few (I will be porting this to another architecture if that helps).
So, any other responses would be great. Or, I could roll out my own simplified version of JS (but that doesn't sound fun at all)

Duktape is written in C, with a focus on portability and compact footprint: http://duktape.org/

I just discovered this ruby: https://github.com/gfwilliams/tiny-js
I've been looking quite some time for this, since spidermonkey/v8 usually is pretty big and comes with several dependancies. Tiny-js is a portable 'run make and your done'-linux c-class. Perfectly for if you are only looking for simple bindings and prefer javascript/c-syntax over lua/other awesome scriptinglanguages.

An ANSI-C engine for ECMA-262: http://code.google.com/p/quad-wheel/
Mozilla SpiderMonkey is written in C as well, but probably to complex and large for you?

SpiderMonkey is Mozilla's C implementation of JavaScript.
http://www.mozilla.org/js/spidermonkey/

muJS from Artifex Software might be another option for embedded JS/ES implementation.

You should look at Jsi, which was just released. It is very small, is a subset of javascript, and is in C (derived from quadwheel).

I think the jsi he's talking about is this: http://pdqi.com/cgi-bin/cgiwrap/pdqi/jsi.cgi/doc/tip/jsi/www/usingjsi.wiki
(Don't blame it is not... hehe)

http://jsish.org will redirect you to the host site.

https://github.com/cesanta/v7 is designed for embedded systems. Has very small footprint.

Have you looked at JerryScript?

If you are completely expect a full Node.js runtime at embeddable, ShadowNode might be a good for you.
https://github.com/Rokid/ShadowNode

Related

Which Box2D JavaScript library should I use? [closed]

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
There are a few different ports of Box2D for JavaScript. Which one is the best?
Box2DJS - "converted from Box2DFlashAS3_1.4.3.1 in an automatic manner"
Box2Dflash 2.0 ported to JavaScript - "one big nasty hack that just happens to work"
box2dweb - "a port of Box2DFlash 2.1a to JavaScript. I developed an ActionScript 3 -to- JavaScript converter to generate the code"
HBehrens/box2d.js - "a JavaScript Version of Box2D 2.1a" (Added Nov 21, 2011)
kripken/box2d.js - "a direct port of the Box2D 2D physics engine to JavaScript, using Emscripten" (Added Sep 24, 2013)
Any ideas which version http://chrome.angrybirds.com/ uses, if any?
Note to readers!
This question was originally asked and answered in 2011, but I'll do my best to keep it up to date!
Here's what I've found:
kripken/box2d.js is a port of Box2D using Emscripten and works well and is fast. I have used this personally with great success.
planck.js is the newest port and is written from the ground-up in JavaScript
Box2DJS is a port of Box2DFlash 1.4.3.1. box2dweb is a port of version 2.1a.
Box2DJS works "as a CommonJS module without any modifications at all" [1]
Box2DJS "not up-to-date and you have to import a big amount of JavaScript files in every project" [2]
box2dweb is contained in a single file [2]
box2dweb is "a much newer port and has a lot fewer issues" than Box2DJS [3]. However, switching might introduce new issues [4].
Box2DJS depends on Prototype but box2dweb does not [5]
Seth Ladd has promoted box2dweb with examples on his blog [6]
Nobody seems to be using the third alternative.
There are also physics simulators not based on Box2D. Check out Matter.js and p2.js
There's also a similar discussion on gamedev.stackexchange.com.
I'd say that the winner is kripken/box2d.js.
This question and its best answer are from 2011. One recent new option is box2.js, an Emscripten translation of the C++ code to Javascript. As of August 2013 it's more up-to-date than the other ports I've found, and the demos seem to work.
LiquidFun (With JS Bindings)
LiquidFun is, at the time I'm posting this, the most recent port to JS. It has all the features of Box2D and liquid physics features. It's ported using emscripten, so performance is decent.
google/liquidfun
google/liquidfun/tree/master/liquidfun/Box2D/lfjs
Probably the best place to keep up to date with Box2D JavaScript ports is the official forum: http://box2d.org/forum/viewforum.php?f=22
JSBox2D looks like a good start.
I would definitely have a look into Matter.js, which seems very well built and very quick. I'm going down this path. http://brm.io/matter-js
Box2d-html5 is also another box2d port including Google's LiquidFun) and active update.
https://code.google.com/p/box2d-html5/
Now maintained at github: https://github.com/flyover/box2d.js
Box2DWeb supports most of the API from the original C++ Box2D except chain shapes. :/
It is the most widely used Javascript Box2D. If you need the API documentation for Box2DWeb, check out Box2DFlash. http://www.box2dflash.org/docs/2.1a/reference/
Box2DWeb is auto generated from Box2DFlash using a compiler. So the API is the same.
I doubt Box2DWeb will get any update in the future anymore as Box2DFlash has shown no activities anymore. You can see the author's rational on why he decided not to write a direct Box2D --> Box2DWeb port.
https://code.google.com/p/box2dweb/wiki/Roadmap

Is there a windows utility similar to HTML Tidy for Javascript? [closed]

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 want to cleanup some javascript files and reformat them with nice indents, etc,
Are there recommendations for utilities to do this under Windows?
Beautify Javascript is a good, simple option.
(Oops. Thought I grabbed the link for the app, not the home page.) ;)
Try the online JavaScript Tidy
Several attempts have been made to
produce programs to reformat code, but
these often fail to cope with
situations such as '{', '}' or ';'
characters inside strings, regular
expressions, or comments, so virtually
all of them end up with broken code.
However, browsers already have their
own parsers built in that deal with
all of these situations. This script
hooks into the browser's own parser,
by wrapping the code in a function
then using the native toString method
to obtain the tidied code. As a
result, it relies on the browser
producing a tidied output, which there
is no requirement for them to do. In
fact, it relies on the browser
decompiling to tidied code instead of
just retaining the original, which is
an expensive process in terms of
performance, and leads to extra
complexity when trying to make sure
the decompiled code still works, so
not all browsers choose to do it this
way.
For best results, use Opera 9.2x- (not
9.5+), Safari or Konqueror on this page. It partially works in Firefox
(nested functions are not tidied,
meaning that most scripts you want to
tidy still end up unreadable), and
fails to reformat code in IE and iCab
3-. Since you can always keep a copy
of Opera 9.2 on your computer (as well
as whatever the current version is), I
recommend you use Opera, and keep a
copy of it around for use with JSTidy.
If you have Visual Studio you can open the Javascript document and press CTRL+K, CTRL+D to format the whole document.
This page on about.com has a tool where you paste in your script and it cleans it up for you.
GNU indent tidies up C-style languages. Perhaps Javascript could be used as a subject as well.
For offline use, this answer to a similar question explains how to set up the code Jonathan suggested to run from a command line with Rhino.
Our JavaScript Formatter uses a language-precise parser to read the Javascript and then format the code. It doesn't get confused by the contents of HTML, strings, or characters. Does run on Windows.

JavaScript Source Code Analyzer [closed]

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
Does anyone know of a good, extensible source code analyzer that examines JavaScript files?
In the interest of keeping this question up-to-date, there is a fork of JSLint called JSHint. An explanation of why JSHint was created can be found here, but to summarize:
JSHint is a fork of JSLint, the tool
written and maintained by Douglas
Crockford. JSLint served me well for
quite some time but in the past few
months it has gotten uncomfortably
opinionated and hostile towards your
code. It is quickly transforming from
a tool that helps developers to
prevent bugs to a tool that makes sure
you write your code like Douglas
Crockford.
JSLint has historically been the main tool for this, but several more now exist:
JSHint - a fork of JSLint that is said to be a little less opinionated
Closure Linter - a linter that checks against the Google Javascript Style Guide
ESLint - a more flexible tool, but newer, and not yet as stable.
If you haven't found it yet, you should take a look at Google Closure Compiler. Compiles your JavaScript and finds errors in code. http://code.google.com/closure/compiler/docs/gettingstarted_api.html
I tried out ESlint and found it good..you can also add custom rules there..Here is the github repo: https://github.com/nzakas/eslint
JSAnalyse has just been published on codeplex. It is a tool which analyses the dependencies between javascript files. You can even define the allowed dependencies and JSAnalysis checks whether the defined rules are fulfilled or not. That allows to keep track about the javascript dependencies even in big projects and to have a clean architecture.
JSAnalyse can be executed as a command line tool or configured via the Visual Studio Layer Diagramm. It is also easy to integrate into the build. With gated check-ins you can keep the dependencies under control.
There exist a parser called ECMAScript parsing infrastructure for multipurpose analysis (esprima) located at http://esprima.org/ with several example tools that can be used in some analysis
ECMAScript parsing infrastructure for multipurpose analysis
Apart from JSLint, JSHint, ESLint, Plato, Google Closure-Linter there's another tool named Esprima.
Here is the link for it: http://esprima.org/
Also, this is the github link for the tool Esprima: https://github.com/ariya/esprima
I faced installation issues while trying out Google Closure-Linter for Windows. But, it does mention on the web page that its support for Windows is experimental. All other tools are easy to use.
I have found JSLint which helps correct a lot of common errors and such; however, I'm hoping to find something that I can add my own rules and such to help automate some coding standards stuff that my company is wanting to implement into JavaScript.
http://www.jslint.com/
I need to look into it's extensibility model more.
There's a few tools on the list of tools for static code analysis at wikipedia that has JavaScript support, you can allso see JavaScript Debugging if any of the tools mentioned would help. There's allso a few good tools at YUI (Yahoo! Developer Network), as well as a lot of helpful components.
I've allways used JSLint myself, and that's the only analysis tool for JS I've tried. I've grown more and more fond of JavaScript, but good tools is still a problem. :(
I use Aptana for JavaScript file analysis. It catches alot of goofs (if condition with a single =). It also describes the class layout. I believe it has a jslint implementation embedded in it.

Are there any JavaScript live syntax highlighters? [closed]

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
I've found syntax highlighters that highlight pre-existing code, but I'd like to do it as you type with a WYSIWYG-style editor. I don't need auto-completed functions, just the highlighting.
As a follow-up question, what is the WYSIWYG editor that stackoverflow uses?
Edit: Thanks to the answer below, I found two that look like they might suit my needs:
EditArea and CodePress
EDIT: See this question also:
https://stackoverflow.com/questions/379185/free-syntax-highlighting-editor-control-in-javascript
The question might be better stated as "What syntax-highlighting editor do you recommended to replace an html textarea in my web app?" (Some of the other answers here deal with desktop apps or pure-syntax highlighters, not client-side editors)
I also recommend CodeMirror, it's written in Javascript and supports lots of browsers. It uses a real parser (rather than regexps) so it can deal with complex problems like correctly highlighting escaped strings. The developer is also very responsive on the discussion group.
Here is a really interesting article about how to write one: (Even better, he gives the full source to a JavaScript formatter and colorizer.)
Implementing a syntax-higlighting JavaScript editor in JavaScript
or
A brutal odyssey to the dark side of the DOM tree
How does one do decent syntax
highlighting? A very simple scanning
can tell the difference between
strings, comments, keywords, and other
code. But this time I wanted to
actually be able to recognize regular
expressions, so that I didn't have any
blatant incorrect behaviour anymore.
Importantly, it handles regex correctly. Also of interest is that he used a continuation passing style lexer/parser instead of the more typical lex (or regex) based lexers that you'll see in the wild.
As a bonus he discusses a lot of real-world issues you'll run into when working with JavaScript in the browser.
See Google code pretify.
See this question for the edit control that stackoverflow uses.
Sorry to drag this back up but the best i have found in CodeMirror http://codemirror.net/
I dont program a lot of javascript but JSEclipse has been pretty helpful for me in the past. It comes as an Eclipse plug-in.
I've been using it for years for free
http://www.interaktonline.com/products/eclipse/jseclipse/overview/
I also rely heavily on FireBug for Firefox whenever I deal with Javascript
You can also try http://softwaremaniacs.org/soft/highlight/en/ - it's fast, it supports not only javascript but many other languages. And if you need a live preview of how the highlighting will work, you can use setInterval to run the highlighting and show it in a separate box.
Although it has a steep learning curve, Vim is the best editor out there, for any language. It has a GUI version, but really shines in terminal editing. Any time spent learning how to use this editor is not time wasted. It has syntax highlighting, as you're looking for, as well as thousands (literally) of other features and plugins.
Gotta go with Bespin by Mozilla. It's built using HTML5 features (so it's quick and fast, but doesn't support legacy browsers though), but definitely amazing to use and beats everything I've come across - probably beacause it's Mozilla backing it, and they develop Firefox so yeah... There's also a jQuery Plugin which contains a extension for it to make it a bit easier to use with jQuery.

What is the best online javascript/css/html/xhtml/dom reference? [closed]

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 9 years ago.
Improve this question
I'm a front-end developer and I was looking for opinions about the best all-round online documentation for javascript/css/html/xhtml/dom/browser quirks and support. I've tried Sitepoint, Quirksmode, W3Schools but all of these seem to be lacking in certain aspects and have been using them in combination.
I like Mozilla's references:
http://developer.mozilla.org/en/JavaScript
http://developer.mozilla.org/en/DOM
These are not at all the one stop site you want, but they help me.
I like gotapi.com (Update 2: Site is apparently offline -- Use another resource such as MDN)
Update: the original answer was from 2008 -- today I would say to check out Mozilla Developer Network (as many others have also said).
You've actually hit the nail on the head in your description. There is no single website that'll provide you with the detail you seek in every one of those facets.
I find these three are incredibly useful when starting on a blank page: Mozilla DOM Reference (for general js syntax, etc), w3schools x/html reference (look up uncommon attributes!) and quirksmode (cross-browser js/style details). These are quite highly ranked so look for their urls if you're searching for something specific.
As for specific browser quirks, your best bet is to handle these as they come up and develop skills for googling for answers efficiently. Lots of browser quirks have many variables that go into what you actually end up seeing and how developed a 'solution' is for a specific quirk depends on how much time someone has spent investigating it. Read a bunch of search results and see if the problems are all similar or completely separate. Then, refine your search!
Go straight to W3C docs. They're a bit cryptic at times, but they're solid documentation.
For quirks, obviously sites like Quirksmode are good. But only once you've read actual W3C documentation.
Sitepoint has a very comprehensive guide to CSS
The same reference which is included in the Aptana IDE is online... just found this... it's really good:
CSS
http://www.aptana.com/reference/html/api/CSS.index.html
HTML
http://www.aptana.com/reference/html/api/HTML.index.html
HTML DOM O
http://www.aptana.com/reference/html/api/HTMLDOM0.index-frame.html
HTML DOM 1 & 2
http://www.aptana.com/reference/html/api/HTMLDOM2.index-frame.html
JavaScript Keywords
http://www.aptana.com/reference/html/api/JSKeywords.index.html
JavaScript Core
http://www.aptana.com/reference/html/api/JSCore.index-frame.html
I like w3schools for html or simple questions.
For Javascript, I find Mozilla Developer Center to be pretty useful: Core Javascript 1.5 Reference
zvon.org
http://reference.sitepoint.com/
blooberry.com is a great HTML/CSS reference site.
devguru.com
I rely on http://quirksmode.org/resources.html for information on HTML/CSS/JavaScript. This resource does a great job addressing cross-browser compatibility issues in a helpful table format.
This may be useful for some javascript functions http://kangax.github.com/es5-compat-table/
I tend to go to http://msdn.microsoft.com/ first.
There is a very good german reference (and french I think) at selfhtml.org.
I recommend going through these JavaScript Video Lectures (15 of them).
GotAPI is a fantastic resource http://www.gotapi.com
http://www.selfhtml.org/ is in German (originally) and French (translated). English translation has been unfortunately suspended: http://en.selfhtml.org/
I'd recommended w3schools.com. It's a pretty good and comprehensive library, I find.
I always start with www.zvon.org, especially the references section. Provides a good overview and links directly to the corresponding standards.
javascriptkit.com/jsref/ (convenient JavaScript reference with examples)
javascriptkit.com/domref/ (DOM reference with examples)

Categories

Resources