Tagged: webdev Toggle Comment Threads | Keyboard Shortcuts

  • Les Orchard 2:28 pm on September 29, 2014 Permalink | Reply
    Tags: , webdev   

    My serial enthusiasm is straying back toward things Indie Web. So, maybe I’ll start lighting this thing up again with little bits and bobs of mad web science. This status post, in particular, is really just an excuse to see if WebMentions work.

  • Les Orchard 4:06 pm on January 18, 2014 Permalink | Reply
    Tags: , , webdev   

    Parsec Patrol Diaries: How To Avoid Smashing Into Things 

    I made a hero ship with beam weapons. I even built drifting asteroids that handle smashing into things. What gave me trouble was finding a way to teach enemy ships how to avoid smashing into things. You know, not perfectly, but just well enough to seem vaguely cunning and worth pretending to outsmart in a video game.

    (More …)

    • Jeremy 3:39 pm on January 27, 2014 Permalink | Reply

      Getting some great looking animation results on the steering. Curious if you were able to actually read the formulas on the Wiki page of if the “AI for Game Developers” book was able to simplify things in code for you. Looking into playing with AI programming myself as it’s becoming more and more difficult to fake intelligent particle behaviors using fields/attractors in 3D art packages.

    • Aristotle 9:53 pm on February 25, 2014 Permalink | Reply

      Btw, if you do you have a use for A*, you want Jump Point Search instead:

    • Aristotle 11:04 pm on February 25, 2014 Permalink | Reply

      Looking at that demo sketch, it does not look as though the ships have a plan for where they’re

      going. They plough head-long into the asteroid swarm half-way between them and the player, then make emergency evasive manoeuvres, often getting stuck swerving two and fro in the narrow spaces between asteroid swarms, because their only throttle setting is “full speed ahead”.

      A real pilot would see the obstacle swarm from miles away and fly around it by steering out of the way at minimal angle at maximal range.

      Looking at the debug graphics, I also notice that the collision detection radius leads to picking up asteroids opposite the direction of the ship – which there is no point incorporation as a repelling force, as there is no way for the ship to collide with them.

      Basically it seems like you want your “area of interest” for obstacles to be something like a trapezoid with its parallel sides ahead and behind the ship, the side behind the ship being very narrow and close to the ship, and the side ahead of the ship being rather wide and stretching far ahead. (Maybe the wide side would need to be capped by a semi-circle to make it smooth.)

      This way, the ship will start steering around oncoming obstacles long before it actually encounters them, while ignoring anything irrelevant to its flight path. I.e.: it would resemble a sentient pilot’s actions.

      You will probably need to make the repulsive force of asteroids moderate and its decay gentle, to keep the force significant even at medium range, but not at long range, so that ships will prioritise keeping a clear flight path over steering towards their target. They should also not overreact to close-by obstacles that are only slightly in their way. And within narrow spaces, the competing repulsions on both sides should cancel out gently, not yield erratic wild swerves.

      That way, fast fighters should end up threading through narrow spaces with minimal steering, zipping towards their target on largely straight lines. I.e. resemble a sentient pilot’s steering…

      And btw – the exact shape of the trapezoid probably ought to depend on the linear and angular thrust of the ship in question (higher linear thrust = farther horizon, lower angular thrust = wider horizon), i.e. fighters would have a very long and narrow one, whereas battleships, a shorter much more wide-angled one. (But even for slow ships it still has to extend a good deal further than the collision detection radius in your demo sketch.) And that would provide one answer to the question of how to make ships with different characteristics behave accordingly.

      (You can also go hog-wild with the idea and have multiple areas of interest that use different magnitudes and decays for their forces, e.g. a very short-range one using large coefficients for evasive action and a large area with more moderate coefficients for “route planning”. This seems more potentially useful for bulky battleships more than for nimble fighters maybe.)

  • Les Orchard 12:53 am on November 27, 2013 Permalink | Reply
    Tags: , , webdev   

    Parsec Patrol Diaries: Entity Component Systems 

    The Entity, Component, & System design pattern is old hat for many game developers. But, keep in mind that I’m a web developer, and mostly on the server side of things for the past decade or so. One of my last big revelations was discovering the Model, View, & Controller way of doing things. Apropos of that, this ECS thing seems to be a Big Deal of similar proportions.

    (More …)

    • Garan 4:18 am on June 2, 2014 Permalink | Reply

      Cool article! But i have a question, how do solve the relationship between systems ? If one system needs the data that must be processed by another system? Let’s say, do you have any thing about the priority between systems ?

      • Les Orchard 10:24 am on June 2, 2014 Permalink | Reply

        Hmm, good question. I just kind of punt on that so far, though: Any data needed by any system is found in the collection of entities.

        But, one other thing I’ve been playing with is a pub/sub system. So, if say something damages an entity, the system causing the damage puts out a message on a certain channel. The health system subscribes to that channel and processes the damage notification. Neither system knows about each other, just that there’s a channel for damage messages.

        • EGodAmonRa 2:25 pm on June 15, 2014 Permalink | Reply

          Oh, and this has been the most clear cut example of the system I’ve found yet. Thank you.

      • EGodAmonRa 2:21 pm on June 15, 2014 Permalink | Reply

        The systems will have to be run in a very specific order “Lockstep”. You cannot correctly update the position component if movement components haven’t been update 1st. And so you cannot accurately Render the Entity if you haven’t updated the location. As the article said, what makes this type of system nice is the fact that we can not only add Components(Functionality) on the fly to Entity’s, we only update what needs to be updated at the time and ignore ALL other data. DamageSystems could be a little more complex. Who damages who 1st?

        • Les Orchard 3:53 pm on June 15, 2014 Permalink | Reply

          Hmm, yeah I think this is a really good point. And my system’s not doing it yet. That is, things run in an order, but I haven’t given it much thought.

          So, say rendering happens before the position gets updated, then it will be always working on slightly stale data. And, if updating the momentum with thrust & gravity & etc happens after updating the position… then things are even more out of whack.

          I should look into making that better

  • Les Orchard 1:44 pm on November 19, 2013 Permalink | Reply
    Tags: , , webdev   

    Parsec Patrol Diaries: Why a Game? 

    I decided to start writing a retro space game for the web, because I thought it might be a good way to exercise a lot of interesting technologies and have fun to boot. You know, like how sending rockets into space yields astronaut ice cream & anti-shock trousers back down on Earth. But, I’ve also wanted to make games all the way back to my Atari 2600, Commodore 64, and Apple ][ days – because Warren Robinett is my hero.

    (More …)

    • Craig Maloney 10:32 am on November 20, 2013 Permalink | Reply

      Funny enough Chris Crawford is my programming hero from my youth, even though I never managed to finish one of his games. In fifth grade I wanted to dress up like him but I’m pretty sure I didn’t pull it off very well. :)

    • BillSeitz 9:39 am on December 4, 2013 Permalink | Reply

      Did you consider any of the free HTML5/JS game frameworks?

  • Les Orchard 12:25 pm on November 19, 2013 Permalink | Reply
    Tags: , , webdev   

    Parsec Patrol Diaries: Hello World 

    So, I’ve been working on a retro space game for the web. I planned it as a fun project to “sharpen the saw” and get myself more current on some newer technologies. I also planned to use it as blog fodder, writing little diary entries about what I’ve been doing & discovering along the way. But, 147 commits and almost 4 months later, I’ve had fun doing the coding and have totally neglected the writing.

    (More …)

  • Les Orchard 12:21 pm on February 23, 2013 Permalink | Reply
    Tags: badger, badges, django, , webdev   

    Looking for a Django app to manage Roles within Groups 

    I want to add some team-based features to django-badger. I was hoping that someone had already built a reusable app to do most of the work for me. This happens quite a lot when I’m working with Django. Unfortunately, I haven’t quite found what I’m looking for yet. Consider this blog post either the product of my thinking out loud toward a rough spec, or a long-winded lazyweb search query.

    (More …)

  • Les Orchard 5:37 pm on January 23, 2013 Permalink | Reply
    Tags: CamelCase, dev, javascript, python, snake_case, webdev   

    Naming Things: CamelCase vs snake_case 

    I’ve contributed code to a number of projects, often as a drive-by bug fix in a GitHub pull request. And, usually, I’ll try to do as the Romans do and follow the local naming and coding conventions. But, sometimes, I’ll fall back to my personal conventions and get dinged in the code review.

    (More …)

    • jr conlin 6:41 pm on January 23, 2013 Permalink | Reply

      I think the biggest problem for folks is that it’s hard to enforce that sort of consistency. A lot of folks tend to have their own rules (anarchy is a rule) and have come from environments where things are a chaotic mess. That or they don’t really care about formatting because they’ve had to “correct” how they’ve coded so many times, they’ve stopped caring. (That would be me. I’ve had to learn double digits worth of “universal style guides”.)

      For what it’s worth, I tend to write things as camelCase unless there’s damn good reason not to. (e.g. CONSTANTS_HAVE_UNDERLINES)

      I, too, would love a simple set of guidelines that everyone would agree to, but I know that developers are as bull headed as they are stylistically challenged.

    • Ian Bicking 6:54 pm on January 23, 2013 Permalink | Reply

      I think consensus in Javascript is mixed case, not snake case. I did use a constructed method name where I felt snake case was more appropriate, kind of like test_someMethod – this is nice if you grep for someMethod and then testSomeMethod may not match. But conventions in Javascript develop slowly, with weird dead ends. Leading commas? I can’t imagine what was going through people’s minds.

    • Will Fitzgerald 7:54 pm on January 23, 2013 Permalink | Reply

      Why do you think people think that constants should be uppercased? (This seems true even among Scala developers, where vals are effectively constants.) This feels like a holdover from days of yore — it seems to me that constants don’t need to shout; they are just symbols as are other symbols.

      My first serious code was written in Common Lisp, so snake case seems more natural to me; I miss the ability to write time-in-milliseconds; that is, names with hyphens in them. Then again, it took me a while to believe that case sensitivity was a useful thing for variable names.

      • lmorchard 8:01 pm on January 23, 2013 Permalink | Reply

        Well, upper case because they’re usually important, generally of global (or at least widely-available) scope, and I want a signifier that makes them look different than mutable variables. Also, constants were upper cased when I first learned what they were, so there’s that too. Also also, I stole a lot of things from Code Complete by Steve McConnell

    • Wes Mason 6:15 pm on January 24, 2013 Permalink | Reply

      The biggest reason for preferring snake-case over CamelCase for non-class-instanced callables (e.g. functions and methods) in Python is because Python has no “new” keyword, and instead uses the callable interface to return a new instance of a class, so for example:

      obj = some_body()


      obj = SomeBody()


      ret = some_function()

      ret = SomeFunction()

      On all other casing PEP8 agrees almost entirely with you. :)

      • lmorchard 2:14 pm on January 25, 2013 Permalink | Reply

        Hmm, okay, I can see that distinction… SomeBody() in camel case is an instantiation, while some_body() is an invocation. I still kind of like instance.nameOfMethod(), though. But, I don’t try to fight PEP8, and that’s just the smell of old Java on me.

    • fluff 5:06 pm on January 25, 2013 Permalink | Reply

      Just to make things even more fun, Go actually uses name case as part of the language spec, and in particular, they use initial-cap vs. initial-lowercase to distinguish between public and private members/methods. FUN TIMES.

    • Stephen Uitti 2:45 pm on February 27, 2013 Permalink | Reply

      The only consistent commenting style i’ve ever seen was no comments at all. It was also the fastest to read. It had the fewest mistakes, since, if the code doesn’t match the comments, it’s highly likely that both are wrong.
      The most consistent naming convention i’ve ever seen was color coding. The guy only used white wire.
      Remember: the term isn’t “anal retentive”. It’s “anal compulsive”.

  • Les Orchard 12:34 pm on November 15, 2012 Permalink | Reply
    Tags: , , , webdev   

    My experience in becoming a FirefoxOS contributor 

    Back in September, I wrote that I wasn’t leaving MDN. And, I’m not, really. But, it turns out that FirefoxOS needs some help to reach its first release milestones. So, some of us webdevs from around Mozilla are temporarily switching our daily efforts over to slay bugs on Gaia. That’s the layer of FirefoxOS which provides the overall system UI and core apps.

    (More …)

    • Schalk Neethling 1:47 pm on November 15, 2012 Permalink | Reply

      Hey Les,

      Very nice write up, great to see you have gone past pull request nr.1, which is where I am still stuck. I have to agree that the biggest stumbling block at this stage is being productive and having a solid, effective workflow.

      There are also a lot of inconsistencies between the environments which is not made clear and, sometimes, one is not even sure if your perception of inconsistency is that or a bug. With all of that said, I agree this is an immensely important project to be involved in and I for one are working on improving the getting started process and the workflow process.

      Keep hacking away and speak to you in IRC ;)

    • Gabe 5:14 pm on November 15, 2012 Permalink | Reply

      Why is FirefoxOS on github but Firefox on Mercurial?

  • Les Orchard 1:50 pm on September 18, 2012 Permalink | Reply
    Tags: apps, , openwebapps, webdev   

    Developing Open Web Apps: First, get it onto the web 

    I’ve been interested in developing open web apps (aka the single-page app) for years. But, it feels like the space is really on fire now, since the advent of HTML5 tech and the recent moves by Mozilla and Google toward truly “appifying” these things to compete with offerings from iOS and Android. Lots of pieces have come into alignment, and great things are coming togethernever mind what the folks at Facebook say.

    So, I think I’m going to build a simple app and blog about it. And, these days, the first thing I think about when starting a web app is: How do I get it onto the web?

    (More …)

    • Lisa Brewster 2:08 pm on September 18, 2012 Permalink | Reply

      Some great hacks here! On Amazon S3, how would one change the content-type header for the app’s manifest file? (As per https://developer.mozilla.org/en-US/docs/Apps/Manifest#Serving_manifests) Changing the header currently isn’t required to install the app on FxOS, but is required for Firefox Marketplace submissions.

      • lmorchard 3:23 pm on September 18, 2012 Permalink | Reply

        Good question! I’m hoping to blog about app manifests and issues like that in a near-future post, but I don’t think I have a quick answer for it.

        After the initial upload, you can go into the Amazon S3 control panel and manually set the Content-Type header under Properties / Metadata for the app manifest.


        Unfortunately, it looks like s3cmd will clobber that header setting whenever it uploads, so I’ve often added the manifest to the exception list until / unless I need to change it.

        I’m sure there’s a better way to handle this, but haven’t quite figured it out perfectly.

  • Les Orchard 1:11 pm on July 25, 2012 Permalink | Reply
    Tags: aerostats, basestations, cloud, , webdev   

    Aerostats, Base Stations, and the Cloud 

    In my thinking about things IndieWeb and user-supported cloud infrastructure, I’ve had a couple of notions bouncing around in my head that might help clarify some “products” I’d like to build if and when I have time. I guess this would be good to blog about, so maybe someone else can steal my ideas (if they’re any good). Because, after all, much of this is sourced from material I’ve stolen from guys like Dave Winer. (More …)

  • Les Orchard 4:37 pm on July 12, 2012 Permalink | Reply
    Tags: , , , twitter, webdev   

    Half-formed thoughts about Twitter, social silos, web APIs, and mashups 

    TL;DR: Turns out, the way to derive value from web APIs is to let your community run off and do free research and development. Harvest the results, and profit. We were never promised participation, but it felt like it was a 2-way street. Silly us. Where do we go from here?

    (More …)

    • groovecoder 5:57 pm on July 12, 2012 Permalink | Reply

      Haven’t read this whole thing yet, but do you follow Matt Asay? http://www.theregister.co.uk/2012/07/05/api_hedging/

    • lmorchard 9:46 pm on July 12, 2012 Permalink | Reply

      Heh, haven’t read his article until just now, but you’d think I was cribbing from him.

    • Maxence_Cote 1:22 pm on March 1, 2013 Permalink | Reply

      I’ve just found this post googling and what a post! Your thoughts on the silos, the web APIs and the sharing of the value resonates so much with our project Cozy Cloud.
      We are trying to help improving this “dire” situation with an open source platform where users have control and install apps instead of registering to closed services. We are in a very early phase but it would be an honor to have your feedback, if you see some pitfalls in our approach to tackle this issue or if you have any advice! Here’s our website: https://www.cozycloud.cc/

  • Les Orchard 10:52 pm on July 10, 2012 Permalink | Reply
    Tags: devops, , webdev   

    How webdev has been getting better 

    So, in the last thing I posted, I wrote about how fixing problems on live web sites feels like fixing space robots. At Mozilla, though, things have been getting steadily better and more interesting:

    There’s still the sysadmin-as-remote-pair-of-hands-driven-by-trouble-tickets thing going on, but less so every day. More and more, we’re getting into continuous deployment. Our sysadmins are really smart cookies: They’re steadily replacing themselves with scripts of varying sizes. That way, they can get on to more interesting things. In fact, just recently, they gave us a great Big Red Button that deploys code from a git repository to the live site on demand. And, for some reason, I’m one of the people who got a key to it.

    Okay, maybe not that exact button, but ours is very keen. Of course, when it broke once, I felt like the Pakled on the right (and not Geordi):

    But, the Big Red Button hasn’t broken very often. So, I’d rather be a Pakled some of the time than pretend to be a rocket scientist all of the time.

    Oh yeah, and we’re using GitHub a lot these days. It’s crazypants awesome for collaboration, and it fits right in with our style because we want to do everything in the open anyway. We’ve even somehow lured people who don’t normally code into submitting Pull Requests. And, it’s amazingly powerful to refer to specific lines of code and commits by URL in IRC or email.

    I’ve also been getting a lot better at building development environments, using Puppet and Vagrant and Amazon EC2. I haven’t quite gotten to the point where I can borrow IT’s Puppet manifests directly – ie. those scripts with which sysadmins are replacing themselves.

    But, we are maintaining the recipes for spinning up dev servers right alongside the code. Our READMEs are shrinking, rather than growing – and yet we’re still adding more services and dependencies. I no longer really fear totally jack-knifing my dev rig, because I can just toss it and conjure up another in the time it takes me to run to lunch.

    Let’s see, what else? I’m sure I’ll think of something. Until then, SHIP IT. (The post, I mean.)

    • groovecoder 11:03 pm on July 10, 2012 Permalink | Reply

      Yeah man it’s pretty awesome to push to production 8 times in 4 days. :)

  • Les Orchard 2:32 pm on July 10, 2012 Permalink | Reply
    Tags: , space, webdev   

    How webdev is like space exploration 

    This isn’t so much a complaint as a set of observations: Sometimes, as a webdev, diagnosing and fixing issues on a live site in production gives me sympathy for NASA scientists dealing with remote space probes. And, that’s because I generally don’t have direct access to the servers. Instead, my access is mediated through sysadmins whose primary communication channel is trouble tickets. (Occasionally, I’ll be lucky enough to have someone I can pester more directly, but that’s a privilege that I try really hard not to abuse.)

    So, I build my own replicas of production sites, as best as I can. I deploy exploratory rovers into those environments, and try to account for what could happen based on everything I know up to this point. Once I’ve done all I can to prepare, I fire up the comms dish and beam out a request to the distant probe. This takes time because I have to wait until the receiver is in alignment, and there’s a transmission & reply delay due to distance. (In other words, I file a bug and wait for someone to pick it up. That takes awhile, because we’re all busy people, and I’m a telecommuter who can’t just go tap someone on the shoulder.)

    I cross my fingers and hope I’ve built up a good-enough model of the remote environment, and maybe I’ll find that my hypothesis will be validated. If not, well, then I at least hope I haven’t broken anything, and hope that there’s new information in the reply that I can assimilate into my replica environment here back at home for an improved next attempt.

    But, I’m not entirely sure how to improve this situation. If I had direct access to production servers, I’d be able to do more. However, if I had that access, I’d be expected to do more. You know, like wear a pager and wake up at 4am to fix an alarm condition. I’ve done that job in the past, and I don’t envy anyone who has it now.

    There are also, I imagine, trust and confidentiality issues: even though I write the code, I’m not necessarily qualified to be in contact with certain kinds of sensitive data on a daily basis. (And by not qualified, I mean not bound by a certain class of contractual or legal obligations and not subject to certain kinds of training. I’ll say you can trust me, but trust is sometimes a formalized thing.)

    Still, some days I like to imagine that what I’m doing is trying to debug the behavior of a robot in orbit around Mars. It keeps me from putting too many dents into my desk with my forehead.

compose new post
next post/next comment
previous post/previous comment
show/hide comments
go to top
go to login
show/hide help
shift + esc