Why is .NET so popular? (Serious Question)
-
harold aptroot wrote:
Suggested replacement: return (x & (x - 1)) == 0;
Um, faster, more clear...
return (x & 0x01) == 0; // Powers of two can't have LSB set, cause that would be an odd number
Or better, why would this need a routine, consuming those wasteful machine instructions and wait states?
if 0 != x & 0x01
{
}Gary
-
Rama Krishna Vavilala wrote:
Depends on whom you ask
Indeed. Let's see: 1. My editor: C# 2. My IDE: C# 3. My system tools: C# 4. My cross-compilers: C# 5. My simulators: C# 6. My image processing: C# + native C 7. My automation stuff: C# 8. My chess utilities: C# 9. My model railroad: C (on Mac), to be ported to C# 10. My web site: PHP (unfortunately) 11. My embedded stuff: C I'll use a native DLL when it is the right choice that fits the requirements, however I can't remember when I last did a native EXE. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
Luc Pattyn wrote:
Indeed. Let's see: 1. My editor: C# 2. My IDE: C# 3. My system tools: C# 4. My cross-compilers: C# 5. My simulators: C# 6. My image processing: C# + native C 7. My automation stuff: C# 8. My chess utilities: C# 9. My model railroad: C (on Mac), to be ported to C# 10. My web site: PHP (unfortunately) 11. My embedded stuff: C
Ah yes, but my compiler compiles your compiler. :)
Gary
-
harold aptroot wrote:
That is not even correct..
Um, I think it is, unless I am missing something. Powers of 2: 1,2,4,8,16,... :-O Oops, not even/odd. My bad. I stand corrected. I shall delete my post. Duh. Guess I shouldn't code at 3:30 AM. [Edit: 1,2,4,... not 0,2,4,... I'm going to bed now. :zzz: ]
Gary
modified on Friday, December 3, 2010 4:00 AM
-
In languages like C, C++, C#, Java etc you still "have to" know how numbers are represented - ok you might get away with ignoring issues like that, but then your code is likely to suck. Such as this, I never want to see this, if I see this I will tell you in your face that you suck and I will tell your boss to fire you:
bool IsPowerOf2(int x)
{
for (int i = 0; i < 32; i++)
if ((int)Math.Pow(2, i) == x)
return true;
return false;
}And yes, I saw that one in the wild. Suggested replacement:
return (x & (x - 1)) == 0;
edit: the replacement treats 0 as power of 2, of course, usually not a problem in my experience and easy enough to change.harold aptroot wrote:
Suggested replacement: return (x & (x - 1)) == 0;
Had to rethink this one. I think wiki algorithm won't work for maximum negative int number. Subtract 1 from it and you'll end up with zero (plus overflow), passing the test with an incorrect returned result.
Gary
-
harold aptroot wrote:
Suggested replacement: return (x & (x - 1)) == 0;
Had to rethink this one. I think wiki algorithm won't work for maximum negative int number. Subtract 1 from it and you'll end up with zero (plus overflow), passing the test with an incorrect returned result.
Gary
-
I have some limited experience with C# and VS 2008 and I don't understand why the .Net framework is so popular. It is a meta environment running on top of the operating system just like Java and the non-Windows implementations do not have all of the capabilities of the Windows version so it's not truly cross platform. I don't see why -- other than Microsoft's semi-forcing the issue -- someone would choose to use this. Shouldn't Win32/64 code run just as well, if not better, since there is no runtime between the code and the system? I can't help thinking of Java or even UCSD P-System Pascal when I look at this. I realize .Net has a large amount of built-in functionality but the same thing could be implemented in native code as well. What am I not seeing here?
You're right! Let's just chuck the whole thing and start over... :) :-D
Steve Naidamast Black Falcon Software, Inc. blackfalconsoftware@ix.netcom.com
-
That's true, however even with 2 special cases for 0 and int.MinValue, it's still a heck of a lot better than a loop with Math.Pow (which, btw, is super inaccurate)
harold aptroot wrote:
That's true, however even with 2 special cases for 0 and int.MinValue, it's still a heck of a lot better than a loop with Math.Pow (which, btw, is super inaccurate)
Harold, you are absolutely correct. I had an Oh-My-Gawd moment when I saw that original logic. Reminds me of a programmer - previous experience was IBM-Assembly - that was given to me for a good-sized project. He would get his work done, but he would struggle. I took time to review his code one day. The man started by writing 90% debug code in his logic, then commenting - I mean GoToing around - his code as he got it to work. Nothing but a pile of garbage. I think someone didn't do their due diligence before hiring this guy. [ What is your experience? IBM-Assembler! You're hired. ]
Gary
-
I have some limited experience with C# and VS 2008 and I don't understand why the .Net framework is so popular. It is a meta environment running on top of the operating system just like Java and the non-Windows implementations do not have all of the capabilities of the Windows version so it's not truly cross platform. I don't see why -- other than Microsoft's semi-forcing the issue -- someone would choose to use this. Shouldn't Win32/64 code run just as well, if not better, since there is no runtime between the code and the system? I can't help thinking of Java or even UCSD P-System Pascal when I look at this. I realize .Net has a large amount of built-in functionality but the same thing could be implemented in native code as well. What am I not seeing here?
-
_beauw_ wrote:
Personally, I like .NET because of its development tools. Breakpoints, step-by-step execution, watches, Intellisense, etc. are all easily available right out-of-the-box.
I don't understand what is so unique here. I work with a 25-year old KMAN language, has all of above built in except Intellisense. C, C++, Assembly have the same capabilities in their tools. And before you ask, because it's not broke, that's why. :-O It bothers me that every month MS is downloading .NET updates to Windows. And when the update doesn't work, you have to unload all .NET (per MS knowledge base), then start over with a reinstall, followed by all updates to date. That kills productivity for users and support staff.
Gary
I was just trying to answer the original question (why I like .NET) after spending a couple of paragraphs basically relating the opposite (why I do not). But that's a good point; the interactive debugger definitely did not originate with .NET. I would go on to say that it also did not invent (or even improve upon) the idea of automatic garbage collection. The update problem bothers me, too, as does the fact that .NET and Visual Studio seem to be getting needlessly flabby. I recall migrating a WPF project from VS 2005 to VS 2008 during development, for example, and watching IDE memory usage more than double. The sad thing is that I was hoping for specific bug fixes that didn't end up getting included (e.g. designer support for ViewBoxes, which I know to be an easy fix for Microsoft.) None of this is to say that I hate .NET; it does have some problems, though.
-
I have some limited experience with C# and VS 2008 and I don't understand why the .Net framework is so popular. It is a meta environment running on top of the operating system just like Java and the non-Windows implementations do not have all of the capabilities of the Windows version so it's not truly cross platform. I don't see why -- other than Microsoft's semi-forcing the issue -- someone would choose to use this. Shouldn't Win32/64 code run just as well, if not better, since there is no runtime between the code and the system? I can't help thinking of Java or even UCSD P-System Pascal when I look at this. I realize .Net has a large amount of built-in functionality but the same thing could be implemented in native code as well. What am I not seeing here?
Probably you ask yourself why all the ppl here make fun of this thread, well more or less :D. The answer you are seeking for would be a document of about 200 pages with brief descriptions of all the advantages, disadvantages and all the other elements that come with development like the community. Long story short: when you experience a few environments and a few companies and try solving complex problems in each environment then and only then you will get an answer to your question. Regards, Sanjin.
-
I have some limited experience with C# and VS 2008 and I don't understand why the .Net framework is so popular. It is a meta environment running on top of the operating system just like Java and the non-Windows implementations do not have all of the capabilities of the Windows version so it's not truly cross platform. I don't see why -- other than Microsoft's semi-forcing the issue -- someone would choose to use this. Shouldn't Win32/64 code run just as well, if not better, since there is no runtime between the code and the system? I can't help thinking of Java or even UCSD P-System Pascal when I look at this. I realize .Net has a large amount of built-in functionality but the same thing could be implemented in native code as well. What am I not seeing here?
b_dunphy wrote:
I have some limited experience with C# and VS 2008 and I don't understand why the .Net framework is so popular.
What makes you think that it is "popular"? How do you define that term? The only data I have seen that seems realistic in terms of the commercial space is the following. http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html[^] In terms of that C# is going up but VB is going down. Thus .Net as a group over time has remained basically flat.