Software/Device Development and Design

Unity3D Supports All .NET/CLR/Mono Languages

I've noticed there's a very common belief in the community that Unity3D can be used with exactly three languages: C#, JavaScript and Boo. (Well, plus C++ if you count Unity's "native plugins" - but there are various issues with that.)

That myth needs to be dispelled.

Yes, Unity only claims to support those specific languages, but the fact is, Unity knows nearly jack about any of them. It knows how to invoke their compilers, but that's about it. What Unity does know however, is Mono. Mono is what Unity uses for scripting, not C#, not JavaScript, not Boo.

Mono, of course, is an alternate implementation of .NET's CLR and libraries. As such, Mono, and therefore Unity3D, will happily run software written in any CLR/.NET/Mono-based language. Such as F# or VB.NET or Nemerle. Personally, I use Nemerle for my Unity work.

So how do you do it? Two steps:

1. Compile your code to a .NET assembly using any compiler for any .NET/CLR/Mono language you dang well choose.

2. Put the resulting DLL into your Unity project's Assets folder.

Simple.

And thanks to the metadata embedded into .NET assemblies, even your public fields will still show up, fully editable as ever, in the Unity editor.

Just because the Create Asset menu only shows C#, JavaScript and Boo doesn't mean that's all you can use. My car stereo lacks a button for "Play Duran Duran" and yet their Rio disc works just fine. Amazing!

On a related note: People, just because Unity automatically launches MonoDevelop when you tell it to edit your code, doesn't mean you actually have to use MonoDevelop to edit your code. Don't like MonoDevelop? Fine. Use something else. Pretty simple solution, huh? (Don't know how? Then I suggest starting with this. You may think I'm joking, but you'd be surprised how many professional programmers don't know how to use a computer.) Personally, I use Programmer's Notepad 2 for code editing, but there are plenty of choices out there.

Read more


MTP, MSC and Google iOS

If you work at either Google or Microsoft and you have had any hand in MTP or the demise of Android's MSC, then you deserve to die. Fuck you and go to hell.

And to all those employed by Google and Microsoft: Quit trying to be Apple, you worthless goddamn subhuman shits.

Read more


Mozilla Doesn't Know What They're Doing

I could go on forever with examples, but I'm going to limit myself to just one for now: How freaking hard is it to unfuck "Save Image As"? Mozilla's been screwing that up in various ways for about five years. Here's a fun instance of Mozilla's complete uselessness.

And of course, in my case the broken "Save Image As" is yet another new previously undiscovered incarnation:

On FF22:

Error: NS_ERROR_INVALID_POINTER: Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIIOService.newFileURI] Source File: chrome://global/content/contentAreaUtils.js Line: 771

Read more


Do Not Use git status --ignored

Sometimes it's useful to find all files in a git working copy that aren't being tracked in the repository. There's an --ignored switch for git status that's supposed to make it show the ignored files. Combined with --untracked-files, that should do the trick nicely. But the problem: The --ignored switch doesn't fucking work. Seriously.

To be more accurate, it only shows some of the ignored files (despite no mention of this fact in the man page). It's easy fooled: Just try adding someUntrackedDirWithUntrackedFiles/* to your .gitignore, and see if you can get git status to mention either the directory or the files inside it. Note that none of the settings for --untracked-files= fix this.

Wanna know the best part? There is no git command known to reliably do what --ignored claims to do. There are various alleged solutions floating around, but unfortunately they don't work. The author in that last link offers a suggestion, but still admits to a lack of confidence in it. Great.

My suggestion is what I recommend for git usage in general: Minimize your reliance on any features beyond the basics. For such an amazingly useful tool (I highly recommend switching to git if you're still on subversion - or worse, CVS or VSS), it's amazing how shitty git gets the deeper you dive into it.

In this case, I suggest using git ls-files to generate a list of the files that are under version control, stick them into a hash set (for quick lookup), then iterate over all the files in your working copy, outputting only the files that aren't in the hash set.

Here's how to do it in D:

/++ Show all unversioned (both untracked and ignored) files and directories in the current git working copy. Much like "git status --ignored --untracked-files=all" except this actually works (although you must run it from the root of the working copy). Further explanation: https://semitwist.com/articles/article/view/do-not-use-git-status-ignored Tested on DMD v2.063.2 Licensed under the WTFPL - Do What the Fuck You Want to Public License: http://www.wtfpl.net/ +/ import std.algorithm; import std.array; import std.file; import std.path; import std.process; import std.stdio; import std.string; string run(string cmd) { auto result = executeShell(cmd); if(result.status != 0) throw new Exception("Command failed: " ~ cmd); return result.output; } void main() { if(!exists(".git")) throw new Exception("Must run from the root of the git working copy"); bool[string] versionedFiles; auto gitOutput = run("git ls-files"); foreach(filename; gitOutput.splitter("\n")) { versionedFiles[filename] = true; // Also include the file's parent directories, since git likes to // pretend there's no such thing as directories: while(true) { auto parentDir = dirName(filename); if(parentDir == filename) break; // Done versionedFiles[parentDir] = true; filename = parentDir; } } foreach(DirEntry entry; dirEntries(".", SpanMode.breadth)) { // The output of "git ls-files" doesn't include the "./" prefix // (like DirEntry does) and uses forward slashes on all platforms. auto filename = entry.name.replace("\\", "/").chompPrefix("./"); if(filename !in versionedFiles) { if(entry.isDir) writeln(filename, "/"); else writeln(filename); } } }

Read more


Debian's Package System is Shit

It's two-thousand-goddamn-thirteen: Why the crap are we manually screwing around with arcane instructions, some arbitrary config file, obtuse meaningless substitute names for the real fucking version number, and the whole disabled-by-default "backports" bullshit, all just to install a vaguely recent version of some program or lib, that's already been backported (really? Shit needs to be ported from Debian to Debian?!?) to whatever version of Debian we're using? What the fuck is this, 90's Slackware?

This is how sane shit works:

% sudo apt-get install libevent2 Ok boss, done.

Or even this:

% sudo apt-get install libevent2 ERROR: That's only available in the 'backports' repo which is disabled by default. You must use the flag '--backports' to install software from the 'backports' repo. % sudo apt-get install libevent2 --backports Ok boss, done.

(I've been writing software nearly all my life and I can tell you right now there is no technical reason why that can't work.)

On the other hand, this is how obtuse moronic bullshit works:

% sudo apt-get install libevent2 'libevent2'? Never heard of it. % sudo apt-get install libevent Installing some useless ancient version...done % Gee, thanks error: Piss off % websearch "how to install libevent2 on debian" Results: Whole bunch of useless crap and some vague buried mention of needing some "backports". % websearch "how to use backports on debian" Results: Bunch of crap and some mention of adding "deb http://YOURMIRROR.debian.org/debian-backports squeeze-backports(-sloppy) main" to some 'sources.list' file. If you're lucky it tells you where fuck 'sources.list' actually is. % gksudo kate /etc/apt/sources.list > /dev/null 2> /dev/null & (Isn't launching a GUI program from the Unix cmdline fun? Almost makes Windows look good. Sort of...) % sudo apt-get update Barf. You were clever enough to guess what YOURMIRROR was supposed to be changed to by blindly copy-pasting from some other random line in the same file, but I'm still gonna crap out for you with unhelpful errors anyway. % remove the "(-sloppy)" bullshit from the new line, because by dumb luck I just happen to know that doesn't belong there. Ok. % sudo apt-get update Could not resolve 'ftp.us.debian.org' (Fucking SERIOUSLY?!?! Yes, I really got that.) % sudo apt-get update (Partially works this time.) % sudo apt-get install libevent2 Never heard of it. % sudo apt-get install libevent2-dev Never heard of it. % sudo aptitude update Sure dude, whatever I guess... % sudo aptitude install libevent2 Never heard of it. % sudo aptitude install libevent2-dev Never heard of it. % websearch "It didn't fucking work, asshole!" Ehh, ok, well what version of Debian you using? % debian 6 Never heard of Debian 6 % What the fuck, you stupid...&*(@#$&^*(?!? Never heard of Debian 6. Please enter the name of some random-fuck Toy Story character instead. % ugh...fine...ummm, a=1, b=2...e=5... And no cheating by using any sane ordering, we've made sure that won't work, either. % FUCK YOU error: command is unrelated to Toy Story. Go screw off and come back when you care more about Pixar. % post-rant "Debian's Package System is Shit..."

Guess which of the above most closely resembles Debian.

It's no &*$^@# wonder that MS-slave corporate suits are such douchebag snobs towards Unix.

If there is already active work in progress at fixing this mess, then sincerely: KUDOS!

Read more


Facebook is not written in PHP

Yea, I know you're thinking "This guy's nuts! Everyone knows Facebook is PHP!" Sit down, shaddup, and I'll explain...

But let me address this first: The claim that "Facebook is written in PHP" is frequently used to rationalize using the world's worst language. This is, of course, idiotic because appeal to authority is a logical fallacy. To put it in simpler terms: Just because Ozzy Osbourne abused the hell out of drugs and alcohol and wound up rich, famous and alive, obviously doesn't mean it's a good approach to imitate. Get the picture? So quit saying stupid shit like "PHP is fine because XXXX uses it". It makes it obvious you're an idiot.

Ok, back to Facebook's usage, or not, of PHP:

Like any remotely sane company, Facebook doesn't use PHP for its core systems. The actual "core stuff" language used varies by company, but at Facebook, they "use C++ heavily on [their] back-end systems"[1]. In fact, they "use C++ at Facebook all over the place".

While Facebook has things that are ostensibly PHP, it's not the real PHP. The real PHP is such a piece of shit, Facebook had to write their own alternate version of it (HipHop's HPHPc, which converted the "PHP" to C++). Then they had to make another, the HPHPi. And then yet another, the HipHop VM. Facebook does not use real PHP, and that's because true PHP is just simply crap unsuitable for them.

Not only that, but the psuedo-PHP that Facebook does use is being quickly overtaken by Facebook's increasing usage of C++: "...two years ago, maybe 90% of [Facebook] programmers wrote PHP and 10% C++. Now there are roughly as many C++ programmers as PHP programmers." Additionally, Facebook has had growing internal interest in D (note that link is over a year old already), and Facebook's HipHop team is one of the sponsors at this year's D conference.

So ultimately, no; contrary to conventional "wisdom", Facebook is not written in PHP.

[1]: See question #4 here.

Read more