20

I have seen articles discussing these two similar frameworks, but most of them are two years old or so. I assume both projects are much more mature now than they were two years ago, and the situation is a more complex one.

So given the current states of each of the libraries, I was hoping someone could provide a detailed explanation of the advantages and disadvantages of each, and which should be preferred at present time.

Noldorin
  • 144,213
  • 56
  • 264
  • 302
cloudraven
  • 2,484
  • 1
  • 24
  • 49
  • Not sure why there are 2 close requests. The question is perfectly valid. – leppie Jul 20 '11 at 12:56
  • Why the votes for "not constructive"? The question does ask for facts and current status of the project, not "which one you like better". Please don't be deletionists of SO ;) – viraptor Jul 20 '11 at 12:58
  • 2
    I also am curious as to this question. A nice detailed answer comparing the two would be much appreciated, so I'm going to set a bounty here. :-) – Noldorin Sep 17 '11 at 15:08
  • Thanks for setting the bounty. We got a very nice answer here – cloudraven Sep 30 '11 at 20:19

2 Answers2

12

CCI

Pros:

  • Can give you finer-grained control on your performance
  • The latest version is a bit more mature

Cons:

  • The object model is more complicated (and confusing if you're new to IL/low-level reflections, like I am)

Cecil (referring to the newer git-hub version)

Pros:

  • Has a simpler object model so will be easier to get started on

Cons:

  • The latest version is less mature, so has fewer code samples available
  • The API is a work-in-progress
  • You won't have as much control over name-caching (for perf)

Which I'd choose

Couting up the pros/cons, it sure looks like I'd pick CCI over Cecil. But I wouldn't.

Cecil is up-and-coming, has an easy API design, has an active authorship (well, did 7.5 months ago, and still seems to now), and was painless to debug through on any issue I encountered.

CCI was quite painful to code against - the interface-based design is taken too far. The code is hard to debug through. Some things seem complete at first glance, but aren't, or don't handle more than a single use case. The NameTable stuff made my head spin (more than it already was).

Merlyn Morgan-Graham
  • 58,163
  • 16
  • 128
  • 183
  • I can't quite remember, but I also think CCI has better support for high-level code generation. Also, support was good/fast for Cecil :) – Merlyn Morgan-Graham Sep 17 '11 at 15:22
  • Can you provide any direct evidence for some of this comments? Also, I'm curious about performance. My suspicion is that Cecil has had much more work gone into it really. It seems to be more used in open-source projects too. Any thoughts? – Noldorin Sep 22 '11 at 02:56
  • @Noldorin: This is my anecdotal experience from trying both out 7 and a half months ago. I got a semi-working solution in CCI, and ditched it for Cecil. Yes, there's probably a lot more work put into it Cecil since then. I remember my worst problems were with: detecting *all* dependent types, determining base types, and doing code generation. My project was to reflect over a type graph and code-gen cleaned-up versions of the types, using lists rather than arrays, nullable types, etc. CCI provided automatic (but incomplete?) visitor-pattern traversal. I don't think Cecil did. – Merlyn Morgan-Graham Sep 22 '11 at 03:09
  • @Noldorin: Also I think CCI had high-level codegen support (?), and Cecil didn't. So I used T4 templates for generating the code once I had the basic types/properties created. Sorry if any of this ends up being misinformation, I just haven't touched it since I finished that project. It took some hero-coding to finish... :) – Merlyn Morgan-Graham Sep 22 '11 at 03:10
  • @Noldorin: As for performance, CCI has [this NameTable concept](http://ccimetadata.codeplex.com/wikipage?title=The%20NameTable%20Object) that should reduce some of the duplication of reflection overhead. It was a pain to work with, tho. – Merlyn Morgan-Graham Sep 22 '11 at 03:15
  • Thanks for the information. I'm tempted to choose Cecil now that you mention these things. CCI looks active still, but won't it effectively be replaced by the MS Roslyn project when it comes out (the library for compiler-as-a-service)? – Noldorin Sep 22 '11 at 13:59
  • @Noldorin: Don't know much of anything about the Roslyn project, so I can't really comment. You could ask that on their mailing list I suppose :) – Merlyn Morgan-Graham Sep 22 '11 at 17:42
  • No problem. Thanks for the info anyway, I think you deserve the bounty. :-) – Noldorin Sep 22 '11 at 21:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/3709/discussion-between-noldorin-and-merlyn-morgan-graham) – Noldorin Sep 22 '11 at 21:37
  • Too bad I was away and didn't have the chance to log in when this discussion happened. Anyway that is a very nice answer. From the little experience I got from playing with both, I agree that CCI felt harder to use than Cecil, and getting community support was easier for Cecil. It is true though that CCI gives you more control, and could be considered more powerful. – cloudraven Sep 30 '11 at 20:24
  • 1
    @cloudraven: I don't know how much more control it really gives you. It lets you optimize perf with the string table, but other than that I think they have technical parity with the opcodes they allow you to emit, and where they allow you to emit them. CCI has a high-level wrapper for its code-gen support, but that isn't always useful (e.g. if you're like me and prefer/can use a T4 template to do the actual code gen). – Merlyn Morgan-Graham Sep 30 '11 at 20:40
1

Cecil - because for me, community support for it is better than the CCI. I have always found answers on mailing lists / sites quicker for cecil.

Vijay Gill
  • 1,508
  • 1
  • 14
  • 16