views:

705

answers:

11

There are several "myths" about the .NET Framework - some are true, some aren't. I don't want do debate about those myth and what arguments there are to prove their right/wrong-status. I'm just curious about what myths you hear about the .NET Framework...

(e.g.: ".NET Software is nearly Opensource because everyone can read the IL-Code with a tool like Reflector" or "Managed languages like C# are always slower than unmanaged languages like C++")

A: 

Myth: Memory allocation is faster in managed code than in native code.

Terminus
Really? I would have thought it was self evident that allocation would be faster. Garbage collection on the other hand...
1800 INFORMATION
That is not a myth. Managed code doesn't suffer from a fragmented heap, and so there is no need to hunt for enough space to allocate memory to a new object. Therefore managed code memory allocation quite often will be faster. Of course the trade off is - relatively - slow garbage collection.
David Arno
"Managed code doesn't suffer from a fragmented heap". Of course the memory buffer .NET uses does not have that issue, but that buffer is allocated from the underlying OS and it may grow in size, needing reallocations, data copying from one place to another, etc. This makes things much slower.
Terminus
But during the lifetime of a normal application, this will not happen often and 99% of the allocations will not suffer from that problem.
OregonGhost
I don't know about .NET because I don't work with it, but Objective-C is faster with managed code than manual allocation.
Giao
Objective-C compiles into native code, not managed code, and recently it has a garbage collector, but it still is native code.
Terminus
@Terminus: in a non .NET app memory allocations still come from the underlying OS and are still subject to the whims of OS memory management. In most cases .NET memory allocation for new objects on the managed heap is generally faster.
Kev
Terminus
Which of those benchmarks specifically test allocations on the managed heap?
1800 INFORMATION
+6  A: 

".NET is only available for Windows"

This is a completely untrue myth, for the open source version of .NET - mono - is available for many OS's.

Edit: Marc Gravell has pointed out another good point surrounding this myth: Silverlight. Micrososft are actively supporting the development of a small-scale CLR/ .NET framework that is truly cross-platform with Moonlight, and have themselves created a OS X version of Silverlight.

David Arno
...but mono supports only a small subset of .NET 3.5.
Terminus
This is a good thing. 3.5 has become a case of bloatware after all.
David Arno
@Terminus: .NET 3.5 is still fairly new to many devs, you say that as if it's impossible to build an app without it.
Kev
I think the real problem is the terminology; mono is a CLI implementation; .NET Framework is Microsoft's CLI implementation. So yes; you can use mono to use CLI code (+1), but it isn't the .NET Framework.
Marc Gravell
A much better counter to this would be Silverlight.
Marc Gravell
@Marc Gravell: Mono project is also doing a free implementation of Moonloght, check out Moonlight.
axel_c
errr, s/Moonloght/Silverlight, sigh, typo
axel_c
@David Arno: I'm not sure you fully understood all of Marc's points. The claim that ".NET is only available for Windows" is valid, as .NET is Microsoft's implementation of the CLI spec. If someone claims ".NET applications can only run on Windows" - *that* is a myth.
Jon Skeet
@Jon Skeet, I understood Marc's points. I disagree with him though. Mono is an implementation of the CLI, CLR and .NET framework (currently covering upto v3.0 I beleive)
David Arno
I want to see an application bigger than Paint.NET developed in Windows that runs in mono. Hmm... none? Right... Even a small application like Paint.NET required extensive porting, and it is a pure .NET 2.0 application.
Terminus
.NET is not a spec/standard to be implemented - it's an implementation in itself. Mono may count as a port of the functionality available within .NET, but Mono isn't a version .NET itself, IMO. With the disagreement here, saying it's "a completely untrue myth" isn't appropriate IMO.
Jon Skeet
@Terminus: no-one is disputing that in some cases some porting may be required, but in principle it is possible to develop apps in both Mono and MS .NET and have a fairly high percentage of code that can be shared.
Kev
@David Arno: as I understand it, ".NET Framework" is a marketing term; mono *is not* the ".NET Framework" - it is a CLI implementation and an implementation of the core classes from the ".NET Framework", plus some bespoke classes. I could be wrong, but that is my understanding.
Marc Gravell
@Marc Gravell, my understanding is slightly different - that the core set of classes that come with each .NET release are the .NET framework, thus the latest release of Mono implements v3 of the .NET Framework. I could be wrong too though. Not sure it really matters too much though.
David Arno
Mono implements the same functionality as the .NET framework, but that's not saying it *is* the .NET framework. As for how much it matters: if you claim that what someone is saying is "completely untrue" when it's technically accurate, that would matter to me.
Jon Skeet
The term .NET is so vague like ActiveX. As 'experts' in our field we should perhaps be using the correct terms - BCL, FCL, CLI, CTS, CLR. Then more accurate and factual comparisons can be made.
Kev
Mono implements *SOME* functionality of .NET (and dot net is more than ecma CLI). Most notable missing functionality is WPF. Nontrivial Applications written with just .NET in mind rarely run on Mono unchaged.
Luka Marinko
+5  A: 

Myth: When you discover a memory leak in your managed application, the reason is that the garbage collector is not working right.

In most cases it is the program not releasing references to useless objects.

Sergio Acosta
Yup! this is a special case of the "You don't need to think about memory management when you've got a GC" - myth
Mendelt
+1  A: 

Myth: ASP.NET is slow

Galwegian
Heh, indeed. ASP.NET (and Java EE) is much much more faster and scalable than PHP/Perl/Python/etc.
Terminus
@Terminus: Whilst I'm a .NET advocate, you can build fast and scalable apps on most stacks provided you know what your doing. Bad dev blames his tools.
Kev
I'd say ignorant devs blame bad devs tools
JohnIdol
Terminus
Damn...I forgot, Don't feed the trolls.
Kev
Wow. I have an objective benchmark that can be tested by anybody. You just have an idea that you can't prove. Look at the facts people.
Terminus
+6  A: 

.net solves dll hell (well ok maybe but as anyone who has worked on a large scale project will tell you it introduces some annoying reference issues)

Also as its managed code you dont have to bother closing connections and destroying objects

alexmac
so wrong - you often do have to worry about closing (ie disposing) objects, just like you have to worry about unhooking event handlers. As for dll hell, it just renamed it to side-by-side reference hell.
gbjbaanb
A: 

@David Arno

That is wrong information.

Microsoft .Net IS NOT available for anything other than windows. Which renders its claim of platform independence into the dust.

While Mono shares a common thread of philosophy/paradigm with MS .Net framework, it being cross platform has nothing to do with MS. In my understanding Mono is a completely separate project.

mirnazim
I did not say that Micrososft .NET is available on multiple platforms. I said .NET is. No mention of Microsoft. Mono is an implementation of .NET. So sorry mate, but you are the one that is wrong.
David Arno
@mirnazim: I don't even think MS make any claims to .NET being platform independent.
Kev
See Silverlight... OK, it isn't the full .NET Framework, but it is a version of the .NET environment available on multiple OS implementations.
Marc Gravell
mirnazim, this should be in a comment. Please use answers to, er, provide answers.
Sklivvz
Mono is an implementation based on the same ecma standards as the .Net CLR. You can run an executable compiled in visual studio on mono as long as you don't use any PInvoke stuff (no winforms, no wpf etc.) that makes .Net cross platform.
Mendelt
No, it makes the ECMA standards cross-platform. To come up with an analogy, the zip file format is implemented cross-platform, but WinZip is still Windows only.
Jon Skeet
The problem with this discussion is the use of the word .NET which is a marketing buzz word and causes the same amount of confusion and grief as 'ActiveX' did.
Kev
I think you can sum it up like this-- can I take a random .NET app and run it in linux under mono? If you find the answer is often no (as I have found many times) then you could come to the conclusion that it is in fact *not* cross-platform.
SCdF
I agree if you want your apps on cli to be cross platform you need to keep Mono in mind from the start.
Luka Marinko
A: 

I however understand and accept that .Net is the best and preferred way to develop apps if you are 120% sure that those apps will not be required to run on a platform other than MS.

If not then you are left with Mono as your option(assuming that you need to develop in a .Net like environment)

mirnazim
You make it sound as if every app written by a dev shop/team must be cross platform which is often not the case.
Kev
A: 

".NET rocks!"

Vulcan Eager
That's not a myth; it is a very real podcast. It's a very good one too.
David Arno
I don't know about the pod cast but my experience with .NET did not rock at all. Most of the applications running on your machines as you read this do not have a viable .NET alternative.
Vulcan Eager
That makes about as much sense as saying "most of the applications running on your machines as you read this do not have a viable Haskell alternative". :)
Kev
That maybe because Haskell was not intended as a platform for desktop development.
Vulcan Eager
You seem to have completely missed my point
Kev
Feel free to elaborate.
Vulcan Eager
Ok...I'll try it differently...if the apps are already written and running, why would I need to look for a viable .NET alternative? You make no sense :)
Kev
A lame excuse. Why are new versions of OSes, browsers, compilers, IDEs and word processors released every now and then? And rewriting new versions from scratch isn't unusual. But yet, after all these years, .NET fails to make its in any area other than web development. Why?
Vulcan Eager
So big deal? Web apps is its biggest strength. You could say the same about Java on the desktop, and I don't see that many Ruby or Python DT apps either. Just because you weren't able to get .NET to work for you or take time to understand it doesn't automatically mean it's a write off for everyone.
Kev
Web apps are a safe platform. After all, how long does a request last? And the GC can safely take place immediately after a request is processed. Not a real test of a platform's capability.And it's not just me; the most impressive .NET desktop app is probably Reflector!
Vulcan Eager
Web apps are not a 'safe' platform if there's a large amount of traffic e.g. this site, it's a perfectly good test of a platform's capabilities. We host 1200 sites per shared server many of them running ASP.NET that's told us quite a lot of good things about how well .NET runs.
Kev
That would have made sense if IIS was a .NET application. Sorry, but high traffic tests your hardware and IIS more that the .NET platform.
Vulcan Eager
Sorry mate IIS is not ASP.NET. Quit trolling and go read some books on ASP.NET's architecture then come back and argue the toss with me . kthxbai.
Kev
A: 

.NET is slower than native code.

leppie
Terminus
I suppose Microsoft's .NET stuff is faster than Mono, though
leod
It all depends what your write. Micro benchmarks says nothing, really.
leppie
It depends, string manipulation should actually be faster in the managed code.
Michael Damatov
@Michael: it *should* be faster, but too often there's so much more of it occurring that it just isn't. Also, if strings were so much faster in .NET, why is there a StringBuilder?
gbjbaanb
+8  A: 

Perhaps a bit too specific to the internals, but here are some common myths:

  • structs always live on the stack (counter: class fields, boxed values)
  • struct variables always live on the stack (counter: captured variables)
  • string is a value type (honestly, I still see this regularly)
  • public fields are faster than properties (almost always inlined)
  • the whole "pass by reference/value" vs "reference-type/value-type" confusion - probably more a cause of myth(s) than a myth itself
  • that you don't have to worry about memory usage any more... (GC is good, but it can't make 4TB available to your XP machine, and it won't collect things you still have hooks into)
Marc Gravell
Have you really had people claim strings were value types? That is a scarely level of misinformation :-O
David Arno
Yes; usually, for example, with generics - i.e. Foo<T>(T value) where T : struct - it works for their int/float/etc - which are all primatives, so surely it should work with string???
Marc Gravell
My lecturers preach string as a value type.
Matthew Scharley
a C#/.NET string is *immutable* which is probably why so many people confuse the two.
Marc Gravell
+6  A: 

According to Microsoft, Generics are faster than casting (even in absence of boxing/unboxing).

Tony Northrup - co-author of MCTS 70-536: Application Development Foundation - states in the same book the following:

I haven’t been able to reproduce the performance benefits of generics; however, according to Microsoft, generics are faster than using casting. In practice, casting proved to be several times faster than using a generic. However, you probably won’t notice performance differences in your applications. (My tests over 100,000 iterations took only a few seconds.) So you should still use generics because they are type-safe.

Please note the argument is not about primitives. Microsoft states that Generics provide better performance than casting between reference types as well - but they do not. I tried that and using generics is slower than casting in this case (confirming Tony Northrup quote).

JohnIdol
Ah, yes; 70-536 - the book with the largest errata I have /ever/ seen. Note that I'm not disputing the performance point, though.
Marc Gravell
yep, the book pretty much sucks
JohnIdol
That largely depend on how much casting you have
Orlangur
I might not have had enough casting (only 10000000 iterations) - but I am guessing Tony Northrup did have enough
JohnIdol