Slashdot Mirror


Does C# Measure Up?

An anonymous reader queries: "Windows::Developer is offering a detailed, quantitative examination [free login required] of C#'s performance versus Java, C, C++ and D. 'Overall the results were surprising, although perhaps unexciting, in showing that C# (and to a less extent Java) is, to a good degree, on a par in efficiency terms with its older and (presumed to be) more efficient counterparts C and C++ at least as far as the basic language features compared in this analysis are concerned,' writes the author, Matthew Wilson. I'm only an amateur coder, and confess to not understanding most of the two-part article. I'd love to hear how true programmers view his results, which are too wide-ranging to summarize easily here. How about it Slashdot, as this special edition asks, 'Can C# keep up with compiled languages like C, C++, and D or byte-code based Java?'"

While we're on the topic of C#, rnd() queries: "It's been a while now, since Mono and DotGnu have begun eroding the market power of Microsoft by creating open source implementations of C# and the Common Language Runtime. Over the weekend I loaded Mono and did some informal benchmarking of object creation, intensive message passing, massive iteration, etc., and the results show that Mono is about 90% as fast as Microsoft's implementation after a very short time. I now want to switch my .NET development over to Linux/Mono exclusively, but I want to first settle on a free alternative to Visual Studio .NET 2003. Any suggestions?"

112 of 677 comments (clear)

  1. Differences by fredistheking · · Score: 5, Funny

    C# is higher pitch than C but less so than D.

    --

  2. In Java's case ... by Anonymous Coward · · Score: 2, Interesting

    Hotspot is really good about compiling bytecodes down to the native machine language. That code is real honest to goodness native code, and will execute at approximately C++ speed.

    Why use anything else?

    - David

    1. Re:In Java's case ... by Bingo+Foo · · Score: 3, Insightful
      Why use anything else?

      Templates.

      Any other questions?

      --
      taken! (by Davidleeroth) Thanks Bingo Foo!
    2. Re:In Java's case ... by JasonB · · Score: 5, Informative

      Java SDK v1.5 (not yet released) contains support for 'generics', which are very much like C++ templates for Java:

      http://java.sun.com/features/2003/05/bloch_qa.html

    3. Re:In Java's case ... by Trejkaz · · Score: 2, Insightful

      Yay! All the power of Java's Generics but with 10 times the code bloat.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
    4. Re:In Java's case ... by Bingo+Foo · · Score: 3, Funny

      How are these mythical generics at metaprogramming? If Java eventually gets libraries like Blitz++, Loki, and boost::Spirit, I'll take a look. Oh, but that would require operator overloading, too. Maybe Sun should release the "J2UE" (Java 2 Usable Edition) as a JVM implementation of C++.
      </snarky>

      --
      taken! (by Davidleeroth) Thanks Bingo Foo!
    5. Re:In Java's case ... by HuguesT · · Score: 4, Insightful

      I was going to moderate, but there you go.

      Because it forces down your throat the concept that everything is an Object. Many people find this counter-productive as object-oriented programming is only well adapted to a subclass of problems (and trying to use that methodology when it just doesn't work is downright ugly).

      Besides inheriting from Object does not solve the same problem as templates do. Templates are super-macros designed for fast runtimes. Universal object orientedness with default virtual methods causes extra overhead that C++ programmers want to avoid a lot of the time.

      Notice that single-object-derived libraries for C++ exist, for example the NIH library, but that they were never as successful as the STL is.

      Inheriting from Object only solves the absence of multiple inheritance in Java.

    6. Re:In Java's case ... by Anonymous+Brave+Guy · · Score: 2, Insightful
      Having everything (with the exception of native datatypes that can be wrapped into classes) be a descendant of a superclass is a far more elegant solution than using c++'s hackish and syntactically awkward template feature.

      Of course it is. That's why Java's adding generics now, I guess: to fix the loopholes that approach didn't cause.

      Not everything is an Object; didn't you first textbook tell you?

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    7. Re:In Java's case ... by Anonymous+Brave+Guy · · Score: 2, Interesting

      I don't think C++ programmers have ever underestimated the value of garbage collection; Stroustrup mentions it himself in several relevant texts, and garbage collectors have been available for C++ for years, for those who want them. Of course, garbage collection isn't nearly so important in a language with automatic variables and deterministic destruction, which is probably why few people actually use those libraries.

      C++ and Java will never be the same language, or even close. They are aimed at two different markets, they have different strengths and weaknesses adapted to those markets, and it's rather unlikely that those markets will converge. The similarity pretty much ends at syntax and basic OO concepts.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    8. Re:In Java's case ... by Anonymous+Brave+Guy · · Score: 4, Insightful

      In C++, casts are rarely necessary. When they are, tools like dynamic_cast allow for the same useful run-time type checking as Java et al support.

      In Java, you can't even pull an object out of a container without a cast, and you can't even use a basic type in a generic container without some sort of wrapper object.

      In C++, the RAII idiom lets you ensure the safe release of any resource type. In Java, you have to write the same finally blocks all over just to make up for the fact that finalizers don't work.

      Java is "more safe" than C++?

      Now that was funny.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    9. Re:In Java's case ... by pyrrhonist · · Score: 5, Insightful
      Did you ever stop for a minute and think that you're doing it wrong, and that there was probably another way to do what you want?

      What many C++ programmers fail to recognize is that Java and C++, though similar, are not the same language, and the paradigms they use in C++ will not work in Java.
      Good programmers learn the new paradigms, bad ones simply criticize that it doesn't work the same.

      --
      Show me on the doll where his noodly appendage touched you.
    10. Re:In Java's case ... by Geek+of+Tech · · Score: 4, Funny
      > Not everything is an Object; didn't you first textbook tell you?

      I never got around to that... my textbook was an object.....

      --
      Stop the Slashdot effect! Don't read the articles!
    11. Re:In Java's case ... by pyrrho · · Score: 4, Interesting

      but you have to remember that C++ is designed to open up the power of the machine to you, not make you think a particular way or be magical for you.

      The onus is on the "our language does it for you" crowd because you were not supposed to say "oh, you have to understand how the VM is working"... right?

      Of course, in the end, all languages will have to tell us this "oh, yes, well, you have to know something". Of course you do! It will always be this way.

      So choose the most efficient and effective language for you and learn it well, learn a different one if called for, etc.

      At least, I take this to be apparent.

      PS: "pyrrhonist"... right on!

      --

      -pyrrho

    12. Re:In Java's case ... by pyrrhonist · · Score: 3, Interesting
      but you have to remember that C++ is designed to open up the power of the machine to you, not make you think a particular way or be magical for you.

      I guess any language ends up indirectly making you think in a different way. Maybe that's the magical part.

      The onus is on the "our language does it for you" crowd because you were not supposed to say "oh, you have to understand how the VM is working"... right?

      Well, my point was that the languages are different in more ways than many C++ programmers (or Java programmers) realize. For instance, many C++ programmers think that finalize methods are destructors, and many of them use finalize incorrectly because of this. Then some of these programmers choose to complain loudly about Java, when the problem lies with them. They need to learn a new paradigm or their programs will continue to function incorrectly. There are definitely best practices in C++ that are bad ideas in Java.

      Obviously, this works in reverse, too. You can't go from Java to C++ without changing your thinking as well. Many Java programmers have made this mistake.

      Of course, in the end, all languages will have to tell us this "oh, yes, well, you have to know something". Of course you do! It will always be this way.
      So choose the most efficient and effective language for you and learn it well, learn a different one if called for, etc.

      Yeah, I agree. I use languages as a tool, not a crutch. If I see a problem that is better represented by Perl than Java, I'll use Perl. Or Python, or 6502 assembly...

      PS: "pyrrhonist"... right on!

      I like yours too. Pyrrho was cool.

      --
      Show me on the doll where his noodly appendage touched you.
    13. Re:In Java's case ... by cakoose · · Score: 2, Informative

      Um...do you know how templates work? I'm not talking about typecasts when I say "lot of code". I'm talking about the almost identical copies each template function (usually, the only difference is a tiny comparison operation).

      Now...I wouldn't consider the extra code to be a fault of template programming, since I can't think of a better solution that would be as fast (time-space, my friend). Templates don't even force you to have the extra code either, but libraries like the STL make use of the feature to speed things up.

    14. Re:In Java's case ... by StillNeedMoreCoffee · · Score: 2, Interesting

      "Inheriting from Object only solves the absence of multiple inheritance in Java."

      I beg to differ the inheritance from Object has nothing to do with the mulitiple inheritance problem with C++. Interfaces in Java which allow you to define the functionality of a type without the conconmitant problems with name ambiquities of commonly inherited instance variables.

      The common Object class comes from Smalltalk where Object Oriented programming stems. It allows truely generic collection classes. That allows them to be written once and re-used as any ADT should. The generics added to Java allows the programmer to take advantage of the strong typing (they could with downcasting), and the re-use of the library. If you are concerned about code size. You could have an application in C++ with say 100 queues. With the template system in C++ you would have 100 different classes each implementing a queue. A major waste of runtime realestate. So Templates are not free.

      Template solve the problem that C++ had before templates, You had little or no code reusue because of the strong typing. If you wrote a Queue, you had to copy and modify it to create a int queue or a queue of your own object types. This was very cumbersom and a major hole in the languages capabilities when it first came out. Without templates the language was not very useful. C++ did not have reflection until later either. So its OOPs capabilities were crippled at the start and patched.

      It is true that C++ is usually used for non-oops or hybrid code that is designed to minimize overhead. There is a large class of problems, a very large class of problems that lend themselves to an OOP's approach. It depends on the job your in. You may just be solving problems that need extreme tuning. You probably just don't see the rest of the world.

      The power of the OOPs model is similar to the power of Databases. When Databases first came in, they were hugely expensive and very slow. But the problem that they solved, that is disconnecting the logical interface from the physical implementation made companies adopt DB's even then. They were spending more time maintaining old "tuned" code that they were not able to get anything new done. Then IT took off because they had a model for data that was more expressive and safer and more maintainable and robust. OOPs is the same model for programs and has the same benefits. It is much more cost effective to write something as ADT's and buy faster hardware than to code in a less maintainable form on slower machines, certainly for the long term it is many orders of magnitude better.

  3. Alternative to Visual Studio by Vaevictis666 · · Score: 5, Informative
    I now want to switch my .NET development over to Linux/Mono exclusively, but I want to first settle on a free alternative to Visual Studio .NET 2003. Any suggestions?

    How about Eclipse?

    1. Re:Alternative to Visual Studio by Anonymous Coward · · Score: 2, Informative

      Eclipse do not seem to support c# natively (I confess to not having tried the c# plugin).

      I would recommend SharpDevelop. I understand work is underway to make it less dependent on WinForms so that it can run under Linux/Mono.

      If the original poster was looking for free-as-in-free-beer-IDE's, there's always the personal edition of Borlands C#Builder, as well.

    2. Re:Alternative to Visual Studio by Glock27 · · Score: 3, Informative
      Eclipse do not seem to support c# natively (I confess to not having tried the c# plugin).

      AFAIK, all language support in Eclipse is by plugin. You're basically saying you've never tried it, but you advise us to try something else.

      Huh?

      (I've used Eclipse a bit for Java, and it is excellent. I'm pretty sure it'll be a fine environment for many languages by the time it's all said and done.)

      --
      Galileo: "The Earth revolves around the Sun!"
      Score: -1 100% Flamebait
    3. Re:Alternative to Visual Studio by PianoComp81 · · Score: 3, Informative

      Eclipse can be good for other languages. My problem with it is that it's just too slow many times. I did have a problem in Windows getting C/C++ to compile, but I think it was looking for cygwin + gcc, and not the MSVC++ I had installed at the time. I too have used it extensively for Java, and probably wouldn't use anything else on a decent-sized project.

  4. Re:But there's just one problem... by Vaevictis666 · · Score: 2, Informative

    Actually VB apps tend to run just fine through Wine, or at least a few little projects I've done in VB have worked for me...

  5. Re:But there's just one problem... by __aagmrb7289 · · Score: 2, Insightful

    (a) That's not the only problem;
    (b) VB isn't the topic; and
    (c) That isn't even true.

    Wow, none out of three!

  6. Microsoft license prohibits CLR benchmarks by Anonymous Coward · · Score: 4, Funny

    Raed it. Ingroe it. Bncehmrak aynawy.

    1. Re:Microsoft license prohibits CLR benchmarks by DrEasy · · Score: 2, Funny

      I find that the "I'm tired of repetitive jokes" thing is getting repetitive as well... ;-)

      --
      "In our tactical decisions, we are operating contrary to our strategic interest."
  7. Duh by be-fan · · Score: 5, Insightful

    This really makes sense if you understand how JITs work, and understand the nature of the benchmarks. These benchmarks are mostly microbenchmarks that test a particular operation in a tight loop. JITs can compile this loop once and run it directly on the CPU afterwords. This doesn't extrapolate well to situations where the JIT gets involved more often in the benchmark.

    --
    A deep unwavering belief is a sure sign you're missing something...
    1. Re:Duh by msgmonkey · · Score: 3, Insightful

      But having said that there is the "rule" that 10% of code runs 90% of the time, hence why caches work. If the JIT is only optimizing code that gets run 90% of the time and it's not doing a bad job (since the JIT compiler would most likely be in 2nd level cache) with the other 10% then the benchmark results would be relatively indicative.

    2. Re:Duh by dnoyeb · · Score: 3, Insightful

      The JIT can optimize code based on the computer its running on, and not just a generic compile time optimization. So JITs have advantages as well.

  8. VS Alternative by contrasutra · · Score: 5, Funny

    I now want to switch my .NET development over to Linux/Mono exclusively, but I want to first settle on a free alternative to Visual Studio .NET 2003. Any suggestions?

    VI. :-D

    C,D, I feel bad for the F Programmer.

    1. Re:VS Alternative by JamesOfTheDesert · · Score: 4, Funny
      C,D, I feel bad for the F Programmer.

      Ah, but there is F#

      --

      Java is the blue pill
      Choose the red pill
  9. Mono risks by alext · · Score: 2, Insightful

    Mono is a bit faster than Java, for some benchmark?

    Well, why didn't you say so before?!

    That way we could have avoided all that tedious discussion about IP infringements, functionality etc. in yesterday's Mono debate. Clearly some dude's performance figure should override all other considerations when choosing a platform.

  10. Uhm... by Black+Parrot · · Score: 4, Funny


    > Overall the results were surprising, although perhaps unexciting, in showing that C# (and to a less extent Java) is, to a good degree, on a par in efficiency terms with its older and (presumed to be) more efficient counterparts C and C++ at least as far as the basic language features compared in this analysis are concerned

    Could we have a few more weasel-words in that sentence, please?

    --
    Sheesh, evil *and* a jerk. -- Jade
  11. jump off the bandwagon by curtlewis · · Score: 2, Informative

    Java has received alot of attention over the last 7 or 8 years or so. It's a great idea in theory, but it falls way short in practice. It does remain viable for a few select uses, though: small widgets, servlets and web app servers. Pretty much other than that, using Java will mean excessive memory usage and slow performance.

    Garbage collection in Java is not guranteed. It's what I call Union. It'll clean up when it god damn well feels like it. In the meantime, the system slows to a crawl.

    Graphics in Java are abysmally slow. Even basic UIs lack the speed and responsiveness of GUIs written in C, C++ or similar languages.

    Java was supposed to be: Write once, run anywhere, but what it is in reality is: Write once, debug everywhere... over and over and over. Or perhaps more appropriately it is" Write once, run screaming.

    I've worked in a variety of Java development projects in the past and not once has it ever risen to the task to show itself as a worthy choice and/or a mature language. Instead it has invariably wasted companies time and money. Primarily because they failed to realize that Java is a small task tool, not suitable for major applications or those requiring performance.

    I know a lot of engineers like Java because it makes life easier for them by doing things for them, but those things it does it does very poorly.

    I'm sure I'll be marked as flamebait or troll by some Java loving mod, but what I've stated are facts and experiences from real life Java development. The results are in and frankly... Java sucks! Stick with C and C++ for most development, there's a reason they are the standard: they work.

    1. Re:jump off the bandwagon by trompete · · Score: 3, Interesting

      to add....

      GUI development isn't that bad in Visual Studio. In fact, it is easy as hell. With emulators like Wine available, it makes sense to develop the software with Visual Studio and its amazing debugging tools for WINDOWS and then use Wine to run it on Linux.

      One could use the GTK and GNU-C to develop multi-platform software in the first place, but then you are dealing with the parent poster's problem of debugging on multi-platforms, not to mention that GTK sucks under Windows (Anyone else use GAIM?)

    2. Re:jump off the bandwagon by Cnik70 · · Score: 5, Informative

      You apparently haven't taken the time to work with any of the newer releases of java (1.3 and 1.4). Java is a very mature and worthy language, especially when it comes to developing non platform dependent applications. I prefer java since I CAN program it on a Linux box, transfer it to a windows, mac or even a mainframe and the program will still run exactly the same without changing a single line. lets see c, c++, .Net or c# do that... Also don't forget about a little thing called J2ME which is slowly but surely making it's way onto cell phones and other small devices. You may want to take another look at todays Java before declaring that it sucks.

      --
      -Cnik
    3. Re:jump off the bandwagon by MikeApp · · Score: 4, Informative

      You claim to have worked on numerous Java projects, then complain only about GUI apps? The large majority of Java projects are server-side, which is where it really rocks. Write once and deploy on your choice of platform (Linux, Solaris, or Windows if need be).

    4. Re:jump off the bandwagon by Trejkaz · · Score: 3, Insightful

      We're going to have to point out the separation of language and platform for you again. If the Perl community can figure it out, then anyone should be able to.

      Java 'the language' is good. Java 'the machine' is good. Java 'the platform' blows presumably because all the people who could make it better are sitting on Slashdot whining about Java's performance instead of doing something about it.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
    5. Re:jump off the bandwagon by Gunfighter · · Score: 5, Insightful

      I'm afraid I'll have to agree with Cnik70 on this one. I can remember struggling through Java programs back in the day and thinking to myself, "No way in Hell this will ever become what everyone is saying it will be." That was then, this is now. Internal benchmarks of our code under mod_perl, PHP, Python (Zope), and Java for our web development show Java (Tomcat) to be the winner by a landslide when it comes to scalability, performance, and rapid development. From what I understand, even eBay is switching to a Java platform (anyone know more about this?). Of course, this is all on the server side...

      As far as GUI applications are concerned, the only thing that is slow about running Java GUI apps on modern hardware is the startup time. This can supposedly be taken care of with accelerator apps which keep a JVM running in the background just waiting for Java apps to be run. Even without such acceleration, I still use jEdit as my text editor of choice for all my programming needs (http://jedit.org/), and as a sysadmin I don't even program in Java (where jEdit is best applied). I usually stick to Perl/Python for automating systems administration scripts. Nevertheless, I find that the features, performance, and overall ease-of-use in jEdit save me loads of time (nice CVS integration too).

      Bottom line, Java is already in enterprise computing environments and, with an experienced developer, ready for primetime in smaller applications as well.

      -- Gun

      --
      -- Stu

      /. ID under 2,000. I feel old now.
    6. Re:jump off the bandwagon by Dr.+Bent · · Score: 4, Informative

      I've worked in a variety of Java development projects in the past and not once has it ever risen to the task to show itself as a worthy choice and/or a mature language. Instead it has invariably wasted companies time and money.

      I would be willing to bet the reason they failed is because you do not understand how to use Java correctly. As long as we're playing the personal experience game, it has been my experience that hardcore C/C++ programmers tend to make horrible Java programmers because they think Java should behave like C/C++. It doesn't (obviously), and when you try to shove that round peg into a square hole what you get is a huge mess.

      At my company, we have a bunch of old school C/C++ progammers and a few Java programmers. As our Java products started to take off (now our #1 selling product line), we wanted to move some of those developers over to Java to help out.

      It was a disaster. They made object pools in order to try to manage thier own memory. They were calling System.gc() and yield() instead of using a Java profiler to find bottlenecks. The never used lazy loading. They never used failfast ("exceptions are too slow!", they said). The result was all the projects they worked on were extremely brittle, used twice as much memory, and ran much slower than our original Java stuff because they were constantly fighting against the system instead of working with it.

      Try reading Effective Java by Josh Bloch and Thinking in Java by Bruce Eckel. Do what these guys suggest and your Java apps will run just as well than as anything written in C or C++.

    7. Re:jump off the bandwagon by pla · · Score: 3, Insightful

      The large majority of Java projects are server-side, which is where it really rocks. Write once and deploy on your choice of platform (Linux, Solaris, or Windows if need be).

      Although true (in my experience), the idea itself has sooooo many things wrong with it...

      Portability - Server-side Java, by nature, does not involve any OS-specific activity. So, with no loss of portability or functionality, you could do the same in C/C++. Which, incidentally, will run on any platform for which GCC exists - About 30 *times* the number of platforms for which a JVM exists.

      Performance - Yes, servers tend to have fairly impressive hardware resources available to them. So lets cripple that hardware by making it run an interpreted language. JIT? Server-side apps also tend to have very short process lives, doing a small task and exiting. In such situations, JIT causes worse performance, as it wastes time optimizing something that will never execute again during this process' invocation.


      I believe (though I do not wish to put words in his mouth) that CurtLewis only mentioned GUI programming because if you use Java anywhere else, you have misused it. It makes it easy to write an app with a similar user experience on any hardware with the resources to run the JVM. If the idea of a "user experience" has no meaning to your app, using Java means you have made a suboptimal choice.

    8. Re:jump off the bandwagon by prowley · · Score: 3, Interesting
      I am not sure what server side applications you have been involved with but in my experience server side applications have LONG process lives. They are expected to be up 24 * 7, for as long as possible. Just as an example lets say Apache.
      Which just happens to not be written in Java... Server processes that do require to be up and running 24/7 are written in C (maybe C++) by people who know why. Servers written in Java for the 24/7 operation are written by people who read why in a magazine. Sorry, but I still cannot stifle a smile when Java and server are mentioned in the same sentence. I know there are many true-believers, but really, even if it does look good on paper, just wait til that garbage collector kicks in and I'll have yer 24/7 right here.
    9. Re:jump off the bandwagon by ForsakenRegex · · Score: 2

      I'll give you scalability, and I'm willing to give you the benefit of the doubt on performance, but Java is definitely not more "rapid" than Perl. If you were holding a gun to my head to get something done as quickly as possible, I would not hesitate to choose Perl over anything else (unless you're talking Windows GUI, in which case I'd use Delphi).

      --
      "A man talking sense to himself is no madder than a man talking nonsense not to himself."
    10. Re:jump off the bandwagon by EMN13 · · Score: 4, Informative

      Server side tasks are just great for java; your arguments don't add up.

      Any platform I've heard of for server stuff will run java. C/C++ may have a wider distribution; but not amongst relevant platforms. Irrelevant to the discussion are portable/client side/ small / light platforms, and the computation heavy things. Servers are about "service" - the naming is not a coincidence.

      Most server processes run forever, or as close as possibly; not very short lived at all. Starting a new process (aka application) for every client is generally not best practice - those are threads, and don't require constant re-JIT-ing or other JVM/CLR overhead.

      Rather, the larger the system, and the more data, generally the less code in relation to that data, and even less JVM in relation to data. So for the quintessential server with tons of data gunk, the c/c++ advantage is much smaller than in the GUI.

      Furthermore, it is a mistake to compare the portability of java to that of c++ in the manner you do. c++ implementations aren't generally compatible. Take a look at the mozilla coding guidlines for portable c++: http://mozilla.org/hacking/portable-cpp.html

      c++ isn't portable, normally. C++-- might be though. Then again, it might not be. The java language is very standardized; and in case you shouldn't have a compiler on that platform, the bytecode is too!

      In conclusion, if you're using c++ for a server-side task you should consider using java instead. As a matter of fact, most scripting languages are probably better suited than c++, I can hardly image a worse fit.

    11. Re:jump off the bandwagon by Anonymous+Brave+Guy · · Score: 3, Interesting

      Give or take a few quirks, most recent (last five years, say) C++ compilers support all the major features acceptably well for most purposes. There are only a few issues that cause significant problems: the infamous export, Koenig look-up and partial specialisation of templates come to mind. None of these features is used very often anyway, though.

      Coding standards that forbid the use of templates, exceptions and half the standard library in C++ are common, but way out of date.

      By the way, I write code for a living that gets shipped on more than a dozen different C++ platforms. Alas, some of them are well pre-standard, and so don't support even basic template or exception mechanics properly, which sucks. But this is an issue we've looked into in some detail, so I'm pretty confident in my statements above.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    12. Re:jump off the bandwagon by C0deM0nkey · · Score: 2
      If you were holding a gun to my head to get something done as quickly as possible, I would not hesitate to choose Perl over anything else...

      The problem with this statement is that it only reflects your experience and those of similar experience. As always, the quickest tool to use is the one with which you are most familiar.

      Personally, as a J2EE developer, I would never dream of using Perl to code anything quickly. I recognize the value of Perl but have had little reason to develop proficiency in it. For me, Java would be the quickest route to success. For you, it is Perl and, I am sure, for someone out there it is Visual Basic.

      "Best", "Quickest", "Fastest" are very subjective terms.

      C0dem0nkey

    13. Re:jump off the bandwagon by deanj · · Score: 3, Interesting

      Start up time should be a lot better in the 1.4.2 release. Last JavaOne they specifically said work was being done on that. Further improvements are in 1.5 (when it comes out).

    14. Re:jump off the bandwagon by cartman · · Score: 3, Informative

      I disagree.

      Garbage collection in Java is not guranteed... It'll clean up when it god damn well feels like it.

      This is false. Garbage collection in Java is guaranteed. The VM times the garbage collection to occur when the CPU was otherwise idle, or when additional memory is needed by the VM or by other programs. This is the most reasonable behavior.

      In the meantime, the system slows to a crawl.

      This is false. Garbage collection is deferred to improve performance. Deferring gc does not make anything "slow to a crawl," since unused objects consume no cache and take no processor cycles.

      Graphics in Java are abysmally slow.

      This is an exaggeration. It is noticeably less responsive however.

      Java was supposed to be: Write once, run anywhere, but what it is in reality is: Write once, debug everywhere... over and over and over.

      Java requires far fewer debug cycles than C or C++, since an entire class of bugs (tricky "pointer bugs") is eliminated. Thus, "over and over and over" is not accurate.

      I've worked in a variety of Java development projects in the past and not once has it ever risen to the task to show itself as a worthy choice and/or a mature language. Instead it has invariably wasted companies time and money.

      It's possible the difficulty was with you or your team, not Java. Perhaps you're unfamiliar with the tools or the language. Other organizations have produced enormous projects, successfully, in Java.

      Stick with C and C++ for most development, there's a reason they are the standard: they work.

      For backend development and enterprise applications, Java is the standard, not C or C++. It's been that way for some time. There's a reason for it.

  12. Languages are not application-neutral by DaMeatGrinder · · Score: 5, Insightful
    These articles set a metric of what is "good". They judge a bunch of languages based on this criteria, and announce a "winner".

    This is just one way to slice the pie.

    Languages are appropriate for different uses. I use C while kernel hacking. I use C++ for its template abstractions. I use PHP for web pages, Perl for command-line scripting. I use bash/tcsh for boot-scripts. I respect VB as an accessible language, but I have no use for a single-platform language.

    What language you use depends on your application. Comparing C, C++, and C# is like comparing a wrench and a screw driver. And concluding they can both be used as a hammer.

    1. Re:Languages are not application-neutral by Waffle+Iron · · Score: 4, Interesting
      Comparing C, C++, and C# is like comparing a wrench and a screw driver.

      Moreover, languages like C and C++ can be used in very different ways, depending on the circumstances. You can code the "safe convenient" way using tools like STL or glib to manage strings, containers, etc. I've found that the overall performance of such an application often is in the same ballpark of a Java implementation (other than Java's obnoxious startup time).

      However, C and C++ also allow you to write in a "masochistic balls-to-the-wall" mode that gives you much higher performance in exchange for 10X the programming effort. To do this, you often have to analyze your algorithms over and over until you can implement them using only stack and static structures. You avoid malloc() at all costs, avoid copying any data unless absolutely necessary, etc. You might disassemble the compiler output, run profilers and arrange data in cache-friendly patterns to squeeze out even more performance. The implementation will be much more brittle and prone to bugs, but you can often get a 10X or more speed improvement over the "natural" C or C++ implementation. Obviously, very few problems warrant this kind of attention, but making blanket statements about "comparing" other languages to C/C++ really should acknowlege the large range of performance that these languages can cover.

  13. I always said by Microsift · · Score: 2, Funny

    C# was Delphi b (best flat sign I could do)

    --
    My other sig is extremely clever...
  14. Conclusions by SimuAndy · · Score: 3, Informative
    After a quick registration, I'm enlightened by the conclusions I drew from his article:
    • C# fares rather well.
    • ... but almost never as well as native C and C++ implementations done "smartly".
    • Java suffers from runtime-based overhead, with the advantage of a well-tested set of runtimes for various platforms. Unfortunately, due to the Java implementation of client-side runtime libraries, programming in Java is still "write once, test everywhere. curse. port everywhere" for real applications.
    And most importantly, as a game programmer, I'm going to pay attention to the relative performance the author received from the Intel-branded compiler, written to the metal of the Pentium IV with streaming SIMD instructions. -andy
  15. Re:I'm holding out for... by ThatDamnMurphyGuy · · Score: 3, Funny

    Remember though, C# and Db aren't the same note outside of the well tempered world!

  16. What's with all of the bellyaching about speed? by defile · · Score: 5, Interesting

    OK lets get a few things settled.

    Given: two identical applications; A, written in low level language like machine assembly, C, or C++; B, written in high level language like Java, Python, VB, hgluahalguha.

    If the application is high in CPU burn (lets call it X), like oh, for (i = 0; i

    If the application is copying a very large file using basic read/write system calls and large enough buffers (lets call this Y), A and B will have very similar performance.

    If the application is printing hello world, they will have similar performance, although the startup costs for B may be higher, and A will probably finish executing faster.

    MOST applications written today are written to solve for Y. The code that most programmers write today is NOT the CPU intensive portion. Usually the CPU intensive portion is in the library called by the programmer: rendering a box, moving things around on a storage device, making something appear on a network.

    In these cases, a high or low level language makes no freaking difference on execution speed. However, your choice WILL make a huge difference on time to develop, maintainability, resultant bugginess, SECURITY, etc.

    OF COURSE THERE ARE EXCEPTIONS. Maybe you're writing a routine that needs to draw lines fast, or move bytes through a network filter at 100MB/sec, or you're compressing a file, whatever. In these cases you tend to write the performance critical code in a more low level language so you have greater control over the physical machine. Sometimes you write the entire application in the low level language.

    Many high level languages provide mechanisms for calling low-level code when it's necessary for performance. It's often pretty easy.

    The performance argument is a red herring.

    1. Re:What's with all of the bellyaching about speed? by abigor · · Score: 2, Informative

      Huh? Wine is a reimplementation of the Win32 API and some other stuff. It uses the C libraries directly; there is no emulation. Look at the code sometime.

      Some of the largest online systems in the world run Java. On the server, Java is unbeatable. I've personally witnessed massive uptimes with none of the degradation you mention. And there's this company called IBM that bases much of their server business on Java (both through WebSphere and through their consulting arm.) These apps do not perform "small activities".

      Your one little client app is probably written poorly, or with a buggy Java implementation. In short, you don't know what the hell you're talking about.

    2. Re:What's with all of the bellyaching about speed? by good-n-nappy · · Score: 4, Interesting

      Maybe you're writing a routine that needs to draw lines fast

      This is one of the specific things you can't really do with JNI and Java anymore. Java graphics is now really complicated. There's no way you'll be able to use low level OS rendering methods and have them integrate with Java2D and Swing.

      It's actually a real problem. You've got no recourse when the graphics primitive you need is too slow. You end up with a Java workaround or you switch to OpenGL or DirectX, which don't have good support for fonts and strokes and such.

      This is where C# may end up beating Java, on Windows at least. Eclipse SWT has promise too since you at least have the potential implement your own graphics code.

      --
      Never underestimate the power of fiber.
    3. Re:What's with all of the bellyaching about speed? by Hard_Code · · Score: 2, Informative

      "For something that will do big work, require lots of memory and run for long periods, Java will come to bite you in the ass."

      Like, say, large scale enterprise/website computing? Oh, wait, that is exactly the area Java excels at. Swing is a notorious hog, and I'm not familiar with your exact circumstance, so I can't really comment on it. But Java is pretty damn rock solid for long, throughput intensive tasks. I say throughput as opposed to latency because low-latency gui stuff is exactly where a VM (and garbage collection) will bite you in the ass. If performance is unbearable there is the native SWT library (like AWT redone from the ground up, but right). Java is not known for its good GUI/client side performance.

      On the other hand, on the server side, latency is usually not the issue - most time will be spent on the network and database, NOT in your code. On the server side, VMs are here to stay. Python, PHP, Perl, Java, C#/Mono, all use VMs. The only real issue with VMs is latency, and with garbage collection its memory usage. I would strongly suggest though, that the vast vast vast majority of user-level/space applications in which C/C++ is being [ab]used, would be better written in a "safe", simpler, language like Java, precisely because in the vast majority of cases, CPU performance does not need to be optimized, and security, reliability, maintainability, and let's not forget, new features, take higher importance.

      --

      It's 10 PM. Do you know if you're un-American?
    4. Re:What's with all of the bellyaching about speed? by GrayArea · · Score: 4, Informative
      This is one of the specific things you can't really do with JNI and Java anymore. Java graphics is now really complicated. There's no way you'll be able to use low level OS rendering methods and have them integrate with Java2D and Swing.

      Sure there is. Have a look at jawt.h header file that's included in your SDK installation. It allows you to access native window system primitives from JNI.

      --
      "The deluded are always filled with absolutes. The rest of us have to live with ambiguity." - Aristoi, Walter Jon Willia
    5. Re:What's with all of the bellyaching about speed? by Richard_Davies · · Score: 2, Informative

      This is one of the specific things you can't really do with JNI and Java anymore. Java graphics is now really complicated. There's no way you'll be able to use low level OS rendering methods and have them integrate with Java2D and Swing.

      Fortunately, the API is being steadily improved so the need for native methods is diminishing significantly with each version of Java. Have a look at these improvements in 1.4 over previous versions (it includes benchmarks you can run to see for yourself).

      The key point here is that if you write your graphics code in pure Java, it will get faster with each new release, in many cases, without you having to lift a finger - and in 1.4, it can already take advantage of things like native hardware acceleration.

  17. I've been coding most of... by rmdyer · · Score: 5, Insightful

    ...my life. It's been mostly C/C++ but also a good amount of assember and VB. Maybe someone here can answer one of the questions that keeps poping up when I write anything. My question is, why do we always end up creating libraries/classes that contain other code we will never use? What I would like is a compile environment where each function or object that I use is individually addressable, without having to pull in other "stuff" I don't need in my specific app. Is that so hard? Why doesn't the OS manage code better than pulling in a whole library? If I use only strcat() for example, why do I need to load in the entire C string library?

    The problem gets even worse with C++ and objects. Huge numbers of member functions and public variables that will never be used. Microsoft's .NET and Suns Java take the cake by making you load an entire "run-time" engine. This consists of vast numbers of "ready-to-go" objects that make your simple "Hello World!" app into an 11 Meg progam. Java can't even share the "run-time" between apps very well!

    Is there a program out there that can tell the efficiency of the operating system environment, apps and OS, by how many functions "aren't" getting used in a normal day by a user? I'm going to go out on a limb here and suggest that most RAM isn't being utilized by apps.

    What I would like is an extremely efficient programming environment that compiles my six line x++ program down to a few hundred bytes total...that's in-memory while running. I want to use my RAM for data and number crunching, not unusable code.

    +1-1

    1. Re:I've been coding most of... by Tyler+Eaves · · Score: 2, Insightful

      >If I use only strcat() for example, why do I >need to load in the entire C string library?

      Because strcat can call another string library function, which can call another, etc...

      Code duplication is bad, remember?

      --
      TODO: Something witty here...
    2. Re:I've been coding most of... by gewalker · · Score: 2, Insightful

      What you want is a smart linker. You still build libraries, modules, etc. But when the program builds the executable it notices that some functions are never referenced, so the code for these is dropped when building the executable.

      Some versions even recognize classes have functions that are never referenced, and these class functions are eliminated.

      You get used to using a smart linker (I've been using Delphi a lot and it has one), it changes your programming style as you build larger modules/libraries since the bloat penalty is not there.

    3. Re:I've been coding most of... by MobyDisk · · Score: 5, Informative

      Linkers already do this. At this point, it is ubiquitous functionality. The linker has a list of functions that are referenced, and functions that are not referenced. Functions and libraries not referenced are discarded. I know for MSVC, this is done by using /opt:ref which is part of the default RELEASE builds. This all works for OO code like C++ as well since the methods boils down to functions as far as the linker is concerned.

      There are some special cases:
      1) You mentioned strcat() which can be inlined by many compilers. In this case, you trade speed for code bloat - the library isn't really used at all here. In MSVC this is an "intrinsic" function.

      2) Dynamic libraries may be treated differently. It is more difficult to try to partially load them. I'm not sure how Linux handles this. Windows allows for a DLL to contain multiple code and data segments, which can be loaded individually if needed.

    4. Re:I've been coding most of... by cookd · · Score: 4, Informative

      Very complicated question. Ughh, there are answers at many levels, and they are all different. But here goes.

      Any decent linker nowadays is "smart." This means that it already does what you are asking for -- it knows how to figure out exactly what the dependencies are, and bring in only the symbols (a symbol in this context is a chunk of code or data) that are (directly or indirectly) referenced by your code. Even though you link against all of the C Runtime, or all of the string library, the linker realizes that you are only using strcat. For this example, we'll assume that strcat uses strlen and strcpy. So your call to strcat pulls in strcat, strcpy, and strlen, but nothing else. So what you mention actually is already happening. (Unless you turn off the "smart" linking, as is common for debugging purposes.)

      However, there are some additional factors at work. The first is the C Runtime (CRT). ANSI C has some very specific requirements about how the environment is to be set up before main() is called, and how the system is to be cleaned up after main() exits. C also has specs about how to prepare the system for unexpected termination and signal handling. Setup and cleanup reference a bunch of additional symbols, so you end up with much more than just main(), strcat(), strcpy(), and strlen() -- you also have atexit(), exit() and etc. There is usually a process by which you can get rid of this and start directly in main with no setup code, but then you can't use any of the CRT-supplied functions (since the CRT isn't initialized) -- you have to set up your process yourself, handle signals yourself, and are limited to calling OS functions directly (no nice wrappers like fopen, printf or such).

      Then there is the issue of linking. Static or dynamic? Static linking means that all of the symbols you reference, directly or indirectly, are compiled into your binary. Dynamic linking means that all of the symbols are converted to references to external binaries, and when your binary loads, the external binaries will also load and you will use the symbol as defined in the external binary. Static linking means everything you need (and nothing you don't) is right there, compiled into your binary, so you'll never load anything you don't need. On the other hand, every program that is statically linked has its own copy of the linked-in routines, which can be wasteful of disk space and memory. With dynamic linking, the entire external binary has to be available, even if you only need one symbol from it. On the other hand, there only needs to be one copy of the binary on disk, no matter how many times it is used. And most of the time, the operating system can arrange things so that only one copy of the binary's code is loaded into memory, no matter how many processes are using it. This can save a lot of memory. For most systems, it turns out to be much more efficient to load a multi-megabyte dynamic link library into every process rather than statically link just the 200k that you actually need from that library.

      Finally, there is the OS involvement. The OS has to do a certain amount of setup for any process, no matter how trivial that process is. It has to allocate a stack, map the process into memory, set up virtual memory tables for it, etc. On a modern OS, in order for it to provide the services we expect, it has to set up a bunch of stuff just in case the process decides to make use of it. It is the price we pay for having a lot of power available to us.

      So for an example, I wrote up two test programs. I'm a Windows guy, so everything was done using Visual C++ 7.1. The first test was just an empty main(). Compiled and linked statically, it takes 24k on disk. That is basically just the CRT startup and shutdown code and the signal handlers (plus error message strings, etc.). It also links (dynamically) to kernel32.dll, ntdll.dll, and the OS itself. It allocates 568k of user memory/136k VM, 7k of kernel memory, and holds 14 kernel objects (thread handle, process han

      --
      Time flies like an arrow. Fruit flies like a banana.
  18. Re:Whoa whoa whoa! by jemenake · · Score: 4, Funny
    There's a D? What's next? Eb? Technology is moving at an incredible rate, indeed!
    Actually, depending upon who you ask, "D" shouldn't be the next in the series. I remember reading somewhere that the "C" got its name because it came after "B"... not in the alphabet, but in the acronym "BCPL", which supposedly stood for "basic combined programming language". (For more info, go read "BCPL to B to C" here.

    So, with that line of thinking, C++ should have been "P" (insert favorite "P Object-Oriented Programming" acronym joke here), and C# (although it shouldn't have been created at all, but was) should have been "L".
  19. What is "good"? by ljavelin · · Score: 5, Insightful

    I don't know if anyone has done any formal study on the complexity of development tools over time - but the fact is that programming tools are getting "lower" over time.

    When I started out in this business, a language like C was a high level programming language. It did a lot for the programmer, especially compared to assembler and FORTRAN.

    Everything we did every day was to save memory and CPU cycles. Can we squeeze a date field into 8 bits? You bet we'd try! And we did! Heck, we could ignore weekends and holidays. Phew!

    At the same time, databases were heirarchical. The databases were very close to the machine, so they were darn fast. As long as you didn't do any unexpected queries (like "sort by first name"), everything was blazing fast and tight.

    Then came the higher level systems. Ouch, they sucked! We were the very first customer to run DB2 in production (quiz- you know which one?) Anyhow, it sucked rocks compared to the heirarchical databases - they were just optimized for speed! Why would anyone ever want a relational database?

    But over years we came to see the light. With faster and faster machines, the number of cycles was less important. With bigger memory and disk, storage was less important. And it was butt-easy to use these tools. Easier and MUCH more maintainable.

    So yeah, Java and C# are going to use more memory and more cycles than plain old C (if using the languages as expected). But for most tasks, that isn't the whole story.

    The whole story is that Java and C# result in less expensive programs. And those programs should run fast enough. Yeah, not in EVERY case. But in most cases.

    Performance comparisons be damned.

    1. Re:What is "good"? by hey! · · Score: 2, Interesting

      First of all, I've been at this professinally for over 20 years. C has always been considered to be a "low level" language -- even compared to something like Fortran. Fortran, in the versions most of us learned it when back whe it was more or less mandatory to learn it, was not "low level", it was just primitive, which is not the same thing at all.

      The big change over the years isn't just that machines have gotten faster: systems have become more complex. Typical application programs are more complex than entire operating systems used to be. It isn't just that Java and C# make programs cheaper, being cheaper is another way of saying more complex systems can be built for the same budget (python takes this to a further degree).

      Making real applications in the real world, I'd say this: performance doesn't matter until it does. At some point you'll deliver a product that is just not fast enough. Probably you screwed up; you should have reorganized this or that, but often its hell to fix. I always tell my guys that there is no difference in a user interface between 100ms and 300ms, not much differnce between 1 hour and 3 hours, but a lot of difference betwen 1 second and three seconds. In those cases a "frees" 2x speed improvement (which we've seen with some library upgrades) or even 20%, is a godsend.

      WRT databases, I'd say this: I'd pit a modern RDBMS against an old hierarchical database -- depending on the query. Machines have got a lot faster, it is true, but databases have also got much, much larger, and the questions we are asking them are a lot more complicated. With the old databases, pretty much every question required some kind of hand coded program to answer. With modern RDBMS's, unless the question is something that can be answered by a trivial algorithm (adding a single column or traversing a single index), there's little doubt in my mind that a modern optimizer will beat what most programmers would produce in the time available to them, and what many programmers could produce with unlimited time.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
  20. Try it before you knock it by nissin · · Score: 3, Interesting
    I've programmed extensively in C and Java, with some C++. I took a typical anti-Microsoft stance early on and refused to even look at C#. I was finally convinced to try it, and I must say that it has some nice features.

    I recommend that any programmers out there try using it before discounting it. It might be especially interesting for those C++ programmers out there who don't like Java for one reason or another.

  21. But, the compiler/os should... by rmdyer · · Score: 2, Insightful

    ...be smart enough to "know" what sub-functions each function you are using needs to be loaded. If strcat() only uses 3 sub-functions, then those should only be loaded for "it". And, if those functions are already loaded "somewhere in memory", the OS shouldn't load them again, and again, and again, as so often happens these days.

    I'm saying that the compiler/OS should be smart enough to "itemize" your entire application in terms of absolute functions/variables needed at compile and run-time.

    Where is that capability? Why aren't compilers smarter?

    -1+1

    1. Re:But, the compiler/os should... by The+boojum · · Score: 3, Informative

      There are enough answers here, but I can't resist jumping in and clarifying.

      Most modern compilers in conjunction with OS's already basically do this. GCC and MSVC and the like all will link in only the functions that they deem referenced by your program and it's dependencies, provided you statically link the library.

      Dynamic link or shared libraries work differently. The OS "loads" them once and uses that one copy for all programs that require that library. The linker that builds the DLL has no way of knowing which functions in the library will be needed by the programs that may use. Some programs may only need one, others may need them all. So the DLL *has* to contain everything it needs to provide.

      The tradeoff is that while static linking means the linker only links in what's nescessary, all executables that use it must provide the same copies of those functions linked into each one. DLL's have to have the whole kit-and-kaboodle, but there can be a single, globaly available copy on this system shared by each.

      It's really a matter of pickin' yer poison.

  22. Re:Whoa whoa whoa! by wkitchen · · Score: 2, Funny
    So, with that line of thinking, C++ should have been "P" (insert favorite "P Object-Oriented Programming" acronym joke here), and C# (although it shouldn't have been created at all, but was) should have been "L".
    "L Object-Oriented Programming"?
  23. C is faster than Java, C#, etc. by Prof.Phreak · · Score: 2, Insightful

    No matter what you say, C is *always* faster. You *cannot* write a loop in C#, and claim that it will run faster than a comprable loop in C. For one, the interpreter for Java or C# is very likely written in C itself.

    Does the speed matter? Does anyone care? No. Well, not for a vast majority of applications. Most of the time the I/O speed is the bottle-neck, not the "code" speed. So if you write a word processor, or some database app in C#, or C++, or C, or Java, more often than not, their 'apparent speed' will be comprable to each other.

    A better question to ask is: Would you do numerical analysis, or number crunching/factoring algorithms in Java or C#? Would you even do them in C? (or would you go for Fortran or distributed Haskell?)

    --

    "If anything can go wrong, it will." - Murphy

    1. Re:C is faster than Java, C#, etc. by Anonymous Coward · · Score: 2, Informative
      No matter what you say, C is *always* faster. You *cannot* write a loop in C#, and claim that it will run faster than a comprable loop in C. For one, the interpreter for Java or C# is very likely written in C itself.

      That's just wrong. For one thing, "C" is a language, not an implementation; same for "Java." Languages have specs but they don't have any associated speed. Only specific implementations of languages have that. Thus, you can compare the speed of C code compiled with Microsoft Visual C++ 7.0 to the speed of code running under Sun's JDK 1.2.2, or you can compare "gcc -O2" vs "IBM JDK 1.3", but you cannot compare "C vs. Java" because those things are specs, and specs can't run code.

      For another thing, you're mistakenly assuming that C# and Java are interpreted languages; they are not. (Neither is C a compiled language; there's nothing in the spec that keeps C from being interpreted.) Again, this can only refer to specific implementations, but even if you had done that, you would still not be right because all popular implementations of Java (notably Sun's and IBM's) have used either Just-In-Time compiling or HotSpot virtual machines (which also compile code.) Sun's Java 1.0 release, about eight years ago, was interpreted, but no version since then has been.

      As far as the possibility of speed goes, languages that just variants of just-in-time compilation generally have a modest startup penalty. This was roughly 700 ms. the last time I measured it, but I understand it has gone down somewhat in more recent releases. (Scripting languages generally start up quite quickly, by way of comparison.) That makes Java unsuitable for things like "ls" that you run often, but it doesn't matter for many applications. As far as the possibility of optimization goes, virtual machine implementations have optimization options that aren't available to compiled languages. (The reverse is not true, to my knowledge.) For example, Sun's HotSpot VM optimizes at runtime and can dynamically take into account conditions at the time a program is run to make optimization decisions. Branch predictions that go one way with small files might go another way with large files, but (for example) a C++ compiler cannot possibly take this information into account, since all its optimization decisions are frozen when the code was compiled.

      For my own part, I have done several performance comparisons of gcc 2.95 with Sun Java 1.3 and 1.4, and I have found them to be roughly at parity. Gcc may have had an edge in the 5% to 20% range, but I also found some applications where java was faster. (gcc needed to have -O2 to be able to compete with Java; without it, Java won almost always.)

  24. Shared libraries by n0nsensical · · Score: 3, Insightful

    And, if those functions are already loaded "somewhere in memory", the OS shouldn't load them again, and again, and again, as so often happens these days.

    If the functions are in a shared library, they shouldn't be. Each library (including, for example, the C runtime) is loaded once into memory and every process uses the same code. If you modify that code in memory, Windows makes an individual copy of the page for the modifying process. I couldn't tell you exactly what the overhead is used for, but the OS isn't loading 20 copies of strcpy or whatever as long as each executable is dynamically linked.

  25. Limbo languishes, sadly by dido · · Score: 2, Insightful

    Too bad Limbo is too deeply tied to Inferno. It's unfortunate. From looking at how it's been designed it seems that Dennis Ritchie still hasn't lost his touch as an exceptional language designer. The Dis virtual machine that goes with it is supposedly designed to make a JIT simpler and more efficient, and well, according to Vita Nuova it gets something like 50% to 75% of the performance of compiled C/C++ code, which, if the article and Vita Nuova's benchmarks are accurate, totally blows C# and Java out of the water performance-wise. Now if only Vita Nuova would care to make it half as platform-neutral as Java... But hey, who cares, I'm already trying to do that. :)

    --
    Qu'on me donne six lignes écrites de la main du plus honnête homme, j'y trouverai de quoi le faire pendre.
  26. The problem is: that's not the problem by Spinality · · Score: 4, Insightful

    You're right. But with ever-increasing CPU horsepower, memory bandwidth, memory size, etc., there simply is no incentive for optimizing the things you're talking about. Moore's 'Law' has attenuated the advancement of software technology, by eliminating the need for efficient software.

    There are plenty of dinosaurian programmers like myself who remember hacking away on small machines. Save a byte by referencing a constant stored as an opcode in the instruction stream? Excellent! SLR R1,R1 is 60ns faster than SL R1,R1? Excellent! Decrease the size of the PDP-8 bootstrap loader by one word? Excellent! (Flipping those toggle switches took a lot of time.)

    In 'the old days' hardware was expensive and programmers were cheap. Hard problems were solved by incredible brainpower from great engineers. As a result, by the early 70's software had made huge advances over the punchcard/paper-tape era, and we had learned a lot about how to build quality systems.

    But there was a magic moment when the curves crossed between the cost of programming time versus the cost of hardware. Suddenly, it became easier to solve a problem by adding iron rather than by thinking harder. And so we slid backwards down the slope.

    As far as I'm concerned, hardly anything significant has happened in software architecture or praxis for a few decades. Sure, we have a bunch of fancy new widgets, and the common man's programming paradigm has changed. And the Open Source movement finally has given substance and a PHB-understandable framework to what Unix, LISP, Smalltalk, and other hacker communities used to do behind the scenes.

    But most of today's 'new' language, compiler, data management, operating system, and other computer science paradigms had their fundamental elements invented back in the 60's and 70's. We're finally RE-discovering many great concepts of the past. But it seems we've totally forgotten the importance of efficient, defect-free code, and the methods that might be used to create it.

    This is not to say that only great systems were built in 'the good old days' -- those days weren't that good, and there was plenty of crap. But the really bright folks figured out how to do things RIGHT; and yet they wound up being ignored, because 'doing it right' became less important than 'letting Bruce the part-time lifeguard do it over the weekend in Visual Basic.'

    So while I totally agree with your rant, and I've made a hundred similar rants of my own, the fact is we probably won't see fundamental improvements in software platforms until subatomic physics finally provides a wall against which hardware advances can bounce. As long as the answer to every performance/capacity complaint is "wait six months" there's no incentive to invest the man-centuries it will take to revamp our software environments. We probably need to build intelligent software that can optimize itself, because WE NEVER WILL.

    </rant>

    --
    -- We all have enough strength to endure the misfortunes of other people. La Rochefoucauld
    1. Re:The problem is: that's not the problem by Aidtopia · · Score: 2
      But with ever-increasing CPU horsepower, memory bandwidth, memory size, etc., there simply is no incentive for optimizing the things you're talking about.

      Not entirely true. We've got more memory and CPU power, but the storage bandwidth has not kept pace. Every significant performance problem I've tackled in the past few years has had to do with cache misses and/or page faults. I've worked on shrink wrap code where the customers have decent though not high-end machines. Load times can be 30 seconds of building fix-up tables for the scores of dynamic libraries before you hit the first line of main(). Add another minute of thrashing while the minimal amount of data is loaded from disk into the far reaches of your address space, and you've got a user who's already wandered off to get another cup of coffee.

      Improving locality of data is nearly impossible if your language is too high-level or if you've delegated to a very general-purpose container library. I once improved the performance of a function from more than a minute to about a second. It was looking up 900 items in an STL map that had somehow spread itself out over zillions of pages causing endless VM thrashing. I replaced the map with a simple array and used bsearch. Zoom.

      I guess my point is we do need to fight the bloat. We need tools that load the bare-minimum. If we surrender some of our control to higher-level languages and libraries, then we need a back door to take control back when it matters.

  27. Who cares? Machine cycles are cheap... by supton · · Score: 2, Insightful

    Bruce Eckel sums it up best:
    "Programmer cycles are expensive, CPU cycles are cheap, and I believe that we should no longer pay for the latter with the former. " from a post by Bruce Eckel on artima.com.

    Perhaps people should stop obsessively benchmarking platform VMs, and start benchmarking coding productivity and teamwork, perhaps in Python, with the performance bits in C. For a real-world example, Zope does exactly that: 95% of the code in Zope ends up being done in Python - only the real performance-intensive stuff need be in C... and the stuff done in Python is easy to read, modify, reuse, and tweak (thus, better productivity for both developers that use Zope as and app-server platform well as developers who work on Zope's core).

  28. SharpDevelop - #develop - GPL .NET IDE by Sean+Clifford · · Score: 4, Informative
    Well, there's always vi a la vim win32 port. :)

    I do a lot of ASP3.0/SQL2k and some utility development on Win32, taking a stab at .NET. It would be nice to move over to Mono.

    Anyway, I've done a bit of poking around and ran across SharpDevelop - AKA #develop . It's open source a la GPL and looks a lot like Visual Studio, and compiles C# and VB.NET; has C# => VB.NET code conversion; does projects or files; has syntaxing for the whole MS shebang. It's a .97 - this build was released Friday 9/12/2K3, officially in beta, and you can get the binaries here, go snag the source here, and get the MS.NET1.1SDK here.

    To those folks who hiss and moan about the whole GNOME/.NET/Mono thing, take a gander at the rationale before playing jump to conclusions (mp3).

    SharpWT - AKA #WT is a .NET port of Java SWT on both Windows/.NET and Linux/Mono platforms. So...you can develop your .NET apps to run on both Win32 and Linux with pretty much the same GUI. Neat, eh?

    Anyway, intrepid Windows Developer, if you can pry yourself away from the MSDN Library for a few minutes, you might find there's something to this Mono business.

  29. Almost as good as Delphi by occamboy · · Score: 2, Interesting

    I've been coding for a million years: 6502 machine code all the way up to a recent foray into C#, and almost everything in between. Here's my take, for what it's worth. And, it's your chance to mod me down for pontificating!

    Delphi is the best all-around language ever for producing Windows apps. The Delphi programmer has control over everything if they want it, but they don't need to muck around with nasty details unless they need to. It encourages clean coding. Performance is superb. And the IDE is excellent. The Delphi package (language plus IDE) has been the path of least resistance to getting an app done for the past six or seven years.

    Prior to Delphi, the way to go was VB with C DLLs. Do the UI in VB, do the internals as C DLLs. VB was great for abstracting nasty stuff, but it often overabstracted, and performance was ungood. Writing companion DLLs in C boosted flexibility and performance.

    Generally speaking, C is basically not much beyond portable assembly language. If a reasonable alternative is available, and it usually is, using C for anything beyond embedded systems or super resource-critical applications is probably not a good idea, as the code tends to be dangerous and obsfuscated. And keeping track of pointers is just nutty.

    C++ is a nightmare. In theory it's object oriented, but all of the code that I've seen is a total mess, more like C using the C++ libraries. Ugh.

    Java is almost good: it is pretty safe, and encourages good habits. But I find it clumsy - like it was designed by academics rather than practical developers. Lack of enumerated types, for example, is insane, and encourages unsafe programming. It's also a pig, which doesn't matter so much for a lot of things these days - we usually have lots of CPU cycles to spare. For doing GUI apps, Swing is a weird joke - a pig's pig - which should be forgotten immediately. And the Java IDEs have only recently become usable for command-line stuff, but they suck as bad as Swing for GUI development.

    Now C#. Having toyed with C# for an app recently, I'm quite impressed. It's sort of like the best of Java with some of Delphi's goodness added. It's ALMOST as good as Delphi - which makes sense, since the same fellow (Anders Hejlsbeg) was key in developing both of these languages. And .NET, to which C# is bolted, is pretty good as well. And the IDE is very nice. So, all-in-all, I think that C# is a good choice for Windows development. The web forms stuff seems interesting, but I have a feeling that using it would be something that I'd end up regretting - there's bound to be nasty gotchas that won't show up until late in the project.

  30. Not from my recent experience by GroundBounce · · Score: 4, Insightful

    I am in the process of coding a data collection server application in Java which collects data from remote devices that dail up over a phone line. The application must interface with the serial port at a low level, send email, generate XLS files, send faxes, create charts, and, of course, communicate with a DBMS. It also has a significant GUI component as well. Oh yes, this application must be able to run both on Linux and Windows (2000 or XP).

    I have been developing on Linux. All in all, to date I've coded around 30,000 lines of code. Because of the high level of portability of the APIs, I had to change all of about a dozen lines of code to get it up and running on Windows. That's one dozen out of 30,000. There's now way you could even come close to that using C or C++, regardless of how cross-platform the library developers say their libraries are.

    As far as performance, Java may have been slow three of four years ago, but the last several versions of the JDK and the HotSpot JVM have seen a steady and rapid improvement in performance and stability. SWING, although it has improved, may still be a bit slow, but computational code written in Java is only slightly slower than in C++. Even current versions of SWING, although arbuably slower than native GUIs like GTK+ or QT, are fast enough so as to not be noticable on any machine faster than 800MHz or so.

    Most people who say Java is unstable or slow are remembering their experience from the JDK 1.1 days. The current JDK 1.4 bears little resemblance to that in terms of performance and maturity.

  31. ...and the .NET Framework is language-neutral by kylef · · Score: 5, Interesting
    What language you use depends on your application. Comparing C, C++, and C# is like comparing a wrench and a screw driver.

    And this is where the .NET Framework shines, because the CLR is a generic virtual machine to which any number of languages can be compiled. Currently there are C#, C++, VB, and even Java (under the moniker J#). There has been talk of writing a Python compiler and even possibly a Perl compiler. So you can choose your language of choice, and your resulting binaries or objects will fully interoperate with the other .NET languages and class libraries.

    And as far as this article is concerned, I think the interesting point is not that they're comparing apples to oranges, but just that the performance numbers for CLR-compiled C# aren't so horrible that they should scare off the majority of developers.

    1. Re:...and the .NET Framework is language-neutral by Daimaou · · Score: 2, Interesting

      You know, I used to think that the idea behind .NET supporting all these languages was interesting, but now that I've actually used it, I can't see what the big deal is; especially since the development environment to program for .NET is different for each of the different languages. Sure, you can hook a smattering of languages together, but who on Earth really does that? I have never worked for a company that says "write in whatever language you want to, we code to .NET so it doesn't matter!" What a nightmare that scenario would be. Most companies force standardization on one or two languages and then hire people with appropriate experience.

      What I find much more useful, and therefore of a much higher "cool" factor, is Borlands new C++BuilderX. Now that is a damn fine looking development tool. I can't wait to try it out.

      C++BuilderX allows a C++ or C developer to pick from several compilers (Borland, MS, GCC, Forte, etc.), it will compile to Windows, Linux and Solaris, and it supports the EXACT SAME development/debugging environment regardless of which combination of compiler/OS you choose. It also lets you seemlessly interface with a variety of version control systems. To me, that seems much more useful than having a bunch of different environments that will compile a bunch of different languages to one VM.

  32. Re:But there's just one problem... by ScrewMaster · · Score: 2, Insightful

    Possibly true for pure VB, but major VB apps aren't. In order to do a lot of things that aren't intrinsic to the language, you end up calling C/C++ or Windows API functions to get the job done. That tends to blow compatibility with non-Windows runtime environments (hell, it tends to blow compatibility with Windows environments.)

    --
    The higher the technology, the sharper that two-edged sword.
  33. #insert <obligatory_Java _generics_rant> by Anonymous+Brave+Guy · · Score: 4, Interesting
    Java SDK v1.5 (not yet released) contains support for 'generics', which are very much like C++ templates for Java:

    I really can't believe this thread. Why do people always come up with this worn out line whenever someone suggests that C++ templates are an advantage? And how come so many people have done so in replying to the same post? All but the first are (-1, Redundant), and the first is (-1, Ill-informed).

    OK, please, read this carefully, for I shall write it only once (in this thread):

    Java's generics are not even close to the power of C++ templates. They are glorified macros to fix a bug in the type system that should never have been there.

    C++ templates were at that level around a decade ago. Today, they're used not only to create generic containers (for which they are, no doubt, very useful) but also, via metaprogramming techniques, as the tool underlying most of the really powerful developments in C++ for the past few years: expression templates, high performance maths libraries, etc.

    If you didn't already know that, please read it again and understand it before proceeding.

    Java's generics don't even come close to the same power. They're a cheap knock-off, aimed at just one of the uses of C++ templates, which fixes a glaring flaw in the previous Java language. For that, they serve their purpose well, but please don't pretend they're anything more.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  34. And both generics and templates are kiddy toys... by alispguru · · Score: 4, Insightful

    ... compared to the code-generating power of lisp macros.

    --

    To a Lisp hacker, XML is S-expressions in drag.
  35. Anyone played Quake II.Net? by Anonymous+Brave+Guy · · Score: 2, Interesting

    Microsoft have had a .Net version of Quake II mentioned on their developer pages for some time now. It's a port to Visual C++ .Net 2003, using the CLR.

    Has anyone tried this? It's presumably managed C++ rather than C#, but it should give a fair indication of the performance you'd get from C# if it's using the same run-time framework. If they can get comparable performance in a FPS using the .NET run-time, it might be worth looking at for games development after all...

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  36. C, C++, and Java by SHEENmaster · · Score: 2, Informative

    share portability in common. I can write an app in C, and run it on my server, laptop, palmtop, ancient SunServer, or even a Windows machine. The same goes for Java and C++.

    If I use C#, I'm effectively locked into .NET. Mono is a good start, but not enough to make my code reliably portable.

    C# has all the speed of Java with all the portability of X86 assembly linked to Windows libraries. Microsoft's BS patents will help ensure that the portability problems aren't corrected.

    The real purpose behind .NET is to make the platform compatibility promised by NT 4 available without opening the source.

    --
    You can't judge a book by the way it wears its hair.
  37. You're missing something by Anonymous+Brave+Guy · · Score: 2, Insightful
    No matter what you say, C is *always* faster. You *cannot* write a loop in C#, and claim that it will run faster than a comprable loop in C.

    Actually, in practice, no it's not and yes you can.

    What you're ignoring is the "late optimisation" effect of virtual-machine and intermediate language execution models. The installer or run-time can take intermediate code and convert it to native code, just as a C compiler would, but with full knowledge of the environment in which that code is going to run. That allows for specific optimisations based on the execution environment that are rarely, if ever, practical for C-based programs. (How many C programs ship with different optimised executables for each Pentium and Athlon series processor, for example?)

    You seem to be writing as someone who knows how things are supposed to work, who has a certain mindset and isn't prepared to look outside it. So-called just-in-time compilers actually have a lot of potential. They aren't, in general, as fast as something like C or C++ yet. However, in theory they could actually be faster once they've matured and caught up, because they can do all the same low-level optimisation tricks as a C or C++ compiler, with more knowledge of the target environment to get the best out of them.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:You're missing something by pantherace · · Score: 2, Interesting
      Actually things like this have been done (re-optimizing compilers) for binary programs. Please note that this is not run-system optimization (as is the case for the c# compile on install, or something like gentoo) this is run-time optimization, which produces faster code. I know of experements on alphas (based on what fx!32 did (which is interpretive emulator+translator+run-time optimization (might be where more jits try to go, and may be considered a very early, and very very advanced jitc.) and in production (as I recall) on pa-risc. This is nice for all the byte-code languages with jit's but under those run-time optimiziation of the code, (and the ability to store it to disk permanantly, vs when the jit loads, or changes (admittedly may be never)) pretty much always found that the c and other binary generating languages would be faster in the beginning, and end.

      Essentially: all languages have a lot of maturation to go through, and more optimizing. :) Hell, I will be impressed when a language runs well on EPIC, with it's lack of hardware support for things most procs do in hardware, as a design idea.

      I look foreward to a reply.

    2. Re:You're missing something by Anonymous+Brave+Guy · · Score: 2, Interesting

      I agree completely: a lot of it is down to the maturity of optimisation technology for the language in question. This is part of the reason that some high level languages -- OCaml, for example -- can generate code of a comparable speed to low-level beasts like C and C++: with a simpler underlying model, it's easier to perform good optimisations. It's also the reason C is still faster than C++ for some things, even though theoretically, C++ should never be slower.

      I was including dynamic optimisation (during the program run) within the "late optimisation" idea, but in practice, I get the impression it's not used much yet. It's far easier to do platform-specific optimisation on installation or loading, effectively, just doing the optimisation phase of a compile late. Effective dynamic optimisation is a very hard thing to do, because you have the overheads of monitoring code speed to overcome before you can even hold your own, never mind gain an advantage. I suspect that in time, dynamically optimising run-times will gain a much stronger foothold in the market, but probably not until a lot more research has been done.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  38. How about Python? by MikeBabcock · · Score: 2, Insightful

    I know the article is about C#, but every time I read something about C# I think to myself "I can do that in Python". Python is cross-platform, interpreted, object-oriented, fast, easy to extend with C or C++ and even more exciting for some people, usable transparently with Java as Jython.

    I've found that almost all the programs I've written I could've written smaller and better and more obvious (and therefore easier to debug and maintain) with Python. None of those that I have rewritten show any noticeable performance penalty for having done so either.

    Just wondering if you've dealt with it at all yet.

    --
    - Michael T. Babcock (Yes, I blog)
  39. Old School C++ Programmers by mrcparker · · Score: 2, Funny

    You mean all the way back 1994-95 era computing? sheesh. You work in a museum.

  40. Re:#insert by pyrrhonist · · Score: 2, Interesting
    Today, they're used not only to create generic containers (for which they are, no doubt, very useful) but also, via metaprogramming techniques, as the tool underlying most of the really powerful developments in C++ for the past few years: expression templates, high performance maths libraries, etc.

    Translation: Today they are used to butcher a perfectly fine language and add new impediments to understanding.

    --
    Show me on the doll where his noodly appendage touched you.
  41. Re:Again, you are speaking... by eloki · · Score: 2, Interesting

    But what if app A doesn't use but 1 function in library A? And, app B only uses 1 other function from library A?

    This is why Linux pages things in on demand. It doesn't read the whole library and load it into physical memory. The library is conceptually mapped into your address space, when you try to access a function foo(), if foo() is in a page that isn't currently loaded in physical RAM, the OS gets a page fault, and that page will be loaded.

    Just because you're linked against libc, that doesn't mean you're physically loading every string function into RAM when your program runs. The granularity you're talking about probably isn't worth the gain in extra complexity.

  42. Oracle by Un+pobre+guey · · Score: 3, Interesting
    So, with no loss of portability or functionality, you could do the same in C/C++.

    Try this:

    Write a backend app in Java, and one with the same functionality in C or C++. Make sure they both read and write data to an Oracle database. Now, with stopwatch in hand, make them both run on Win2K, Cygwin, Solaris, and Linux.

    Guess which language will allow you to finish first.

  43. Re:#insert by Anonymous Coward · · Score: 2, Interesting

    Correction: generics are unglorified macros. Templates are glorified macros. Templates can add type safety at compile time with no runtime penalty. Generics macro expand their type safety into java casts, which incur a decent runtime penalty (especially for large container intensive algorithms).

    Additionally, I once saw someone (saurik from saurik.com) use templates to do dynamic programming at compile time. He wrote an exponentially increasing algorithm to have an exponentially increasing compile time but constant run time when an arbitrary limiting value n was increased. Not actually useful, but still really damn clever and it illustrates the versatility of templates for meta-programming. And more importantly, I am pretty sure the same program is illegal for generics.

  44. Re:Whoa whoa whoa! by willtsmith · · Score: 2, Interesting

    I would suspect that brininging a "managed environment" to system level programming would be a good step.

    C/C++ have served us all well. However, I suspect that something a bit more portable and simpler may be relevant, especially with the byzantine complexity of C++ behavior.

    On the application end, I would suspect aspect-oriented programming is next on the horizon. More structures to ensure quality (pre/post conditions). More programming by definition and constraint with glue (built in quality control).

    --
    -------- -------- Support Wesley Clark for president!!!
  45. Re:#insert by pyrrho · · Score: 3, Interesting

    I posted this already... go see how blitz++ works.

    It doesn't make the language butchered in the least, quite the opposite, the end result is very clear to use and the confusing part is hidden inside the classes, where it cannot cause trouble.

    the thing about C++ is, sometimes things are hard, but the reason you do them anyway is because they are worth it, and you can get high levels of abstraction (arbitrarilly high) without taking runtime hits. You have the ability to control your overhead, templates are a great example, especially the examples the parent poster mentions, expression templates, and high performance math libraries.

    Blitz++ uses templates in an elegant, mind blowingly cool way. It might not be clear how it works to many, but that doesn't change how it works. Truly beautiful. And it makes the code easier to read, not harder.

    --

    -pyrrho

  46. Re:C# is not the only .NET language by willtsmith · · Score: 2, Insightful

    The multiple language angle is

    1) to allow anyone accessibility with there skillset.

    2) allow the integration and migration of legacy codebases.

    3) Not piss of VB customers who are perfectly happy with their ugly piglatin language ;-)

    Serious, there are large Fortran libraries out their. Microsft's approach allows easy integration.

    A cobol implementation exists. Though, COBOL is almost always spagetti code riddled with non-modular entry points. But I suppose well written COBOL code can be migrated into a mixed .net environment.

    Ultimately, distilling it all into cross-platform IL is a thing of beauty. Managed code that can be accessed from any language and run on virtually any platform.

    --
    -------- -------- Support Wesley Clark for president!!!
  47. Bad Kool-Aid. by rjh · · Score: 4, Interesting

    Currently there are C#, C++, VB, and even Java

    If I understand the .NET framework correctly, there is no way to support either multiple inheritance or templates--in which case C++ cannot be accurately modeled in .NET. Nor will Java be .NETtable after 1.5, which will introduce pale imitations of templates (but imitation enough to give the CLR a hissyfit).

    The .NET CLR does not support multiple languages. It supports one language--C#. Its "multiple language support" comes from being able to compile down many functionally-identical languages with different syntaxes down to the same bytecodes.

    But truly different languages are not representable in the CLR. Show me how to do a Scheme continuation in the CLR, please, or export a C++ template, or a LISP macro.

    The only languages .NET supports are those which are subsets of C#. And once you realize that, .NET becomes much less interesting.

    (Warning: haven't used .NET much in the last few months. Last I checked these things were true, but after being very unimpressed with .NET I haven't kept up with things.)

    1. Re:Bad Kool-Aid. by Keeper · · Score: 3, Informative

      If I understand the .NET framework correctly, there is no way to support either multiple inheritance or templates--in which case C++ cannot be accurately modeled in .NET. Nor will Java be .NETtable after 1.5, which will introduce pale imitations of templates (but imitation enough to give the CLR a hissyfit).

      The next version of .Net (2.0) is supposed to introduce native template support to IL. Not sure about multiple inheritance, but I doubt it.

      The .NET CLR does not support multiple languages. It supports one language--C#. Its "multiple language support" comes from being able to compile down many functionally-identical languages with different syntaxes down to the same bytecodes.

      If you want to get technical, the CLR supports IL (implementation language), which is interpreted by the virtual machine. The virtual machine has a set of instructions it understands, and the various .Net compilers compile to those set of instructions. This isn't very different from taking a C++ program and building an executable that consists of instructions for an x86 cpu. The machine (virtual or not) provides the facilities for performing the operations you want to do.

      If you can represent what you want to do in IL, you can write a compiler for it. There's some guy out there who wrote an 386 asm->IL compiler (why? because he could I guess...) for example. Not that I think it's a terribly great idea, but it is neat.

      But truly different languages are not representable in the CLR. Show me how to do a Scheme continuation in the CLR, please, or export a C++ template, or a LISP macro.

      IL doesn't have special instructions designed to support those things, but they can be done; they just won't be necessarily be done fast or efficently; for instance, you could do C++ templates the way your average C++ compiler does them --> your compiled code has a unique object for each templated type required. And I can pretty much guarantee you that you could write a Scheme or LISP compiler -- it'd just be a pain in the ass to do (which I'd imagine any proper LISP compiler would be), and it wouldn't be wicked fast.

      The only languages .NET supports are those which are subsets of C#. And once you realize that, .NET becomes much less interesting.

      A more accurate statement would be that IL supports object oriented / functional languages very well, and other things not so well.

      Most commonly used programming languages are OOP or functional in nature. I haven't used a non object oriented language since I got out of college. Perl, C, C++, Java, Basic, Fortran, Pascal, Python, Cobol, Smalltalk, various shell languages, etc. are all either functional or object oriented languages.

      I'd argue that implementing optimal support in a form that most languages translate well to (as opposed to a form that rarely used languages translate well to) was a good design decision.

      The power of this allows you to write code to get what you want done, instead of spending a lot of time writing code to get a round peg to fit in a square hole. There are many other peripheral benefits that .Net brings to the table, and I personally think this isn't one of the big ones -- I think it's more of a "cool" factor than anything else -- but dismissing it outright because the design doesn't perfectly suite some obscure language that is generally used by AI researchers is kind of silly in my opinion.

    2. Re:Bad Kool-Aid. by mrdlinux · · Score: 2, Informative

      I don't know why the OP mentioned Lisp macros, because they certainly have nothing to do with the backend of a Lisp compiler. However, problems still do exist with compiling to IL, mostly focusing around calling-conventions and potential limitations instituted by the CLR.

      For example, Common Lisp has advanced object-oriented features such as multiple-dispatch methods and method combination, and this would most have a large conceptual mismatch with the typical calling conventions used by languages in IL, hence the CL compiler would need to use its own calling conventions and would be incompatible with other languages (thus defeating the point of IL).

      Same goes for memory layout, stack management, etc... all due to Common Lisp's advanced data types and capabilities such as multiple-inheritance, CHANGE-CLASS, resumable conditions...

      As far as I know, all real Common Lisp compilers that support Windows have not yet made any serious steps towards adding an IL backend, since there is very little benefit to be gained until those issues can somehow be worked out. Franz, in particular, put out a list of roadblocks a few years ago, but I do not know what became of it.

      Scheme, on the other hand, has call/cc which requires heap-allocated stacks. This has been a sticking point with Scheme on JVM; the Schemes there simply do not support the full call/cc as a result. JVM is very limited with what the call-stack can do, for "security" reasons. I imagine CLR has similar issues, unless someone clever found a way around it.

      In general, the problem of an ideal "Universal Intermediate Representation" for all languages, so that only one backend is needed per platform, has been extensively studied for probably 30 years and I do believe the conclusion so far is: it's not possible.

      I highly doubt that Microsoft has beat out academia in this regard.

      As for your other statement regarding various languages and their supported paradigms, I would like to clarify something:

      C, Basic, Pascal, Fortran, and Cobol are not regarded as functional nor object-oriented languages. I highly recommend you consult the definitions of said terms. In addition, I would not count the following as object-oriented languages, in an ideal world: C++ and Java, due to their mostly static (and pain-in-the-ass) nature.

      (Hint: functional language means higher order functions and closures)

      --
      Those who do not know the past are doomed to reimplement it, poorly.
    3. Re:Bad Kool-Aid. by gglaze · · Score: 3, Interesting

      How can this comment be (+5 Interesting) while each of the subsequent comments are 1's and 2's? When I first read this, I almost jumped to write a diatribe, and found that the other replies had already covered most of the important points very nicely. This comment should be marked (-1 : Ill-Informed) or some such rating, as it is highly misleading to anyone on /. who might be trying to learn about .NET.

      As the others have mentioned here, the CLR is an abstraction of the assembly instruction layer, not the "object-oriented" layer. Thus, a statement such as "CLR does not support {select archaic c++ OO concept}" does not make any sense. This obviously applies for things like multiple inheritance, templates, etc.

      Furthermore, the idea that the CLR "does not support multiple languages" is the most ridiculously malinformed statement I have ever heard about .NET, and trust me, I've heard plenty. One of the major objectives, if not the most important, is to bring to prime-time quality Microsoft's idea of supporting many languages on the same framework. They started this idea a long time ago with COM, and as it evolved, they realized all of the flaws in the COM architecture, and .NET is the next generation of multi-language support, in that sense. .NET currently supports what, like 20+ languages? Not all of them developed by MS, btw... Many of these languages use different paradigms (scripting-oriented, functional-oriented, procedural, etc.), and they all have access to the full breadth of the .NET framework. If that's not "multi-language support", I don't know what is.

      To assume that languages supported by .NET are "subsets of C#" is either naive or very malinformed. Anyone who knows the history of this knows that VB has always been Microsoft's baby, and C# is just the new kid on the block. Yes, now that C# has realized its potential, perhaps it is overtaking VB in popularity. But to claim that VB provides a "subset" of C#'s functionality is precisely backwards - in fact it is literally backwards - if anything, C# provides for the most part a subset of VB functionality, although technically the two provide somewhat intersecting but not fully overlapping sets of functionality - there are some things you can do in VB that you can't do in C#, and there are some you can do in C# that you can't do in VB. And the same goes for all languages on the .NET platform.

      Features like templates and multiple inheritance are first and foremost a feature of a language at the OO-level of abstraction - not the assembly level. As one poster noted here, Eiffel is a good example of a .NET language which already supports these concepts. If you wan't to complain that C# doesn't support them, that's ok. But to complain that "CLR doesn't support them" really doesn't make sense. Get your argument straight first.

    4. Re:Bad Kool-Aid. by adrizk · · Score: 2, Informative


      Most commonly used programming languages are OOP or functional in nature. I haven't used a non object oriented language since I got out of college. Perl, C, C++, Java, Basic, Fortran, Pascal, Python, Cobol, Smalltalk, various shell languages, etc. are all either functional or object oriented languages


      Imperative, they're imperative or OOP, not functional. Functional languages are languages exactly like LISP or Scheme. You construct a C program out of a bunch of statements, not a bunch of functions.

    5. Re:Bad Kool-Aid. by mrdlinux · · Score: 2, Interesting

      As I hinted, without built-in support for higher-order functions and closures, a language cannot be considered to be `functional', because you would essentially have to implement these features yourself in your program (and most likely need to work around the limitations of that language also).

      Does attending a university make me an academic? I don't think so---I also work, and understand the practical viewpoint of a coder; I just don't see it as adequate justification for throwing away the dictionary. As it is, `functional programming' is also supposed to mean `no side effects' but that has now been relegated to `pure functional programming'.

      Personally, I backed away from the pure FP stance a long time ago, but I still think that higher-order functions and closures can be an extremely useful tool for any programmer and they can easily be mixed into other paradigms (just look at Smalltalk and Common Lisp).

      --
      Those who do not know the past are doomed to reimplement it, poorly.
  48. SharpDevelop, alternative to VS2003 by Bazouel · · Score: 2, Informative

    There is an open source alternative IDE for .NET called SharpDevelop, which you get at http://www.icsharpcode.net. It is not as good as VS2003, but quite near :)

    --
    Intelligence shared is intelligence squared.
  49. Re:Whoa whoa whoa! by Jugalator · · Score: 2, Informative
    --
    Beware: In C++, your friends can see your privates!
  50. There's no performance overhead for a VM by cartman · · Score: 2, Interesting

    I've done significant work in benchmarking Java programs versus equivalent C/C++ programs. I've found that garbage collection is the sole reason that Java is slower than C++; having a "virtual machine" imposes no performance penalty whatsoever. This is unsurprising, when you think about it; a JIT compiler simply moves the latter phases of compilation ("byte code->assembly") to runtime.

    Contary to what many people think, even most traditional C compilers work by compiling source to byte code, optimizing the byte code, then compiling byte code to assembly. There's no reason to expect that the resultant assembly will be any slower just because the final phase is done at run time by a JIT.

    Programs compiled using IBM's Java compiler routinely outperform equivalent programs compiled using "gcc -02", if garbage collection is not used in the Java program being compiled.

  51. Dubious choice of benchmarks by gibara · · Score: 2, Insightful

    Since registration is required to read the article, I have not read it. But given the title of the publication I was alert to the possibility of bias, and I think it's quite strongly present in the introduction. Java is the platform against which .Net will be measured for the forseable time and I think that the choice of benchmarks in Part 1 strongly favour .Net.

    application invocation (time to load and execute)

    It seems likely to me that the CLR will be be preloaded/vigorously cached by a Microsoft OS whereas the JVM is treated like any other application. Startup times will be skewed appropriately

    algorithms and recursion (calculating Pi and Eratosthenes's sieve)

    One of the small number of additional features of the CLR over the JVM is support for tail-end-recursive algorithms. This test will favour the CLR for the reason.

    conversions (int to float, float to int, int to string, string to int)

    A valid test but half useless. How much time is spent in an application casting from float to int or vice versa? Conversion between ints and strings is a valuable benchmark (XML based applications have to that often).

    string comparison, string concatenation, string tokenization

    Java has a weakness (actually it has had many) with its treatment of String handling. They are slow to manipulate and memory heavy. Further changes are being made in 1.5 (introduction of non-synchronized StringBuilder class). If the .Net libraries can't do better than the Java libraries then I'm appalled.

    From the outside, this article just looks like another opportunity has been taken to falsely bash Java with .Net

    --
    Programmers of the world unite, you have nothing to lose but your strings.
  52. Am I the only person who read the article? by Ninja+Programmer · · Score: 3, Informative

    First of all -- what's the deal with this whole "WARMUPS" thing? This is just the most explicit way possible of training the JIT mechanisms without measuring its overhead. That might be fine if you believe that the overhead asymptotically costs nothing, however, I don't know what evidence there is of this. The test should use other mechanisms other than this explicit mechanism to allow the language itself to demonstrate that the overhead is of low cost.

    The way this test is set up, the JIT people could spend hours or days optimizing the code without it showing up in the tests. This is the wrong approach and will do nothing other than to encourage the JIT developers to cheat in a way such as this just to try to win these benchmarks.

    Ok as to the specific tests:

    1. FloatInteger conversion on x86 are notoriously slow and CPU micro-architecturally dependent. It also depends on your rounding standard -- the C standard dictates a rounding mode that forces the x86s into their slowest mode. However using the new "Prescott New Instructions", Intel has found a way around this issue that should eventually show up in the Intel C/C++ compiler.

    This does not demonstrate anything about a language other than to ask the question of whether or not the overhead outside of the fi rises to the level of not overshadowing the slowness of the conversion itself.

    (That said, obviously Intel's compiler knows something here that the other guys don't -- notice how it *RAPES* the competition.)

    2. Integer to string conversion is just a question of the quality of the library implementation. A naive implement will just use divides in the inner loop, instead of one of the numerous "constant divide" tricks. Also, string to integer will use multiplies and still just be a limited to the quality of implementation as its most major factor determining performance.

    3. The Pi calculation via iteration has two integer->floating point conversions and a divide in the inner loop. Again, this will make it limited to CPU speed, not language speed.

    4. The Calculation of Pi via recursion is still dominated by the integer divide calculation. It will be CPU limited not language limited.

    5. The Sieve of Erastothenes (sp?) is a fair test. However, if SLOTS is initialized to millions, and the comparable C implementation uses true bits, instead of integers, then I think the C implementation should beat the pants off of C#, Java, or anything else.

    6. The string concatenation test, of course, is going to severely ding C for its pathetic string library implemenation (strcat, has an implicit strlen calculation in it, thus making it dramatically slower than it needs to be.) Using something like bstrlib would negate the advantage of C#, Java, or any other language.

    7. The string comparison with switch is a fair test, and gives each language the opportunity to use whatever high level "insight" that the compiler is capable of delivering on. It should be noted that a sufficiently powerful C compiler should be capable of killing its competition on this test, however, I don't believe any C compiler currently in existence is capable of demonstrating this for this case. I.e., this *could* be a legitimate case to demonstrate that C# or Java's high level abstractions give it an advantage over where the state of the art is in C compilers today.

    8. Of course the tokenization is another serious ding on the rather pathetic implementation of the C library. None of strtok, strspn, etc are up to the task of doing serious high performance string tokenization. If you use an alternative library (such as bstrlib or even just PCRE) you would find that C would be impossible to beat.

    -----

    Ok, while the results here are interesting, I don't think there were enough tests here to truly test the language, especially in more real world (and less laboratory-like) conditions. Please refer to The Great Win32 Computer Language Shootout for a more serious set of tests.

  53. C# is NOT what's being tested by ClubStew · · Score: 2, Insightful

    When are people going to learn that languages that target the Common Language Runtime (CLR, only part of the .NET Framework) compile to the same thing (Intermediate Language - IL)? C# is not being tested here. The C# compiler optionally optimized and compiles source code into IL which is later JIT'd and executed. Because of this, it's the CLR and the base class library (BCL) that are being tested.

    This could just as easily been done with VB.NET (not that I condone anything resembling VB) or J#, although MC++ is a different monster because it can (but doesn't have to) use native code in mixed mode and, thus, is not verifiable).

    The only differences besides language syntax is the specific language compiler and the optimizations it makes. The C# compiler does - as far as I've tested - a better job of optimizing. The VB.NET compiler, for instance, automatically adds an extra local var to support the syntax FunctionName = ReturnValue whether or not you use it!

    So, let's get the facts straight. C# is not being tested here. The .NET CLR and BCL are.

  54. Re:-1: Ill-Informed by rjh · · Score: 3, Interesting

    First, I'll ask you to please see my comments in the other response to you...

    Done.

    In fact, even his "brilliant" graph algorithms may have been top-class during his time.

    As far as I can see, remember, or am concerned, Dijkstra's contributions to computational graph theory are fundamental to the field. If you think they're brilliant-in-quotation-marks, all I can ask is what you've discovered that's comparable.

    That's not meant as an insult or a challenge, incidentally. It's meant to say that in hindsight many things become obvious which required real genius to see them in the first place. Dijkstra's graph algorithms are simple and straightforward, and in hindsight they're obvious--but let's not forget that the only reason they're obvious to us is because Dijkstra had the insight to see, in foresight, what's obvious in hindsight.

    If in your academic mind you truly believe this,

    You keep on calling me that, an "academic". The reality is I'm nothing of the sort except in the sense that I'm a graduate student. I'm a hacker, not an ivory-tower academic. I believe in solving problems and sharing those solutions with the world.

    It's axiomatic that if you're faced with a problem, one of the worst things you can do is stubbornly insist that it be solved with X technique. You have to show some flexibility. You have to be able to approach the problem from different angles. For GUIs, I've found object orientation is almost always best. For scientific programming, I've found template metaprogramming best. For using computers in math theory courses, I use LISP or ML. For writing system-level software, I use C++. Etcetera.

    My insistence on multiple paradigms is unequivocally not born out of "academia", a word which it seems you're using as an insult. My insistence on multiple paradigms is born out of my demand that I use the right tool for the job. .NET claims it will support all programming languages. It doesn't. It doesn't even come close. Once you realize .NET is just another VM that can be more easily targeted by compilers, you realize that "hey, this is ... really ... not all that interesting or useful," as I said in the post which kicked all this off.

    Why is it not all that interesting or useful? Because we already have that with Java. We've got a virtual machine which provides managed services and is targeted by over 60 different languages, all of which can use all the facilities of the other languages once their code has been reduced down to bytecodes. We've got a VM which allows you to interface with the native hardware to get a massive speed boost.

    Am I talking about .NET or am I talking about Java? In this case, Java. (I can't confirm the 60+ languages bit, but that's the number I see. Last I heard, Java supported more languages than .NET, but this gap was rapidly closing and the numbers are a couple of months old.)

    So where is .NET interesting? It was interesting the first time Sun did it with Java. (Or, for us dinosaurs, it was interesting the first time I saw UCSD Pascal do it with their VM.) It's not interesting this second time around.

    Where is .NET useful? If you're married to the Microsoft platform, then I guess it's useful. But really, where's the huge win for .NET over Java? There isn't one. It's an alternative to Java, not really something new and innovative, not something which allows you to solve more problems than Java or even allows you to solve them all that much differently.

    That said, is it useful for Company A, which prefers VB, and Company B, which uses Java, to be able to collaborate on software, each using their preferred language, with their results able to be executed on a shared VM?

    Sure it is. That's not what I mean when I say ".NET is neither useful nor intere

  55. Re:-1: Ill-Informed by rjh · · Score: 2, Interesting

    if you have some kind of auto-email thing turned on let me know, because I'm a relative /. newbie and have no idea how to set that up if it exists...

    Check your User Page.

    You'll see a dropdown box saying "Comment Reply". Select "Email", then save your changes and you're done.

    That said, I hope you enjoyed that act of friendliness, because I see nothing but disagreements in the near future. :)

    What I really wanted to point out was the fallacy of the "language worth learning" quote, in that it only uses "worth" in once sense of value, when in fact the majority of people in the world who deal with technology use a completely different set of criteria on which to place the "value" of learning a language - and this usually comes down to $ in the end.

    I'm utterly unconvinced that the software industry has any sensible valuation of worth, particularly in the management field. Paul Graham has a great essay on why this is--what it boils down to is management's knowledge of the field and languages is primarily imparted by marketing glossies and marketing departments (either Sun's or Microsoft's, it appears). Hackers' knowledge of the field is primarily imparted by catastrophic disasters.

    As an example of this, Java is being used in a lot of places today where it really shouldn't be. In 2000 during the height of the Java hype, a friend of mine who worked for a major United States bank was driven up the wall by a management decision to migrate all their COBOL apps to Java. "After all," Management said, "COBOL is a dead language and these are fifty-year-old legacy programs."

    To a hacker, COBOL may well be a dead language, but a program that has a fifty-year record of reliability basically swaggers around the RAID array menacing newer programs with <DenisLeary>"yeah, I may be written in COBOL, but I haven't crashed in fifty fucking years, guy, okay?"</DenisLeary>

    So was this major U.S. bank wise in their decision to migrate all their legacy COBOL apps to Java? By your logic, yes, because industry knows the value of software and can properly evaluate things in a dollars-and-cents manner. I'm certain there was a great business case made for this mass migration. I can't imagine what else could make a bank decide to undertake something that risky.

    And after about 150 man-years of work--optimistically, about $15 million of development--the program was abruptly cancelled due to the fabled dollars and cents failing to materialize.

    Wherever you look in the industry there are all sorts of examples like this. In the commercial software industry, I've seen far more projects fail than succeed. How does the industry respond to this? By declaring any software project that comes in at under 500% cost overrun and a year late to be a "qualified success".

    The thing is, we all know this. We've all read The Mythical Man-Month. Most of us--I imagine you do, I know I do--have horror stories about death marches and the Project That Would Not Die And Yet Never Truly Lived, Either.

    Given the spectacularly poor state of software management nowadays, I'm deeply skeptical of any claims that the software industry is in a position to make accurate estimations of value, whether that value be in a financial or a technical sense.

    I'm a hacker. I don't know about how to value software in a financial sense. (I'm heartened by the fact that nobody else does, either.) On the other hand, I do know how to value software in a technical and artistic sense. My estimations will differ from the next hacker's, but in general we can make certain agreements--that COBOL is crufty but COBOL legacy apps that run for fifty years rock, that LISP is woefully underused, that people keep on using C when they really want to be using something else, etc.

    if they had the same skillset level and also the same level of mathema