The Stochastic Game

Ramblings of General Geekery

Posts with tag 'programming'

    Effects of CPU Caches

    I recently read this post by Nicolas Douillet about CPU caches and performance. I recommend it! Apart from being a nice, fairly easily digestable recap of how CPUs work when it comes to memory, it also taught me the existence of something I totally didn’t know about until now: the Translation Lookaside Buffer. It’s used to cache recently used mappings between physical and virtual memory. I had no idea that this stuff was cached, and that it therefore could have some important effect on performance.
    Read more...

    GDC 2018 Recap

    So that happened – I went to my second GDC and this time I presented something. Look at how shiny my forehead is! Big thanks to the Toolsmiths guys (Geoff and David) for organizing a full day summit dedicated to tools programming – a topic that I always thought was lacking a proper worldwide community the same way, say, graphics rendering or animation have. Not only did I have the chance to present my talk as part of that “Tools Tutorial Day”, but I had the honours of being the inaugural talk!
    Read more...

    I didn't feel like working on it

    This blog has been quiet for the past 4 months. And not only that, but most of my open-source projects have been quiet too. I just didn’t feel like working on it. This is something that Adam Stacoviak and Jerod Santo talk about occasionally on their Changelog podcast1, whose episodes generally involve interviewing people from the open-source community. I think they called it “project maintainer fatigue”, where an open-source project maintainer basically gets tired, at some point, with the work involved with managing their project.
    Read more...

    Overtime at Frostbite Cinematics

    These past couple days most of the video games development community was set on fire by some pretty bad article written by some pretty famous guy on some pretty high traffic website. I’m not going to comment on it – other people like Rami Ismail did that very well already. Interestingly enough, it revived the old debate about “passion” and “crunch”, and we’ve seen a fair number of interesting articles about it as a result.
    Read more...

    PHP is fucked up

    You may be shocked by what I’m about to say but here it is: PHP is fucked up. Oh, no. Wait. No you’re not shocked. You already knew it. Today’s topic: namespaces. PHP’s namespace implementation is fucked up. There’s really no way to say it nicely, and you will realize it 5 minutes after starting to use them, when most of your code breaks and you need to litter the beginning of your files with use statements and you really wonder what you gained in the process.
    Read more...

    MongoDB for Lucene and ASP.NET

    My latest home project (yet to be announced) is using MongoDB for storage, which led me to write a couple of libraries you may be interested in if you use that kind of database. Keep reading for the details. MongoDB directory for Lucene MongoDB.Lucene is what you would expected given the name: a MongoDB backend for Lucene indexes. It’s a simple port of the standard FSDirectory using Mongo’s GridFS storage. I’m sure there’s a lot of room for improvement (performance, storage efficiency, lock reliability), but it’s working well enough for small applications.
    Read more...

    The extension method trick

    If you’ve been writing C# code lately you should be pretty familiar with extension methods: it’s a nice compiler feature added to C# 3.0 which lets you “attach” methods to an existing type. So for instance, if you define the following extension method: static class ConsoleExtensions { public static void WriteReversed(this TextWriter writer, string message) { writer.WriteLine(new string(message.Reverse().ToArray())); } } You can write:
    Read more...

    Formatting mongo output

    If you’re working with MongoDB’s mongo command line tool and you often see yourself reading through this: > db.contactInfos.find({"source":ObjectId("4e39da93058cfe28a039b546")}) { "_id" : ObjectId("4e6e9a9f058cfe01dc1bcded"), "source" :ObjectId("4e39da93 058cfe28a039b546"), "sourceId" : "754731", "sourceUserName" : "loudej", "ful lName" : "Louis DeJardin", "description" : "A software guy on the ASP.NET te am and author of Spark", "avatarUrl" : "http://a2.twimg.com/profile_images/1 161371928/DSC01367_normal.jpg", "websiteUrl" : "http://louis.dejardin.org", "location" : "Kenmore, WA", "friendCount" : 97, "followerCount" : 1428 } { "_id" : ObjectId("4e6e9a9f058cfe01dc1bcdf3"), "source" : ObjectId("4e39da9 3058cfe28a039b546"), "sourceId" : "16925866", "sourceUserName" : "sebastienr os", "fullName" : "Sébastien Ros", "description" : "", "avatarUrl" : "http:/ /a1.
    Read more...

    IEnumerable is awesome

    I’ve always thought that one of the most underrated features of C# is the yield statement and its companion, IEnumerable<T>. It may be because I’m working a lot with people coming from an exclusively C++ background – it takes some time to adapt to a new language with new paradigms, especially when that language can look a lot like “C++ without delete!” at first. But there are so many wonderful constructs in C# (especially in the past couple versions) that it’s a shame when people keep writing code “the old way”…
    Read more...

    Making WPF controls double-clickable

    A common UI pattern features the ability to double-click on a control to go in “edit” mode. So for example, you have a TextBlock that shows you the name of an object, and you can double-click it to change it into a TextBox where you can edit that name. At this point, it’s easy to hook up the MouseDoubleClick event, or some other mouse event, but that’s not very MVVM-like, is it?
    Read more...

    Xaml serialization quirks and gotchas

    I recently had to build a little tool that would read its configuration from a XAML file (because XAML serialization is, most of the time, better and more customizable than standard XML serialization). The trick was that this tool had to be built on top of .NET 3.0 – not 3.5 or 4.0. And I discovered that there are a few little gotchas in .NET 3.0’s XAML serializer that I, somehow, never ran into before.
    Read more...

    Spam your friends with Yahoo! Pipes

    You know how it goes: you’re an internet hipster with blogs and Twitter feeds and all that kind of new age stuff, but only other internet hipsters read them. Your friends (at least the ones that are not internet hipsters) only stick to Facebook. So how can you bring your stuff to them? At first, it seems easy: Facebook can pull “stories” from various websites and services. Go to your profile, and under the status update box, click “Options” and then “Settings”.
    Read more...

    About unit testing Maya and MStatus macros

    Programmers in the video games and movies industry rarely write unit tests for all kinds of reasons and excuses, but every now and then, it happens. And it can get a bit complicated when you want to test a plug-in hosted by a 3rd party application like Autodesk’s Maya. Setting up the unit test project The good thing is, unlike most other 3d modeling packages, Maya comes with built in “batch” and “library” modes.
    Read more...

    Writing a custom Main() method for WPF applications

    Creating a new WPF project in Visual Studio gives you the following pretty simple application markup and code: <Application x:Class="WpfApplication2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml"> </Application> namespace WpfApplication2 { public partial class App : Application { } } Understanding how it really works, and how to supply your own custom Main() method, is just a search query away. You basically need to change the application’s build action from “Application Definition” to “Page”, create a constructor that calls “InitializeComponent”, and write your Main() by eventually calling one of the application’s “Run” method overloads.
    Read more...

    Visual Studio Express’ limitations lead to bad practices

    Visual Studio Express only has a subset of what you can find in Visual Studio Professional, which makes complete sense, but two missing features actually prevent users from following best programming practices in my opinion. The whole point of Express is to let enthusiasts and students discover the joys of programming – so we might as well let them do it the proper way.

    Read more...

    Experimental IronCow branches

    I created 2 experimental branches for future versions of IronCow. “IronCow Mobile” is a branch that adds support for the .NET Compact Framework. Thanks to jwboer for the initial patch. “IronCow Local Search” is a branch that adds local search for tasks. We basically cache all the tasks in memory, and handle search queries locally, instead of sending a request to the RTM server and parsing the response markup. The lexical analysis and AST building of the search query is a bit dodgy, as I can’t get a proper tool like ANTLR to work with RTM’s search grammar (probably me doing something wrong), but it’s not too much of a problem right now since search queries tend to be quite short, and we already are significantly faster than a web request.
    Read more...

    Target the .NET Compact Framework using Visual Studio Express

    Microsoft only supports Visual Studio Professional for developing Windows Mobile applications and, more generally, code based on the .NET Compact Framework. You get nice things like application deployment and emulators and remote debugging and all. But if you just want to compile something against the .NET Compact Framework, for example to check that you’re using supported methods and classes, you can do that with Visual Studio Express. Create a project in Visual Studio Express and open it in a text editor.
    Read more...

    Conditional operator fun

    A good friend of mine sent me this little “gotcha” a few days ago, so I thought I’d share: #include <iostream> #include <string> void main() { int a = 0; int* ptrA = &a; const int b = 1 ; <span style="color: blue">const int</span>&amp; refA1 = (ptrA ? *ptrA : 1); <span style="color: blue">const int</span>&amp; refA2 = (ptrA ? *ptrA : b); std::cout &lt;&lt; refA1 &lt;&lt; std::endl; std::cout &lt;&lt; refA2 &lt;&lt; std::endl; a = 42; std::cout &lt;&lt; refA1 &lt;&lt; std::endl; std::cout &lt;&lt; refA2 &lt;&lt; std::endl; }
    Read more...

    Visual Studio Tips & Tricks

    Stephen Walther recently blogged about tricks that every developer should know about Visual Studio. Most of those he mentioned I use on a daily basis, so I highly recommend them. It actually surprises me how many other programmers don’t know about those features. Somehow, most programmers know Visual Studio as much as they know Microsoft Word: there’s a big space in the middle to type your text, and then maybe they know a couple of menus and shortcuts and that’s it.
    Read more...

    IronCow and the design for testability

    IronCow is a library that wraps the Remember The Milk (RTM) web services. The “upper layer” of the IronCow API is an object model that stays in sync with the server and is designed with data binding in mind. Of course, one of the things that went into IronCow’s design was testability. IronCow ships with a suite of unit tests that, well, test that the API is working fine. However, there’s another testability aspect: how the clients of your API are going to test their stuff.
    Read more...

    Fixing a bug can cause bugs

    Microsoft apparently fixed something in .NET Framework 3.5 Service Pack 1 that previously didn't work, or somehow worked differently. As a result, Milkify will crash if used on a machine that doesn't have this service pack installed. What you get is a XamlParseException that says that a ContentStringFormat property cannot be converted into a TemplateBindingExtension. This is because Milkify is using its own WPF skin where, among others, the check box control has a new custom template.
    Read more...

    A variation on the auto-completing WPF TextBox

    In this world of web 2.0 tagging madness, any good (or at least shiny enough) application needs a way to apply tags in a user-friendly way, namely with auto-completing text boxes. For example, the awesome Remember The Milk application has this: What if we want a similar text box in WPF that would display a drop-down list of all the existing tags that match what the user is currently typing? The answer is, unfortunately, that we need to do it ourselves… but don’t be afraid, we’ll be playing around with cool things!
    Read more...

    WPF application patterns continued: convention over configuration

    In my previous post on WPF application patterns, I went over a few of the most common patterns available, and gave some pointers on how to implement them in WPF. I mentioned how you could use a dependency injection framework to decouple the implementation of your views and controllers from each other. However, the problem when using dependency injection out of the box is that you need an interface to bind to.
    Read more...

    Announcing IronCow

    One of the projects I'm working on at home, IronCow, is now in a state of "somewhat usable alpha". It's a .NET API that allows developers to use Remember The Milk, the to-do list website, from any .NET language. IronCow is composed of two layers. One layer is a "dumb" wrapper around the public REST API, in way very similar to what FlickrNet does with Flickr's own REST API. The second layer is a "rich" object model that exposes your tasks (and other data) through classes that stay in sync with the server as you manipulate them.
    Read more...