The great thing about mono and C#

So, it seems like a ton of programs I've been trying to use recently don't work with the latest version of their dependencies. For instance, Metasploit doesn't work with Ruby >= 2.0. I was using some other program that required Python 2.0 rather than 3. And we've all heard the horror stories about programs requiring specific versions of Java.

I never have this problem with C# though. In theory, it could happen.. but Microsoft really likes keeping things compatible, it's their business plan. And as an extension of that, Mono never seems to flat-out drop support for anything in their core software. I have never seen a program that requires a specific version of .Net or Mono.

This is awesome! The worst thing I have to do with Mono is compile it from git so that I get pre-release (good) support of portable class libraries. Now, let's break this down. Why exactly is it like this though?

  • C#/.Net uses compiled-to IL
    • This prevents that issue of deprecating or changing misleading language features. It's all IL after compilation, so it doesn't matter
  • There is a spec for .Net. In theory, if you abide by the ECMA spec, most things should work, logic-wise
  • It's easy to take my dependencies with me with .Net

Now let's step through why this isn't easy with Ruby/Python

  • The language is improving and getting better. This can cause old programs to break, but is unavoidable with scripting languages
  • There isn't a spec that the latest version will always implement. This is probably a good thing though
  • There is a huge emphasis on not taking your dependencies with you. This leads to breaking changes in gems and such breaking your program.

What about Java? Honestly, I have no idea why Java doesn't benefit more. In theory, they should be equally as capable as .Net.

Am I saying .Net is perfect? By all means, no. In fact, .Net has seen some breaking changes

  1. I've a JIT bug that only happens when using .Net 4.5's runtime, not .Net 2.0's
  2. In .Net 4.5, they changed marshaling to be more "strict", breaking at least one program I've seen (at my work)

And mono of course is (by design), not a complete copy of Microsoft's .Net. In fact, I've even seen a bug where .Net accepted a piece of IL, where Mono broke, due to Microsoft not being "strict" about the ECMA spec.

With all that being said though, this seems to be the major leg-up for compiled to bytecode languages. They'll probably work a very long time, despite the bytecode runner being updated.

This is also avoidable. I've seen some scripting language use a version number attribute, so that it can avoid this scenario. I'm sure there are other methods as well.

All I know is, I'm tired having python 2 and 3 installed on my system because not all my programs will run on just one or the other.

Posted: 6/3/2013 5:49:16 AM

MarkdownSharp is freaking slow!

So, I use MarkdownSharp on this website for translating my posts from markdown to HTML. During a profiling session, I found that MarkdownSharp is horribly HORRIBLY slow. It was the bottle neck of my entire website. On my personal machine, requests per second went from 325 (or ~22ms per request) to 720 (or ~9ms per request) when I cached the markdown translated text.

Personally, I find it pitiful that Markdown was more of a bottleneck than my database. Getting of my post data from my database: ~5 ms. Translating all of the text in the posts to HTML: ~15ms. What the hell is wrong with this!?

I'm sure Markdown isn't trivial to translate of course, and mono generally sucks at string operations anyway. But still, I find this absolutely ridiculous that the only thing so far I've had to cache is markdown translations.

Anyway, this website is updated now and should be capable of handling about 100 requests per second. I suspect the primary reason I can't achieve anything higher than that is a combination of Apache having a lot of overhead and my VPS being rather weak anyway. But, this should be plenty for this low traffic blog.

Posted: 12/3/2012 4:36:54 AM