Which Box2D JavaScript library should I use? [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 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

Related

Does Microsoft's ChakraCore provide any performance benefit over Google's V8 when used as JS Engine for Node.js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
[I have Edited my question to narrow down the scenario to only Node.js. Please Re-Open it. It is a helpful question and Proper answers might come in future and not sooner as ChakraCore is still at very young age. But this question is Valid and Should be here]
We all have known / read / heard about the glory of Google's V8 Engine and how it has made node.js the beauty it is, for years.
But now that we have an option to choose between Microsoft's ChakraCore and Google's V8 as our preferred JavaScript Engine, I am wondering if someone has any evidence, or test cases where they have found one to be more efficient than another for nodejs.
Please back your answer with some facts and results, because someone should not be using/choosing Chakra only because he/she loves Microsoft or and same applies for V8 and Google.
Thanks.
How they are different?
Whereas most modern JavaScript engines translate all JavaScript code into efficient machine code (source), Chakra has an intelligent and high-performance interpreter. This interpreter has intelligent heuristics that can determine whether to compile your code into machine code or interpret it. An interpreter is usually faster to start and requires less memory to run, which makes Chakra very attractive for resource-constrained environments (such as a Raspberry Pi).
In 2015 Microsoft introduced support for Node.js with Chakra to allow developers to target the Windows IoT Core platform. The recent open-sourcing of ChakraCore has allowed Microsoft to develop in the open and align better with Node.js release schedules.
In a recent JavaScript Air episode, Steve Lucco mentioned that the Chakra team are planning to "really take the community seriously and take their input seriously in terms of the direction that the engine will go [and] give the community a lot more input than, for example, they have had in the direction of V8".
In striving to build a memory efficient JavaScript engine, Microsoft have actually built a competitively fast one. At the time this article was written, Chakra outperformed V8 in some cases:
(source: msecnd.net)
Benchmarks aren't necessarily indicative of real-world performance but this competition in VM performance will eventually lead to a faster Node.js runtime for users of all VMs.
It's also worth mentioning that having their own JavaScript engine will allow Microsoft to freely innovate. One early innovation is time-travel debugging.
How they are different?
Well the question is bit too broad to answer currently in the format but i will try answering it.
Google's V8 engine has all the features which is required to have a blazing fast performance out of it. So, basically this one is the base for the nodejs for quite a while and it will be there for long run.
On the other hand Microsoft's ChakraCore is also been actively developed and it has two layer structure (unable to name it) with Chakra Shim and ChakraCore.
Thing to notice Chakra Shim implements the most essential V8 APIs so that the underlying JavaScript engine change is transparent to Node.js and other native addon modules written for V8.
Source: NodeJs-ChakraCore
For OP: Look for webassembly too.

Best way to port c++ game to web [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I realize the above question is rather broad so I will narrow it down. I have a simple opengl c++ game engine that lives in a static library (could be converted to a dynamic lib).
I have been thinking of ways of getting it to run in web. From what I can see I could use ActiveX or Google NaCl to run the c++ code in browser. But these technologies do not seem easily cross platform? Or maybe I have misunderstood.
Another option I have seen is converting the engine to javascript and WebGL and running in an HTML5 canvas. Would this be slower than c++? It would be very cross platform though.
What do you think is the best option, or better yet is there any other option I have missed?
EDIT: what about a custom plugin similar to the unity webplayer?
There is a library created by #kripken which is still under development. It takes LLVM bitcode and convert into Javascript.
You can see the project page here, with working examples.
https://github.com/kripken/emscripten/
I would strongly suggest porting to NaCl.
Advantages:
Performance: You can use the full power of the CPU to render your game. If your game uses good 3d graphics or physics, you can make it look smooth even on old system configs. The performance of NaCl is comparable to Native OS applications, it only looses nearly 5 to 10% of FPS when I compared the same game to Win32 version.
There are a lot of already ported examples, games for NaCl that can help you do it easily.
It is already cross-platform. Chrome runs on Windows, Linux, Mac OSX.
Disadvantages:
Might take you around a week to port. You have to port to OpenGL ES 2.0 (However, it should be the same with any browser based methods, especially HTML5)
Runs only on Chrome.
If you want something portable in a browser, then it has to rely on Javascript (and likely WebGL, although IE does not support that).
ActiveX and NaCL are just not portable in any way, shape or form.
I can't say which is easier, but you have an option of rewriting your game in Javascript, or using a tool like Emscripten to compile your C++ to JavaScript.
Note that if you use the latter, it's still not a silver bullet. You'll likely have to make lots of changes to your code (for example because the libraries and APIs used in your C++ game won't be available on the browser)

AVM2 and ABC (Adobe's ActionScript bytecode format) spec licensing.. can I use it? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Google is failing me on this one.
Let's say I have some ECMA script that I've compiled to an ABC bytecode file using the compiler in the Open Source Flex SDK.
Is it within the terms of use (That I can't seem to find) for me to use the AVM2 specification from adobe to create a new interpreter for this file?
The best I can manage is a sentence in wikipedia that says that the flash specification is available "without restriction". I'm not making a flash player though, and AFAIK the AVM2 spec is separate from the SWF spec.
Does anyone know off-hand if my intentions are legal?
Adobe open sourced the ActionScript virtual machine as a Mozilla project named Tamarin under an MPL/GPL/LGPL tri-license. If I remember correctly, this source code also includes documentation for ABC bytecode. With that in mind, it seems to me that you're free to build your own interpreter.
You are certainly free to interpret ActionScript byte-code; the wonderful part about their open-source projects (and open documentation), is that you can read a solid reference manual and implementation, without being restricted by it (there is no NDA, and so forth). This is in contrast to dark times, where bytecode had to be reverse engineered in a "clean-room" environment.
I'd like to point out to the very good public domain project by Thatcher Ulrich and company, entitled: GameSWF. It includes an ActionScript bytecode interpreter amongst many other very nice things.
It's substantially different than Tamarin, in that it does not build up a cache of cpu operations, it's simpler, it uses a switch statement. This means it will run slower than Tamarin on heavy loops.
GameSWF is in active development and is available under the tu-testbed project on sourceforge.

Decent JavaScript IDE [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
What is a decent IDE for developing JavaScript, I'll be writing both client side stuff and writing for Rhino. Ideally It needs to run on Mac OSX, although something that runs on Windows too would be nice.
ADDITIONAL:
Having had a play with both js2 and Aptana, I think I'll be continuing to use Aptana. Mainly because I find emacs a bit hard to get my head round, although I did think that the error hi-lighting in js2 was better than that in Aptana.
I'm still looking for a way to visually debug my js code that is running atop Rhino...
Aptana IDE, absolutely. Stable, great syntax support for all the major javascript libraries, very good css and html editors. Also good support for php, air, ruby on rails and iPhone app development (I never tested this one).
Aptana can also connect to remote site via ftp (sftp in the pro edition) and to svn and cvs repositories.
It's based on Eclipse, so it's not exactly a lightweight application. But it's really, really good. You can also use it as an Eclipse plugin if you develop java wab app, but when I tested it in this version, about 1 year ago, it was not stable. Much better to use the standalone version.
If you're familiar with Emacs Steve Yegge's js2-mode could be worth a look.
Aptana Studio, both standalone and Eclipse plugin versions were quite ok last time I used them.
I have found the Spket Eclipse plugin very useful.
Take a look at WebStorm HTML/JavaScript Editor. It's lightweight and runs on MacOS. It supports debugging and running your code right from IDE and has very smart autocompletion capabilities for JavaScript both DOM-based and browser-based.
Komodo Edit/IDE is definitely the best IDE/editor (that I have used) for developing JavaScript.
Notable features include live error reporting, JavaScript macros and syntax auto-complete for ALL major frameworks!
If you have a very big application written in Javascript, there's only IntelliJ Idea. It parses multiple Javascript files and highlights not only syntax errors but undeclared variables and functions, allows to jump from function call to function definition, and more.
I've tried Emacs (because that's my favorite editor) and Komodo, and they don't come close. I guess it's the same for Eclipse.
Personally, I think that superior parsing and navigation abilties of Idea are only required when you're working with crappy undocumented code, otherwise I'd happily write the code in Emacs using js2-mode, but I'm working with huge poorly documented and buggy framework and it really helps to be able to jump to the source of the function or superclass to check how they work.

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.

Categories

Resources