Technology brotherhoods

I often hear people talking about which technology is better between C / C++ / C# .Net / java. Most of the time, it’s more a political/brotherhood/community thing (like football, even thought frenchies like me aren’t so proud of their team now) than a technical talk. I find it absurd. Computer science is about efficiency and making more money. You can take into account the pleasure you have to work on a technology (as you will be more likely to be more efficient with it), but it should still remain about efficiency. ...

July 6, 2010 · Florent Clairambault

Recycling .net objects to improve performances

C# .Net allocation and freeing system is quite efficient but when you need to create a huge number of objects, it’s just not fast enough. So what you can do is try to recycle each object to avoid to recreate them. You will then just need to set their property. In my tests, this class reduced the allocation time from 12 to 15 times: public sealed class Heap<T> where T:class, new() { private readonly Stack<T> _stack = new Stack<T>(); private int _count; public T Allocate() { if ( _count == ) { return new T(); } else { --_count; return _stack.Pop(); } } public void Free( T obj ) { ++_count; _stack.Push( obj ); } } You might think that this process is really painful as you have to manually free every single objects you use. But in fact you just have to recycle most of the objects. If you forget some, that’s not really important (they will just get garbage collected). ...

June 15, 2010 · Florent Clairambault

Google PowerMeter and sample C# .Net API usage

Update 2011-06-25 A lot of people still contact me about this project. I received this mail today, just in case you’re getting interested by the project, you should know that it will die pretty soon: Dear PowerMeter User, We first launched Google PowerMeter as a Google.org project to raise awareness about the importance of giving people access to their energy information. Since our launch, there’s been more attention brought to this issue, and we’re excited that PowerMeter has helped demonstrate the importance of access to energy data. However, our efforts have not scaled as quickly as we would have liked, so we have decided to retire PowerMeter. ...

May 29, 2010 · Florent Clairambault

Stupid C++ vs C# performance comparison

I found out that there is real test than the little one I did here. The core of the post is this spreadsheet : I recently did a basic comparison test between C++ (g++) and C# .Net (mono). My point is to show that the .Net framework has performances close to the C++ ones. It allows automatic hardware-specific optimization. The only real drawback you have in the .Net framework is the garbage collector. It prevents the C# .Net it from being a realtime language/framework. But does it really matter for you ? ...

February 26, 2010 · Florent Clairambault

D language

This is just a very short post about this language I recently discovered : the D language. As described on its little website : “D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. Special attention is given to the needs of quality assurance, documentation, management, portability and reliability.”. It has most of the features of the java and the C# (best language ever), but it is fully compiled (no JVM or JIT stuff). ...

February 25, 2010 · Florent Clairambault

SPSecurity.RunWithElevatedPrivileges

If like me you’re wondering what exactly does SPSecurity.RunWithElevatedPrivileges, this is what I understand of it : SPSecurity.RunWithElevatedPrivileges( () => { using( var newSite = new SPSite( site.Url ) ) { // your stuff } }); Is equivalent to : using( var newSite = new SPSite( site.Url, site.SystemAccount.Token ) ) { // your stuff } So if this is just to open an elevated privilege SPSite, it will be equivalent. But if you do some more complex things, as soon as you load a new SPSite it will open it with the original UserToken. And you lose… ...

February 22, 2010 · Florent Clairambault

C# .Net : How works automatic assembly versioning

When you choose to automatically generate a new version of your assembly at compilation, you have to set in the AssemblyInfo.cs file, this line : // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] But what do these automatically generated numbers mean ? Well, chances are you don’t care. But one day after using this features for years I decided that I would. ...

February 21, 2010 · Florent Clairambault

Loading plugins assemblies in .Net

This might seem like a quite complex thing to do, but it’s in fact very simple. Thank you .Net for being so well built. Note: With .Net 3.5, there is a much more advanced method called Add-In. But it’s also much more complex. You should use it on long-term projects with some evolutions of the plugins API (and no possibility to change the plugins). I’ve used it for a project and that really made us lose a lot of time. ...

December 1, 2009 · Florent Clairambault

NDepend

Title: A Review of NDepend Patrick Smacchia kindly provided me with a professional license for v2.12 so I could explore and share my thoughts. As it was a gift, I made sure to spend some time diving into its features. After exploring it thoroughly, I must say I like it. NDepend isn’t the ultimate tool you must use, but, like others such as Resharper or Reflector, it gives you a valuable perspective on your codebase. ...

November 8, 2009 · Florent Clairambault

.Net, Flex and WebORB.Net

I’ve been working on a project where we had to use Flex on a .Net environment and it had to be realtime. I was a little worried at first that it could be tricky to set up. But with WebORB.Net it’s pretty easy. We used the integrated RTMP (Real Time Messaging Protocol) messaging server. It’s almost like using WCF. The most important differences are that, by default, objects are transmitted as Hashtable and calls can’t be synchronous. We can bind the object to right .Net object within the WebOrb management console but we decided to do it ourself using reflection (because we don’t like to depend too much on the management console). ...

October 24, 2009 · Florent Clairambault