n2liquid's sandbox

Archive for the ‘Personal’ Category


I have recently created an account on MyFigureCollection.net, a really nice site in which you can post and manage collections of action figures you own, favorite and comment others’ photos, etc. It is pretty much a small social network for action figure enthusiasts.

Hatsune Miku and Black Gold Saw (MFC.net banner by Danboard_san)

The site contents truly is amazing, and I’ll certainly actively participate in it once I get a fine camera and more figures.

Overall the site is pretty good and the idea is really nice, but the service is not as good as it could be.

The matter of what is good and what is bad is pretty much personal, and there’s likely people out there who love MFC (no, not that MFC), but the site has a long way to go to suit my tastes in plenty.

For example, I think the site design could be greatly improved. Of course I can use Greasemonkey to do that, but people wouldn’t see it if I sent them links to my profile, so that only solves half the problem.

Another thing is that if I wanted to create some crazy relationships between my images (like saying 3 images have the same pose, only each has a different background and the last one is photoshopped to, say, remove the joints) I would have to resort to linking them in the description.

But I want better.

For a moment I thought about making a similar service with the changes I’d like to see, but I noticed it wouldn’t be worth it. Most people would stay in MFC.net, some would use both, and we would have the redundancy and mess that Orkut, Facebook, Google+ et al introduced.

It then striked me that these kinds of things wouldn’t happen if web federations like we had in Google Wave were more common.

Federated webspaces

Google Wave’s intent was to reinvent e-mail. One of the most important characteristcs of how e-mail works is that it is distributed.

Can you imagine how far behind we would be if we had a single e-mail provider? It could be Hotmail, guys!

The ability to set up a new mail server is something we take for granted, and we think we would be in a ridiculous position if we couldn’t.

And what if we had multiple e-mail providers that couldn’t send messages to each other? If your e-mail ended in @hotmail.com and mine ended in @gmail.com, I would have to create a Hotmail account just to send you a message. How freaking awkward would that be? Insane, isn’t it?

Insane it is, but that’s what we do when I’m on Facebook and you’re on Google+ today.

The creators of Wave obviously knew all this, and since they wanted to make “a better e-mail”, their product couldn’t have such a major setback, so they developed the Federation Protocol: a way to allow waves to cross server borders.

Not long ago, if I remember correctly, there was a big fuss around Facebook and its apparent reluctance in permitting users to interact with other services such as Twitter. Facebook has obviously changed its mind now, but they still don’t want to give users the ability to export their own data.

Also recently, Google decided to ban Anonymous from G+, and there’s been a lot of discussion on whether they should allow codenames to be used in their network. Some guys from Anonymous then decided to start work on their own social network, Anonplus (which, by the looks of it, isn’t going too far, but it is a noble initiative), but integration with other services is sure going to be tough.

There are many reasons to make social networks interact with each other, and it’s pretty much common sense that this is an important feature to have because the very idea of social networks is that people should be able to interact, and people are scattered across many different services.

One way of achieving such interactions is by federating a social network service just like we did for e-mail and Google Wave.

There is a social network called DIASPORA* being developed, whose server anyone can run an instance of locally and participate. This is by far the most promising social network project I’ve seen.

What I find, as a developer, particularly cool about federations, is that it allows nearly limitless personalization and improvement of services without breaking things. If MFC.net had a federation protocol, I would be able to friendly extend it instead of starting everything from scratch as if I hated it entirely. MFC.net is cool, I just want some small improvements here in there. No need for a wholly new service. That’s drastic.

Now, as a person, what I find important about federations is freedom.

If a service like G+ decides to ban me because it doesn’t like the ring of “n2liquid”, or because I’m excited about all the mess Anonymous is causing, I can just take my stuff and go to another server; maybe even my own if nobody likes me, and, in this case, I wouldn’t have to start a new social network project like Anonplus from scratch. I would simply pick something pre-made and put on a server, WordPress-style.

I hope somebody makes an easy-to-use framework for this so that everybody can effortlessly build the web of the future. XMPP is cool, but it’s nothing more than a foundation for such a framework. As it stands, I don’t see many people making simple websites like MFC.net using it for building federated networks.

I hope federations become the rule. It’s not just cool; it can become a pillar of internet freedom.

Got this from Play-Asia.com today:




Very well articulated, cute, and bigger than I expected \o/

She’s fantastic! *-* Btw, sorry for the low-qualiy shots.

For some reason I don’t yet understand, there’s an abyssal segregation of object-oriented and generic code. I’m still to meet someone who wholeheartedly supports both.

The OOP folks think dynamic dispatches have negligible performance impact most of the time, which is undeniably true, so they really don’t care virtuals aren’t used in generic programming. Generic programming’s biggest raison d’être is “somewhat cool” at best for object-oriented heads.

On the other hand, the GP folks think dynamic dispatching is a useless feature that comes with a considerable performance penalty, which is also undeniably true (that is, sometimes the performance penalty is considerable; that’s not in contradiction with what I said earlier).

Dynamic dispatch has almost identical performance to direct calls, but is much slower compared to a small inlined function. Either way, these small penalties sum up a lot in some cases.

In general, GP is used for writing scientific simulation software, because the calculations are so massive and the overheads really sum up, and the gains of inlining become blatant.

loli haets 3d!

C++ is a programming language that supports OOP and GP, but separates them; they just don’t click together in this language.

One of the strenghts of generic programming is its support for duck typing, albeit only compile-time duck typing. At the same time, generic programming-based duck typing in C++ is one of its major pitfalls, because you don’t really have a choice not to use it.

There’s always been some tricks to put restrictions on types accepted by templates in C++, but they were all very far from perfect. For those curious, I think the best bet currently is to use C++11’s static assertions and type traits.

Concepts were proposed to give C++’s generic programmers the ability to formalize requirements and restrictions for template parameters, but the standards committee declined putting it into C++11 because, as far as I know, they wanted the idea to mature more. There are good chances that concepts will be introduced in a future iteration of C++.

The problem I see with concepts is that they’re essentially redesigned classes with a few additions. They’re calling it something new, but concepts are quite similar to classes. In the case of C++ there are (probably arguable) reasons for the insertion of concepts instead of making improvements to classes, so I wouldn’t set my word to stone that this would be the best for that language, but I’m pretty sure this could work amazingly well for Chii.

Later I’ll post the ideas I have for doing good OOP+GP, the Chii way.


I blamed C++ (and pretty much all of the most famous languages too) on my previous post, and I left everything pretty much unjustified. That bothered me, but I didn’t feel great energies with the idea of going in-depth as to why everything sucks, in my most not humble opinion, bear in mind.

So it occurred me that instead of blaming everything I hate (and boy, that’s a lot), it’d be easier to describe what I’d love to have (that’s also a lot, but still fewer than what I hate).

Chii (from Chobits) on the Water TowerI love helpless cuties. I also love persocons and, obviously, I love Japan.

So, it’s only natural, if I were to name my programming language, it’d gotta be Chii!

Since programming languages have many aspects to them, it’s hard to “explain everything in a single go”. Doing that would make this blog post become a book, but I want to go slowly and in small steps, so I’ll create a category “Chii Language / Chii’s Design”.

You can see how’s the progress by navigating the Chii Language / Chii’s Design category.

I’m gonna use this first post to talk a little about one of the first things I thought about Chii:


I imagine something quite complex when it comes to enumerations. It’s not my fault the current definition of an enumeration is so oversimplified, though.

An enumeration should create a data type capable of… well, enumerating a discrete set of values that carry special meanings. Enumerations are a very basic language construct, so they certainly get used a lot; but in my experience, most cases that call for an enumeration are simply too much for this language construct, and I end up avoiding them.

For Chii I would like an enumeration solution that really solved the problem of enumerating things. The first feature I’m interested in is called sparse enumerations.

I also gave a bit of thought to some other important aspects of enumerations, like inheritance, but they’re not well consolidated in my head yet, so I’ll have to post them later.

On to what matters…

Sparse Enumerations

Sometimes the elements of an enumeration are dictated by possibilities scattered throughout many files. If such an enum has to be defined all in a single place, you end up having to make changes to it. This doesn’t feel much like you’re plugging files together, but more like you’re gluing them.

Sparse enums allow you to define an enum in many different places and use it just like a regular enum.

Suppose you have an image resizer component that supports many different filtering algorithms. You write the resizer, declare an enum FilterType, and let the many different filtering algorithm modules “extend” this enum.

Another example in pseudo-code:

// File A
enum InputPackage.Button { CROSS, SQUARE, TRIANGLE, CIRCLE };

// File B
enum InputPackage.Button { DOWN, LEFT, UP, RIGHT };

// File C
// naturally use those sparsely defined
// enumerations as one would expect to be able to
InputPackage.Button pressed = DOWN | LEFT | CIRCLE;

An enum can be marked final, in which case it cannot be sparsely defined:

// File A
final enum MyPackage.StrictState { STATE_A, STATE_B, STATE_C };

// File B
enum MyPackage.StrictState { STATE_D }; // error; MyPackage.StrictState
                                        // is marked final elsewhere

Keep in mind that I’ve only quickly skimmed through those ideas. They certainly must be properly studied and improved before making real sense and actually solving problems and not just being another fallacious dream of mine.

Yet, I’d love to hear early constructive opinions, if you cared to leave a part of you in this blog; thanks. 🙂

Afternote: I think I could’ve been more specific when I targeted imperative languages; I think I should’ve said procedural languages instead. Not that it changes much, just to be pedantic…

I know, I know, there are lots of blog posts and web pages telling why their authors hate C++.

I know putting yet another one on the network won’t give me much visibility. I know most people will just ignore it thinking I’ll just reiterate over the same points again.

But I have to say, as a foreword, that I never entirely agreed to any of such rants, so this one might be just a little bit “new” compared to them.

I used to really love C++

… for its C-like closer-to-the-hardware (compared to most other languages) approach. For one, I felt like C++ would never push me towards dynamic allocation when that wasn’t needed. It’d never push me towards dynamic dispatching when that wasn’t needed. Wouldn’t push me towards pointers unless they were really called for.

I felt that I had total control over my tool set

When you drive a car you start feeling like it’s an extension to your body; you know your summed up dimensions, so you don’t crash when taking it out of the garage.

In the case of higher-level languages like Java, C#, or even Delphi or Visual Basic, when you do something, you always have to ask others what are the exact implications of what you’re doing.

Are you comparing strings without knowing? Are you using dynamic dispatch when you think you’re doing an extremely trivial task inside a tight-like-hell loop?

Documentation never makes those things clear.

For reasons I’m not really sure, ever since I started using C++, I always felt like I automagically knew the implications of all my steps. I knew I wasn’t buying bloat for a triviality.

As my knowledge of the language evolved and I discovered new language features, I was always surprised that even though that feature was there, I hardly ever used it even if indirectly. And they were still very useful. And I never took more than a few minutes to understand how that worked and exactly how it’d impact my code.

I can’t say I was never took by surprise. For example, I remember I was shocked when I discovered dynamic_cast would do an insane amount of string comparisons depending on the implementation. But, frankly, I don’t remember of any other event like this.

I then started using Java at the university

And was damn shocked that people just starting to code were using a very large chunk of the C++ tool set without even knowing it. Every breath a Java programmer take causes a handful of virtual dispatches (edit: I didn’t know the JIT’ter eliminated those back then, heh) and dynamic allocations to happen behind the scenes.

Everything is a pointer, so everything gets dynamically allocated (okay, maybe the VM actually puts stuff in the stack when it thinks it’s a good idea, but the point is that you don’t see this happening; the programmer is blind to those details), every variable is nullable, pass by reference and pass by value are mangled into the same syntax and people don’t get it why modifying an object argument modifies the original one, and why modifying an integer argument doesn’t. They have no idea how tough string concatenation really is for a computer and simply use it blindly all the time, among other things…

“Hahaha!! Java’s such an utter mess~! :3”, I thought. “Thank goodness I’m a C++ programmer :’DD”.

Even today I don’t know what magic spell is used so that the processor prefetches the right code path when a Java method is called, or if Java programmers just don’t care about those things. “Come on, that doesn’t impact code speed!”, right?

Well, I am a game programmer. I must be able to make things look good on a Nintendo DS. I’m sorry if my game doesn’t run in a data center cluster, ok? I’ve seen presentations showing how proper caching and prefetching impact PS3 games, and no over-engineered piece of OOP code compensates for one cache miss every two instructions.

Same thing goes for C#, and I didn’t even get started with dynamically typed languages.

So, seeing how every language used so many things C and C++ taught me were not to be taken lightly without even telling me, I felt C++ was my safe little castle. And it was very comfy while it lasted.

Then I started understanding better why C++’s features existed

I started understanding that OOP didn’t just mean creating objects the way I saw fit. I bumped upon the principles of object-oriented design, and I felt I groked a bunch of them.

I thought I finally understood what designing software was like and started foaming through the mouth like a mad dog to put everything into practice. I felt I understood what good software design really was about.

I noticed that even though I understood that a class should respect the open-closed principle (OCP), any but the simplest of the classes played well with it when putting it into practice using C++.

I noticed that soon enough my classes simply had to be modified to be extended, and the more I struggled to make them “OCP-compliant”, the more I had to resort to dynamic_cast‘s, hash maps, etc., slowly drifting towards C++’s higher-level, heavier constructs.

I might as well just switch to a dynamic language if I’m to use everything I have to use to make this shit work. And we’re just talking about one of the most basic principles of OOP here.

I then thought I should remain calm, though. C++ just had to have means to do things right without becoming Java-without-the-VM. So I started digging into templates and template metaprogramming, just to find out those features were largely meant for a different paradigm altogether.

C++ isn’t just OOP, it’s multi-paradigm, remember?

So I got in touch with this new paradigm, called generic programming (GP), and noticed it simply didn’t click with OOP, at least not in C++.

“Wtf?”, I asked myself. “It feels as though I’m programming the same thing in two different, incompatible programming languages!”, I thought. I could write part of my code using GP, part of it using OOP and more or less get both parts to “talk” one to another, but sure like hell both paradigms couldn’t coexist inside one same logical part of my code.

This confused me a lot.

At first sight, C++’s templates and OOP looked like they’d beautifully complement each other, but that couldn’t be further from the truth.

Getting them to complement each other requires hacking through the most obscure quirks of template metaprogramming and discovering just how ugly the C++ standard really is.

I discovered that, overall, the GP guys don’t like OOP, and the OOP guys don’t like GP, and that templates were introduced into C++ so that it would support GP just for the sake of those who liked that paradigm. No effort seems to have been put to make both work well together.

Some guys from the Research and Development Laboratory at EPITA, a french computer engineering graduate school (whose website seems to be offline for years; does anybody know why?), who, like me, were not fully satisfied with either GP or OOP actually got to mix both together using pure C++.

They named this technique SCOOP (Static C++ Object-Oriented Programming) and released a library to ease its use, and although I really respect those guys for what they did, I feel like SCOOP may all-too-easily become a maintenance nightmare, not to mention nobody would understand your code if you started using SCOOP in your everyday code.

This discovery was the last straw it took me to accept my idealization of C++ as simply one massively giant fallacy. Not only programming the way I thought was right would produce hard-to-maintain, hard-to-understand code, it would also use too much templates, which basically means the memory footprint would skyrocket because the compiler would vomit infinite amounts of slightly different versions of the same machine code into the executable file, which is generally cool on the PC, where memory is abundant, but is just suicide in embedded devices like video-games.

Ever since then I feel like C++ just can’t convey my voice anymore, be it like a computer or a video-game developer.

C++’s expressiveness dried out for me

When I write C++ code now I feel like I’m wearing a goddamn straitjacket.

My mind goes blank and I can’t help myself to write anything. All attempts to equalize my code with the best practices in my mind feel like I’m bumping into walls.

What bothers me the most, though, is how everybody is just happily getting stuff done in the world, be it with C, C++, Java, C#, Python, Ruby, JavaScript, or whatnot, while I’m completely stuck watching them breaking each and every principle of OOP and saying they love OOP.

I think now’s a good time to ask you what the hell do you mean when you say you feel comfortable with the OOP expressiveness of your language?

Sure, you can more of less map the agents of your problem-universe and it kinda feels like your design is “living”. But you must be fucking kidding me if you tell me you can write good OOP with Java or C#, or even C++.

With the currently available statically-typed languages, I don’t see how the best OOP practices can be put into use. Static typing simply fucks it big time.

If you’re creating classes in Java, C#, or C++ and thinking you’re actually doing mankind a favor you’re just fooling yourself. You are not. You’re just awkwardly getting the work done. Your OOP skills are a joke. You should reeducate yourself. You’re sacrificing your most brilliant ideas by writing them the wrong way, making everybody have to rewrite them later if they want to reuse them.

Languages like JavaScript, on the other hand…

… from what I have seen, really do empower you as a programmer.

But JavaScript is a gigantic hash map, and what did I say about taking strings, the computer cache, and memory footprint lightly?


I want a language that empowers me, but not by defecating on the hardware’s head. What do I do?


I’ve written a lot in this post, but I passed far from explaining why I think this way. Hopefully you’ll forgive me for not citing any references. I’m just too depressed to get things straight. This post isn’t as much for you as it is for me, the n2 whose brain is bursting to flames and wanted to write down the reasons why.

I still feel the urge to code, but I’m afraid it will pass with every failed attempt to feel good programming again.

I might try one of those purely functional programming languages out there, but I don’t see how a game could be naturally described with them.

And, really… I hate C++ now. No other language seems to solve my problems, but at least they didn’t deceive me for so long. I wish I could believe somebody would point me out to something in it that would enlighten me and let me restart my programming journey, but I’m afraid I’ve seen enough of C++ to know this isn’t going to happen. I need something else.

And I need something new.

Tell them you’re only 18.

And you’re not even trying out Mary Jane, cocaine, MDMA, LSD or gay sex.


It’s just JavaScriptCoffeeScriptserver-side JavaScriptautomatic programming, and Haskell, goddamn it!

I have around 9…

C++ class interfaces to write before SonettoJS development can proceed, plus their Direct3D implementations

Those are:

  • Texture

    Houses a GPU texture resource. It has a target channel, format, width, height, mipmap depth, and the texture data (which’s actually inside a GPU buffer).

  • IndexBuffer

    Houses an array of indices in GPU memory. It basically contains a switch determining the index format (16- or 32-bit), a length, and the index data (which’s, again, inside a GPU buffer).

  • VertexBuffer

    Is the same but for vertices. It contains a vertex declaration which specifies the format of each vertex (what data, e.g. position, normal, color, texture coordinates, etc., is available for each vertex and its offset relative to the beginning of the vertex), a length and the vertex data itself (held by the GPU).

  • PixelShader and VertexShader (or maybe a mixed ShaderProgram)

    Hold pixel (also called “fragment” in OpenGL) and/or vertex shaders. They simply receive the shader data and manage it in GPU memory.

  • ShaderConstant

    Represent a shader constant (contrary to what that page looks like, shader constants are also available in shader models prior to 4; shader constants are also called “uniforms” in OpenGL). These are parameters sent to the shader programs that don’t change while it executes, e.g. lighting data, the current time or a deformed skeleton used for hardware skinning.

  • FillMode

    Just holds the way triangles are meant be be filled. This can be either “solid” or “wireframe”.

  • BackFaceCullingMode

    Expresses how triangles are meant to be back-face culled. This can be “none” (culling disabled), “clockwise” or “counter-clockwise”.

  • PixelBlending

    Controls how drawn objects are blended with their target surface. Pixel blending (known as “alpha blending” in Direct3D, when in fact it may not use alpha information at all; that’s why I call it pixel blending) can be enabled or disabled. If enabled, the blending depends on three parameters: blend operation and source and destination blend factors.

Those are pretty simple to implement, and once written will allow me to do a lot of 3D job already. Although there are other important things beyond them, I preferred to delay thinking about that at least until I can get around to implement those first.

I’m pretty confident these are all absolutely required, and also pretty confident I know how to implement each.

But I just can’t get around writing them because it seems so fucking downright boring!!!

Conceptually they’re nice, in practice an infinite amount of fancy stuff can be done with them, but implementing these classes just suck.

Especially because I have to write them in C++…

I hate when code doesn’t fully capture my thoughts

And C++ really isn’t helping me at that lately.

You see, each class is actually an interface whose implementations must conform to. I can ensure all implementations will feature all the mandatory methods through inheritance, but I still can’t ensure the users of the implementation classes will be able use them absolutely as if they were using their interfaces, because there’s no way I can formally enforce a class will be constructible in any given way.

The abstract factory pattern is exactly what I would need, but I couldn’t find any satisfactory way to use it in this case.


Until now, that is, because writing this post made me suddenly come up with an idea!

How does SCT relate to all this?

My point here is that I had a handful to write in these damn past two weeks (for chrissake, two breathing weeks threw out through the window), but I didn’t feel energy to write a single useful line because I was stuck thinking how it was all boring and that I didn’t know how to solve the construction problem.

I slept a lot, even drunk the hell outta myself three days ago, because even wanting so bad to work on this, even feeling that my whole life depended on it, and knowing that there were things I could write beyond the fucking class constructors, I didn’t manage to work.

And the worst part is that now that I’m feeling I know how everything clicks together, writing the classes don’t even feel boring anymore! How can one explain that? I’ve just said doing that was boring inside an h2 tag and suddenly it doesn’t seem boring anymore, because I’m excited feeling that I can sit down, write the code and be sure everything will be into place the way I intended them to be.

There are three equally plausible answers or a combination thereof: 1) SCT fucks me up and will eventually fuck up my whole life, 2) I’m a spoiled little brat that won’t do things unless they’re exactly the way I want, or 3) I really am just lazy and will only work when excited.

If anyone out there suffers the way I do, I’d really want to meet such a person

In teh world wild webz there’s bound to be someone who feels the same as me. If you’re reading this and you do feel like that, or if you know somebody who’s just like this, please contact me.

I’ll go crazy if I can’t understand what’s happening to me and how can I work around this problem.


Twitter (technical)

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Twitter (personal)

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Get messaged when I post something new!
Just enter your e-mail and hit Follow:

Join 171 other followers

%d bloggers like this: