Forgot your password?
typodupeerror
Graphics Programming News

Google Ports Box2D Demo To Dart 194

Posted by Unknown Lamer
from the match-stick-pyramid dept.
mikejuk writes with an excerpt from an article at i-programmer about a neat graphics demo written in Dart: "One of the difficulties in getting a new computer language accepted by a wider audience is that there is doubt that it is real. Is it a toy language that just proves a concept or can it do real work? In the case of Dart, which is Google's replacement for JavaScript, the development is speeding ahead at a rate that is impressive but worrying. To prove that Dart is already a language that can be used, we now have a port of the well known 2D physics engine Box2D, the one Angry Birds uses, to Dart." Box2D has previously been ported to Javascript. Source is available at Google Code (under the Apache license). Note that you'll need Chromium to run the demos.
This discussion has been archived. No new comments can be posted.

Google Ports Box2D Demo To Dart

Comments Filter:
  • Not again! (Score:2, Insightful)

    by TechGuys (2554082)

    Note that you'll need Chromium to run the demos

    As a web developer and after all the nuisance old IE's gave me and other web developers back in the day, this is really what's stupid with Chromium and Google's approach. They're mimicking the old Microsoft here - make your own "standards" and break the web by making features and sites that only work Google's browser. I seriously thought we would had been past that and the old IE's were the last browsers that didn't adhere to standards. IE9 is now fully standards compliant, and what does Google do? Oh yes,

    • Re:Not again! (Score:5, Insightful)

      by bhagwad (1426855) on Monday January 16, 2012 @11:26PM (#38721054) Homepage
      So how does a company create something better than the standards? Or are you perhaps implying that standards once set are the best for ever and ever? It's not as if Google is DROPPING support for Javascript. That would be...outrageously stupid. What exactly is your problem here?
      • That, plus the fact that Dart compiles to Javascript.

        Indeed, what is the problem?

      • by DrXym (126579)
        The problem here is that Google is introducing a bunch of technologies - WebM, WebP, SPDY, Dart, Nacl, PNacl etc. without submitting to standards bodies, without forming concensus from other browser makers to agree or disagree to use the tech and basically using the weight of their entire company to foist these standards onto the web whether they are ready for it or not.

        What they're doing is not really that different from when Microsoft introduced VBScript or attempted to steamroller Office Open XML throu

        • by anonymov (1768712)

          without submitting to standards bodies, without forming concensus from other browser makers to agree or disagree to use the tech and basically using the weight of their entire company to foist these standards onto the web whether they are ready for it or not

          Does somebody do that? All major features were introduced independently and codified later. It's a race between browsers to see who can invent the next big thing - MS, Mozilla, Google, Apple, Opera, everyone introduces new features and implements interesting features introduced by others every release.

          Sure, not every feature sticks - nobody flocks to Chrome to check out WebP, and nobody flocks to FF to check out Javascript 1.8.5.

          You make it sound like Google has browser monopoly and can pull their weight be

    • by eldavojohn (898314) * <[moc.liamg] [ta] [nhojovadle]> on Monday January 16, 2012 @11:28PM (#38721070) Journal

      They're mimicking the old Microsoft here - make your own "standards" and break the web by making features and sites that only work Google's browser.

      From Dart's wikipedia page [wikipedia.org]:

      Google will offer a cross compiler that compiles Dart to ECMAScript 3 on the fly, for compatibility with non-Dart browsers.

      And, in fact, dartc already cross compiles Dart code to plain Javascript. Once it's integrated into browsers, use it or don't use it.

      It's like Microsoft all again.

      Right, that's a stretch. You conveniently cherry pick details here. For example, NaCl is released under a BSD license [google.com] with source code readily available. Are you saying the same was true of ActiveX since it's launch?

      • by melted (227442)

        >> And, in fact, dartc already cross compiles Dart code to plain Javascript

        Last I checked, it compiled "hello world" into a 17K line Javascript program. Not exactly optimal.

      • by makomk (752139)

        So the net result is basically that users of Chrome on Google services will get the faster Dart version, whereas users of other web browsers will get a slower version that's been compiled to JavaScript badly. What's more, Google has very little incentive to optimise either the JavaScript version or Chrome's JavaScript support at that point, leaving other websites with a choice: use Dart and get decent performance on Chrome and sucky performance elsewhere, or use plain JavaScript and get decent performance e

        • by anonymov (1768712) on Tuesday January 17, 2012 @08:21AM (#38723104)

          Net result of any new extension is that users of the browser implementing it get a faster and better version. If it turns out to be a good idea other browsers follow and everyone ends with a net benefit.

          Canvas, for example, was Apple's extension in WebKit, year or two later other engines caught up to it too.

          XHR was created by MS for Outlook Web Access, with other browsers implementing it in a year or two after that, and W3C draft standard appearing only 5 or 6 years later.

          That's how innovation worked in browsers for a dozen years.

          • by makomk (752139)

            Net result of any new extension is that users of the browser implementing it get a faster and better version.

            Except they don't necessarily. Canvas and XHR were popular because they were relatively small features that could be added incrementally without disturbing anything else, though XHR wasn't actually entirely compatible between browsers initially precisely because it was a Microsoft-specific feature implemented in a Microsoft-specific way. Dart requires rewriting or replacing the entire JavaScript engine of the browser in question, including its interface to the DOM and every other feature like Canvas or XHR

            • by anonymov (1768712)

              Why should it _replace_ JS engine? Sometimes I feel people forgot that <script> element has language="" attribute there for a reason.

              Scripting engine shouldn't be hard coupled with the main application. Exposing DOM should be as easy as creating new FFI wrappers for the same old objects JS engine calls on.

              Google guys seems to have it right, if they managed to include a new scripting layer without disturbing their old V8.

              Of course what I (and I'm sure I'm not only one) really wish for would be not a si

              • by makomk (752139)

                Why should it _replace_ JS engine? Sometimes I feel people forgot that <script> element has language="" attribute there for a reason.

                It doesn't have to, but the alternative is to bloat the browser with two independent JavaScript interpreters each with their own interface to the DOM and everything. Also, I think that may require some hairy code to allow objects to from one to be accessed in the other.

                Google guys seems to have it right, if they managed to include a new scripting layer without disturbing their old V8.

                I'm pretty sure that they designed it to be integrated heavily with V8 at the very least, if not an actual part of it. Dart was even created by the same person as V8.

                • by anonymov (1768712)

                  Yes, it's hard, but doable. Re: bloat, it depends. Lua, for example, is around 100kB. Even if bindings take twice or four times that, it's an insignificant blip - just compare to single xul.dll's 16Mb or opera.dll's 15 or chrome.dll's 29. And all of those are just _parts_ of the application (well, except Opera, there it seems to be all there is + 1Mb of application exe)

                  A side note, per my observations, many would be happy to see Lua embedded in browsers, there's already Emscripten and there was a NaCl Lua b

    • Couldn't agree more. We just got past the point where IE6 can finally be considered dead and now Google tries to make exactly the same problem. No web developer will be insane enough to target a Google-only platform given their recent history of throwing shit at the wall to see what sticks.
      • Re: (Score:2, Informative)

        by Anonymous Coward

        I think you fundamentally misunderstand the purpose of Chrome/Chromium, and that misunderstanding is blinding you to the very obvious differences between what Google is doing with Chromium (NaCl, Dart, SPDY) and what Microsoft did with IE. If you start instead from the right premise, and realize that everything Google has done has been open-sourced, you start to get a better appreciation for what's really going on.

        • by makomk (752139)

          everything Google has done has been open-sourced

          Just because it's open sourced doesn't mean it's of any use to other browsers. NaCl is tied to a huge Chrome-specific set of APIs that are deeply integrated into the browser and probably not practical for anyone else to implement, Dart is part of their JavaScript VM which no-one else uses and again the JavaScript VM and browser are so deeply integrated no-one else could use it, and SPDY is pretty much the same and in addition is undocumented and requires modified SSL libraries.

    • Here we go again! [slashdot.org]

      Every time I click on a news story involving Google, I'm all but positive that the first post will be:

      a) Posted with a 2.5+ million UID

      b) Over 100 words long, yet still posted the same minute the story goes live

      c) Negative towards Google

      Here we go again. Welcome back CmdrPony / InsightIn140Bytes / DCTech. Happy shilling. Hope you karma manages to hold out for more than 4 days this time.

      • Re: (Score:2, Funny)

        by Anonymous Coward

        Well, Google is the new Microsoft!

      • Over 100 words long, yet still posted the same minute the story goes live

        Pro tip: subscribers get to see stories ahead of time. You don't have to be a shill to write a long first post.

    • Re:Not again! (Score:5, Insightful)

      by Korin43 (881732) on Monday January 16, 2012 @11:35PM (#38721132) Homepage

      You do know how web standards work right? It goes something like this:

      1. A bunch of people come up with ideas that would be cool to have in browsers.
      2. Some of them add those things to browsers.
      3. After we figure out which approach works / is most acceptable to all browser makers, it becomes a standard.

      For some reason it's a common belief that it works the other way around (make standard -> implement standard), but anyone know hows anything about programming can tell you why setting everything in stone and then writing the software is a terrible idea.

      • ...anyone know hows anything about programming can tell you why setting everything in stone and then writing the software is a terrible idea.

        Okay, pretend I know nothing of programming and explain to me why this is a bad idea.

        • Set in stone? Really, so all the browsers did not update themselves to meet the standards as they evolved?

          Well IE lagged behind, and is now playing catchup but they now all implement the published standards even though they did not before, and mostly implement the core of what will be HTML5

          They all implemented what they thought the standard would be or should be, and then modified their system to be closer to the actual standard and it was worked out ... which is how it should work ...

        • by biodata (1981610)
          Maybe you're tolling, I'm not sure, but here goes.

          There is something called 'requirements' - stuff people want to do, and there is something called 'solutions' - software that does stuff. As soon as human being starts to use a piece of software, it changes their requirements, because they have new ideas of stuff they want to do. Hence it is impossible to define the 'true' requirements before the software exists, because the true requirements don't exist until the software does, and vice versa. Softwar

      • by makomk (752139)

        NaCl and Dart are both fundamentally unacceptable to at least Firefox though - they consider them basically impossible to implement. Google is going ahead with them anyway. I don't think any of the other browser manufacturers are any more willing either.

        • by Korin43 (881732)

          NaCl and Dart are both fundamentally unacceptable to at least Firefox though - they consider them basically impossible to implement. Google is going ahead with them anyway. I don't think any of the other browser manufacturers are any more willing either.

          So they fail. What's the problem?

          Google wants to convince other people to implement something they like, so they created their own implementation to demonstrate it. How else do you expect them to convince anyone? Or should they just leave things how they are and get off your lawn?

    • A remark like is is modded interesting? Really?

      I've been a /. user since 1996 and I'm seriously considering leaving this site. The user-interface is broken and unintelligible and the comments seem to be heading towards brain-dead.

      Y

    • There's a large difference tho.
      Google has the public opinion still on it's side. MS had lost it way before they started ActiveX.

      And technically - Google's stuff is usually slightly better and more open (because yeah, no matter what you hear, some MS still is actually genuinely awesome.Surface, Kinnect, Singularity, etc, are actually splendid, some of which are open too)

      And that is why Google is currently a danger for the free web we still have today.

    • Another example is NaCl, or Native Client, which tries to mimic Microsoft's ActiveX, and again

      And Mozilla's NPAPI plugins....

      But of course thats different, right?

    • by mwvdlee (775178)

      IE9 is now fully standards compliant

      No, it isn't.
      As a web developer I was really looking forward to IE9 so I could finally have a single set of HTML templates for all browsers.
      Sadly, IE9 only meant I have to maintain yet another set of browser-specific hacks.

      Not to say chrome doesn't have it's faults, but they're nowhere near as bad as IE's were, and in many ways still are.

    • by DarkOx (621550)

      Depends on your perspective, as to if they were Mistakes for Microsoft. Yes there were other factors, like their near total owner ship position on the Desktop, something Google kinda enjoys today with search, but whatever Microsoft did it worked in sense.

      IE became the web browser, many websites took the attitude other browsers need bother with a GET. Microsoft's position on the desktop was if anything cemented because you more or less needed a Microsoft platform to use 80% of the WWW. It got them a footi

    • There is a huge difference between M$' "standards" and dart. Dart is intended to be used by everyone and doesn't lock you into one browser. Where as an M$' "standard" only runs on Windows in order to lock you into their own ecosystem.

      It only runs on Chromium (not even Chrome) because it's a work in progress so obviously no one else is going to support it.

      I'm actually going to have to believe the astroturf accusations or assume you're an idiot for not comprehending it's not ready for everyone to use.
    • and we want our web page noticee back - 'This page should be viewed on browser X with screen resolution y by z'

      This is enough for me not to bother clicking on the link. Saying this about your web page is a risky strategy and I guess only Google can get away with this and get a subset of people to dutifully switch browsers just to see what the exciting page has on it (and possibly Apple could too).

      Moving on.

  • The JS port (Score:5, Informative)

    by LDoggg_ (659725) on Monday January 16, 2012 @11:35PM (#38721126) Homepage
    The article mentions, box2d-js. The more current port is box2dweb: http://code.google.com/p/box2dweb/ [google.com]
  • by Skapare (16644) on Tuesday January 17, 2012 @12:06AM (#38721268) Homepage

    Is this a programming language with an existing shell script interpreter style implementation, too? If so, then I might have actual use for it. Basically, that means a light-weight interpreter (light enough to use it during system boot up to run rc scripts, so not more bloated than bash in its basic form) could be named in the script like having "#!/bin/dart" on the first line, and it would execute the file however it is designed to run them. I'm not talking about using in a browser here. For extended features beyond shell script code, it should have modules (in binary .so files or in Dart) that it can load.

    I'm just starting to use Lua for this kind of thing now. Lua was intended as an embedded language, but has a shell script style interpreter which is pretty much a nice example of simple embedding. If they put Dart in a browser, and implemented it cleanly in the process, then a shell script embedding should be trivial. Have they done that?

    I'd be more impressed if they make Dart do all these kinds of things (including directly run in a web server) than by implementing Box2D in it. That would mean a clear separation of execution from environment, something that Javascript only partially succeeded doing. Something that Lua did succeed at, but I still want a C-like syntax class for.

    Oh, and I would definitely love to have a clean integer-only typing available, something I consider a major problem with Javascript.

    • Re: (Score:2, Interesting)

      by Anonymous Coward

      Yes, you can run it from the command line via the Dart VM without translating it to Javascript. Haven't tried #!/bin/dart style invocation though - but being open source someone is probably working towards it if it doesn't yet support it.

      I've used Dart a bit and it really is a great language - not so different that it takes ages to learn, but IMHO a big improvement on both Java and Javascript.

      • by Skapare (16644)

        Yes, you can run it from the command line via the Dart VM without translating it to Javascript. Haven't tried #!/bin/dart style invocation though - but being open source someone is probably working towards it if it doesn't yet support it.

        I've used Dart a bit and it really is a great language - not so different that it takes ages to learn, but IMHO a big improvement on both Java and Javascript.

        It should not be hard. Someone already familiar with how the Dart native runtime engine works (I'm not one of those, so excuse me if that term to describe it is technically wrong, but I think you probably know what I am referring to) should be able to whip it out in a day or so and clean it up in a few weeks. They just need to set up a few pieces: the common language interpreter, a minimal library where needed, and something to make sure the hash-bang in line one is treated as a comment that can supply pa

  • Am I really the only one on Slashdot who dislikes JavaScript? Every time I have to work with JS, I feel like shooting myself in the head -> Little IDE support, no type safety, no compile phase... These things make it extremely hard to work on a large application base. In fact, at work we have a custom Java -> JavaScript compiler, which makes things a lot more manageable. Most of the bugs we get in our issue tracker are related to the web interface which is still written in plain JavaScript.

    I actually

    • by dingen (958134)

      Most people working with Javascript don't really know the language that well. It's easy to get frustrated that way, because JS's C-like syntax makes you think it's a C-like language, which actually it isn't.

      There is a lot wrong with JS, nobody is denying that. But it also has its nice elements. And since every device on the planet is equipped with a browser running Javascript these days, the language really is here to stay. So instead of hating it, its a lot more constructive to try and understand it, so yo

      • by petsounds (593538)

        The problem is that most people who love Javascript seem to love it for the bad parts -- the "everything goes" language parts. There's no classes, just anonymous functions. Some people seem to love this half-assed prototype-based OOP and label it with words like "expressive" and "powerful". It's not so powerful when you're building complex RIAs. In that case, it's really dreadful compared to class-based OOP languages. As people start developing more advanced HTML5 apps, this will become apparent. There's no

      • I would say it is more the fact is is called JAVAscript which makes people think it is a Java-like language, which actually it isn't.

    • by BZ (40346) on Tuesday January 17, 2012 @02:42AM (#38721898)

      Little IDE support is helped by building IDEs, not coming up with a new language that has even less IDE support.

      Dart doesn't do type safety by default. There have been proposals to add optional type annotations of the sort Dart _does_ have to JS... and they were shot down by certain members of the JS standards committee, last I checked. Don't recall what the stance of Google's representatives on it was, but they weren't the ones pushing it.

      As far as a compile phase goes, Dart doesn't have one either unless you're cross-compiling it to JavaScript. You just load your Dart code directly in the browser, which then compiles it. That's what browsers do with JS too.

      So ignoring for the moment whether these things are good or not, I don't see Dart making much of an improvement over JS here, except in the type-safety department, where Google didn't exactly try to improve JS in the first place.

    • JavaScript is really very simple to use.

      Build an object model from your data. Merge your model with your view. Bind your model, view and dat source with PubSub events. Controllers update the model, subscribed views then update to match and the data source gets an async update in the background.

      Was that hard or complicated?

      This is a known and solved architecture that can be applied to DOM views, Canvas views or SVG views.

      If you want to get fancy you can add support to filter, sort or mutate your data. You ca

      • by spongman (182339)

        JavaScript is really very simple to abuse.

        tftfy

  • by afabbro (33948) on Tuesday January 17, 2012 @01:22AM (#38721558) Homepage

    the development is speeding ahead at a rate that is impressive but worrying.

    Worrying because...?

  • but can it deal with a concave polygon?

    "Is it a toy language that just proves a concept or can it do real work?"

    depends on the work at hand

Today's scientific question is: What in the world is electricity? And where does it go after it leaves the toaster? -- Dave Barry, "What is Electricity?"

Working...