views:

387

answers:

9

In my non-programming life, I always attempt to use the appropriate tool for the job, and I feel that I do the same in my programming life, but I find that I am choosing C# and .NET for almost everything. I'm finding it hard to come up with (realistic business) needs that cannot be met by .NET and C#.

Obviously embedded systems might require something less bloated than the .NET Micro Framework, but I'm really looking for line of business type situations where .NET is not the best tool.

I'm primarly a C# and .NET guy since its what I'm the most comfertable in, but I know a fair amount of C++, php, VB, PowerShell, batch files, and Java, as well as being versed in the web technologes (JavaScript, HTML, and CSS). But I'm open minded about it my skill set and I'm looking for cases where C# and .NET are not the right tool for the job.

I choose .NET and C# because I'm comfortable with it, but I'm looking for cases where it isn't appropriate.

+12  A: 

C# and the .NET Framework might not be the best choice for a hard real-time application. Your application will hose on the first garbage collection, and real-time systems often have memory constraints that make the full-blown .NET framework unsuitable.

That said, there are ways around these problems, see here: http://www.windowsfordevices.com/c/a/Windows-For-Devices-Articles/Adding-Realtime-to-Windows-Embedded/

Robert Harvey
Can you elaborate on a `hard real-time application`? Do you have a concrete example?
Nate Bross
For example, a car engine control system is a hard real-time system because a delayed signal may cause engine failure or damage. Other examples of hard real-time embedded systems include medical systems such as heart pacemakers and industrial process controllers. http://en.wikipedia.org/wiki/Real-time_computing
Robert Harvey
+1, for Excellent explanation
Wonde
I wish there fav comments and answers too.. :)
Srinivas Reddy Thatiparthy
A: 

They move the programming paradigm away from small interoperating tools to large monolithic applications, due to the fact that their load times, minimum worknig sets and interactions with the file system are much higher than those written in compiled-to-host languages.

That's not always a bad thing, but it does mean that the highly efficient (albeit high learning curve) command-line based programming models - a la UNIX - become less used, which is a shame in my opinion.

dcw
-1: dcw, I've been programming .NET since Day One, and I never heard all this stuff. Please provide some citations, and I'll remove the downvote.
John Saunders
@dcw: At least on the Windows platform, command-line tools haven't enjoyed the same popularity and significance as on UNIX-like platforms -- possibly because of Windows' legacy (MS-DOS), which had a very limited shell. Thus, the OP probably won't care too much about about the command-based programming model, as you call it. -- Note also that whether you write small console programs or large monolithic monster programs doesn't depend so much on the framework/platform, but on the task at hand and on what you want to achieve.
stakx
+2  A: 

C# might not be a good choice for complex algorithms, especially those benefitting from parallelism, that would be better expressed using a functional language like F#.

See: http://stackoverflow.com/questions/141985/why-should-a-net-developer-learn-f

Simon Chadwick
The Task Parallel Library and other Task-related enhancements in .NET 4.0 make parallelism a lot easier to write correctly. Not as elegant as F#, for example, but still quite doable. Parallel.ForEach, for instance, or `AsParallel`.
John Saunders
True, but it's the difference between "much less horrible than it used to be" and "fun."
Joel Mueller
@Josn: some people don't need fun, just to get the job done.
John Saunders
@John: People who do not find their jobs fun tend to be less diligent at them. This means that even more errors slip in. When you consider that concurrency is already a highly error-prone field, this is a recipe for disaster.
JUST MY correct OPINION
@ttmrichter: way to overgeneralize it.
John Saunders
+1  A: 

C# and .NET are not the right solution if you work in a heterogeneous environment with many platforms. For all practical purposes .NET is a Microsoft-only solution (yes, I know about Mono and I stand by my statement) that locks you in to one vendor and hardware architecture. If your workplace has Macs and Linux boxes and SPARC servers and PowerPC blade servers, etc. etc. etc. then C#/.NET is not going to do you a whole lot of good.

You also have the problem of vendor lock-in. Let's say you write a server application in C# and .NET. Now let's say ARM's recent foray into server-grade components pans out and ARM-equipped server kit hits the market like a thunderbolt. If you use C#/.NET for your app you're hosed until Microsoft ports their stuff over to the ARM-based architectures (if ever -- NT once supported many more architectures than it does now: the trend is toward shrinking the Windows ecosphere, not expanding it). By locking yourself in to one vendor-specific technology you've made yourself less able to survive market shifts.

JUST MY correct OPINION
Yes, if the market shifts away from Windows, you'll be in trouble.
John Saunders
Not if. When. There was a time when IBM occupied a position in the computing world that Microsoft now occupies. Betting against IBM sounded like a fool's gamble. The market shifted....
JUST MY correct OPINION
Yes... I agree - its time to move to Apple... we can already see by their new license agreements that they are the Microsoft of ten years ago!
Mark Pearl
Moving to Apple would be the same mistake as using any other proprietary system for the same reason.
JUST MY correct OPINION
In general it is considered polite, dear -1er, to explain the -1. Is there something incorrect in my answer? Does it not apply to the question for some reason?
JUST MY correct OPINION
@Just: No other company *ever* held the position in the computer world that Microsoft now occupies, not by a long shot. That being said, I disagree with the statement "locks you into one hardware architecture" - the whole point of using bytecode is that it's architecture-independent...
BlueRaja - Danny Pflughoeft
That is the point of it, BlueRaja. It is not the reality of it. The reality is that if you do C#/.NET you're going to be working on Windows/x86(-64) *and nothing else* for all practical purposes. (Mono is lagging FAAAAAAAAAR behind current .NET and will always be that way.) Wanna disprove my stance? Point me to a complete and up-to-date implementation of C#/.NET for ARM, MIPS, SPARC and PowerPC under Solaris, Linux and/or the BSDs -- just for starters. (Hint: this is not possible.)
JUST MY correct OPINION
A: 

London Stock Exchange was originally written in .NET http://blogs.computerworld.com/london_stock_exchange_suffers_net_crash

You can gain some insightful insights about why using .NET and any non-deterministic memory releasing apps(aka garbage collection) for that matter, does make things like real-time systems not amenable on .NET, see the following link. Humor is bonus http://tech.slashdot.org/tech/08/09/08/185238.shtml

And they ditch .NET, and chooses MilleniumIT which uses C++ http://linux.slashdot.org/story/09/10/06/1742203/London-Stock-Exchange-Rejects-NET-For-Open-Source?from=rss

For anything like volume money transactions and life matter(embedded device for car engine), you cannot let just garbage collection kicks-in randomly and incessantly

[EDIT]

Why the downvote, are there any Microsoft shills here? I just talk in general terms in which the underlying paradigm .NET was architectured in (managed and garbage collected). Perhaps if I just say that the only instances where .NET are not to be used are in car engines and machines that are connected to humans (e.g. heart pacemaker, dialysis machine), I would not get downvoted

Hao
-1 on several grounds. First, blaming the LSE crash on .NET is simplistic, verging on plain old stupid. I've seen C and C++ apps that crash under load as well, indeed more than I have seen Java or .NET apps do the same. Bad architecture is bad no matter what the underlying platform. Second, please study up on automated memory management (a.k.a. garbage collection). There are real-time garbage collectors out there -- HARD real-time! -- and it takes wilful ignorance to not know this, given they've been around for over 20 years!
JUST MY correct OPINION
@ttmrichter: hey! i'm not blaming .NET, I made it now on general terms. Perhaps you should not be on as hard stance that .NET can be used for everything. I'm just saying that .NET has some features(good or otherwise) that makes it not as amenable to real-time system as compared to its C/C++ cousin
Hao
It is childish to call people who disagree with you shills. For the record? No Microsoft code on my personal machine at all. None. Naught. Zip. Zero. Goose egg. I'm just not ignorant.
JUST MY correct OPINION
perhaps we're both childish, why say willful ignorance to me if i do my homework? HARD real-time garbage collection, do you mean explicitly deleting memory? excerpted from other SO question "explicitly calling the garbage collector is a bad idea because (if the runtime system pays any attention to the call) it is most likely to make your application run slower". If the managed runtime always monitor your code for consuming and freeing memory, that can't make a language realtime in my book
Hao
Hard real-time by the definition of the term hard real-time. Pick up a book on automated memory management and learn. What you think you know about garbage collection? It's probably out of date by about **fifty years** -- in other words out of date by longer than you've likely been alive. At the very least it's out of date by thirty years which is still likely longer than you've been out of school.
JUST MY correct OPINION
Hao
-1 - the LSE desaster is, if you manage to read about it and not just a headline, more a straetegic move (they BOUGHT the company making the other system cheaper than the maintenance was on the .net solution) and the stupidity of getting a hugh consulting company doing a large system that costs shitloads of money and then is badly implemented. This is not a .NET / C++ isssue, but a "stupid consulting vs. smart technology company" issue. Especially in the financial area most software is written by idiots.
TomTom
Check out Sungard Martini if you don't believe me - it loads the whole database into a (32 bit, no more) memory - trading history, everything. 10 year old tech, sold today (!) as state of the art.
TomTom
Because in any design decision you have trade-offs. "Hard real-time" does not mean "fast". (That is one of the major mistakes people who've never done real-time programming make.) There are many systems which are faster *on average* but which cannot meet the hard real-time commitments. For most purposes people want best *average* performance, not best *guaranteed* performance. If you're making a runtime for broad spectrum use, you shoot for what most people (the overwhelming majority) want.
JUST MY correct OPINION
I read about LSE in its entirety, not just the headline, the mere fact that Microsoft wanted the LSE project to be its poster boy for its "Get the Facts" case studies and they help Accenture win that rallying point. I would not be as sold that .NET(its architecture) at least don't have something to do about that LSE disaster. And for all I know, Microsoft and Accenture hardly epitomizes idiotness
Hao
"Hard real-time" does not mean "fast", "If you're making a runtime for broad spectrum use..", "best average performance..", tmmrichter I agree with you on these points
Hao
This still doesn't change the plain, trivially-observable fact that you are wrong (on the order of http://goo.gl/bb5Z). The LSE project did not fail because it was .NET (and I say this as someone who **hates the .NET platform**!). It failed because the people who wrote it were body-shopped consultants with no horse in the race and would have screwed up ANY platform, even your oh-so-precious C++-to-the-metal one. Managed memory is also not intrinsically unsuited to speedy (or even hard real-time!) code. You're just wrong. There's no shame in this unless you choose not to learn from it.
JUST MY correct OPINION
@tmmrichter: "You're just wrong" <-- Don't be so smarmy, who knows, I might be right? They might just end up rewriting it in Visual C++, as they will handcraft each timing-sensitive memory allocation/deallocation in their code anyway. And as ironic as it is, I say this as someone who **loves the .NET platform!**
Hao
You *might* be right. You are not, however. I know of a nine-nines uptime soft real-time system done in a a managed, garbage-collected language. (Note: that's **nine** nines, not the piddling **five** nines that most financial software shoots for!) Erlang (managed, garbage-collected) has been used in exactly such a real-world, project. This is how I know I'm not wrong and you are. **I have seen it done.** (I've also seen hard real-time garbage collection done on an embedded telephony platform.) You. Are. Wrong.
JUST MY correct OPINION
"You are not, however" <-- hmm.. Is that proof by blatant assertion? :-)
Hao
If the OP specifically ask for implementing realtime systems on GC-architected and managed runtimes, this discussion might run the whole gamut of why implementing hard realtime system on GC-architected and managed runtimes is not always favorable. The OP ask for .NET as a product problem, not as its underyling architecture, yet most answers sways towards .NET as an architecture, specifically the GC-implicated problems, that should at least make you assess that **there is** a problem using some of these technologies on hard realtime, and most of it stems from GC-related problems
Hao
+2  A: 

There isn't, really, all that much difference between the problem domains served by different programming languages. Rather, the choice usually comes down to

  • What languages do you/your team already know you can be productive in?
  • What is available in the libraries (built-in or available from elsewhere) for the language?

The answer to this question will therefore depend on you. For example, if I personally was doing a quick text processing task I'd whip it up in Perl, because I know Perl well and can do that sort of task efficiently: if you asked me to do it in C# I'd say that was the wrong tool for me, because I can do it quicker in Perl.

If you are looking to learn and diversify your programming toolbox -- which is a good idea -- then rather than asking where C# is the wrong tool, you need to ask which language is most appropriate for each task, and make an effort to learn that language better. Otherwise C# will always be the best tool for all jobs, for you.

Andy Mortimer
+1  A: 

Hi, you've asked an interesting question.

I'll rephrase it: Why Object Oriented? And why .NET? And when not?

I suppose the thing to keep in mind is why OO is so popular. In the modern world, much of the demand for programs is essentially for business. This is why object oriented paradigms are so popular; it is often the most straightforward way to turn a business problem into a program. You basically take a look at a business, break down what the interacting parts (people, machines, places, etc) are, and write something that mimics it in code. So OO is popular because it allows you to mimic many real world situations.

.NET I suspect is popular because it seems so comprehensive. You get loads of components with it, and all you're really doing is mimicking a business issue by writing some connective tissue between these components. Add to that the fact that there's a huge community of people using it already, and the network effect speaks in .NETs favour.

Finally, when would you NOT use .NET?

If your problem is not a business problem, ie isn't merely an issue of connecting some premade components, you might need something different. For instance, if you're writing a driver for a new piece of hardware, that driver is really a layer below the business layer, because

1) It needs to work regardless of what the composition of components is used for 2) The business layer doesn't really care how it works

There's plenty of programming problems where you wouldn't use an OO model, but I suspect OO is useful because it connects all the parts (which aren't OO, like databases and drivers) to create a whole.

Carlos
+1  A: 

I would not use C# for application that make heavy use of resources and need close acces to hardware, ie high profile computer games.

Real time applications (lets say some app that monitors the temperature in a nuclear plant, unless of course Homer simpson in runnig it) have been mentioned, but not games.

World class 3D intensive, IA Intensive games are best server by C++ (at leats the core of them), because you need to be close to the procedural paradigm and hardware, and you need to tell the computer what to do and how to do it, without anything in the middle (the CLR)

Daniel Dolz
A: 

I've recently watched an InfoQ presentation where Neil Ford presents a Thoughtworks project that chose Ruby on Rails over .NET because of the alleged better flexibility of Rails and Ruby. Take a look there at their take on the subject.

Jordão