Slashdot Mirror


High-level Languages and Speed

nitsudima writes to tell us Informit's David Chisnall takes a look at the 'myth' of high-level languages versus speed and why it might not be entirely accurate. From the article: "When C was created, it was very fast because it was almost trivial to turn C code into equivalent machine code. But this was only a short-term benefit; in the 30 years since C was created, processors have changed a lot. The task of mapping C code to a modern microprocessor has gradually become increasingly difficult. Since a lot of legacy C code is still around, however, a huge amount of research effort (and money) has been applied to the problem, so we still can get good performance from the language."

777 comments

  1. Slashdot by Anonymous Coward · · Score: 0

    God, what has been happening? Can't OSTG afford a test server for Taco to mess around with?

    1. Re:Slashdot by jamie · · Score: 2, Informative

      We had to make a change to our 'comments' table schema that would have locked up the site if we had allowed full access. At over 15M rows, this takes some time. Sorry about that.

    2. Re:Slashdot by wish+bot · · Score: 1

      OK! Forgiven!

      --
      lemonade was a popular drink and it still is
    3. Re:Slashdot by Yvanhoe · · Score: 1

      That, and the URL format changed, so ancien links doesn't work anymore.
      "Older Article" link returns a 503 error.
      RSS links are not valid anymore.

      Should I make an entry in the bug tracker or is it obvious enough ?

      --
      The Wise adapts himself to the world. The Fool adapts the world to himself. Therefore, all progress depends on the Fool.
    4. Re:Slashdot by jawtheshark · · Score: 1

      I understand these kind of tasks are needed. No site goes without maintenance. Still, you could put a little notice on top of the page: "Commenting disabled: Site in Maintenance". The ideal position would be where the text "Have you meta moderated today?" appears.

      --
      Ahhh...the great dumpster continuum. Many a free computer will be found there. -- sowth (748135)
  2. Old debate by overshoot · · Score: 5, Informative
    Twenty years ago we were still in the midst of the "language wars" and this was a hot topic. The argument then, as now, was whether a high-level language could be compiled as efficiently as a low-level language like C [1].

    Well, we ran our own tests. We took a sizable chunk of supposedly well-written time-critical code that the gang had produced in what was later to become Microsoft C [2] and rewrote the same modules in Logitech Modula-2. The upshot was that the M2 code was measurably faster, smaller, and on examination better optimized. Apparently the C compiler was handicapped by essentially having to figure out what the programmer meant with a long string of low-level expressions.

    Extrapolations to today are left to the reader.

    [1] I used to comment that C is not a high-level language, which would induce elevated blood pressure in C programmers. After working them up, I'd bet beer money on it -- and then trot out K&R, which contains the exact quote, "C is not a high-level language."
    [2] MS originally relabled another company's C complier under license (I forget their name; they were an early object lesson.)

    --
    Lacking <sarcasm> tags, /. substitutes moderation as "Troll."
    1. Re:Old debate by StarvingSE · · Score: 4, Insightful

      C is not a low level language. If you're not directly manipulating the registers on the processor, you are not in a low level language (and forget about the "register" keyword, modern compilers just treat register variables in C/C++ as memory that needs to be optimized for speed).

      If anything, C is a so-called mid level language. If it wasn't, you'd be using an assembler instead of a compiler.

      --
      I got nothin'
    2. Re:Old debate by dpilot · · Score: 1, Insightful

      Ain't it great to know that Modula-2 - and essentially ALL of the strongly typed and structure languages - have pretty much died out. I did piles of stuff in M2, including reading and parsing legacy binary files, re-entrant interrupt handlers in DOS, etc.

      --
      The living have better things to do than to continue hating the dead.
    3. Re:Old debate by Anonymous Coward · · Score: 1, Informative

      "[2] MS originally relabled another company's C complier under license (I forget their name; they were an early object lesson.)"

      Lattice

      From a gray fox....

    4. Re:Old debate by StrawberryFrog · · Score: 2, Informative

      essentially ALL of the strongly typed and structure languages - have pretty much died out.

      Uh, Java and C# are strongly typed and structured languages.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    5. Re:Old debate by CapnOats.com · · Score: 3, Informative

      ...trot out K&R, which contains the exact quote, "C is not a high-level language."

      Actually the quote from my copy of K&R, on my desk beside me is,

      C is not a "very high level" language...

      emphasis is mine.

    6. Re:Old debate by Anonymous Coward · · Score: 0

      [2] MS originally relabled another company's C complier under license (I forget their name; they were an early object lesson.)

      I think this was Lattice C. Well, there are actually only a few products from Microsoft that have been developed by themselves from scratch...

    7. Re:Old debate by shreevatsa · · Score: 5, Informative

      For what it's worth, at The Computer Language Shootout, OCaml does pretty well. Of course, C is still faster for most things (but note that the really high factors (29 and 281) are in OCaml's favour!), but OCaml is pretty fast compared to Java or Perl. Haskell does pretty well too. Functional programming, anyone?
      Of course, these benchmarks measure only speed, are just for fun, and are "flawed", but they are still interesting to play with. If you haven't seen the site before, enjoy fiddling with things to try and get your favourite language on top :)

    8. Re:Old debate by 3waygeek · · Score: 1

      You sure it was Lattice and not Wizard? Or am I thinking of Borland?

    9. Re:Old debate by Anonymous Coward · · Score: 0

      >Or am I thinking of Borland?

      Nope, Borland is still alive (barely).

      I wish they'd got Borland; VS might have been a better product.

    10. Re:Old debate by Anonymous Coward · · Score: 1, Interesting

      Yes, the guy's main point is valid - an optimizer needs lots of semantic information, and putting that information into a language tends to make that language higher-level. But C++ has lots of this metadata now and it's still horribly low-level in use (lack of garbage collection makes sure of that). I spent a year prototyping a language myself which was just an extension to C with lots of metadata directed at the compiler. It was still a low-level language. So high vs low doesn't determine speed, some other aspect of language design, as yet unnamed, is responsible for how fast the program ends up. And of course, the lowest level language of all is your assembler and with the complete chip specs on one hand and a keyboard on the other (and plenty of time!) a programmer can always beat any compiler.

    11. Re:Old debate by cerberusss · · Score: 2, Informative
      It also says in the introduction (next page):
      C is a relatively "low level" language.

      --
      8 of 13 people found this answer helpful. Did you?
    12. Re:Old debate by bloodredsun · · Score: 4, Interesting

      If I had mod points I'd certainly mod you informative. Those benchmarks might be synthetic and flawed but as a general illustration of how the various languages differ, that link is fantastic.

      Of course I'll just use it for my own ends by convincing my managers that we're using the right languages - "Yes boss you'll see that we use C++ for the stuff that needs to be fast with low memory overhead, Java for the server side stuff, stay the fuck away from Ruby and if you say 'Web 2.0' at me one more time I'll be forced to wham you with a mallet!" ;-)

    13. Re:Old debate by masklinn · · Score: 2, Informative

      No they're not, they're statically typed but many languages exist with much stronger type systems (Ada, Modula2, Haskell).

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    14. Re:Old debate by dpilot · · Score: 1

      To be honest, I'm not terribly familiar with either. But from what I read, though Java is well entrenched, it seems to be approaching 'legacy' status, and is well-bashed these days. (The next remark will really open up a can of worms.) Compare Java with Cobol, in a strange sort of way.

      --
      The living have better things to do than to continue hating the dead.
    15. Re:Old debate by masklinn · · Score: 3, Interesting

      Haskell also does very well, and Digital Mars' impressive D is consistently in the top spots (one wonders why the hell Soustrup is still trying to improve C++ when he could just switch to D and build from there)

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    16. Re:Old debate by Anonymous Coward · · Score: 2, Interesting

      The O'Caml examples are not functional, they're imperative. The best-performing Haskell examples are also written imperatively.

    17. Re:Old debate by StarvingSE · · Score: 2, Insightful

      Key word is "relatively." C is low level compared to languages such as Java and C#, which do a lot of things such as memory management for you.

      --
      I got nothin'
    18. Re:Old debate by StarvingSE · · Score: 2, Interesting

      Java is hardly going the way of a legacy language. It is heavily used in the business world for web applications, which are becoming much more popular, not less.

      And although you call Cobol legacy, it really isn't. Many financial institutions still run applications written in cobol since it is too costly and risky to migrate the old code to a new language. Cobol was meant for the financial industry, and its probably there to stay. Colleges and universities are even starting to teach it again since it is in high demand in the job market right now (older cobol programmers are retiring).

      --
      I got nothin'
    19. Re:Old debate by Bastian · · Score: 5, Insightful

      The article addressed this point by mentioning that the definitions of high and low level language are a moving target. Nowadays I think most people consider assembly language to be its own thing, and the low-level classification has now been shifted into a domain that was once described completely by the term high-level. The term "high-level language" has been replaced by the term "programming language."

      If you're going to go with the jargon as it's most often used nowadays (which is a perfectly reasonable thing to do), then C would certainly be about as low as you can get without manipulating individual registers - i.e., without being assembly language.

    20. Re:Old debate by ArikTheRed · · Score: 1

      Uh, K&R is slightly older than Java or C#... there was no such thing as memory management or virtual machines (as we know them today) back then.

    21. Re:Old debate by Bastian · · Score: 2, Informative

      I'm pretty sure that over my C programming career I've managed (sometimes by accident, sometimes by misguided designs at creating a "clever hack") to cram data of every type into a bin that was reserved for every other type without the use of a cast. C is statically typed, but I wouldn't say it's strongly-typed at all.

    22. Re:Old debate by Anonymous Coward · · Score: 2, Informative
      And although you call Cobol legacy, it really isn't. Many financial institutions still run applications written in cobol since it is too costly and risky to migrate the old code to a new language.
      Errr, well if they're no longer running it, you can't debate if it's legacy, can you? The code would be gone. Not to be an English nazi or anything, but as a word, legacy just means it was handed down from a predecessor, usually a different generation. I've always assumed this meaning carried over to programming as well.
    23. Re:Old debate by overshoot · · Score: 1
      You sure it was Lattice and not Wizard?
      I'm very sure it was Lattice -- thank you, I'd forgotten their name.

      One of my favorite early examples of the consequences of being Microsoft's "special friend."

      --
      Lacking <sarcasm> tags, /. substitutes moderation as "Troll."
    24. Re:Old debate by plague3106 · · Score: 1

      I can't speak for Java, but C# and Vb.net are gaining in popularity pretty quickly. So much so that .Net is becoming the 'new' Win32 (that is, it will replace Win32, must like win32 and Win32s replaced the older system).

    25. Re:Old debate by Marcos+Eliziario · · Score: 3, Informative

      Not really. Modern pipelined architectures make hard-written assembler slower than compiler generated. A human can't really deal with out-of-order execution.

      --
      Your ad could be here!
    26. Re:Old debate by Megane · · Score: 2, Informative

      Uh, K&R is slightly older than Java or C#... there was no such thing as memory management or virtual machines (as we know them today) back then.

      Actually, there were virtual machines back then, just not on micros or minis.

      And as far as this high-level/low-level thing goes, I'd call C a "mid-level" language.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    27. Re:Old debate by jacksonj04 · · Score: 3, Insightful

      Low level says what you want the system to do. High level says what you want the language (Via compiler, interpreter etc) to make the system do.

      --
      How many people can read hex if only you and dead people can read hex?
    28. Re:Old debate by rainman_bc · · Score: 4, Interesting

      stay the fuck away from Ruby

      What's wrong with Ruby, as a replacement for a very ugly language called Perl?

      Ruby is an elegant language, fully Object Oriented, and does just as well as Python and Perl...

      Ruby On Rails OTOH is a different story and don't want to get into a flame war over it, but Ruby itself is pretty good for a lot of things you'd otherwise write in Perl but don't like the ugliness of Perl...

      I've found some people don't get the distinction between Ruby and Ruby on Rails.

      --
      09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
    29. Re:Old debate by Anonymous Coward · · Score: 0

      I like to rever to C as "Structured Assembly Code", and C++ "Object Oriented Assembly Code". The programmers I share this with seem to immediately understand and
      smile.

    30. Re:Old debate by Another_Luc · · Score: 1

      Microchip has designed their latest micros around their compiler ( I think it is based on gnu c).. While not done Do {Compile, look for ways to optimize cpu or compiler};

    31. Re:Old debate by dzfoo · · Score: 2, Informative

      >> Uh, K&R is slightly older than Java or C#... there was no such thing as memory management or virtual machines (as we know them today) back then.

      Didn't Infocom implemented their "database query system" (which eventually became their famous text-adventure game engine) using a virtual machine they called the Z-machine? As far as I know that system predated Java and C# by a few decades.

      http://en.wikipedia.org/wiki/Z-machine

              -dZ.

      --
      Carol vs. Ghost
      ...Can you save Christmas?
    32. Re:Old debate by StarvingSE · · Score: 1

      Not quite sure what you're getting at, but I'm pretty sure memory management was an important issue "back in the day" when C was created (memory was expensive back then, ya know).

      --
      I got nothin'
    33. Re:Old debate by masklinn · · Score: 2, Informative

      Yep C is very weakly typed (some could say that it's untyped, as is ASM) as only the compiler does some sanity check, and even then it doesn't work too hard at it.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    34. Re:Old debate by Anonymous Coward · · Score: 0

      Modula-2 was a teaching language: meant to teach students some vague concepts about programming that they would eventually have to un-learn when they entered The Real World and started using a proper language. One brought up on a "teaching language" might never discover that it is possible, desirable even sometimes, to be able to convert (say) an integer to a floating-point number; much less that integers, floating-point numbers, double-precision numbers, characters and any other datatype I missed out actually all share the same memory space. Originally, Pascal was a teaching language, too; but it accidentally got extended so it could be used for creating real-world applications. Matters came to a head when eventually, Pascal had reached the point where it became possible to assign an integer value to a floating-point variable without causing a fatal error. This so royally pissed off its inventor that he went on to create Modula-2, the intention being that it should only ever be capable of use as a teaching language.

      Real World programmers are still using BASIC {don't laugh: Windows and Office were written in BASIC and so is a lot of industrial software, where it's more important to get it working quickly than what the code looks like or whether it does what it's supposed to} and C; though there are a class of coders who think they are l33t because they understand Perl. Of course, there are still those who are not l33t enough to understand Perl, particularly its method to prevent one confusing the addition of numbers with the concatenation of strings. Where some languages insist that you somehow force things you want to add to be numeric before subjecting them to the + operator, Perl introduced a whole separate operator for concatenating strings, at the expense of dropping the - operator for deconcatenating strings {not that that was ever widely supported, and anyway you can use s/// to do the same job}. Perl is also self-ZIPping, since the number of bytes used to create a construct is inversely dependent upon how often it is used.

    35. Re:Old debate by masklinn · · Score: 1

      You probably won't be surprised by the fact that you're not the first one to compare Java and Cobol:

      It's next to impossible for java code to evolve gracefully because the language doesn't allow it. Welcome to the COBOL of the 21st century you little monkeys. At least you have your fancy IDEs that can do half the thinking for you. Now if only corporate could get rid of the monkeys all together and replace them with really smart IDEs.

      Ilsa

      Java is Diet Cobol

      Brian Foote
      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    36. Re:Old debate by NickFitz · · Score: 2, Interesting

      The statement "C is not a high level language" is not logically equivalent to the statement "C is a low level language", so the OP is still entitled to his beer money :-)

      --
      Using HTML in email is like putting sound effects on your phone calls. Just say <strong>no</strong>.
    37. Re:Old debate by StrawberryFrog · · Score: 1

      Nobody said that C was strongly typed. C# is a differnet matter.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    38. Re:Old debate by maximthemagnificent · · Score: 1

      Having coded an awful lot of time-critical assembly routines, I can say c is definitely not low-level! Mid-level
      probably describes it pretty well.

      Maxim

    39. Re:Old debate by exp(pi*sqrt(163)) · · Score: 2, Insightful

      Haskell does OK. But compare to Clean, another pure lazy functional language. Clean blows away Haskell most of the time and competes favourably with C, sometimes beating it.

      --
      Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
    40. Re:Old debate by I+Like+Pudding · · Score: 1

      Why the hate? RoR very effectively uses what the language has to offer: terse-yet-expressive, DSLs, dynamic as hell, metaprogramming.

    41. Re:Old debate by ArikTheRed · · Score: 1

      That's hardly a general purpose harware virtual machine (hence the "as we know them today" qualifier... do you read parentheticals?). Obviously the existance of ANY virtual machine is not new. The concept of general purpose hardware virtual machine's with built in memory management? Quite recent (early-mid 80's, see Smalltalk). But considering that K&R was written in the 70's, I fail to see how you've proven me wrong.

    42. Re:Old debate by Randolpho · · Score: 1

      Yeah, my first thought was "Ada is more strongly typed than C#? WTF??".

      C# still lets you get runtime invalid cast errors with object-typed collections like ArrayList, but C# 2.0 reduces this a bunch with generics. Even then, C# is still as strongly typed as Ada or Haskell. You get an invalid cast exception if you try to use an inappropriate type from an ArrayList, rather than invalid data or a memory access violation.

      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    43. Re:Old debate by Anonymous Coward · · Score: 0

      No wonder you are a starving SE. 'C' IS a low level language.

    44. Re:Old debate by networkBoy · · Score: 1

      OT

      Why is FR-4 the root of all evil?
      Without it signal quality would suck &&|| boards would cost literally 100x their current price and be far more fragile...
      -nB

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
    45. Re:Old debate by seasoned · · Score: 0

      Actually, I HAVE worked with PDP 11 Assembly!!!! The person that wrote that article OBVIOUSLY doesn't know C, Assembly, PDP 11, computers, etc..... C is NOT EVEN CLOSE to PDP 11 assembly! BASIC STUFF: C has concepts like a stack, heap, etc... Many of those have to be managed in assembly! C has sub routines! I forget if PDP 11 had macros, but even VAX 11 Macros don't come close to C! C has an INFINITE number of variables of ANY type! Assembly uses limited registers, and usually lacks types common in C. IN FACT, the microvax STILL lacked them! It used a library to EMULATE various types of real math operations. GRANTED, many processors today have FPUs, but even THEY must be programmed for. C IS a high level language. It has all the constructs and abilities of ANY language! With C++s extensions, it even has every facility JAVA does! K&R May be using things like the lack of low level language support for a string to argue it is low level. Then again, are you SURE that is what they meant? I still remember that the IBM PC had instructions for a setup dip that were WRONG FOR YEARS! Did they EVER correct it? But to call C a low level language, and eqate it to ASSEMBLY is JUST PLAIN WRONG! As for your comparison, most modula is COMPILED! ALSO, you YOURSELF admitted the program was CHANGED! HECK, for all we know you used matrices for some complex calculation, and blew C away by thus using optimized C low level routines to do what modula is so good at. COMPILE TIME Actually, C STILL compiles QUITE FAST! That really IS amazing when you consider that many now link BEHIND the scenes. So a 20 second compile may REALLY only be 5 seconds, with the rest of the time linking! Don't start comparing it with JAVA, VB, etc.... They do NOT TRULY compile! It is merely TOKENIZED! EXECUTION SPEED Java can NEVER be as fast as C over all! WHY? 1. Tokenized, so a parser WASTES TIME 2. Dynamic allocation, so the JVM wastes time 3. Garbage collection, so the CPU WASTES TIME! 4. Written mainly in C, and how can a handicapped C program be faster than a NON handicapped one? For simple data entry, or programs changing parameters to LOW LEVEL methods, Java runs FINE! You will see little difference. For more complicated things, FORGET IT! THAT is why so much java runs SLOW, and so many companies have decided to KEEP things in C, etc... PORTABILITY? One word can shut THESE people up! UNIX! CPU SPEED? FORGET IT! A faster cpu will speed up C also JVM CPU? FORGET IT! This WILL slow down C, and speed up Java, but the speed would be SLOWER than an IDENTICAL machine code processor. How such articles can be written is ASTOUNDING! Just the fact that the language, JVM, and many low level routines are written in C should put it to rest! Steve

    46. Re:Old debate by oofoe · · Score: 1

      If anything, C is a so-called mid level language. If it wasn't, you'd be using an assembler instead of a compiler. I don't know... Haven't people generally considered C to be kind of a cross platform assembler? That certainly seems to be the attitude of the Scheme crowd...

      --
      Curse you plastic mold maker!
    47. Re:Old debate by xenocide2 · · Score: 1

      And amazingly enough, systems are often written in C, with a bit of assembler when nothing else will do.

      --
      I Browse at +4 Flamebait

      Open Source Sysadmin

    48. Re:Old debate by fruity_pebbles · · Score: 1

      But then again... Twenty years ago I was working on a small project using Logitech Modula-2, part of which involved copying files. My file copying code was nothing fancy - allocate a large-ish buffer (large being 16KB or 32KB or something like that - this was on a 640KB MS-DOS box), read from the source file into the buffer, write the buffer to the destination file, repeat until done. When I ran the program the file copies seemed to be really slow, and after comparing the copying time using the Modula-2 program to copying from the DOS command prompt the file copying was indeed quite slow. For no good reason I fired up a low level debugger (SymDeb or Debug or something) and started digging into the compiled Modula-2 code. It turned out that the Logitech runtime library had helpfully "optimized" my "read 16KB into this buffer" call into a series of 512-byte reads and buffer copies.

    49. Re:Old debate by Panaflex · · Score: 0

      Java is Dead! Long live Java! God bless us all, and pass the Ammo!

      --
      I said no... but I missed and it came out yes.
    50. Re:Old debate by Anonymous Coward · · Score: 0

      The distinction between ruby and RoR? One performs terribly and the only performs on and off, adding layers of indirection and redundancy to web development tasks that are trivial without it. Ruby is a great language and it's a shame that the current runtime performs so poorly. RoR is just utter crud, and the hype is probably doing a huge disservice to a neat little language.

    51. Re:Old debate by spinkham · · Score: 1

      Really? According to the shootout, regular expressions are much faster on Ruby then C++ or java.
      Most of my web programming spends its time either in database lookup or regex processing, so ruby seems to not be such a bad fit...
      http://shootout.alioth.debian.org/gp4/benchmark.ph p?test=regexdna&lang=all

      --
      Blessed are the pessimists, for they have made backups.
    52. Re:Old debate by Anonymous Coward · · Score: 0

      I find it incredibly ironic that these benchmarks run the "fast" languages for lengths of time on the order of 0.5-1 second but give "slow" languages upto an hour to complete the same. Or to put it another way, for languages you would choose for throughput they measure instantaneous speed and for languages you would choose for covenience or ease of programming they measure throughput.

      I have found the benchmark maintainers incredibly unresponsive to corrections that might alter the results, such as for instance running the O(N) benchmarks for X time instead of N items. I mean seriously if you are going to write something that runs for 0.5 seconds in C or 1 seconds in Java then I'd say you're pretty much a retard for not writing it in Ruby or perl unless there's some awefully good reason not to.

    53. Re:Old debate by Anonymous Coward · · Score: 0

      MS relabeled latice C.

    54. Re:Old debate by Anonymous Coward · · Score: 0

      Okay, speaking of intelligent debate.

      A dealloc has a different purpose that a "garbage collection" delete. A dealloc is "real-time" in that it is returned to the available memory pool immediately and is available for reuse. The overhead of the return is "well" controlled since it is synchonized to the dealloc call. You take the overhead hit "now".

      In a garbage collection system the garbage collection is a background task, or in response to the out-of-memory condition. Usually, the garbage collection is done to completion, eating resources at the wrong time. But, it allows immediate return to the application on the delete.

      It all depends on when you wish to take the overhead.

      Both have there place. It is not that one is "superior" over the other. Both have there place in the correct application.

    55. Re:Old debate by Anonymous Coward · · Score: 0

      What are you talking about? He said he bet beer money that "C is not a high-level language," and then cited K&R saying the same thing. He didn't call C a "low-level language" at all.

      My own preference is to call it a "medium-level" or "fairly low level" language, meaning it has some abstraction and structured features, and some low-level features (bit-shifting, for example, can hardly be called a "high-level language" feature).

    56. Re:Old debate by fyngyrz · · Score: 2, Informative
      C would certainly be about as low as you can get without manipulating individual registers - i.e., without being assembly language.

      Actually, I think Forth is a little lower. The RPN nature of the language makes for a considerably closer mapping from language use to stack use for one thing, and for another, Forth atoms tend to be more primitive and more prefab than what a particular expression in C might produce.

      C remains my favorite for anything that requires speed. It has always seemed to me that when someone who understands what is going on at the machine level writes C code, they can make quite fast results as compared to someone who has learned C syntax, but doesn't have a sense of what is happening with stacks, LEAs, how a particular problem may map to float, fixed or integer approaches on top of a particular processor or chip set. C++ approaches appear overrated to me. If I want objects, I make them. If I want a *really* high level approach, I use Python.

      Basically, give me C or give me Python.

      --
      I've fallen off your lawn, and I can't get up.
    57. Re:Old debate by Bastian · · Score: 1

      In the words of some unnamed character in a famous Monty Python sketch, "This isn't an argument, this is just contradiction!"

      That's one definition of low/high level. It's pretty much the older one that I was talking about in my original post. The existence of that definition doesn't invalidate the new set of definitions.

      It's kind of annoying that the meanings of the words keep changing, but if you worry too much about that in a field that's as sloppy with its jargon as computer science, you'll go insane. At least the two different definitions of low/high level have more to do with each other than, say, the million different definitions of Model-View-Controller.

    58. Re:Old debate by fyngyrz · · Score: 1
      Real World programmers are still using BASIC {don't laugh: Windows and Office were written in BASIC

      No one is laughing. There may be some tears here and there, however.

      I can pretty much believe Office was written in BASIC, given the profound speed and reliability problems it is well known for. I'm going to have to call [prove it] on the Windows claim, though. Windows, for all its other faults, is pretty efficient. Not a hallmark of any BASIC product MS has ever been associated with that I am aware of, anyway.

      --
      I've fallen off your lawn, and I can't get up.
    59. Re:Old debate by MetaKey · · Score: 2, Insightful
      To fill out your item [2], the name of the company was Lattice. MS bought the Lattice compiler and renamed it MS C.

      It was an early example of the MS method of software development: buy out someone who has a viable product and do a much better job of marketing that product.

      I maintain that MS has never been much of a software development company but, rather, a software marketing company. Certainly, the vast majority of their "innovations" have been in marketing. MS tends to incrementally improve on other developers software while being very innovative in their marketing of that software.

      Lattice C was an early example. Excel is a mid-life example. A more recent example is the Groove Networks collaboration tool. MS recently bought them and will include the Groove in the next version of Office. They pretty much had to do this as Office is pretty stale. Who really needs a newer version of Word for example? And OpenOffice is coming along and is free. The only way to improve the Office product enough to warrent an upgrade was to add serious collaboration capabilities. And, this being MS we're talking about, the only way to do that was to go out and buy serious collaboration capabilities. Now they'll integrate it into Office and market the bejeezus out of it.

      I rest my case...

    60. Re:Old debate by NickFitz · · Score: 1
      1. Somebody says he made bets on the truth of the assertion "C is not a high level language".
      2. Respondent replies that "C is not a low level language".
      3. I respond to 2, pointing out that 1 never said anything that could logically be construed as "C is a low level language", meaning 2 is denying something that was not said.
      4. You post telling me that "He [meaning 1] didn't call C a 'low-level language' at all", which is just repeating what I have already said.

      What are you talking about?

      --
      Using HTML in email is like putting sound effects on your phone calls. Just say <strong>no</strong>.
    61. Re:Old debate by fyngyrz · · Score: 1
      According to the shootout, regular expressions are much faster on Ruby then C++ or java.

      Now compare Ruby against Python. :)

      --
      I've fallen off your lawn, and I can't get up.
    62. Re:Old debate by Julian+Morrison · · Score: 3, Interesting

      If you looked at the shootout you'd see what was wrong in Ruby: it's just about the slowest serious scripting language. It seems to be using pure bloody-minded interpretation without any bytecode or JIT stage.

      Nothing wrong with the language that a proper implementation couldn't cure, basically.

    63. Re:Old debate by Anonymous Coward · · Score: 2, Interesting

      Yeah, but Clean is endorsed by a small dutch company (whereas Haskell is promoted by several people with english-sounding names who can write research papers in perfect English) so nobody cares about Clean.

    64. Re:Old debate by dpilot · · Score: 1

      I'll just mutter something about the real world, Mars missions, explosions, English/metric, and not paying careful attention to data typing.

      I've coerced data in both Pascal and Modula-2. It's not that you aren't supposed to do it. You aren't supposed to do it without careful thought and clearly explicit coding that it's exactly what you meant to do, and not an accident.

      Perhaps Modula-2 was designed as a teaching language, but it also addressed shortcomings of the teaching language Pascal, in order that it could be a teaching language that was also useful. Nor do I buy your 'the intention being that it should only ever be capable of use as a teaching language,' line. How much real experience do you have designing and coding with Modula-2?

      Incidentally, after Modula-2, Wirth went on to do Oberon and Oberon-2, and followers of those ticked ME off. I was trying to read my old binary data, but couldn't find the type coercion capability. I asked about it on Usenet, and was told that I shouldn't be using that old data any more - I should get all that old stuff rewritten in Oberon-2, so that all of the data access would just work. Yeah, right! I suspect the 96,200 hits for oberon-2 vs 702,000 hits for modula-2 reflects this, as well.

      --
      The living have better things to do than to continue hating the dead.
    65. Re:Old debate by Bastian · · Score: 1

      Forth is a bit of a weird case. On one hand, it generally lacks things like types that you'd normally assume are a necessary part of a programming language, and, like you mentioned, it puts the programmer in charge of taking care of the stack, to the extent that function parameters don't exist in Forth.

      On the other hand, it has compiling words, which are somewhat similar to LISP macros and are a [i]very[/i] high-level kind of thing.

    66. Re:Old debate by Anonymous Coward · · Score: 1, Interesting

      You can manipulate individual registers in some compilers by using inline assembly. Furthermore, on many microcontrollers you can manipulate the registers inside the memory mapped peripherals in the C code. Many compilers provide facilities for writing interrupt handling functions in C as well.

      I argue that C is not a low-level language, but can provide low-level interraction with the hardware components (arguably C# with the .NET Framework 2.0 can do this too with the SerialPort class).

      The language is high-level and compiled into machine language unlike other high-level langauges that are compiled into byte-code and interpreted.

      I think a good border is:

      1) Low-level - Machine code that can be directly converted into assembly.
      2) High-level - Machine code that can be directly converted into assembly; however, there is no 1-1 mapping of it into the language it was originally written in (i.e. C, because different compilers will create different machine code for the same platform). What I aim to say is that it's not possible to figure out the exact C code from looking at the assembly.

    67. Re:Old debate by Doctor+Faustus · · Score: 1

      Functional programming, anyone?
      The problem with functional programming is that it's really only good for problems where you have a fixed set of input data and you aren't going to need any user input. Historically, that's been a pretty small problem area. Now, though, a lot of web programming fits that mold, so hopefully we'll see a bit more use of functional languages.

    68. Re:Old debate by msuarezalvarez · · Score: 1

      I guess by "imperatively" you mean in a monadic style, at least for Haskell. May I ask: so what?

    69. Re:Old debate by msuarezalvarez · · Score: 1
      The problem with functional programming is that it's really only good for problems where you have a fixed set of input data and you aren't going to need any user input.

      Huh? Where on earth do you get this impression from?

    70. Re:Old debate by dubl-u · · Score: 1

      But from what I read, though Java is well entrenched, it seems to be approaching 'legacy' status, and is well-bashed these days. (The next remark will really open up a can of worms.) Compare Java with Cobol, in a strange sort of way.

      No, there's no denying it, Java is the new COBOL. That's not to say it's as bad as COBOL; you can definitely do good work in it. But it is also the default language choice for people with more money than sense. Those businesses with a lot of money tend to hang around, and a lack of sense means not designing for long-term maintainability.

      Combine that, and hey presto! you have a lot of legacy code.

    71. Re:Old debate by Fahrenheit+450 · · Score: 1

      This is true (well the OCaml bit at least. I didn't look at the Haskell examples), but in one important sense, this is a big plus for languages like OCaml.
      See, one of the big problems with things like the Shootout is that the mini-benchmarks they use don't really tell you anything about larger program performance. And it is often here that functional constructs are said to shine through. So now one can write the overall program in a more functional style (yielding cleaner, more maintainable, and supposedly speedier code), yet still optimize certain core sections by transforming them into a more imperative style when needed.

      Of course, I've yet to see any real comparisons of larger programs like these, almost all of these language comparison sites seem to stick to under 100 line of code benchmarks.

      --
      -30-
    72. Re:Old debate by masklinn · · Score: 1

      Yeah, my first thought was "Ada is more strongly typed than C#? WTF??".

      Yes it is. I take it you've never coded in Ada (likewise for Haskell).

      And no, generics are not enough, Ada's or Haskell's type systems are still much stronger than C#'s.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    73. Re:Old debate by letxa2000 · · Score: 2, Insightful
      Haven't people generally considered C to be kind of a cross platform assembler? That certainly seems to be the attitude of the Scheme crowd...


      Anyone that considers C to be a "cross-platform assembler" probably has never worked in assembler, and almost definitely hasn't done so on more than one platform.

      'C' is only "low level" to those that don't get any closer to the hardware than, say, Visual Basic. Anyone that has programmed in assembly language will assure you that 'C' is quite high level. I'd be willing to accept "mid-level", but in reality once you've worked at the assembly level you will realize that there's very little difference between 'C' and Visual Basic. 'C' and VisualBasic are essentially both high-level languages; but 'C' just seems more intimidating than VisualBasic to the VisualBasic programmer. Those that call 'C' mid-level are probably VisualBasic programmers that think 'C' is intimidating so it clearly can't be a high-level language like VB.

      When you write a single line in 'C' and realize that that can correspond to hundreds of assembly language instructions, you realize that 'C' is very much a relatively high-level language. When you try to do floating point math on an 8-bit processor with no floating point instructions, you realize that 'C' is very much a high-level language. When you try to add three numbers and multiply it by a fourth, and you come from 'C', you realize that (1 + 2 + 3) * 4 is a heck of a lot more complicated than you imagined.

      The main difference between VB and 'C' is that VB gives you more self-contained packages to let you interact with today's GUI's. 'C' gave you printf which was fine for writing to a terminal. VB gives you all kinds of controls to let you do pretty GUI stuff. The concept is exactly the same, and both are high level.

      I say all of this having programmed in assembly language, then Basic, then QuickBasic, then 'C', then VisualBasic, and now almost exclusively 'C' and assembly language in truly embedded systems (embedded != Windows or Linux in a small form factor).

    74. Re:Old debate by Fahrenheit+450 · · Score: 1

      It seems to be using pure bloody-minded interpretation without any bytecode or JIT stage.

      As I understand it, that's precisely the case, with the interpreter working on the AST of the program.
      I also believe that the plan is to go with some form of bytecode/JIT solution in Ruby 2.0.

      --
      -30-
    75. Re:Old debate by The_Wilschon · · Score: 4, Informative

      Garbage collection, a form of memory management in widespread use today, was invented "around 1959" by John McCarthy as he discovered LISP. This predates K&R, first edition in 1978, by quite a bit.

      --
      SIGSEGV caught, terminating

      wait... not that kind of sig.
    76. Re:Old debate by aevans · · Score: 1

      No, it's stuff like "string literals and integers are objects" and continuations especially, that make it slow. Continuations are nice sugar, but they are death to efficiency. You could get 10x potential optimization by just having a variant datatype or just a function that you convert primitives to when needed. This could even be done behind the scenes.

    77. Re:Old debate by civilizedINTENSITY · · Score: 1

      So then what matters is whether new code is being written? Would this, by your definition, include maintence, or just new application development?

    78. Re:Old debate by overshoot · · Score: 1
      Microchip has designed their latest micros around their compiler ( I think it is based on gnu c).. While not done Do {Compile, look for ways to optimize cpu or compiler};
      Microchip's compiler is indeed based on gcc.

      As for "latest" there are several and you may be overstating the case.

      --
      Lacking <sarcasm> tags, /. substitutes moderation as "Troll."
    79. Re:Old debate by colmore · · Score: 1

      Ruby is still very young. The version in development will run on a bytecode VM, and there's an independant project in works to port the language to the .NET platform.

      Ruby's speed is a problem, but less so than you'd think. It is _very_ easy to write Ruby code for multiple machines. A lot of companies have found the developer time saved by going with Ruby (at the cost of $60,000 per developer per year + insurance & benefits) more than makes up for the cost of a a few extra $1000 boxes.

      --
      In Capitalist America, bank robs you!
    80. Re:Old debate by Anonymous Coward · · Score: 0

      The parent proposed this as an endorsement for functional programming. It is not functional programming. It is imperative programming. When the style is changed from an imperative style the performance of the equivalent O'Caml or Haskell program decreases. This is not complicated to understand.

    81. Re:Old debate by overshoot · · Score: 1
      To fill out your item [2], the name of the company was Lattice. MS bought the Lattice compiler and renamed it MS C. It was an early example of the MS method of software development: buy out someone who has a viable product and do a much better job of marketing that product.
      Except that MS didn't buy out Lattice. They had a marketing agreement where MS was allowed to relable "Lattice C" as "Microsoft C" and the result was that MS sales took over. When the agreement came up for renewal, MS pulled out their reimplementation and told Lattice thank you very much but we don't need you any more.

      Lattice lingered for a few years after that before vanishing, but they were never the company they had been.

      --
      Lacking <sarcasm> tags, /. substitutes moderation as "Troll."
    82. Re:Old debate by Emmet · · Score: 1
      MS originally relabled another company's C complier under license (I forget their name; they were an early object lesson.)
      Lattice C
    83. Re:Old debate by civilizedINTENSITY · · Score: 4, Informative
      Actually, there was, way before C (let alone Java or C#.)

      "Lisp is very old language, second only to Fortran in the family tree of high level languages." A Little history

      Whereas C (rather like Fortran) wanted to stay "close to the metal", Lisp wanted to transcend metal to get closer to the math. Hence, innante elegance :-)
      Towards the end of the initial period, it became clear that this combination of ideas made an elegant mathematical system as well as a practical programming language. Then mathematical neatness became a goal and led to pruning some features from the core of the language. This was partly motivated by esthetic reasons and partly by the belief that it would be easier to devise techniques for proving programs correct if the semantics were compact and without exceptions. The results of (Cartwright 1976) and (Cartwright and McCarthy 1978), which show that LISP programs can be interpreted as sentences and schemata of first order logic, provide new confirmation of the original intuition that logical neatness would pay off.
      It is true that Lisp ran inside an interpreter rather than a VM. Still, garbage collection is *old*, and memory management techniques from the 1950s/60s shouldn't be considered a new thing.

      Still waiting for the Visual.Lisp.Net, though :-) When UML and visual design paradims are finally swallowed by Lisp, oh what fun times we'll have! ;-)
    84. Re:Old debate by Serveert · · Score: 1

      I noticed that. I think we need more OCaml tools.. OCaml MVC, hibernate for OCaml, etc. I'll get right on that in my copious free time. ;)

      --
      2 years and no mod points. Join reddit. Because openness is good.
    85. Re:Old debate by Another_Luc · · Score: 1

      At theseminar I was at a couple of months ago, this applied for the PIC18s (wich have their own optimized C compiler), and the DSPIC/PIC24s. If there are newer ones, I had not heard of them as yet.

    86. Re:Old debate by Junks+Jerzey · · Score: 1

      The problem with functional programming is that it's really only good for problems where you have a fixed set of input data and you aren't going to need any user input.

      Wow, that's so completely...wrong. "Functional" doesn't mean "using mapping functions in the mathematical sense."

    87. Re:Old debate by msuarezalvarez · · Score: 1

      Using the monadic style to program in Haskell does not make it any less "functional". That is the *whole* point of the monadic style.

      It's not as if by using IO referential transparency is lost, is it?

    88. Re:Old debate by Rimbo · · Score: 1
      If you're not directly manipulating the registers on the processor, you are not in a low level language.


      Funny that you would mention that, as just last month I was directly manipulating several write-only and read-only registers on a processor in C.
    89. Re:Old debate by Breakfast+Pants · · Score: 1

      Why not just use C++ and only use very little beyond the C subset. Namespaces come to mind as something C is sorely missing.

      --

      --

      WHO ATE MY BREAKFAST PANTS?
    90. Re:Old debate by Doctor+Faustus · · Score: 1

      Asking for user input is a side effect.

    91. Re:Old debate by Randolpho · · Score: 1

      Cite, please. How do Ada and Haskell have stronger typing than C#? No Is it because of C#'s explicit keyword "unsafe"? No implicit conversions? What?

      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    92. Re:Old debate by stevesliva · · Score: 1
      Excel is a mid-life example.
      Excel? Certainly MS bought PowerPoint back in the day, but I thought Excel was created by MS as a 1-2-3 competitor. Microsoft may not be creating substantially new applications, but they are writing most of their own software. If they had grown more by acquisition, they would have far more than the North Dakota campus from the Great Plains Software acquistion and the Bay Area campus from the PowerPoint acquisition. The great majority of their developers are in Redmond. However, by not being able to discern which parts of Office were purchased, and which home-grown, you make a better case for MS being a top-notch software integration company than a marketing company. The same claim cannot be made for the software stack of most other serial software acquirers.
      --
      Who do you get to be an expert to tell you something's not obvious? The least insightful person you can find? -J Roberts
    93. Re:Old debate by slapout · · Score: 1

      Sure ya can:

      int main()
      {
          __asm{
                          mov eax, esp
                    }
      } :-)

      --
      Coder's Stone: The programming language quick ref for iPad
    94. Re:Old debate by stonecypher · · Score: 1

      Key word is "relatively." C is low level compared to languages such as Java and C#

      C is low-level compared to almost everything except assembly. Do remember please that when that quote was written in the 1970s, Java and C# would have seemed absurd and unrealistic.

      --
      StoneCypher is Full of BS
    95. Re:Old debate by Anonymous Coward · · Score: 0

      C has proper lexical scoping and several intrinsic namespaces which, combined, provide far more elbow room than is necessary for systems programming.

    96. Re:Old debate by thorongil · · Score: 1

      Do you really think that high-level programming is just C with GUIs? If so, you have a pretty limited understanding of that world. I'm not familiar with VB, but putting C in the same category as, say, Python or Scheme makes no more sense than viewing C as cross-platform assembler.

      I can understand thinking that C is high level after working with assembler. I can also understanding thinking that it is very low level after working with high level languages. Both viewpoints have some truth.

    97. Re:Old debate by stonecypher · · Score: 1

      What's wrong with Ruby, as a replacement for a very ugly language called Perl?

      What's wrong with a Gremlin as a replacement for a Yugo? What's wrong with rancid meat as a replacement for rotten meat? Or, since this is SlashDot, what's wrong with Mussolini as a replacement for Hitler?

      Just because there's something worse doesn't mean the thing one references is good.

      --
      StoneCypher is Full of BS
    98. Re:Old debate by Anonymous Coward · · Score: 0

      Yes as a matter of fact using I/O and depending on state violates referential transparency. The purpose of using a monad in such case is to isolate imperative programming. In the example of the IO monad it is the intention to disallow computations on values within the IO monad outside of IO. Thus relegating side-effects to a little compartment. Programs written in a heavily state-oriented manner are not functional, they are imperative. It is the case in these microbenchmarks that "object-oriented" and "functional" styles are eschewed for the more efficient imperative representations. In essence writing the same program in the same way with different syntax, exposing the strengths and weaknesses of the implementation at compiling/interpreting these simple imperative programs with whatever additional overhead that accompanies the language features used in such an implementation. The versions that utilize a more natural implementation style sacrifice performance and typically lose out to the dirtier versions.

    99. Re:Old debate by StarvingSE · · Score: 1

      Yes, perhaps saying Cobol is not a legacy language wasn't quite the right phrase to use. When I hear legacy, I think "hardware/software that is still supported, but is in the process of being replaced by something newer." I am probably wrong in my definition, its just what comes to my mind ;)

      --
      I got nothin'
    100. Re:Old debate by Anonymous Coward · · Score: 0

      Many financial institutions still run applications written in cobol since it is too costly and risky to migrate the old code to a new language.

      Isn't that the definition of legacy?

    101. Re:Old debate by Anonymous Coward · · Score: 0

      the mark-sweep and reference counting GC algorithms (used by Ruby and Python, for example) were both published in 1960.

    102. Re:Old debate by Anonymous Coward · · Score: 0

      Sorry, thought you were responding to OP! That'll teach me to reply in a rush...

      beers[3] = { "You", "Me", "OP" }; /* my shout */

    103. Re:Old debate by MyDixieWrecked · · Score: 1

      If you're going to go with the jargon as it's most often used nowadays (which is a perfectly reasonable thing to do), then C would certainly be about as low as you can get without manipulating individual registers - i.e., without being assembly language.

      it's all relative. C, for all intents and purposes, is a low-level language. Especially when compared with the vast majority of programming language in existence today. Sure, there are lower level languages (primarily assembly), but when you compare it to something like Python or even Objective-C, the difference is night and day.

      also, I don't think it'll be too long before even C++ is considered generally low-level. considering that you need to do your own garbage collection and memory allocation for statically typed variables, it's relatively low-level compared to PERL or Pike or python or ruby.

      for some odd reason, I'm having a very hard time thinking up a non-C based language that's compiled to an actual binary and not interpretted or run by a virtualmachine...

      --



      ...spike
      Ewwwwww, coconut...
    104. Re:Old debate by MyDixieWrecked · · Score: 1

      Ruby is an elegant language, fully Object Oriented, and does just as well as Python and Perl...

      and you've neglected to mention that ruby programming "fits the brain well."

      --



      ...spike
      Ewwwwww, coconut...
    105. Re:Old debate by CapnOats.com · · Score: 1

      Sorry, my point was more along the lines that if you are trying to be a smart-ass, try to be a correct smart-ass.
      Nothing hurts like the shame of having someone call you up on something when you were being a dick to them to begin with. Misquoting K&R to a C Programmer is like misquoting The Bible to a Priest.

      http://www.google.com/search?q=define%3A+exact
      Definitions of exact on the Web: ...
      accurate: (of ideas, images, representations, expressions) characterized by perfect conformity to fact or truth ; strictly correct; "a precise image"; "a precise measurement"

    106. Re:Old debate by Lars+T. · · Score: 1
      If C were a low-level language, it had data-types like Byte, Word etc.

      If C were a high-level language, it wouldn't have "signed chars".

      --

      Lars T.

      To the guy who modded me down from perfect to terrible Karma - Apple haters still suck

    107. Re:Old debate by Kymermosst · · Score: 1

      So, why does implementing something in Java mean that it is not maintainable in the long term? (Yes, you didn't directly say that, but you sure as hell implied it).

      What do you suggest in its stead? C#? Or some quasi-functional* language that was designed for doing math and not implementing large applications?

      Actually, what languages do you think lead to better maintainability?

      * There are very few pure functional programming languages out there.

      --
      "Alcohol, Tobacco, Firearms, and Explosives" should be a convenience store, not a government agency.
    108. Re:Old debate by Julian+Morrison · · Score: 2, Insightful

      Nah, that's nonsense. Python has string objects, Scheme has continuations. Ruby's still slower.

      First-class reentrant continuations and dynamic typing (another major efficiency hog) probably constrain you to, in the best case, the same box as compiled Scheme - about the same as Java.

    109. Re:Old debate by heson · · Score: 1

      Thats pretty similar to the definition I use "Some old crap we still have to run since we havn't got the resources to port it."

    110. Re:Old debate by Anonymous Coward · · Score: 0

      I'd be more impressed with that link if I wasn't able to divide the execution time for a random java program by more than 2 (spectralnorm, for what it's worth) by moving one allocation, removing a redundant initialization and removing that -server. This, incidentally, would put java right at the top spot, better then Intel's FORTRAM.

      Those benchmarks don't measure speed, they measure the skill in a language of the guys who wrote them.. Or their impartiality.

      The simple fact that they have that -server switch for java in the first place - which increases startup time by compiling more stuff upfront - when a program is supposed to last a few seconds speaks volume about the whole thing.

      Oh, yeah... diff:
      31d31
                                    for (int i=0; i MultiplyAtAv(n,u,v);
      > MultiplyAtAv(n,v,u);

      73c74,75
                    private final void MultiplyAtAv(int n, double[] v, double[] AtAv){
      > double[] u = new double[n];

    111. Re:Old debate by Lars+T. · · Score: 1

      But it came after the p-System.

      --

      Lars T.

      To the guy who modded me down from perfect to terrible Karma - Apple haters still suck

    112. Re:Old debate by Anonymous Coward · · Score: 0
      For instance, I suck at SlasHTML :-)

      The diff again:
      31d31
      < double[] w = new double[n];
      32a33
      > for (int i=0; i<n; i++) v[i] = 0;
      35,36c36,37
      < MultiplyAtAv(n,w,u,v);
      < MultiplyAtAv(n,w,v,u);
      ---
      > MultiplyAtAv(n,u,v);
      > MultiplyAtAv(n,v,u);
      73c74,75
      < private final void MultiplyAtAv(int n, double u[], double[] v, double[] AtAv){
      ---
      > private final void MultiplyAtAv(int n, double[] v, double[] AtAv){
      > double[] u = new double[n];
    113. Re:Old debate by Vellmont · · Score: 1


      Didn't Infocom implemented their "database query system" (which eventually became their famous text-adventure game engine) using a virtual machine they called the Z-machine? As far as I know that system predated Java and C# by a few decades

      While I'm sure Infocom invented an interpreted language to create text adventure games, I wouldn't put this in the same class as Java or C#. How is this any different from creating the bash shell that interprets bash scripts?

      --
      AccountKiller
    114. Re:Old debate by Dr.+Zowie · · Score: 3, Interesting

      There are two main problems with Ruby as a replacement for "a very ugly language called Perl":

      * It's not sufficiently prettier than Perl

      * It's not Perl

      Perl may look ugly but it is to most programming languages as English is to most other languages. Perl is a brawling, sprawling mess of borrowed, Hamming-optimized idioms that is extremely ugly from the POV of a syntax engineer and extremely expressive from the POV of a fluent speaker.

      Ruby is more like Esperanto - elegant, clean, and spoken by practically no-one because it isn't very expressive.

    115. Re:Old debate by masklinn · · Score: 2, Interesting

      How about the fact that you can't use an integer as an array index in Ada and you have to use natural numbers (defined as a positive or null integer), because array indexes can't be negative (in most languages anyway, some -- like Python -- are exceptions to this quite common rule) and you therefore shouldn't be allowed to use a number that might ever be negative as an index. C# merely gives you a warning if your index is explicit (e.g., myArray[-1]) and doesn't do anything otherwise, before throwing an IndexOutOfRangeException at runtime.

      That's one measly example, but I find it quite interresting.

      So no, C#'s unsafe keyword isn't a factor (and the lack of implicit conversion clearly isn't, if anything implicit conversion is the sure sign of quirky and unsafe type systems).

      When people say that an Ada program that compiles will usually work without problem, they're not joking, Ada's type system is so extensive and so strong that it misses very few errors (that it could handle, that is, flaws in your own logic can't be patched by a compiler).

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    116. Re:Old debate by msuarezalvarez · · Score: 1

      The IO monad does not break referential transparency.

    117. Re:Old debate by msuarezalvarez · · Score: 1

      I am sorry, I do not have the energy to explain this.

      You would probably benefit from reading an explanation of what the monadic style is, for example.

    118. Re:Old debate by Anonymous Coward · · Score: 0

      Feel free to submit it, they accept better programs.

    119. Re:Old debate by Anonymous Coward · · Score: 0

      I/O is not referentially transparent. Period. The IO monad exists to compartmentalize non-functional code. Referential transparency of functions is preserved by not permitting values to be extracted from the IO monad. All code that performs IO must be in the IO monad. Code inside of the IO monad is not referentially-transparent. You seriously have no idea what you're talking about.

    120. Re:Old debate by nolsen · · Score: 1

      Nice links, thanks.

    121. Re:Old debate by chromatic · · Score: 1
      Ruby is still very young.

      The first public release of Ruby predates the first public release of Java.

    122. Re:Old debate by cerberusss · · Score: 1

      Sorry, my point was more along the lines that if you are trying to be a smart-ass, try to be a correct smart-ass.

      And right you are! Me too, actually. I actually found it interesting that there were two statements about this in K&R. The misquoting analogy made me rolling on the floor...

      --
      8 of 13 people found this answer helpful. Did you?
    123. Re:Old debate by lewp · · Score: 3, Funny
      Do remember please that when that quote was written in the 1970s, Java and C# would have seemed absurd and unrealistic.

      Some things never change.

      --
      Game... blouses.
    124. Re:Old debate by msuarezalvarez · · Score: 1

      Can you please show me a little Haskell program in which referential transparency is broken?

    125. Re:Old debate by pthisis · · Score: 1

      And stackless Python has string objects _and_ continuations.

      --
      rage, rage against the dying of the light
    126. Re:Old debate by Anonymous Coward · · Score: 0
      My new sig. Look for it soon.

      "I know those benchmarks are flawed, but I like what they say so I'll repeat them anyway." - booldredson

    127. Re:Old debate by Kazoo+the+Clown · · Score: 1

      The upshot was that the M2 code was measurably faster, smaller, and on examination better optimized.

      Optimized for speed, or space?

      I'd like to know more about what the problem was, how the M2 solved it, how the C coders solved it, etc., before deciding what such a test supposedly means. At the very least it might teach some C coders some better techniques.

      C is a relatively low-level language, and that is its advantage, IMHO. However, it is harder to code in a lower level language, requires more experience and knowledge of the compiler and the hardware. It's the next best thing to a good macro assembler and enough time to work on it. :-)

      On the other hand, it is true that modern processors have capabilities that most programmers are unaware and do not understand the effects it and their compiler will have on their coding constructs. This was not true originally, when many programmers were familiar with the machine language of the processor they were coding for, even when writing in C.

      When "hello world" in a modern language produces a binary that is tens or hundreds of K in size however, I can't help thinking that "optimization" has come to mean "optimized to waste memory and CPU time so that dealers can sell processor and memory upgrades."

      As a sanity check on the "new high-level languages are better" concept, pick a recent highly rated demo from http://scene.org/ and recode it in your favorite new language-- then compare the size & performance and see how things fare. When your language consistently comes out ahead then I'll likely agree...

    128. Re:Old debate by pthisis · · Score: 1

      1. You'll wind up fighting the compiler figuring out how to turn off exceptions, rtti, etc
      2. You don't gain much over lexical scoping.
      3. C is not a subset of C++ (even forgetting trivialities like variables named "new", etc). You won't be able to re-use existing C code without strictly auditing it because of subtle difference (e.g. on 32-bit Intel, sizeof('a') is 4 in C but it's 1 in C++). Those differences are often of the "it compiles fine but behaves differently" type, which really sucks.
      4. You get saddled with C++'s crappy stricter typing. When your type system is crap, making it stricter hurts rather than helps.

      --
      rage, rage against the dying of the light
    129. Re:Old debate by Anonymous Coward · · Score: 0
      "This isn't an argument, this is just contradiction!"

      No it isn't.

      oh lord what have I started now?

    130. Re:Old debate by BritneySP2 · · Score: 1
      type system is crap

      Would you care to elaborate a bit?

    131. Re:Old debate by Anonymous Coward · · Score: 0

      But note that many of the programmers favor those languages and the benchmark-makers themselves favor those languages.

      I can take any benchmark on that site and put C or C++ on top if I ignore the rules about solving the problem the same way. That is, for any given problem listed on that site I can do it the fastest in C. Without exception... (ignoring assembly language of course)

    132. Re:Old debate by funfail · · Score: 1

      Let's not forget that Java is backed by industry leaders, and aimed at enterprise world. Ruby was a hobby language until the last few years.

    133. Re:Old debate by StrawberryFrog · · Score: 1

      As the original article notes, high-level languages have a lot more metadata avialable. there are good tools for Java and c# (the c# one is called fxCop, I don't know what the java one is called) that can inspect your bytecode and report a wide variety of errors of this kind.

      IMHO, having done a fair bit of Pascal/Delphi, I find C#s enums to be a leaky abstraction - you can't quite forget that they're really ints.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    134. Re:Old debate by dubl-u · · Score: 1

      So, why does implementing something in Java mean that it is not maintainable in the long term? (Yes, you didn't directly say that, but you sure as hell implied it).

      No, you inferred it. Incorrectly, I should add. Note that I said "You can definitely do good work in it." To me, maintainability is part of doing work. I take it you feel otherwise?

      Actually, what languages do you think lead to better maintainability?

      I don't think languages really matter much for maintainability; it's mainly the people and their behaviors. That's why I said, "a lack of sense means not designing for long-term maintainability."

      At a guess, I'd say that maybe 5% of maintainability is language choice. And in that 5%, Java does ok. Java 1.5 was a step up, but they could go a lot further.

    135. Re:Old debate by pthisis · · Score: 1

      The most common example has to do with void pointers:

      int *a;
      a = malloc(sizeof(int)*10);

      vs.
      a = (int *) malloc(sizeof(int)*10);

      C++ requires the latter, which does nothing but make the code more brittle in the face of change. void * is supposed to convert implicitly to other types, that is its entire reason for its existence. Code gets more fragile when you have to sprinkle references to an object's type all over the place instead of having some minimal (bare-bones, craptastic) polymorphism.

      The core problem is that both the C and C++ type systems are jokes. But C++ got stricter without fixes the system itself, so you wind up having to put additional cruft in your code to no positive end.

      --
      rage, rage against the dying of the light
    136. Re:Old debate by lgw · · Score: 1

      This is the first valid criticism of C++ vs C I've ever seen. Most complaints about C++ are "it's not what I'm used to" from C programmers, but this is just a fundamental design flaw in C++.

      From my experiance, the huge advantage of C++ over C in systems programming is the ability to use object destructors for clean-up of resources. But, of course, taking advantage of that requires a different coding style than most C programmers use, so it's no advantage at all if you're "writing C with a C++ compiler".

      --
      Socialism: a lie told by totalitarians and believed by fools.
    137. Re:Old debate by BritneySP2 · · Score: 1

      Well, all I can say is that C++ is (so much) more than just a "stricter" C.

    138. Re:Old debate by jgrahn · · Score: 2, Insightful
      This is the first valid criticism of C++ vs C I've ever seen. Most complaints about C++ are "it's not what I'm used to" from C programmers, but this is just a fundamental design flaw in C++.

      What fundamental design flaw -- that malloc() is less convenient to use in C++? For crying out loud, use new!

      Ok, void pointers are less useful in C++ than in C. In my experience, that has been a non-problem. But then I've never tried to program in C with a C++ compiler -- I have enough problems without creating artificial ones.

    139. Re:Old debate by pthisis · · Score: 2, Informative

      Well, all I can say is that C++ is (so much) more than just a "stricter" C.

      While I agree with your core point, I have to take exception to the implication that C++ is at all a stricter C (even if it's also more). C++ and C are different languages, and C is not a subset of C++. There are valid C programs that are invalid in C++ (even not using things like variables named "new", etc), and features like implicit void casting that C++ lacks. There are programs that are valid C and valid C++ but behave differently.

      And that's without getting into features of modern C (variable size arrays, language built-in complex numbers, restricted pointers, etc) that are not in C++ as far as I know.

      But as far as your main point, yes, the reason to use C++ is if you want/need C++ features. My original objection was to the suggestion that you just "write C but use a C++ compiler to add namespaces and nothing else". Many of the drawbacks of C++ compared to C are pretty minor, and may be worth the tradeoff if you're going to take advantage of a lot of language features. Writing "C in C++" is just silly, though.

      --
      rage, rage against the dying of the light
    140. Re:Old debate by jgrahn · · Score: 1
      Yep C is very weakly typed (some could say that it's untyped, as is ASM) as only the compiler does some sanity check, and even then it doesn't work too hard at it.

      Huh? What kind of static type checking cannot be described as "only the compiler does some sanity check"? Are there languages where extraterrestrials, Jehovah, or the NSA, or whoever, helps the compiler?

      I think you need to learn about type systems in various languages. Alternatively, you could just say "I think C sucks".

    141. Re:Old debate by hyc · · Score: 1

      OOO has nothing to do with that; the processor still has to provide the appearance of in-order execution. A sufficiently skilled and fanatical human can hand-write assembler that executes faster than any compiler. It's just a tradeoff of human productivity, there's probably better things to do with that human's time.

      --
      -- *My* journal is more interesting than *yours*...
    142. Re:Old debate by lgw · · Score: 1

      It's not just malloc, there are several places where Stroustrup's attempt to tighten up the type system are painful. His goal of making it easier for the compiler to understand the coder's intention was laudable, but the implementation sucks. Don't even get me started on reinterpret_cast(), confusing_cast(), bullshit_cast(), etc.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    143. Re:Old debate by Dolda2000 · · Score: 1
      I'd argue against that. Once you have a parse tree of a C program, you can more or less just output a fixed chunk of assembly for each construct. It isn't entirely true, of course, since the compiler handles things such as register allocation, but when everything comes around, a non-optimizing C compiler isn't much more than a preprocessor for the assembler. It's just a convenient way of writing assembler. Don't get me wrong, though -- I love C just for that reason.

      Compare that to actual high-level languages like Haskell or Prolog, where you really need to create an abstract representation of the concepts in the program and examine their interactions with one another in order to even begin to compile it. Or, just look at languages like LISP or Python, which normally aren't compiled since it is much easier to just write a VM than a compiler which would really be able to handle every edge case. These languages aren't just convenient forms of assembler -- they are defined at a "higher level", isolated from the actual instruction set of whatever computer they run on.

    144. Re:Old debate by BritneySP2 · · Score: 0, Offtopic

      I'd mod you up if I hadn't lost my mod points yesterday.

    145. Re:Old debate by Amazing+Quantum+Man · · Score: 1

      Re [2]: I believe it was Lattice C.

      --
      Fascism starts when the efficiency of the government becomes more important than the rights of the people.
    146. Re:Old debate by Randolpho · · Score: 1
      Er... I don't know what Ada you've been writing, but Ada definitely lets you define arrays with negative indexers, although it's admittedly frowned upon. Observe:
      type negatively_indexed is array(-100..100) of Double;
      Additionally, C# allows for types that are indexed by negative numbers, just like Ada and Python, although the default C# array is not negatively indexed. You can even build types that are indexed by non-integral types in C#.

      Regardless of the outright wrongness of your example, it is not an example of type saftey at all. It's an example of bounds-checking -- one the "logic errors" that you say Ada can't catch -- at least not without a crystal ball.

      Regarding implicit conversions -- yes, C# allows implicit conversions, but only where the conversion does not result in a loss of data or type. So you can implicitly convert from an integer to a long, since you don't lose data, but if you want to convert from a signed integer to an unsigned integer, you must do so explicitly, as you'd lose the sign bit. Ditto polymorphic types; you can implicitly cast "downward" in the class hierarchy (i.e. casting from string to object), but to cast up you have to do so explicitly. This is not considered type unsafe by most CS scholars these days, but it is an admittedly contentious point.

      So.... ignoring the implicit conversion issue, which in C# is one of those "agree to disagree" issues, I again ask: "How is Ada (or Haskell) more typesafe than C#?"
      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    147. Re:Old debate by Kymermosst · · Score: 1

      No, you inferred it. Incorrectly, I should add. Note that I said "You can definitely do good work in it." To me, maintainability is part of doing work. I take it you feel otherwise?

      No, I agree. And I stand corrected on your comment. I reread it and understand what you're getting at.

      I don't think languages really matter much for maintainability; it's mainly the people and their behaviors. That's why I said, "a lack of sense means not designing for long-term maintainability.

      I disagree. While you can write unmaintainable code in any language, I think some make it a lot easier to write unmaintainable code than others. There's a reason my employer switched from Perl/CGI to J2EE for a lot of critical systems.

      As a 2nd-place winner of The Perl Journal's 4th Annual Obfuscated Perl contest, I can definitely tell you it's far easier to write unmaintainable code in Perl!

      --
      "Alcohol, Tobacco, Firearms, and Explosives" should be a convenience store, not a government agency.
    148. Re:Old debate by cervo · · Score: 1

      What surprised me the most about the shootout is the comparison between Python and Perl. I consider Perl the scripting language benchmark to beat and Python does seem to present a fair alternative to Perl performancewise.

    149. Re:Old debate by Anonymous Coward · · Score: 0

      Ruby, not very expressive ? Now, that's funny. That's one of the most expressive language I know, and I think I know all the famous "industrial" ones, except Fortran.

    150. Re:Old debate by Pseudonym · · Score: 1
      a = (int *) malloc(sizeof(int)*10);

      malloc is deprecated in C++. The strict C++ equivalent is:

      int* a = new int[10];

      But a good programmer would be more likely to write:

      vector<int> a(10);
      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    151. Re:Old debate by chthonicdaemon · · Score: 2, Informative

      Automated memory mgmt via garbage collection has been a feature of Lisp and many other languages since the early 1960s http://www-128.ibm.com/developerworks/library/j-jt p10283/

      --
      Languages aren't inherently fast -- implementations are efficient
    152. Re:Old debate by Pseudonym · · Score: 1
      And that's without getting into features of modern C (variable size arrays, language built-in complex numbers, restricted pointers, etc) that are not in C++ as far as I know.

      Apart from restricted pointers, all of these (or work-alikes) are in C++.

      C++ has std::vector, which is more useful for most applications than C's variable size arrays. There's some trickiness here because of the issue of calling the destructors of array elements when the array goes out of scope. Nevertheless, variable size arrays will most likely be in the next C++ standard.

      Most C++ compilers ship with complex number libraries. For those that don't, Boost has one along with quaternions and octonions. (I have to ask, though: What proportion of programs need complex numbers that it should be built into the language?)

      C++ doesn't have restricted pointers, but it comes close in one respect: Because C++ is more type-safe, the compiler is allowed to assume that pointers with different types don't alias. This does rule out certain types of potentially unsafe (though powerful if it's what you want) pointer hackery. (Yes, this happened to me once. I had a block of memory that I was using as an array of pointers that I knew was junk, and wanted to reuse it as a temporary array of pointer-sized integers. I had to jump through some hoops to convince the compiler.)

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    153. Re:Old debate by Anonymous Coward · · Score: 0

      If anything, C is a so-called mid level language.

      Ah, C, I remember it fondly. C had all the power of assembly language, with all the ease-of-use and friendliness of assembly language.

    154. Re:Old debate by UnknownSoldier · · Score: 1

      I really love C++, but for some things, it really sucks. // 1. Cant' overload funcs with different array lengths, and/or pointers
      void foo( int a3 [3] );
      void foo( int a4 [ 4 ] );
      void foo( int * p ); // 2. no native / built in null type // can't tell the difference between null pointer and int
      void foo( int n );
      void foo( char * p );

      vood bar()
      {
            foo( NULL );
      }

    155. Re:Old debate by Tim+Browse · · Score: 1

      Ok, void pointers are less useful in C++ than in C. In my experience, that has been a non-problem.

      Agreed, and furthermore, to quote Dale Rogerson:

      "The evil void pointer strikes again, hiding types from our friend, the compiler."
    156. Re:Old debate by Anonymous Coward · · Score: 0

      Didn't Infocom implemented their "database query system" (which eventually became their famous text-adventure game engine) using a virtual machine they called the Z-machine? As far as I know that system predated Java and C# by a few decades.

      True, true, but as a programming language it was hideously difficult; after all, all the profiler/debugger would tell you was, "You are about to be eaten by a grue."

    157. Re:Old debate by chthon · · Score: 1

      almost all of these language comparison sites seem to stick to under 100 line of code benchmarks

      I have been busy doing comparative benchmarking between languages, and it is much work to write benchmarks a) which do the same and b) which are then optimised for each language.

      All of my benchmarks are currently less than 50 lines.

      I would like to have something longer, but then I need to have a problem which can be easily designed, and should be, let's say, between 100 and 500 lines.

      After that the applications should be written in each language to benchmark, together with scripts for building and running automatically, and to extract meaningful data from them.

      So, much more work than one would probably think.

    158. Re:Old debate by angel'o'sphere · · Score: 1

      Anyone that considers C to be a "cross-platform assembler" probably has never worked in assembler, and almost definitely hasn't done so on more than one platform.

      C is aportable assembly language. Its designed to be that. by James Colien, citating Brian Kernighan, co inventor of C, in a lecture he gave in Karlsruhe, germany at the FZI (research center for computer science/informatics).

      C, is very very low level! Most macro assemblers can do more than C can (in terms of defining "functions" and "structs"). The only thing that is more or less "abstraced away" are registers.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    159. Re:Old debate by pthisis · · Score: 1

      Apart from restricted pointers, all of these (or work-alikes) are in C++.

      [SNIP next three paragraphs saying that none of them are actually in C++ but other features can do the same thing]

      Obviously being a Turing-complete language C++ can do anything C can. The point is that it is not a superset of C, and you can't just use a C++ compiler to compile your C code.

      Use a C++ compiler for C++. Use a C compiler for C. And always remember that C++ is not an "extended C", nor is C a subset of C++. They are seperate (albeit related) languages).

      --
      rage, rage against the dying of the light
    160. Re:Old debate by angel'o'sphere · · Score: 1

      Regardless of the outright wrongness of your example, it is not an example of type saftey at all. It's an example of bounds-checking -- one the "logic errors" that you say Ada can't catch -- at least not without a crystal ball.

      Did you read his example? Obviously ...
      Did you understand it? Nope!

      C#:
      A = array[-1]; // compiles, but gives a runtime error

      Ada:
      A = array[-1]; // does not compile

      In both languages you can use language features to allow negative indices, which will compile AND run AND even be correct.

      Nevertheless you very EASYLY can shot the C# type system to shredds, but you CAN'T do that with Ada, the compiler will find ALL bugs(erm, errors) that are related to type issues. BEFORE running it and getting runtime errors.

      In Ada you define a type for the index, and you define an array type for the array using that index ... Thats called making a specification. In C# you only overwrite the index operator, and your implementation of that operator still may have errors. If your usage of that implementation is still wrong, the compiler can't even detect that, but in Ada the compiler can.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    161. Re:Old debate by cyborg_zx · · Score: 1

      When "hello world" in a modern language produces a binary that is tens or hundreds of K in size however, I can't help thinking that "optimization" has come to mean "optimized to waste memory and CPU time so that dealers can sell processor and memory upgrades."

      Which modern language? A Java class file for a "hello world" program would be a few bytes. The only time I can think this would occur is when an executable is created that includes all the code for the static libraries used by the program. That's not the fault of the language per se, maybe just the compiler or the OS environment (Windows having the history it does has never done anything to really encourage programs to use standard shared libraries for these sorts of things whereas this is far more the norm on Linux systems).

      I mean you can't possibly be suggesting that the actual business logic for "hello world" is being expanded to a few hundred Kb right?

    162. Re:Old debate by Anonymous Coward · · Score: 0

      I'm curious as to if anyone actually looked at the code being used too - synthetic and flawed indeed... :(

    163. Re:Old debate by LQ · · Score: 1
      Computer Language Shootout [...]

      Speed is one thing. But which language would you want to write a web browser in? A major retail web site? A SQL server? A CAD tool?
      This speed obsession is just one giant premature optimisation.

    164. Re:Old debate by Anonymous Coward · · Score: 0

      Garbage collection, a form of memory management in widespread use today, was invented "around 1959" by John McCarthy as he discovered LISP. This predates K&R, first edition in 1978, by quite a bit.

      I know LISP is old but it even in the primordial soup of early computing languanges weren't "discovered".

    165. Re:Old debate by letxa2000 · · Score: 1
      See above. 'C' is only "low level" to those that haven't truly worked at a low level. Yes, it is lower level than VB, but it is far from low level. Try coding some of the above arithmetic formulas in assembly and you'll realize just how low level 'C' isn't. 'C' is far higher level than just "abtracting away the registers." Printf? That library function can convert to hundreds--even thousands of instructions (no, I'm not just talking about 80x86/Pentium assembly language here). Floating-point math? Generally a nightmare in assembly language and can, again, correspond to hundreds or thousands of assembly language instructions. Scanf? Same. Etc. etc.


      Sure, those are libraries in the language. But if you aren't going to count that as part of what 'C' is, then you shouldn't count all the GUI stuff that makes VB what it is. If we're just going to look at the underlying control structures of every language, every language is low-level. But they aren't. A language is made up of its underlying control structures and the libraries of functions that go with the "core" language. And, in that sense, 'C' is far, far, far away from being "low level."

      Again, someone that hasn't worked at a low level will be forgiven for thinking that 'C' is a low level language.

    166. Re:Old debate by letxa2000 · · Score: 1
      Do you really think that high-level programming is just C with GUIs? If so, you have a pretty limited understanding of that world. I'm not familiar with VB...


      Amazing that you'd comment if you aren't even familiar with all the languages in the discussion.

      Anyway, I didn't say that VB was just 'C' with GUIs. But if you've programmed in assembly language, 'C', and VB and you had two make two logical groupings, assembly language would be in one group and 'C' and VB would be in the other.

      I can understand thinking that C is high level after working with assembler. I can also understanding thinking that it is very low level after working with high level languages. Both viewpoints have some truth.

      Perhaps. But I suspect that if you've worked across the spectrum of languages, 'C' has a lot more in common with high level languages than with a low level language. Like I said elsewhere, I'd be ok with calling 'C' a lower level language than VB, but calling it a low level language really ignores all the "magic" that 'C' does for the developer.

      Essentially, if you can write a program in a language with essentially no knowledge of the underlying architecture and/or instruction set, I have an awful hard time calling that a "low level language." And, yes, you can write most 'C' code knowing next to nothing about what's going on under the hood. And this is often a problem in the truly embedded industry; 'C' hotshots come along and think they can just sit down and write good embedded code because they know 'C', but they don't know the first thing about the embedded platform they are compiling for. They produce all kinds of marvelously bad and inefficient code. And because 'C' is such a high-level language, they can often get away with it--until something blows up and they don't have the first idea why because they know nothing about what's going on at the low levels.

    167. Re:Old debate by giantpencil · · Score: 1

      This is a great way to describe Perl :) I'll definately be using it. Though you can make Perl look structured, as with English. So much effort though, as with English.

    168. Re:Old debate by garote · · Score: 1

      Speak for yourself. I've done my share of machine language coding, and I consider C to be low-level, because I can generally look at the (unoptimized) assembly that a C compiler spits out and correlate it with the code I wrote in C. (Of course nowadays all my guesswork is eliminated by a good set of debug symbols.) For this reason, I do not consider any included libraries I link to as a determining factor.

      I agree with the creators of the language when they declare it is essentially portable assembly. I also consider it low-lewel because I have done my share of high-level programming, which to me means Objective C (terrific) Flash ActionScript (horrifying) and tangled craploads of object-oriented Perl (still not as bad as Flash). Essentially any such thing for which there's no (or no decent) procedural description, and/or is massively interpreted.

      From the thrust of your comments, it looks to me like you resent the declaration of C as "low-level" because it gives you an opportunity to show off what you know about assembly. Nothing more. Unfortunately you picked the wrong forum to do that. >:)

    169. Re:Old debate by The_Wilschon · · Score: 1

      Lisp, particularly as McCarthy initially defined it (before it got into the hands of hackers, that is), is as much a mathematical structure (for finding the value of any computable function) as it is a programming language. In mathematics, when someone writes about a particular mathematical structure for the first time, particularly if they show it to have some interesting properties or applications, we say that they have discovered it. Thus, I say that John McCarthy discovered Lisp.

      Additionally, as simple as (McCarthy's, not Common) Lisp is (only seven primitives), any structure which has (as primitives) atom, car, cdr, cons, cond, eq, and quote is in fact a dialect of Lisp, in a very mathematical sense. It might not have to look identical, but those seven mean that there is an isomorphism with Lisp, which in turn means that they are the same structure.

      Lisp is not the only programming system like this. For instance, see the concept of a One Instruction Set Computer. Anything with the (equivalent of a) subtract and branch if negative instruction is isomorphic to this. So, the subleq OISC could be said to have been discovered as well.

      --
      SIGSEGV caught, terminating

      wait... not that kind of sig.
  3. Bah by perrin · · Score: 4, Insightful

    So we "still can get good performance" from C? The implication is that C will somehow become overcome by some unnamed high-elvel language soon. That is just wishful thinking. The article is not very substantial, and where it tries to substantiate, it misses the mark badly. The claim that C cannot handle SIMD instructions well is not true. You can use them directly from C, or the C compiler can use them through autovectorization, as in gcc 4.1. The claim that C cannot inline functions from another source file is also wrong. This is a limitation in gcc, but other compilers can do it, and IIRC the intel compiler can. It is certainly not "impossible".

    1. Re:Bah by TheRaven64 · · Score: 5, Insightful
      The claim that C cannot handle SIMD instructions well is not true. You can use them directly from C, or the C compiler can use them through autovectorization, as in gcc 4.1

      You have two choices when using SIMD instructions in C:

      1. Use non-portable (between hardware, and often between compilers) intrinsics (or even inline assembly).
      2. Write non-vectorised code, and hope the compiler can figure out how to optimally decompose these into the intrinsics. Effectively, you think vectorised code, translate it into scalar code, and then expect the compiler to translate it back.
      Compare the efficiency of GCC at auto-vectorising FORTRAN (which has a primitive vector type) and C (which doesn't), if you don't believe me.

      The claim that C cannot inline functions from another source file is also wrong. This is a limitation in gcc, but other compilers can do it, and IIRC the intel compiler can. It is certainly not "impossible".

      When you pass a C file to a compiler, it generates an object file. It has absolutely no way of knowing where functions declared in the header are defined. You can hack around this; pass multiple source files to the compiler at once and have it treat them as a single one, for example, but this falls down completely when the function is declared in a library (e.g. libc) and you don't have access to the source.

      --
      I am TheRaven on Soylent News
    2. Re:Bah by Anonymous Coward · · Score: 5, Insightful

      C is faster in the same sense that assembly is faster: You have more control over the resulting machine code, so the code can by definition always be faster. You can optimize by hand. But that comes at a price: You have to optimize by hand. That's why C isn't always faster, especially not when it's supposed to be portable. The question isn't whether there could be a faster program in a language of choice, it's whether a language is at the right level of abstraction for a programmer to describe what the program must do and not a bit more. Overspecification prevents optimization. If you write for (int i=0; i<100; i++) where you really meant for (i in [0..99]), how is the compiler going to know if order is important? The latter is much more easily parallelized, for example. C is full of explicitness where it is often not needed. Assembly even more so. That's the problem of low level languages.

    3. Re:Bah by madcow_bg · · Score: 1

      > You have two choices when using SIMD instructions in C:
      > 1. Use non-portable (between hardware, and often between compilers) intrinsics (or even inline assembly).
      > 2. Write non-vectorised code, and hope the compiler can figure out how to optimally decompose these into the intrinsics. >Effectively, you think vectorised code, translate it into scalar code, and then expect the compiler to translate it back.

      Why not create standard libraries with classes (well, only for C++ maybe, but worth a try), that will use optimizations with SIMD instructions. For example, if the library is compiled with gcc, it will optimize. With other compilers it won't, but it will work either way. And someone would extend it...

      > When you pass a C file to a compiler, it generates an object file. It has absolutely no way of knowing where functions declared in the header are defined. You can hack around this; pass multiple source files to the compiler at once and have it treat them as a single one, for example, but this falls down completely when the function is declared in a library (e.g. libc) and you don't have access to the source.

      But if the function is in a pre-linked library there is no way to make it inline whatever language you use. You'r example of libc is not very good, because you can use the source of glibc :).

      Anyway, the article has a point, but the proposition that C can be slower with modern processors is not a sound one. But in the future, who knows?

    4. Re:Bah by Anonymous Coward · · Score: 1, Insightful

      When you pass a C file to a compiler, it generates an object file. It has absolutely no way of knowing where functions declared in the header are defined. You can hack around this; pass multiple source files to the compiler at once and have it treat them as a single one, for example, but this falls down completely when the function is declared in a library (e.g. libc) and you don't have access to the source.

      You say this as if C defines an object format and you can toss libraries around without assuming a particular compiler, linker, and loader facility, e.g. a specific C implementation such as GCC with the GNU toolchain!

      C compilers can and do store intermediate forms in "object" files such that the linker can do final inter-procedural optimization at link time or even dynamic load time. The SGI Irix compiler did this, for example.

    5. Re:Bah by gbjbaanb · · Score: 2, Informative

      It seemed to me the article was criticising C and trying to compare Java favourably. ie, C is a low level language that canot be optimised, Java is a high level language that can. roughly.

      It didn;t say much at all otherwise, but it did have a nice collection of adverts.

      Optimisation:
      You don't have to hack around, some compilers do it for you. The new MS compiler does a 'whole program optimisation' where it will link things together from separate object modules. Still cannot handle libraries, but then, that's just an issue that applies to all programs that are split into component parts. (except as the article implies, java that uses the bytecode in class libraries... except when compiled to native code as the first page of the article mentioned as a way to boost speed. Can't have it both ways :-) )

    6. Re:Bah by bhima · · Score: 1

      Yes you are right but I *realy* pine for really good autovectorization.

      GCC 4.1 does slightly worse than I can do myself and Intel C does it slightly better.

      But I know some folks that work on compiliers and I know they can do better.

      --
      Nothing in the world is more dangerous than sincere ignorance and conscientious stupidity.
    7. Re:Bah by rbarreira · · Score: 2, Insightful
      Use non-portable (between hardware, and often between compilers) intrinsics (or even inline assembly).

      Which usually isn't a big problem anyway since the code sections in which that's an advantage are usually quite small and infrequent, so if you really need the performance you can make a very little sacrifice of inserting conditional compiling statements with different code for the platforms which you are interested on.

      It's certainly not an ideal solution but it's a very attractive one, and it has the advantage that you can have experts on each CPU optimizing the code of the platform they know best.
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    8. Re:Bah by Anonymous Coward · · Score: 0

      experts on each CPU

      We call that "compiler".

    9. Re:Bah by Anonymous Coward · · Score: 0

      A further note, most high level language compilers, parsers, and libraries are written in C. Esentially making the high level language a frontend for the underlying C code. Though the lack of efficieny might not be noticable on today's processors, there will always be a latency for any of the high level languages since they have to pass through thier an abstraction layer. A hinderance thier low level counterparts don't share.

    10. Re:Bah by rbarreira · · Score: 1
      experts on each CPU

      We call that "compiler".

      Funny, I call it "people who made the compiler". Or in fact, some other people as well. Such as people who made the CPU. Such as people taught by people who made the CPU via optimization manuals. Your compiler has still a long way to go to be an expert.
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    11. Re:Bah by phasm42 · · Score: 1

      Mod parent up -- that was a very concise explanation of the problem of optimization.

      --
      "No one likes working in a hamster wheel, and your shop smells of cedar shavings from here." - TaleSpinner
    12. Re:Bah by eraserewind · · Score: 2, Insightful
      Compare the efficiency of GCC at auto-vectorising FORTRAN (which has a primitive vector type) and C (which doesn't), if you don't believe me.
      You see this all the time in SW Engineering. If there is a well defined high level API specifying what something is trying to do rather than how it should be efficiently (at the time) done, it will eventually be far more efficient to use the API because it will be get dedicated instructions in the chipset or even be completely implemented in a dedicated HW device whereas the how to do it version will be forever limited by how it's doing it.

      For PCs this isn't so obvious, since generic hardware + biggest CPU going tends to get used, but in embedded devices the dedicated hardware is much more often the way to go than the processor upgrade. My last project I can think of two APIs that gave us this benefit immediately without SW effort on our part, and a third area that benefitted by ripping out all the "optimized" code that bypassed the API, and using the (now HW accelerated) API directly.
    13. Re:Bah by mrsbrisby · · Score: 1
      Compare the efficiency of GCC at auto-vectorising FORTRAN (which has a primitive vector type) and C (which doesn't), if you don't believe me.
      In general, vectored operations are in the realm of hardware-specific stuff. FORTRAN's vector type doesn't translate into vector instructions for all sizes of vectors, and for all compilers, and for all systems. I'm not saying I don't love it, I'm just saying, it's not going to be the reason I write everything else in FORTRAN.

      In practice, GCC's vector extensions are "pretty good", and GCC is on loads of architectures and platforms. So these days, and for the majority of C programming that goes on, I'd venture to say that GCC is C.

      When you pass a C file to a compiler, it generates an object file. It has absolutely no way of knowing where functions declared in the header are defined. You can hack around this; pass multiple source files to the compiler at once and have it treat them as a single one, for example, but this falls down completely when the function is declared in a library (e.g. libc) and you don't have access to the source.
      That's not true. The compiler can load the libraries, and remove the prolog and epilog of the function call and insert it directly into the object. I've written compilers that do this, it's not even very hard.
    14. Re:Bah by sasdrtx · · Score: 2, Insightful

      From the first sentence: "The closer to the metal you can get while programming, the faster your program will compile..." WTF? How fast a language compiles has nothing to do with the so-called myth, whcih is that low-level languages allow a good programmer to produce programs that run faster. They may well compile faster (and they probably retain that advantage), but that's beside the point.

      Oddly enough, he proceeds to jump back on track and discuss optimization techniques and levels, most of which is OK. But he berates Java for implementing arrays (that's supposed to be an advantage over C and C++, which don't), and ignores the advantages of managed memory provided by a virtual machine.

      C. Needs more work.

      (yes, that's a pitiful pun.)

      --
      Most people don't even think inside the box.
    15. Re:Bah by Erich · · Score: 1

      When you pass a C file to a compiler, it generates an object file. It has absolutely no way of knowing where functions declared in the header are defined. You can hack around this; pass multiple source files to the compiler at once and have it treat them as a single one, for example, but this falls down completely when the function is declared in a library (e.g. libc) and you don't have access to the source.


      If you want to do cross-file optimization, the (reasonably) elegant method is to leave the compiler IR in the .o file and then re-invoke the compiler at link time to do global optimization. This is what Open64 does. But it's not very reasonable to expect a compiler of any kind to optimize around libraries it doesn't have any notion of, is it? Can the java compiler optimize with some random library it has no notion of? Of course not.


      (Now of course you can dynamically translate and optimize Java and optimize across library calls... but that's not a function of the language, but the interpreter's technology. You can do it with any type of application, including ones compiled with a C compiler. See projects like HP's Dynamo or Transmeta.)

      --

      -- Erich

      Slashdot reader since 1997

    16. Re:Bah by grimarr · · Score: 1

      some unnamed high-elvel language

      I like the sound of that. It reminds me of the good ol' days, when computers had their own
      room, with water pipes and acolytes. You had to be a high elf to be allowed to run one of
      those beasts yourself...

    17. Re:Bah by TheGreek · · Score: 1
      Your compiler has still a long way to go to be an expert.
      Perhaps.

      But it's a lot cheaper than an expert and a lot better than a non-expert.
    18. Re:Bah by Anonymous Coward · · Score: 0

      In practice, GCC's vector extensions are "pretty good", and GCC is on loads of architectures and platforms. So these days, and for the majority of C programming that goes on, I'd venture to say that GCC is C.

      Maybe for some but I like to think that these days doing things in plain C is a strong indicator that you do not want to lock the project into a specific compiler. Otherwise you could just as well use C++ or some single-vendor mandated "high-level" language.

    19. Re:Bah by rbarreira · · Score: 1

      Of course... But if that was what's being discussed here, the discussion would have been over long ago (maybe before starting hehe).

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    20. Re:Bah by Anonymous Coward · · Score: 0

      > Why not create standard libraries with classes (well, only for C++ maybe, but worth a try), that will use optimizations with SIMD instructions.

      Using a library will typically defeat interprocedural optimization. A shared library absolutely will.

      There are exceptions, like SGI's funky linker, but they still won't give you all the benefits of up-front compilation (on an SGI, you would take into account the latency of your entire vector pipeline, so at the fastest point, faster FPU ops simply didn't matter).

    21. Re:Bah by chthonicdaemon · · Score: 1

      That's just plain BS. I can write a C compiler in AWK, using an AWK that runs on LISP in a LISP machine and generates JAVA bytecode. That does not mean it is no longer a C compiler but just a frontend to the JAVA virtual machine. Just because some Haskell compiler is written in C (and might I add most modern native compilers are self-compiling as a matter of pride), doesn't mean you just have a 'high level language frontend for the underlying C code'.

      The real problem is how coupled compilers and languages are in most peoples minds. Languages aren't fast, compilers are efficient. Anything you say about C can be said about any other Turing complete language. They are all equivalent in computing power. However, compilers may be very good at converting the language to efficient machine instructions. This is due to language semantics and some accidental effects like the number of man-hours that have gone into tuning said compilers. In every case, the efficiency of a compiler is not an absolute that can be calculated but a qualitative measure of how well it does.

      So, language efficiency is really not a sensible phrase. We could be worrying about matching compiler abilities with language semantics, but even then, machine architectures vary, leading to changes on the language level to cater for achitectural differences (would C still do well on a Lisp machine or a PostScript printer or a GPU?). In the end, making choices based on specific machine capabilities will lead to short term gains, but as compiler tech gets better and the number of platforms increases more abstraction will make it easier to get 'ok' performance on 'most' platforms.

      --
      Languages aren't inherently fast -- implementations are efficient
    22. Re:Bah by Anonymous Coward · · Score: 0

      Microsoft's compiler can inline from a separate source file or a library.

    23. Re:Bah by ultranova · · Score: 1

      That's not true. The compiler can load the libraries, and remove the prolog and epilog of the function call and insert it directly into the object. I've written compilers that do this, it's not even very hard.

      But is it a good idea ? Suppose a compiler did this, and then the library got updated. The user thinks that the program is using the new library, but in reality at least some of the functions used - the inlined ones - are from the old library. It's even more fun if the inlined functions handled some datatype internal to the library, and that datatype got changed during the update, resulting in memory getting randomly corrupted without any sensible reason. Even better, suppose that the library in question is really a hardware access layer like OpenGL, and the compiler inlines some functions from it - do you need to recompile all OpenGL programs because you updated the display driver ?-)

      Ironically enough, Java (or any other interpreted language which can be JIT compiled) can do this kind of optimization easily and without risks, since it's done at runtime, not compile time.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    24. Re:Bah by vesulius · · Score: 1

      The Open-64 compiler does inline from one source file to another. It does so by storing the intermediate form of the compiled object inside the .o file as another section, instead of say, .text. Then at link time, the linker calls back out to the compiler.

      The flag is -IPA, and it is done all the time.

      Check out the Open-64 project.

    25. Re:Bah by joib · · Score: 1


      Compare the efficiency of GCC at auto-vectorising FORTRAN (which has a primitive vector type) and C (which doesn't), if you don't believe me.


      Typically this is due to aliasing, not because "Fortran has an primitive vector type and C hasn't". For that matter, the GCC Fortran frontend scalarizes array expression (i.e. converts them into equivalent loops) before handing them over to the middle end.

    26. Re:Bah by jenesuispasgoth · · Score: 1

      When you pass a C file to a compiler, it generates an object file. It has absolutely no way of knowing where functions declared in the header are defined. You can hack around this; pass multiple source files to the compiler at once and have it treat them as a single one, for example, but this falls down completely when the function is declared in a library (e.g. libc) and you don't have access to the source.

      ICC (Intel C Compiler) does what they call "IPO" - InterProcess Optimization, and yes, they use inlining between files. But on the other hand, you can't use the object files anymore, because they're not "real" object files (they contain symbols to indicate where to inline stuff, for instance). So you have in-file inlining, and then, at link time, ICC is able to inline functions that can be.

    27. Re:Bah by mrsbrisby · · Score: 1
      ... then the library got updated. The user thinks that the program is using the new library, but in reality at least some of the functions used - the inlined ones - are from the old library.
      This problem exists without inlining: What happened when Debian replaced libdbd-sqlite-perl with one that linked to libsqlite3? Everyone's SQLite databases stopped working.

      But see below.

      It's even more fun if the inlined functions handled some datatype internal to the library, and that datatype got changed during the update, resulting in memory getting randomly corrupted without any sensible reason.
      This problem exists without inlining: libSDL changed the interior of the SDL_SysWMinfo structure- a structure that's designed to be interacted with directly. Programs that did so, when libSDL was upgraded, crashed..

      Even better, suppose that the library in question is really a hardware access layer like OpenGL, and the compiler inlines some functions from it - do you need to recompile all OpenGL programs because you updated the display driver ?-)
      In practice this can't happen because the OpenGL library doesn't bind directly to the HAL. If the dynamic linker did this (on the other hand) we might have more of an issue.

      Actually, it wouldn't be such a bad idea to let the dynamic linker do it. If i386 had real PIC support, we could have a object format that represented a bunch of GLUE(a,b,c) functions that would resolve the appropriate code section at load-time. If the kernel knew about our GLUE() function, it could preserve mappings, say using mmap() with MAP_GLUE or something.

      Just wacky thoughts at that point...
    28. Re:Bah by ultranova · · Score: 1

      This problem exists without inlining: libSDL changed the interior of the SDL_SysWMinfo structure- a structure that's designed to be interacted with directly. Programs that did so, when libSDL was upgraded, crashed..

      If the structure is meant to be interacted with directly by the program using the library, then it's not an internal data structure for the library, now is it ? Internal data structure would be something that the program doesn't even know exists.

      In practice this can't happen because the OpenGL library doesn't bind directly to the HAL. If the dynamic linker did this (on the other hand) we might have more of an issue.

      At least in Linux OpenGL library is part of the display driver package, and gets updated with the driver, and the new version may differ internally from the old (optimization, utilizing a new internal interface to the kernel driver, etc). So, as far as I can tell, if you inline functions from it you may run into very serious problems when it gets updated.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    29. Re:Bah by mrsbrisby · · Score: 1
      If the structure is meant to be interacted with directly by the program using the library, then it's not an internal data structure for the library, now is it ? Internal data structure would be something that the program doesn't even know exists.
      No, but I mean the problem occurs because people aren't thinking ahead.

      At least in Linux OpenGL library is part of the display driver package, and gets updated with the driver, and the new version may differ internally from the old (optimization, utilizing a new internal interface to the kernel driver, etc). So, as far as I can tell, if you inline functions from it you may run into very serious problems when it gets updated.
      Err, you're referring to NVIDIA's "GL" drivers. If NVidia supported GLX correctly, this wouldn't be necessary.

      Nonetheless, _those_ GL drivers _are_ tightly bound to the nvidia drivers, and as a result, _do_ get updated at the same time.
    30. Re:Bah by Creepy · · Score: 1

      optimizing by hand is near impossible these days - you not only have multiple pipelines you need to feed out-of-order instructions to, you've got multiple parallel processing units and often processors (int, float, vector/SIMD - even GPU).

      Something like the for loop you described would be better done with thread pools if you want to take advantage of parallelism, but that isn't part of the C standard, so you get a bunch of different thread systems depending on platform (many support their own as well as POSIX, but some, like Windows, only really support their own). The problem is with C itself - it's designed for 1970s era processors and additional functionality was bolted on but has not become part of the definition over time. C should have a standard thread and structures for thread parallel-able code, for instance, but fat chance of seeing that anytime soon.

    31. Re:Bah by njh · · Score: 1

      You have more control over the resulting machine code, so the code can by definition always be faster.

      That is not always the case - C doesn't provide a very good fit with modern CPUs. For example, the PowerPC architecture has condition codes which can be operated upon in parallel to arithmetic instructions. However, C's definition of boolean makes these operations never get used, affecting the performance of tight loops considerably.

      I suspect that the main reason C is fast is because it has so many dollars spent on making it fast.

    32. Re:Bah by njh · · Score: 1

      You can do memory management without a virtual machine - compiled LISP and the boehm garbage collector are two common examples of this. Indeed, I find C++ with boehm and STL nicer to work with than Java, and faster too.

    33. Re:Bah by BasharTeg · · Score: 1

      I agree whole heartedly. This guy is obviously just another Java apologist. C programming is so classic anymore, that to write anything new and exciting, you have to take an anti-C position and try to prove that Java is some how "just as good" as C development.

      His first point basically tries to blur the lines between high, mid, and low level languages. This point is debatable, but more importantly, irrelevant.

      His second point is basically that the major architectures have changed so much that C no longer allows low level access to all their features and functionality. The sole example he brings out is, of course, vector instructions. That's handled in one of a couple ways currently. Applications can use the non-standard asm {} extension or link to object code written in assembler. Application can use a vectorizing compiler. His argument against using a vectorizing compiler is that you're converting vector operations into scalar operations and then hoping that the compiler figures that out. That's basically how low level languages work on architectures that have higher level assembly operations. Look at Itanium for an example of "compiler should be able to figure out what I'm doing" in action. It's a hollow argument because he says it like it doesn't make sense and implies that it doesn't work, when in fact, it has been shown to work.

      His third point is where he really starts into his Java apologism. He starts out describing high level versus low level languages, as if this were some kind of abstract discussion. By the third page, he reveals that this is a Java versus C rant, explaining why people's arguments against Java aren't fair, and that C isn't that much faster than Java, blah blah blah. Insert silly assertations about how expensive function calls are on most architectures and how functions aren't inlined between source files, and how VM based languages (LIKE JAVA) don't have these kinds of limitations. This implies that Java has some kind of advantage over C when it comes to highly procedural code, which simply isn't true. Most benchmarks I've seen that "show" that Java is faster than C (as explained by these silly "advantages"), involve poorly written C or C++ code because Java-heads don't always write the best C. On top of that, they're comparing an open source C compiler (gcc), to Sun's Java VM. Next time one of you Java apologists wants to benchmark C and Java, maybe have someone with a little more C programming skills than yourself write the C, and consider compiling it on Intel C Compiler or Microsoft's C compiler, rather than using gcc and Borland. Then you can do your benchmark and show that Java is capable of some kind of relevant inlining optimization that C is not, and therefore actually has some kind of performance benefit.

      His fourth point seems to be that Java array access could be better in theory, which is fine but irrelevant to the fact that doing things like image conversions in Java where numerous accesses to byte arrays are useful is dog slow (same with C#.NET). If Java does what he damns C for doing, giving you a vector class that generates SIMD instructions, that would be news to me. Most of his other argument here is that the fact that Java has a foundation class library means that it can provide "transparent" logical switching between classes, like dictionaries and associative arrays. In C, you'd have to find or write a class that did the same thing, OR do what most developers do and look at your usage and decide which one fits better. I don't need foundation classes figuring out which data structure is best for me, I went to college, I can figure it out for myself.

      His last point is part of the more standard Java apologist dogma, which states that "the process of programming" supports Java, because you can more easily explain to the compiler what you're trying to do. Somehow, C developers are able to get into the right mindset to explain to the compiler what they're trying to do. That's part of being a developer and a computer s

    34. Re:Bah by cookd · · Score: 1

      That's why you only inline stuff from static libraries, not stuff from dynamic libraries.

      --
      Time flies like an arrow. Fruit flies like a banana.
    35. Re:Bah by cookd · · Score: 1

      Though this is one interesting thought about JITted environments such as Java and .NET -- they CAN (and do) inline between dynamic libraries at JIT time, gaining some performance advantages that non-JITted code cannot. This can even work with AOT (ahead-of-time) compiling for .NET starting with version 2.0.

      --
      Time flies like an arrow. Fruit flies like a banana.
    36. Re:Bah by Tim+Browse · · Score: 1

      C compilers can and do store intermediate forms in "object" files such that the linker can do final inter-procedural optimization at link time or even dynamic load time. The SGI Irix compiler did this, for example.

      And Microsoft's tools do this too. It's no longer an "I heard about some research that..." area anymore.

    37. Re:Bah by Doctor+Memory · · Score: 1
      some unnamed high-elvel language

      It's not that it's unnamed, it's just that you need the Tengwar fonts to spell it...
      --
      Just junk food for thought...
    38. Re:Bah by kaffiene · · Score: 1

      Not really true. Runtime optimisations aren't really possible in C unless you think that implementing a runtime C compiler (and ignoring CPU cache flushes for re-writing code) is something you should consider as part of normal C code optimisation.

  4. High Level by HugePedlar · · Score: 4, Insightful

    I remember back in the days of the Atari ST and Amiga, C was considered to be a high-level language. People would complain about the poor performance of games written in C (to ease the porting from Amiga to ST and vice versa) over 'proper' Assembly coded games.

    Now I hear most people referring to C and C++ as "low level" languages, compared to Java and PHP and visual basic and so on. Funny how that works out.

    I like Assembler. There's something about interacting intimately with your target hardware. It's a shame that it's no longer feasible with today's variety of hardware.

    --
    Argh.
    1. Re:High Level by rbarreira · · Score: 1

      Yes, I also think it's quite fun to program in assembly (if only debugging it was fun and easy too...). And as Randall Hyde says, the impact on project time of choosing assembly as a language isn't as big as people think; most of the time is usually spent in designing anyway. As you say, the biggest problem is portability today... That's probably the biggest reason why programs made completely in assembly are more and more rare nowadays.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    2. Re:High Level by Anonymous Coward · · Score: 0

      Assembly still gets used a lot for microcontrollers, even micros that come with, or even are designed around, higher-level languages (the Parallax Propeller for example). In general, you first write your code in whatever is it that is available (C, Java, Spin etc.) to make sure the algorithm works, then convert it to asm, sometimes by hand and sometimes starting from the assembled high-level code and tweaking it.

    3. Re:High Level by hummassa · · Score: 0
      Assembly still gets used a lot for microcontrollers, even micros that come with, or even are designed around, higher-level languages (the Parallax Propeller for example). In general, you first write your code in whatever is it that is available (C, Java, Spin etc.) to make sure the algorithm works, then convert it to asm, sometimes by hand and sometimes starting from the assembled high-level code and tweaking it.
      And then, you'll still have code slower than a good global-optimizing compiler would produce.
      --
      It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    4. Re:High Level by FinchWorld · · Score: 1
      Is that true?

      I've just completed my first year at university doing electronic engineering, a good portion was microcontrollers, and although we could have used Ansi C for them (Which we also learnt), we were recommended to use assembly on the basis most in industry do, as portability seems a small issue when coding for microprocessors.

      --
      "I may be full of crap about this game, and I may be wrong, and that's fine." -Jack Thompson
    5. Re:High Level by rbarreira · · Score: 1
      And then, you'll still have code slower than a good global-optimizing compiler would produce.

      Do you have any credible proof of that extraordinary claim?
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    6. Re:High Level by radarsat1 · · Score: 4, Insightful

      No. Well, generally you'll have faster code if you code it in assembly. But things change when you enter the world of embedded programming... you're right, portability isn't AS important as speed. Sometimes. In certain parts of your program. But I recommend you DON'T disregard portability, even when it comes to microprocessors. In a real-world engineering project, you never know when one day parts will change, parts become obsolete, and you don't want to be left having to translate thousands of lines of assembly code.

      Rather, usually whats done is that most of the code is written in C, and only those parts that REALLY REALLY have to be optimized, like interrupt handlers for example, can be done in assembly. People use assembly for routines that, for example, have to take exactly a certain number of instruction cycles to complete.

      But it should be avoided as much as possible. It's just not worth losing the portability.

      More and more these days, microprocessors are embedding higher level concepts, and even entire operating systems, just to make software development easier.

    7. Re:High Level by Bazer · · Score: 1

      I like Assembler. There's something about interacting intimately with your target hardware. It's a shame that it's no longer feasible with today's variety of hardware.

      That would be better than the diversity we have today wouldn't it?
      No need to worry about portability of any kind.
      Your hand-tuned assembler code would run on any machine with no effort at all and with blazing speed.

      Yeah, a shame.

    8. Re:High Level by laffer1 · · Score: 1

      This argument is passed around by some computer science professors now. It seems that the logic is that most people don't know assembly well enough to write better code than gcc or whatever can produce. The problem is that if you get the intermediate assembly gcc spits out and know assembly for the target system at all you can still make some optimizations. I was taught how to do this in a sparc assembly course. I did get code that was slightly faster than what gcc produced but it wasn't much faster. Lesson learned was that most generated code is good enough and it takes routines used heavily (large loops) to really benefit from the extra time spent.

      There were a few cases in my class where my code was worse than gcc's code, but I was still learning too. I think sometimes people forget about issues with memory alignment and things when they write assembly.

    9. Re:High Level by rbarreira · · Score: 1

      Yes... And the reply to those arguments is pretty easy - people made compilers. Of course, it might take too much work and knowledge to optimize sometimes which is why compilers exist. But it's another matter entirely to say that people can't optimize as well as compilers. We currently can, both in theory and in practice. In theory we'll always be able to. In practice, I think we'll be still be able to for quite some time :)

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    10. Re:High Level by mrsbrisby · · Score: 1
      No. Well, generally you'll have faster code if you code it in assembly.
      I don't know about that. MY compiler knows it can multiply by nine fast using: lea eax,[edx][edx*8] but I know lots of people that "write in assembly" that still don't.

      Result? My C compiler is faster than their assembly.

      But besides that, I agree with your post :)
    11. Re:High Level by rockmuelle · · Score: 2, Interesting

      "I like Assembler. There's something about interacting intimately with your target hardware. It's a shame that it's no longer feasible with today's variety of hardwar"

      A minor observation about the feasability of working with the target hardware: the two most popular instruction set architectures for commidity hardware, PowerPC and IA-32, have both been stable since the mid 90s. The programming guide for PowerPC processors is still pretty much the same document as it was in 1996, around the same time the PowerPC ISA was defined. IA-32 has undergone some changes with each new major processor family, but is still backwards compatible at the instruction level with processors released in the 80s.

      Contrast this with high-level (i.e., non assembly languages). Java has undergone a few major revisions in its 10 year lifespan. C++ has yet to have a compiler that fully implements the spec (think export and the really fun template games). Scripting languages are constantly evolving and sometimes aren't backwards compatible over a 4 year period. Then there's the Microsoft switch to .Net that invalidated billions of lines of VB and VC++ code. Compared to these languages, machine code is incredibly stable and portable (across processor iterations, at least).

      Of course, there are architecture considerations for squeezing performance out of code. But, again, these haven't changed much in the last 10 years, either. The memory bus is still the bottleneck and you still get 50-80 instructions for 'free' on each load, even if you're not filling the pipeline completely. If you are doing something that isn't memory bound, it's not that hard to look up the instruction latencies in the manual and code things up to fully utilize the processing units and keep the pipline full. At least, it's no more difficult developing scalable EJB applications for your favorite web application engine...

      -Chris

    12. Re:High Level by ArikTheRed · · Score: 1

      I've got one better. A new guy we just hired was complaining about Java being a "low-level" language. He wants to use "high-level" languages, like Python and Ruby. Compiling is soooo 1990's!

    13. Re:High Level by GroinWeasel · · Score: 1

      Correction: your C compiler is fater at multiplying by 9 than crappily written assembler. Thats a pretty small corner you've got yourself and your case into there.

    14. Re:High Level by hunterx11 · · Score: 1

      People can prove the four color theorem, too, but we never will.

      --
      English is easier said than done.
    15. Re:High Level by mrsbrisby · · Score: 1
      Correction: your C compiler is fater at multiplying by 9 than crappily written assembler. Thats a pretty small corner you've got yourself and your case into there.
      So where do you draw the line? If it's faster than C code, then you've got an expert assembly programmer? So therefore, assembly is faster than C?

      Yes: there are cases where expert assembly has beaten expert C, but those are extremely rare. More often, it's amateur assembly beating amateur C, when a better improvement would've been seen by an expert C programmer for the given architecture.

      Consider: djbfft and note that it's written in C and yet outruns most implementations of FFT- including lots of those implemented in assembly. And it's still portable.
    16. Re:High Level by mparker762 · · Score: 1

      Spoken like someone who has never written assembly outside of class.

      I did a fair chunk of it in my younger days doing embedded and DOS development, where it was common for 10%-20% of the code to be in assembly. I haven't had much need for it the last decade or so, but had to write a few hundred lines last year to solve a bottleneck that couldn't easily be beaten algorithmically. The assembly outperformed the C++ handily (~10x faster), and this was on a modern processor with all the bells and whistles that are supposed to make things difficult (64-bit Xeon).

      Assembly is like any other language, it isn't really that hard once you're familiar with it. This wasn't necessarily true back in the early 80x86 days where you were seriously starved for registers, but once you get 10+ GP registers available then assembly gets pretty easy to write -- I always preferred the 680x0 over the 80x86 for this reason. Anyway, the hard part is the design and verification of the algorithm, the rest is just coding and debugging.

    17. Re:High Level by maximthemagnificent · · Score: 1

      Since apple just switched to intel, I wouldn't be so fast to discount it just yet!

    18. Re:High Level by jguthrie · · Score: 1
      It's hard to make sense when talking about performance when computers are involved, and the more general the topic, the more difficulty is encountered. I once dramatically improved the performance of a gas flow computer (meaning: "The system spent considerably more time performing the idle loop.") by re-writing an assembly-language interrupt service routine in C because of the way that the system worked originally.

      I don't think it is possible to get any sense out of the topic "programs written in language <x> are necessarily going to be faster than the same programs written in langauge <y>".

    19. Re:High Level by rbarreira · · Score: 1
      People can prove the four color theorem, too, but we never will.

      Why? Has it been proved that there is no simple proof? If so please let me know because I'd like to read that. I'm not being sarcastic here, just skeptical.
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    20. Re:High Level by jeremyp · · Score: 0

      If C is low level, then so is Java. They have almost identical syntax, but Java offers a few extra features e.g. array bounds checking and built in support for object oriented programming. Everything else is just libraries.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    21. Re:High Level by Jeremi · · Score: 1
      Lesson learned was that most generated code is good enough and it takes routines used heavily (large loops) to really benefit from the extra time spent.


      A lesson I learned is that if you hand-write or hand-optimize assembly you run the risk of introducing subtle bugs into your program that will cause you lots of pain later on(*). Is the benefit of a 5% speedup in routine X worth the risk of having your program mysteriously crash once a month at the customer's mission-critical site? Sometimes it is, but often it's not.


      (*) Yes, I admit to being a pencil-necked whuss when it comes to assembly coding. The near-complete lack of type-checking gives me the screaming heebie-jeebies.

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
    22. Re:High Level by Anonymous Coward · · Score: 1, Insightful

      If C is low level, then so is Java. They have almost identical syntax

      No. It's the semantics that matter, not the syntax.

    23. Re:High Level by fyngyrz · · Score: 1

      6809 -- easily the best combination of instructions ever put into a microprocessor. Not register rich, but then again, it handled memory so well, and in so many ways, that really didn't matter. The 68[000-040] series was a dissapointment by comparison. I've written tens of thousands of lines for both. Unfortuately, the 6809 really never made it out of the 8-bit/64k world.

      --
      I've fallen off your lawn, and I can't get up.
    24. Re:High Level by fyngyrz · · Score: 1
      Why use one word when two polysyllabic agglomerates will do.

      Breviloquence.

      --
      I've fallen off your lawn, and I can't get up.
    25. Re:High Level by Krunch · · Score: 1
      Rather, usually whats done is that most of the code is written in C, and only those parts that REALLY REALLY have to be optimized, like interrupt handlers for example, can be done in assembly.
      (Part of) interrupt handlers are written in ASM rather than C because they have to mess with registers, not because of speed problems.
      --
      No GNU has been Hurd during the making of this comment.
    26. Re:High Level by mparker762 · · Score: 1

      The 6809 was awfully nice, but the Intel 9600 is probably my favorite of the 16-bit processors. Three-register instructions, 128 registers (mapped to zero-page along with all the I/O addresses), nearly perfectly orthogonal architecture. The TI 9900 (used on the obscure TI99/4 microcomputer) was also pretty neat, it mapped the 16 GP registers to memory via a register base pointer so you could do ordinary stack allocation with your registers mapped into the stack, sliding window stacks, or even heap-allocated frames if you needed continuations, and since the registers were mapped to memory you didn't have to save or load them on procedure call since the hardware did it for you.

      Ahhh, those were the days. Not boring x86 or RISC stuff like today.

    27. Re:High Level by hunterx11 · · Score: 1

      If there is a proof simple enough to be checked by humans, it is difficult enough to find that no one was able to find it before computers found the current proof, and that no one has been able to find it with computer assistance and knowledge of a working proof. Given that it has already been proved, and that there are not really any far-reaching implications of the proof other than the curiosity of trusting computers, why would people continue to exert sufficient effort to find a simpler proof which may or may not exist?

      --
      English is easier said than done.
    28. Re:High Level by pthisis · · Score: 1

      For the same reason that Feynman diagrams won a Nobel prize. There's often very high value in explaining something in a way that can be easily understood.

      --
      rage, rage against the dying of the light
    29. Re:High Level by donaldm · · Score: 1

      That is the concept that made the Unix OS and from what I can gather it still holds true today.

      IMHO The power of the C language is it's simplicity and it's massive suite of libraries. In fact you can normally link object code from other languages (examples: Assembler, C++ and FORTRAN) as well as being able to call scripts and programs. So C can become the "glue" that can integrate many compilable languages and that leads to portability as well as efficiency.

      It is very common in Unix to run a program which normally is a script (Bourne, Korn or Bash ... ) that in-turn will actually call the appropriate binary code which could have originally been written in a language other than C. As far as the user is concerned they don't care as long as the program works.

      --
      There ain't no such thing as proprietary standards only proprietary formats. Standards are by definition open.
  5. Article is theory not practice - no measurements by ChrisRijk · · Score: 2, Interesting

    Not really much "meat" here. The proof is in the pudding as they say - but there's no benchmarks here. Just some minor talk about how things should compare.

    I don't agree with the basic premise of the article at all - but I've also written equivalent programs in C and more modern languages and compared the performance.

  6. Inaccurate summary by rbarreira · · Score: 4, Insightful
    The task of mapping C code to a modern microprocessor has gradually become increasingly difficult.

    This is not true. What they mean, I think, is "the task of mapping C code to efficient machine code has gradually become increasingly difficult".
    --

    The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    1. Re:Inaccurate summary by 10101001+10101001 · · Score: 1

      It's worse than that, really. It all comes down to CISC vs RISC design. CISC is great for its ability to do all sorts of nifty functions directly in hardware. At the same time, CISC having all these nifty functions directly in hardware makes it rather hard to have portable code with consistent speed as well as writing a compiler for all levels of languages that'll have reasonable results. Put simply, the die space dedicated to the extra functions in CISC processors that could have went towards more general improvements (ex. more registers) instead goes towards a specific function (say hardware sqrt) and then leaves it to each compiler to figure out how to exploit these special functions.

      In the end, the very highest level languages have it best, as very high level languages remove the program from a lot of the low-level details, leaving the compiler to be able to more abstractly choose which instruction to choose. And the lowest level languages (ie, assembly) have it the next best, as a person can program exactly what they mean without having to pray that the compiler does the "right" thing, but they're also required to do all the hand optimizing themselves instead of having a compiler crunch through and make overall more optimal choices than they're likely to. (And yes, a person skilled enough will almost certainly beat the compiler, but those people are by far the exception). It's the middle languages, like C, which have overly explicit constructs that are left in a situation where, as others have stated, the compiler has to guess what is meant and hope that doing not exactly what was written but instead producing some probably expected result is the best manuever.

      And why do I spit all this out? Mostly because RISC processors in general avoid this. They're designed to be simple enough that there's little advantage at any language level (at least, innately). But to differentiate each RISC processor requires the feature creep towards a CISC design which removes the chief design decision from the start. And it's always that trade-off of just how often programs really need that feature you're adding and whether the complexity, in the end, hurts a large group of developers. An ironic example of this, I would say, is the ARM line of processors, as the conditional execution in ARM mode comes at the cost of having all instructions as twice the size of the non-conditional execution in THUMB mode. Having a compiler try to figure out which is "optimal" is, except in situations where bus bandwidth gives you a clear winner, is just rife as an optimization problem without a simple answer.

      The truth is, there's nothing modern about the difficultly of mapping C code efficiently to machine code. And for the most part, it's only marginally more difficult if you look at all extant processor lines.

      --
      Eurohacker European paranoia, gun rights, and h
  7. It's very simple by dkleinsc · · Score: 4, Interesting

    The speed of code written in computer language is based on the number of CPU cycles required to carry it out. That means that the speed of any higher-level language is related to the efficiency of code executed by the interpreter or produced by the compiler. Most compilers and interpreters these days are pretty darn good at optimizing, making the drawback of using a higher-level language less and less important.

    If you don't believe me, I suggest you look at some of the assembly code output of gcc. I'm no assembly guru, but I don't think I would have done as well writing assembly by hand.

    --
    I am officially gone from /. Long live http://www.soylentnews.com/
    1. Re:It's very simple by rbarreira · · Score: 4, Informative
      I'm no assembly guru, but I don't think I would have done as well writing assembly by hand

      I don't believe this as much as the people who I see repeating that sentence all the time...

      Not many years ago (with gcc), I got an 80% speed improvement just by rewriting a medium sized function to assembly. Granted, it was a function which was in itself, half C code, half inline assembly, which might hinder gcc a bit. But it's also important to note that if the function had been written in pure C code, the compiler wouldn't have generated better code anyway since it wouldn't use MMX opcodes... Last I checked, MMX code is only generated from pure C in modern compilers when it's quite obvious that it can be used, such as in short loops doing simple arithmetic operations.

      An expert assembly programmer in a CPU which he knows well can still do much better than a compiler.
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    2. Re:It's very simple by hummassa · · Score: 2, Insightful
      An expert assembly programmer in a CPU which he knows well can still do much better than a compiler.
      FOR ONE FUNCTION. If you programmed the whole system in asm, you'd see that the assembler+you combo would lose so many opportunities for optimization that a good compiler got. And that's the whole point of the article.
      --
      It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    3. Re:It's very simple by spinkham · · Score: 2, Interesting

      True, since they can always start with the compiler output, and are thus will at least do no worse.
      The more interesting question is if a person with only passing familiarity with assembly can do better then the compiler, and the answer to that is usually no these days.

      --
      Blessed are the pessimists, for they have made backups.
    4. Re:It's very simple by rbarreira · · Score: 1

      Not if you're willing to throw time away on optimizing it. I'm not saying that it's necessarily good to have an expert assembly programmer doing an entire program (because of time, money constraints and because sometimes performance is already good enough). I'm just saying that the compiler is often WORSE than him at optimizing, nothing more than that.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    5. Re:It's very simple by jtshaw · · Score: 3, Interesting
      Most compilers and interpreters these days are pretty darn good at optimizing, making the drawback of using a higher-level language less and less important.


      In the past, most compilers were dreadful at optimizations. Now, they are just horrible. I guess that is an improvement, but I still believe there is a lot of good research to come here.

      I do agree that the playing field has become pretty even. For example, with the right VM and the right code you can get pretty good performance out of Java. Problem is "the right VM" depends greatly on the task the program is doing.. certainly not a one vm fits all out of the box solution (ok.. perhaps you could always use the same VM, but app specific tuning is often neccesary for really high performance).

      At any rate.. people just need to learn to use the best tool for the job. Most apps don't actually need to be bleedingly fast, so developing them in something that makes the development go faster is probably more important then developing them in something to eek out that tiny performance gain nobody will probably notice anyway.
    6. Re:It's very simple by marcovje · · Score: 1


      True. However the use of such optimizations is shifting. I usually get more in making malloc application specifically optimized then by mucking with assembler.

      However there is some Image recognition stuff where I still use (SSE-) asm.

    7. Re:It's very simple by lbrandy · · Score: 1

      I don't believe this as much as the people who I see repeating that sentence all the time...

      I can often get 4-5x speed improvements with most computational functions (image processing). I have gotten in the order of 10x speed improvements for address-calculation-heavy functions. I've looked at thousands and thousands of lines of code generated from modern compilers of all varieties, and I can say with absolute certainty that they are _not_that_good_. SIMD, alone, will provide huge speedups. So-called autovectorization doesn't work that well. Even if it was able to vectorize the calculation, it still does a terrible job using temporal vs non-temporal memory storage (look up write-combining). For certain types of function you can get 50% improvements by using write-combining correctly.

      In very tight loops based on address calculations, compilers are just plain bad. Create an array of 3d arrays where each value is an index to a quantized lookup table, and then try to do a sum over all that. Look at that generated assembly code and it's a complete mess. Do it by hand correctly factoring out all the non-loop dependant stuff, and you will get huge improvements.

    8. Re:It's very simple by lbrandy · · Score: 1

      The more interesting question is if a person with only passing familiarity with assembly can do better then the compiler, and the answer to that is usually no these days.

      This seems to be conventional wisdom. Have you ever actually tried it? I don't think you have. I don't think anyone who keeps this wisdom has. Why? Because my experience tells me that assertion to be just plain wrong. For small, compact, numerical (which includes address calculation) loops, "naive assembly" code will outperform your compiler. The sophistication of the algorithm will determine the speedup. (Ie, a block move isn't probably going to be sped up that much).

      I urge you to try it. If you need a simple numerical algorithm.. how about an image blur? 3x3 Gaussian convolution is pretty simple. You don't even need to use SIMD (but if you do, you'll win, by alot).

    9. Re:It's very simple by IamTheRealMike · · Score: 1
      The speed of code written in computer language is based on the number of CPU cycles required to carry it out.

      And also resource usage. One of the reasons Java apps tend to drag on consumer level systems (ie not big servers) is because Java is so profligate with memory consumption. Who cares how well optimised your code is when a single page fault that goes to swap can wipe out the benefits?

    10. Re:It's very simple by mrsbrisby · · Score: 1
      Not many years ago (with gcc), I got an 80% speed improvement just by rewriting a medium sized function to assembly.
      And not many years ago (with gcc), I got a 700x speed improvement by rewriting (a coworkers) assembly inner-loops into C.

      Does it even bother you to think for a minute that you might have chosen a slow algorithm to begin with?

      I generally don't bother unless the optimization will bring me orders of 700x improvements, and then usually it's the algorithm that's flawed, and not the compiler. And believe me, I've written a large number of really flawed algorithms :)

      An expert assembly programmer in a CPU which he knows well can still do much better than a compiler.
      Consider djbfft, which is written in C, and yet outruns many FFT implementations that are written in assembly, some of which were written by experts.

      I'm pretty sure lots of "expert programmers" have written FFT implementations, but they aren't expert algorithm designers, and I'll say with certainty that counts a lot more than whether you use assembly language or not.
    11. Re:It's very simple by Greyfox · · Score: 1
      An expert assembly programmer in a CPU which he knows well can still do much better than a compiler.

      Well that's part of the problem. On PC desktop hardware you don't really need to worry about programming in assembly most of the time -- the speed advantage isn't as noticable as it used to be for most applications. And for embedded programming that level of specializaiton would cause you to not be the hot-pluggable "resource" that most companies consider their employees these days. No sense in spending a couple of years becoming an expert at a single processor and architecture when the company could change its hardware specs or outsource your job to Elbonia at the drop of a hat. If you DO find an expert like that, he's going to come with a huge salary requirement as well. Again, most companies would rather hire someone fresh out of college at a quarter of the price.

      It's really too bad... working right at the 'iron' level was a lot of fun back in the day. Do they even teach it in college anymore?

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    12. Re:It's very simple by rbarreira · · Score: 1
      Does it even bother you to think for a minute that you might have chosen a slow algorithm to begin with?

      Well, the code in question was a tight mathematical routine belonging to a distributed computing of a quite well known project, which was originally programmed by a mathematician and then adapted by another mathematician who is also a very good programmer. Along with the fact that, along with me, people used to optimize code also looked at it. So no, what you say doesn't bother me very much, since I think that possibility is very unlikely.

      In fact, someone (later) came up with slightly faster code for the same routine. Unfortunately for your hypothetical argument, also coded in assembly.

      Consider djbfft, which is written in C, and yet outruns many FFT implementations that are written in assembly, some of which were written by experts.

      Amusingly, check out this excerpt from the FAQ at the page you pointed to:

      Don't modern compilers take care of instruction scheduling?
      Sure, if you don't care about speed.


      And, a look at the TODO file reveals stuff such as:

      do properly scheduled Pentium/PMMX asm
      pass parameters in registers
      organize asm to fall through function entry when possible
      organize asm to reduce i-cache pressure


      So thanks for helping me prove my point...
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    13. Re:It's very simple by rbarreira · · Score: 1

      Sure, the practicalities of optimizing code are complicated. But we're talking about facts regarding languages and optimizations, not petty practical details :P

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    14. Re:It's very simple by mrsbrisby · · Score: 1
      Well, the code in question was a tight mathematical routine belonging to a distributed computing of a quite well known project, which was originally programmed by a mathematician and then adapted by another mathematician who is also a very good programmer.
      If your assembly was better than his C, then you must have a forgiving definition of the term "good".

      In fact, someone (later) came up with slightly faster code for the same routine. Unfortunately for your hypothetical argument, also coded in assembly.
      Did you misunderstand me? I alluded that most speedups come from algorithmic shifts, rather than implementation shifts. But because of the mythos surrounding assembly programming, people believe just rewriting inner loops in assembly will get them better performance. djbfft demonstrates this is not the case.

      Amusingly, check out this excerpt from the FAQ at the page you pointed to:
      Check the source. It wasn't written in assembly. The entry you point to: Don't modern compilers take care of instruction scheduling? is highly revealing. The fact that djbfft was written in C demonstrates it's still possible to handle these things from C code. It demonstrates that there are more valuable speedups gained from a better algorithm.

      And, a look at the TODO file reveals stuff such as: do properly scheduled Pentium/PMMX asm, pass parameters in registers, organize asm to fall through function entry when possible,
      organize asm to reduce i-cache pressure
      So the author knows how to improve the algorithm. Why does this surprise you? You'll note that only one of them suggests writing assembly code, and it's to handle an obsolete case.

      So thanks for helping me prove my point...
      Your point? That assembly is faster than C? All you've demonstrated is that someone's assembly is faster than someone elses' C. I've provided an example: C code that outruns commonly used assembly. Is it necessary that you define assembly as the faster implementation, in order to prove it's faster than C? Will you need to say that "well, nobody has bothered to implement a faster FFT yet" in order to maintain your argument?
    15. Re:It's very simple by mparker762 · · Score: 1

      I have looked at the assembly output of gcc, and have been horrified by how bad it is. Seriously, it's cringe-inducing. MSVC is better but still not great (though MSVC.NET 2005 seems noticeably improved).

    16. Re:It's very simple by poot_rootbeer · · Score: 1

      An expert assembly programmer in a CPU which he knows well can still do much better than a compiler.

      This is true, but it is also true that for the cost of hiring one expert assembly programmer, you can hire three or four competent, if inexpert, Java programmers.

    17. Re:It's very simple by Kjella · · Score: 1

      FOR ONE FUNCTION. If you programmed the whole system in asm, you'd see that the assembler+you combo would lose so many opportunities for optimization that a good compiler got. And that's the whole point of the article.

      That's about as fair as comparing an assembler programmer to a compiler with optimizations turned off. Each method should have as much information as possible to its disposal, and that the compiler can't do iterative optimization based on existing machine code is not the assembly programmer's fault.

      In theory, the assembly programmer should never do worse than the compiler since he can adapt his code perfectly, not limited to any predefined rules. In practise, it's practical matters like availability of high-quality programmers, time and cost that are the limit. So if that's the point of the article (no, I didn't read it) then the point is redundant already, and has been for many years. And like the parent proves, we still need assembly programmers for when the compiler lets us down.

      So what was the point again? That we can't compete with the compiler in an unrealistic comparison with arbitrary limitations? I'll "hire" a compiler over an assembly programmer any day of the week, unless I really really need one. And when I do, the compiler doesn't cut it. If there was a point to be made here, I don't see it.

      --
      Live today, because you never know what tomorrow brings
    18. Re:It's very simple by Anonymous Coward · · Score: 0

      I'm no assembly guru.

      hinthint ;)

    19. Re:It's very simple by spinkham · · Score: 1

      Yes, I have tried it. However, I don't work in the graphics or numerical space much, and when I do I use pre-optimized libraries like BLAS and ATLAS. I've mostly tried coding things like sorting, searching, parsing and such routines in assembly, with little to no gains.
      In the programming spaces I work in, researching better algortihms always pays off over better implementations, so that's how I spend my optimization time. For most other people this is true also.
      There are subsets of programming such as graphics and numerical programming where you will see large benifits to optimizing the implementation even once you have chosen the correct algorithm, but they are definatly not the majority of programs.

      That being said, I do program in assembly for program and memory size reasons on microcontrollers, calculators, pdas and such. Significant savings can be had that way. But for general speed reasons, compilers are close enough to what the average programmer would do, such that assembly is usually not a productive use of your time.

      --
      Blessed are the pessimists, for they have made backups.
    20. Re:It's very simple by Anonymous Coward · · Score: 0
      The more interesting question is if a person with only passing familiarity with assembly can do better then the compiler, and the answer to that is usually no these days.

      I wrote in ARM assembler a blitter routine that draws an 8-bit bitmap scaled 2X times (from 160x144 to 320x288 pixels). That was 1 week ago. My emulator now runs 15-20% faster than before on my PDA! and I'm new to ARM assembly language! Anyway, ARM assembly is easier than x86 (specially when you have ~10 general purpose registers :))
    21. Re:It's very simple by hummassa · · Score: 1

      Hi Kjella! The points, IMHO, are:
      1. Higher-level languages can (and will) be faster than lower-level languages -- if the compiler takes advantage of extra information supplied by the programmer.
      2. C is a low-level language.
      3. Good, optimizing, C compilers are becoming more and more complex, because:
      3a. the low-level abstractions present in C don't match well with current processors; and
      3b. they make the programmer "undo" some optimization and hope the compiler can redo it.
      4. C passes really few information to the compiler (because it's weakly typed), so it can't optimize a lot of stuff that can be optimized in higher-level languages.
      5. Assembly == lots of control; but if you want to optimize a whole system, code it in a higher level language and optmize only a small part of it -- in assembly, if needed.

      --
      It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    22. Re:It's very simple by forkazoo · · Score: 1
      Not many years ago (with gcc), I got an 80% speed improvement just by rewriting a medium sized function to assembly. Granted, it was a function which was in itself, half C code, half inline assembly, which might hinder gcc a bit. But it's also important to note that if the function had been written in pure C code, the compiler wouldn't have generated better code anyway since it wouldn't use MMX opcodes... Last I checked, MMX code is only generated from pure C in modern compilers when it's quite obvious that it can be used, such as in short loops doing simple arithmetic operations.

      An expert assembly programmer in a CPU which he knows well can still do much better than a compiler.


      I'm not going to disagree with you out of hand, because I don't think you are wrong exactly, but I would like to add some extra caution for readers who may be more gung ho with assembly than is best. A well-seasoned assembly programmer can absolutely write faster code than a C compiler -- for a specific chip. A friend of mine is currently working on a database that has a ton of very low level assembly optimisations. These optimisations were all fantastic on the 486. However, modern CPU's work quite differently than 486's did. Assumptions about what instructions are slow, and what are fast no longer apply. It would be very easy to write some nice portable, easy to read and maintain C that runs much faster than all that perfectly optimised assembly --0 if you are going to run it on a P4 instead of a 486.

      If you are going to use assembly "optimisations," you have to understand that you will have to basically rewrite the assembly every time another new CPU microarchitecture comes out. If you are doing something that will be certainly dead, or no longer performance sensitive in three years, then this may not matter. Another example I can think of is when OpenGL first started to become common on PC's, but almost nobody had hardware OpenGL accelerators. A lot of people scoffed at OpenGL because it was to 'heavy weight,' because it had features they didn't need. So, they spent a bunch of time and effort writing their "perfectly optimised" software rasterisers (which were indeed faster than the OpenGL reference rasteriser). Then, their customers all got TNT2's, and wondered why the "perfectly optimised" software ran so much slower than the software which used "excessively heavy" OpenGL.

      In other words, do the simplest best solution first. Then, if it isn't good enough, make your "perfectly optimised" version as an additional path, not as the only choice. Your perfectly optimised version will be hard to maintain, and hard to reoptimise in a few months.
    23. Re:It's very simple by ysachlandil · · Score: 1

      > The speed of code written in computer language is based on the number of CPU cycles required to carry it out.

      Nope, not true anymore. The speed of code written in computer language is based on how efficiently it utilizes the cache of the CPU it is running on. Loop unrolling for instance used to be a surefire way to increase speed. Now it just takes up valuable cache space and actually reduces speed. Counting the number of cycles instructions take is pretty irrelevant if a cache-miss takes up 10 times the amount of time the execution of the instruction takes.

      --Blerik

  8. Still An Interesting Article by Anonymous Coward · · Score: 0
    The article is not very substantial, and where it tries to substantiate, it misses the mark badly.
    You're right, for the topic the article is not very substantial. Of course, he's addressing all high level programming so that's at least a book. And then he's addressing C so that's at least another two books.

    What I think the author may have been trying to get at with the SIMD part is that our machines are becoming multiprocessor based. And not multi-CPU based but my machine right now has a CPU, GPU & probably some microprocessors for the chipset. I think that you missed his point in that processors and machines have changed a lot. Thirty years ago, things were different and C was optimized to be the fastest. It probably still is the fastest but that doesn't necessarily mean that new languages are slow--in fact, they themselves may be optimized to take advantage of multi-processors better than classic C can. Again, that's not saying someone can't add to the gcc for that particular set up but you can't ignore what the author is saying.
  9. C is the 3vil by Anonymous Coward · · Score: 4, Funny

    Isnt the JIT for java written in C though.

    ahah now we know why my java program is so slow. damn C slowing it down.

  10. Great article! by TeknoHog · · Score: 4, Funny
    This is exactly what I've been saying over and over, why I think that e.g. Fortran is better than C in many respects. The main point is neatly summarized at the end:
    the more information you can give to your optimizer, the better the job it can do. When you program in a low-level language, you throw away a lot of the semantics before you get to the compilation stage, making it much harder for the compiler to do its job.
    --
    Escher was the first MC and Giger invented the HR department.
    1. Re:Great article! by menkhaura · · Score: 1

      "Do what I mean"? Hehehe

      --
      Stupidity is an equal opportunity striker.
      Fellow slashdotter Bill Dog
    2. Re:Great article! by Anonymous+Brave+Guy · · Score: 1

      Absolutely. There's a balance between higher-level languages having more semantic information that they can use to optimise, and lower-level languages having fewer overheads because they're closer to the machine and the abstractions, such as they are, don't carry much deadweight.

      Naturally, as optimisation techniques develop to take advantage of the higher-level abstractions, and processor architectures go beyond the model of the traditional lower-level languages with multiple cores, vectorised instructions and so on, the balance will shift.

      I think of it a bit like the old software optimisation contrast: you can optimise at a low level, and get a small multiplier in your speed-up, or you can optimise your algorithms, and get something with lower complexity but with a practical difference that only matters for larger-scale problems. In the long run, improving algorithmic complexity can bring far greater returns, but your low-level stuff has to be reasonable to start with.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    3. Re:Great article! by Anonymous Coward · · Score: 0

      I'm not sure why the grandparent is modded funny and how you think "do what I mean" comes into it. You can tell someone to go to the nearest gas station (high level), or you can tell someone to drive a mile, turn right, drive half a mile, turn right again, drive half a mile and stop (low level). The former instruction allows optimization: Maybe the compiler knows a shorter route or even a closer gas station. The latter instruction doesn't even include the information that you want him to go to a gas station and it doesn't include the information that the route isn't important either. There's no room for optimization.

    4. Re:Great article! by rs79 · · Score: 0

      "This is exactly what I've been saying over and over, why I think that e.g. Fortran is better than C in many respects."

      There's things you DON'T want to do in FORTRAN that are easy in C and vice versa. String manipulation and matrix inversion come to mind.

      People still use FORTRAN? What happened to WATFIV-S ?

      That's the cure thing about FORTRAN. There's so many to choose from. There's only one C.

      --
      Need Mercedes parts ?
    5. Re:Great article! by Frumious+Wombat · · Score: 1

      To the poster with their "there is only one C"; Horsefeathers. That there is Only One C explains why every C program I have is a twisty little maze of #ifdefs, often for minor differences in machine/compiler combinations, and as likely to break after a compiler upgrade as continue to build. It continues to exist only because it's suitable for assembly-language-type functions, such as OS kernels, which means it ships with every unix out there, and is taught to unsuspecting comp-sci students because it came free with the OS. It's amazing that after the problems of the past few years, including buffer-overrun exploits, memory leaks, etc, caused by C's unsafe, seat-of-the-OS memory handling, that people continue to defends its use as a general purpose language.

      The OP may be trying to be funny, but in fact a modern Fortran (F90/95) is easy to do string manipulation in, has dynamic memory, is type-safe, and is arguably a much higher-level language than C. (on the other hand, F90/95 bears a curious resemblence to Ada, but we'll let that slide). Memory aliasing isn't nearly the issue it is for C programs, which is why Fortran still out-performs C/C++ on any modern architecture, as long as you're using a competent compiler. (i.e. I don't want to hear about how slow your G77/GFortran programs are; they're great tools, but they're primarily Fortran Lints (flints)). Where Fortran fails is that is has the same name as a particularly onerous language from the mid-60s, known variously as FORTRAN-IV or FORTRAN66. If it was named differently, such as Cerulean, for instance, you'd complain about its verbose, Python-esque syntax, with Begin and End, rather than { and }, but you'd grudgingly learn it, write interfaces to libraries, start new projects in it, and treat it as an appropriate tool. Flame wars would break out here as the Cerulean programmers made fun of the Java-weenies, because their language is byte-code interpreted, and doesn't have matrix operations built in as primitives (how can you do quick 3d graphics without matrix ops). Because of the antique name, you picture a black and white room full of guys in white shirts with pocket-protectors and crewcuts, smoking while they load pounds of manila cards into the keypunch.

      Back when we were in college we used to comment that C was a step backwards, as in terms of being a high-level language it ranked right up there with VAX assembler. Let it go. Use C++/Objective-C/Java if you're obsessed with line-noise syntax, or move on to Eiffel http://eiffelsoftware.origo.ethz.ch/index.php/Down loads/ /Ada or even SmallTalk http://www.squeak.org/ for new work.

      --
      the more accurate the calculations became, the more the concepts tended to vanish into thin air. R. S. Mulliken
    6. Re:Great article! by rbarreira · · Score: 1

      The former instruction allows optimization: Maybe the compiler knows a shorter route or even a closer gas station.

      Is it ok if the compiler uses carefully placed nuclear bomb in order to arrive there faster? :)

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    7. Re:Great article! by TigerNut · · Score: 1

      Good points. The main problem with trying to benchmark CPU performance using C code that was "previously optimized" by competent programmers, is that it was written to exploit features and capabilities of a particular platform. As an example, there used to be a distinct advantage on many platforms if you used pointers to index arrays; if you didn't then the compiler would generate code that explicitly dereferenced from the array start for every access. Most compilers (even for embedded systems) now have enough brains to create a pointer in a register and index with it, regardless of whether or not you wrote the source code that way. A few years ago I discovered that the embedded compiler I was using, would generate smaller code if I selected "optimize for speed" as opposed to "optimize for size"... When life hands you lemons, make lemonade. That truism applies to writing software, but as systems get bigger and you're working with smarter compilers, it makes sense to write your source so that it tells the compiler what you want the program to do, not how it ought to do the machine code.

      --

      Less is more.

    8. Re:Great article! by joib · · Score: 1


      how slow your G77/GFortran programs are; they're great tools, but they're primarily Fortran Lints


      The Polyhedron Fortran benchmarks puts gfortran at about 30 % slower than the fastest compilers (ifort or pathf90 depending on platform).

    9. Re:Great article! by Frumious+Wombat · · Score: 1

      When running on PPC hardware or Power3 hardware (Mac G5, AIX, respectively), for quantum chemistry packages, G77 was capable of being up to 50% slower than XLF. At 30% slower, that's equilvalent to running your machines for 8 months of the year, versus 12. Since I run simulations that routinely take two months, that 30% is a big difference.

      --
      the more accurate the calculations became, the more the concepts tended to vanish into thin air. R. S. Mulliken
    10. Re:Great article! by joib · · Score: 1


      Since I run simulations that routinely take two months, that 30% is a big difference.


      So do I, but us HPC users are few and far between. There are many situations, even where Fortran is used, where a 30 % worse performance than the top of the line commercial compilers is good enough.

    11. Re:Great article! by TeknoHog · · Score: 1
      The OP may be trying to be funny, but in fact a modern Fortran (F90/95) is easy to do string manipulation in, has dynamic memory, is type-safe, and is arguably a much higher-level language than C.

      *sigh* I was definitely serious. I have a background in scientific computing, which is how I've gotten to know Fortran's strengths. And I don't like the fact that the physics world is moving towards C++, though the tools involved (such as Root) are arguably better in some respects.

      This is certainly not the first time that my 'insightful' and 'funny' intentions were confused... perhaps the 'me too' style of my original post didn't help much :-/

      --
      Escher was the first MC and Giger invented the HR department.
    12. Re:Great article! by Frumious+Wombat · · Score: 1

      Fair enough, and I'll admit that I have one code that I often built using G77 for stability reasons. I am (or was) actually rather fond of G77, having run it originally on OS/2 using the EMX suite, and then used it as my primary development platform for years. However, given that Fortran has been a bit of a red-headed stepchild in the GCC suite, and the current F90 compiler is choking on a major F77 code I use on a daily basis, I have a hard time recommending it any more. I hope that GFortran improves enough that I can go back to using it, as it was nice having a consistent Fortran across various platforms for debugging. Sadly , I miss G77; I used to use it to build older codes that my colleagues would bring to me, that modern compilers such as IFort choked hard on. I probably just need to be patient with GFortran, since if it gets within a few percent of the Absoft compiler, then it's the most cost-effective 64-bit compiler for what is soon to become my legacy cluster. (Mac OS-X) I had purchased them on the mistaken assumption that XLF had a future, and for 32-bit code, I really could not be happier, unless some of the underlying algorithms in the packages were improved. Actually, I could be happier; the programs could also colllate the data and write up the results for me, but that's an AI problem, not a Fortran problem.

      --
      the more accurate the calculations became, the more the concepts tended to vanish into thin air. R. S. Mulliken
  11. What has changed? What should we change? by rufty_tufty · · Score: 1

    Is this a surprise?
    C is designed for classic Von-Neumann architecture machines using a stack based methodology and an attempt to give programmers all the rope they could want.
    This is a good thing for solving one set of problems.
    It also showed it can be adapted and built on to solve further more advanced problems.
    This is also a good thing.

    I would question however if in these days with ever increasing usage of multiprocessors, MMUs, Register heavy CPUs, massive on chip caches, huge latency to access memory etc if the concepts embodied within C are still the best methodology?

    I guess what I'm saying is i wonder if there is an equivalent medium level language* around that better suits todays reality.
    Let me as a possibly poor example take the cell processor as an example here:
    The kind of tools I'd like to see for this (were a cell style processor to be used in my next desktop) would be:
    1) Access to the low level assembler.
    2) An extemsion to the C language (possibly a library) which would mean I could run all my existing code as is on this multi processor machine, but I could then profile the code to make better use of new processor architectures in the interim until I migrate my code/programmers over to new methodology.
    3) High level languages like python, Perl etc running in some mode - for tools like this I normally don't care about performance if I'm using thse tools - and wioth any luck, clever compilers/interprators will do some of the multi core management for me
    Although a new high level language which allows instruction/task level parallelism would be cool!
    4) A new medium level language (along the lines of occam) which would allow me to have a comparable level of control and automation over this multi processor register and cache heavy system.

    to me, 1 is implicitly required for any design, 3 comes for free once you have 2, and 4 is a way to progress forwards and gain productivity.
    That leaves 2 as a stop gap measure.
    That is all you programs compiled using #2 would make very inefficient use of such a processor,, but would maintain compatability for the time being until we can move on to more appropriate things.
    Will we ever leave C behind? Well we never left Fortran behind really, it's still there. I don't see any more reason to keep C for modern desktop processors than there was to keep training most programmers in fortran.

    But will we ever move GNU off of C?
    I won't be throwing out my C LRM yet ;-) Unfortunatly...

    * By my definition:
    High level language - Hide all/as many as possible of the details of the machine from the programmer
    Low Level language - expose the programmer to as many of the machine details as possible
    Medium level - make some parts of the machine automated (e.g for loops) make some exposed to the programmer (e.g. memory managment)
    Yes this is a sliding scale, so arguments as to where a langauge lies are always open to debate

    --
    "The weirdest thing about a mind, is that every answer that you find, is the basis of a brand new cliche" -
    1. Re:What has changed? What should we change? by Anonymous Coward · · Score: 0

      Rubbish. C is at home on Harvard as it is on Von-Neumann: the standard does not allow conversions between pointers to code and pointers to data.

    2. Re:What has changed? What should we change? by mwvdlee · · Score: 1

      Since the cell cores (the SPE's) are so specialized, I doubt you'll be able to use ANY generic programming language. At best you could probably get subsets of C and the likes. I doubt anybody would want languages such as Python and Perl running on the SPE's.
      The other core in the cell architecture is simply a PowerPC core, so any current programming language which compiles on PowerPC platforms should work just fine for that core.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    3. Re:What has changed? What should we change? by rufty_tufty · · Score: 1

      :-)
      That's why I said it was a bad example...
      What I was meaning though was that if you had the SPEs less specialised (say as more generic PowerPC style cores) then it might get a bit more interesting.

      Perhaps the best example is just a hypothetical future CPU with dozens/hundreds of CPUs on it - how do we program that - I really hope this is a problem the general programming community move towards solving now (like that'll ever happen :-))

      I'm just thinking when the majority of desktop users have a dozen cores on their desktop, how will we use them - or put another way, how will we not. If the language is the the reason to not use those other cores (and C is a very good reason) then the speed of the language is a MAJOR problem...

      BTW I am aware of the issues of parallel architectures - this is a hard problem. However I find it an interesting problem, and assume others would too. Let some people carry on doing their programming in Ruby or whatever the hell they want, let other re-wrire apache (for want of an example) to best make use of these many cores/cpus. Let's make this re-write easy by a language that supports these arcitectures, not a language designed for a single threaded processor.

      --
      "The weirdest thing about a mind, is that every answer that you find, is the basis of a brand new cliche" -
    4. Re:What has changed? What should we change? by rs79 · · Score: 0, Troll

      "Will we ever leave C behind? "

      (clears throat) I was the second person to use gcc. Keep in mind though it didn't start as gcc: DECUS-C begat GCC and DECUS C became so when Dave Conroy donated the RSX-11M C compiler he wrote to DECUS. We couldn't get a UNIX licence and we had to use RSX. I worked with Dave at Teklogix in the late 70's and Vik Sondi and I were the only people besides Dave that used it while he was writing it. Back then PDP-11's were the entire universe and since of course dmr wrote C for the same machine it translated very very well. God I miss that instruction set, the last decent one ever made. But I digress.

      We would compile a module then look over the assembly code. If we didn't like the code it produced (for the robotics crap we were doing) we'd change the source... or bug Dave.

      C was meant to be a shorthand for Assembly. It really helps if you keep this in mind and write very simple C or know somewhat what the compiler it likely to spit out. Some of the C I've seen makes me fucking cringe frankly. Dan Benrstine gets it. Nicest C code I've ever seen. I'm digressing again, aren't I?

      Yet, golly, there sure is a lot of C. Little things like all of unix and all the server software running this here intarweeb.

      Nobody is more surprised that C is still going as strong as it is as dmr. He's happy.

      Will C be around forever? Probably. RPG still is, and it's bloody useless. C may be replaced at some point when something better comes along. I don't expect to see this in my lifetime. And I'm only in my 40s (just).

      --
      Need Mercedes parts ?
    5. Re:What has changed? What should we change? by rufty_tufty · · Score: 1

      *Bangs head on desk*

      "Rubbish. C is at home on Harvard as it is on Von-Neumann"
      Ok Mr AC you make a grand point - considering most CPUs with their MMUs separating Data and Instruction address spaces are as good as Harvard too.

      By Von Neumann I was simplfying there, there are many architectures that are compatable with C - however there are many that aren't.
      An easy example for me is something like the transputer, although C compilers ended up being developed for it(in the end), it was a bodge and I see C as a stranglehold.
      As the person below says, C is a great shorthand for assembler - I just hope people realise that's what it often is.

      --
      "The weirdest thing about a mind, is that every answer that you find, is the basis of a brand new cliche" -
    6. Re:What has changed? What should we change? by mwvdlee · · Score: 1

      I am intrigued by the idea of a language developed solely for parallel processors (which isn't necesarily the same as multithreaded, though I think we're talking about the same idea here).
      What would make a language suitable for parallel CPU's and what is it about a single-CPU language that makes it a single-CPU language and stops it from being suitable for parallel CPU's?
      I can imagine you'd want to handle memory allocation differently, and perhaps you'd need to look at functions in a way as to intrinsicly avoid deadlocks.
      Are current methods of using semaphores, mutexes, locking, etc. truely the best way to handle such problems or are they just kludges and would a more fundamental approach be possible?

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    7. Re:What has changed? What should we change? by rufty_tufty · · Score: 1

      Well I'd love to see C stick around as the language for programming micros and other single process machines at the metal level. It does that job great! Most of my hardware test scripts are written in C, it does the job great!

      I'm just not sure it's the best tool to write all the software on my computer in.
      I suppose we're already seeing a migration away from C in the highest application levels - but I can't justify that.

      --
      "The weirdest thing about a mind, is that every answer that you find, is the basis of a brand new cliche" -
    8. Re:What has changed? What should we change? by Erich · · Score: 1
      Since the cell cores (the SPE's) are so specialized, I doubt you'll be able to use ANY generic programming language.
      If you can do loads, stores, adds, shifts, logicals, compares, and branches, you can generate a C compiler.

      You can write a C compiler for the SPEs on Cell.

      --

      -- Erich

      Slashdot reader since 1997

    9. Re:What has changed? What should we change? by TheRaven64 · · Score: 1

      Erlang is a good example of a language designed for concurrency. It has process creation and message passing primitives in the language, and scales incredibly well (I've used it for deploying code on a large SMP box and a cluster).

      --
      I am TheRaven on Soylent News
    10. Re:What has changed? What should we change? by Mikkeles · · Score: 1

      'I am intrigued by the idea of a language developed solely for parallel processors ...'

      occam?

      --
      Great minds think alike; fools seldom differ.
    11. Re:What has changed? What should we change? by adisakp · · Score: 1

      FWIW, I'm a PS3 developer and the preferred method (i.e. generates the fastest code for the general case) for programming SPU's is to use C with intrinsics. C mind you... not C++. Heavy use of esoteric C++ features on the SPU's just generates some of the worst performing binary code you might ever see. Plus, there are lots of compiler specific (GCC) tricks though. A great place to see some of the performance tricks on CELL is on PS3 developer Mike Acton's site http://www.cellperformance.com/

      I prefer to use general optimizations first over compiler specific ones but if top performance is required (and in video games it often is) you have to occasionally make sacrifices of portability and code readability for speed in low level routines.

  12. It goes both ways by JanneM · · Score: 4, Interesting

    Sure, CPU:s look quite a bit different now than they did 20+ years ago. On the other hand, CPU designs do heavily take into account what features are being used by the application code expected to be run on them, and one constant you can still depend on is that most of that application code is going to be machine-generated by a C compiler.

    For instance, 20 years ago there was nothing strange about having an actual quicksort machine instruction (VAXen had it). One expectation was still, at the time, that a lot of code would be generated directly by humans, so instructions and instruction designs catering to that use-case were developed. But by around then, most code was machine generated by a compiler, and since the compiler had little high-level semantics to work with, the high-level instructions - and most low-level one's too - went unused; this was one impetus for the development of RISC machines, by the way.

    So, as long as a lot of coding is done in C and C++ (and especially in the embedded space, where you have most rapid CPU development, almost all coding is), designs will never stray far away from the requirements of that language. Better compilers have allowed designers to stray further, but stray too far and you get penalized in the market.

    --
    Trust the Computer. The Computer is your friend.
    1. Re:It goes both ways by pesc · · Score: 4, Informative

      20 years ago there was nothing strange about having an actual quicksort machine instruction (VAXen had it).

      While the VAX had some complex instructions (such as double-linked queue handling), it did not have a quicksort instruction.

      Here is the instruction set manual.

      --

      )9TSS
    2. Re:It goes both ways by JanneM · · Score: 1

      Hm, I'm misremembering it then. Was it perhaps one of the late-model PDP:s? I know one machine of that era had it, and of course now I can't remember correctly which one :(

      --
      Trust the Computer. The Computer is your friend.
    3. Re:It goes both ways by Trailer+Trash · · Score: 2, Informative
      For instance, 20 years ago there was nothing strange about having an actual quicksort machine instruction (VAXen had it). One expectation was still, at the time, that a lot of code would be generated directly by humans, so instructions and instruction designs catering to that use-case were developed. But by around then, most code was machine generated by a compiler, and since the compiler had little high-level semantics to work with, the high-level instructions - and most low-level one's too - went unused; this was one impetus for the development of RISC machines, by the way.

      As someone else mentioned, there is no quicksort instruction. That's far too complex and involves looping and conditional branching. Probably the most complex of vax instructions was the polyf/polyg instruction, which would compute a polynomial to 7 iterations thus allowing one instruction to compute a trigonometric function. There were also instructions for copying strings up to 64k (and those instructions were interruptable), and instructions to format numbers a la cobol pics. These instructions were generally emulated in the smaller microvaxen and such, but were in microcode on the larger ones. Note that even x86 has a string copy instruction.

      Now, here's where you're really wrong. Those instructions weren't put in there as a convenience to humans writing in assembly. Instead, they were put in there as a convenience to compiler writers who could make use of the high-level assembly instructions to ease their code generation. The cobol compiler was almost unnecessary. They had numeric data types to cover it, it was nuts.

      They also had instructions to deal with octawords (128 bit integers), and of course the vax allowed accesses of any size integer on any boundary, which could mean a couple of fetches for a particular piece of data. There are assembly instructions to force alignment.

      The only non-magic of which I'm aware is that it was "required" that between writing a piece of code into memory and executing it there should be an intervening rei instruction, apparently to clear all caching. I put the word "required" in quotes for a reason. A professor at a college that I attended wrote a very popular Scheme compiler. I mentioned one day to a grad-student friend this requirement, and somehow we ended up getting to the prof. He didn't have that in his compiler and it worked just fine writing to a piece of memory then executing it. I showed him the page in the VAX Architecture Handbook (probably around 276 or 278) and we got a good chuckle.

      Anyway, shortly after VAX came out people started to seriously think about simplifying the instruction set and putting more burden on the compilers. I still believe the Alpha is probably the king of risc, ironic given that VAX is the king of cisc. Most of the lessons that VAX taught us were in the negative.

    4. Re:It goes both ways by Waffle+Iron · · Score: 3, Interesting
      That reminds me of the most specialized machine instruction I ever saw. Back in the 80s I was in a EE lab where we made our own CPUs on breadboards out of AMD bitslice chips, then we implemented the specified instruction set in microcode. A large chunk of the grade was based on the lab instructor running a standard test program on each team's "system" and checking the expected results.

      One guy I knew realized that he was never going to get his rig stable enough to run through the whole test, so he set up a single opcode to just dump the entire expected output of the test program to the printer then halt. IIRC, he pulled it off.

    5. Re:It goes both ways by VAXcat · · Score: 1

      Nope, it wasn't the PDP-11s either. The VAX's most complicated, least used and most poorly understood instructions were POLYx, CRC, and INDEX (the Vector instructions were middlin' complicated as well, but not a lot of Vector processor equipped VAXes were produced and sold).

      --
      There is no God, and Dirac is his prophet.
  13. High-level languages have an advantage by Bogtha · · Score: 5, Insightful

    The more abstract a language is, the better a compiler can understand what you are doing. If you write out twenty instructions to do something in a low-level language, it's a lot of work to figure out that what matters isn't that the instructions get executed, but the end result. If you write out one instruction in a high-level language that does the same thing, the compiler can decide how best to get that result without trying to figure out if it's okay to throw away the code you've written. Optimisation is easier and safer.

    Furthermore, the bottleneck is often in the programmer's brain rather than the code. If programmers could write code ten times faster, that executes a tenth as quickly, that would actually be a beneficial trade-off for many (most?) organisations. High-level languages help with programmer productivity. I know that it's considered a mark of programmer ability to write the most efficient code possible, but it's a mark of software engineer ability to get the programming done faster while still meeting performance constraints.

    --
    Bogtha Bogtha Bogtha
    1. Re:High-level languages have an advantage by Eivind · · Score: 5, Insightful
      If programmers could write code ten times faster, that executes a tenth as quickly, that would actually be a beneficial trade-off for many (most?) organisations.

      Especially since you can combine. Even in high-performance applications there's typically a only a tiny fraction of the code that actually needs to be efficient, it's perfectly common to have 99% of the time spent in 5% of the code.

      Which means that in basically all cases you're going to be better off writing everything in a high-level language and then optimize only those routines that need it later.

      That way you make less mistakes, and get higher-quality better code quicker for the 95% of the code where efficiency is unimportant, and you can spend even more time on optimizing those few spots where it matters.

    2. Re:High-level languages have an advantage by StormReaver · · Score: 2, Informative

      "If programmers could write code ten times faster, that executes a tenth as quickly, that would actually be a beneficial trade-off for many (most?) organisations."

      This sound perfectly reasonable in theory. In practice, however, it's not. Users want speedy development AND speedy execution. I developed a Java image management program for crime scene photos, and the Sheriff Patrol's commander told me flat out: we'll never use this. It's too slow.

      I rewrote the program using C++ and Qt, and gained a massive speed improvement. The Sheriff Patrol and detective units have been using it ever since, and they love it. I had been a Java booster for upwards of eight years until then. That was (roughly) three years ago, and I haven't written a line of Java since. I have, however, run my historic Java programs in SUN's most recent JVM. The newer hardware runs it faster, but Qt/C++ still smokes Java. Qt gives me speedy development, and C++ gives me fast execution. It's the best of both worlds.

    3. Re:High-level languages have an advantage by D-Cypell · · Score: 1, Insightful

      I am going to assume there are some rounding errors in your 8+3 years because you are going back to a time prior to the first Java release. It is feasible that your worked for Sun but I would think you would have mentioned it.

      "It's the best of both worlds"

      The problem with that assertion is that software development has more than two worlds :). I remain a Java booster but even I would have raised an eyebrow if you had come to me to suggest the development of a photo manipulation tool using Java. Sure, it can be done but you can loosen a bolt with a hammer and chisel. To be perfectly frank, your example sounds like a text book example of a poor work-man blaming his tools.

      There are applications that benefit from running in a managed environment, and spend the vast majority of their time waiting for input or shifting memory around. These are cases where QT and C++ would be bad choices (the consequences of 'mis-shifting' memory in a language like C++ are well documented). Java wouldn't be the only choice, but I wouldn't call you crazy (or a bad work-man) for making that choice.

      Please don't fall into the trap of using the wrong tool and then blaming the tool when things go wrong. This is exactly the kind of thing that has been plastered all over these discussions for the last ten years or so.

    4. Re:High-level languages have an advantage by espressojim · · Score: 1
      If programmers could write code ten times faster, that executes a tenth as quickly, that would actually be a beneficial trade-off for many (most?) organisations


      Sounds perfect for prototyping. I'd love to have some code I could bang out to prototype a system, because my users often like to say "We'll know it's what we want when we see it." - and while you can say it's best to push the users harder, you'd be suprised at how well quick mockups work instead of taking huge amounts of time to spec on paper. Eventually, the mockups become to spec (or the use cases), then we can code. Doing that 10x faster would be fantastic.

      Heck, at that point, users could play with the 'slow' version and fix workflow issues, etc, until the 'fast' version that supports the wider audience comes out.
    5. Re:High-level languages have an advantage by mrsbrisby · · Score: 2, Insightful

      The more abstract a language is, the better a compiler can understand what you are doing

      Except it doesn't. Nobody has written a compiler that smart, and I don't care what anyone says: I don't think anyone ever will.

      Learning how to invent and develop algorithms is important. Learning how to translate those algorithms into various languages is important. And knowing how the compiler will translate those algorithms into machine instructions- and how the CPU itself will process those machine instructions, will yield a lot more performance than choice of languages.

      Consider djbfft, one of the fastest FFT implementations, outruns many FFT implementations in Java, Haskell, Lisp, or assembly, and yet it's written in C.

      Don't confuse me: I'm not saying C is fast, or C is good, I'm saying djbfft is good. Reordering the instructions in the C code will lower the efficiency- even if the code is otherwise equivelent.

      That said, I agree with almost everything else in your post.

    6. Re:High-level languages have an advantage by IamTheRealMike · · Score: 1

      What does a photo management application do if not spend the vast majority of their time waiting for input or shifting memory around?

      Managed code has always been pushed by Sun and more recently Microsoft as The Way to develop all new applications, not just some. Do Sun tell you to write new client side applications in C++? Er, no. They say use Java. And everybody ignores them because it has been learned the hard way that Java has atrocious client side performance and is completely unsuitable for that. But this is hardly a case of poor workmanship - no matter how good a programmer you are, Java client side apps will always suck, it is inherant to the design of the platform.

    7. Re:High-level languages have an advantage by Just+Some+Guy · · Score: 1
      If programmers could write code ten times faster, that executes a tenth as quickly, that would actually be a beneficial trade-off for many (most?) organisations. High-level languages help with programmer productivity.

      I wrote my company's web application in Python on Zope. Although neither of those are screamingly fast by themselves, most of the real work is done by calls to PostgreSQL and Imagemagick. Our production server is currently 72% idle with a load average of 0.48.

      I have a lot of easy-to-read high level code that isn't a maintenance problem, and my application code could take ten times as long to execute and the machine would still have plenty of cycles left over to keep up with demandJ. There are places where bare metal optimization is appropriate, but I'm more than happy to glue that stuff together with code that lets me concentrate on algorithms instead of implementation.

      --
      Dewey, what part of this looks like authorities should be involved?
    8. Re:High-level languages have an advantage by Anonymous Coward · · Score: 0

      I know that it's considered a mark of programmer ability to write the most efficient code possible, but it's a mark of software engineer ability to get the programming done faster while still meeting performance constraints.

      That would be the mark of a programmer's administrator, if such a think exists. Engineering should care about quality before cost.

    9. Re:High-level languages have an advantage by Anonymous Coward · · Score: 0

      That's beside the point. Computers aren't creative, so naturally a manual optimization of a tight loop will result in faster code. But most programs aren't hand optimized, not even the 1% where the program spends 99% of the CPU time. That's why it's important to find the right level of abstraction. Every compiler improvement, hardware acceleration, etc, will then boost all programs. If your language is too close to the machine, the compiler can't optimize, but you don't get the benefits of being so close to the machine either, because you don't have the time to handtune your code.

    10. Re:High-level languages have an advantage by D-Cypell · · Score: 1

      What does a photo management application do if not spend the vast majority of their time waiting for input or shifting memory around?

      Clearly, I was not involved in the development of this particular project, but many image processing applications are processor bound. Companies like pixar need tremendous processing power to do the kind of heavy lifting required to render their movies. This is not a sensible application of Java. I made the assumption that this was where the grandparent's application was slow, in the image manipulation. Maybe it was a flawed assumption, but it is based on the information available.

      Managed code has always been pushed by Sun and more recently Microsoft as The Way to develop all new applications, not just some.

      Some types of client side application are well suited to Java or C#. There are some that are not, and the only people who think that you can write any application in Java are those who work for Sun or Microsoft's marketing department. No decent developer that I have every met (Sun/Microsoft employee or not) would seriously suggest that we have a 'one size fits all' language available today. Selecting the right tools for the job is part of the software developer's role. Selecting the wrong tool for the job is poor workmanship, by definition.

      no matter how good a programmer you are, Java client side apps will always suck, it is inherant to the design of the platform.

      Nonsense! My Java IDE is 100% pure Java and performs to a level that I am completely satisfied with. If it did not, I would not pay the license fee. I have personally written applications in Swing that perform. It takes a little more than Sun might have you believe and you need a little experience of the platform but do not assume that just because you cannot do it, that it cannot be done.

    11. Re:High-level languages have an advantage by Dun+Malg · · Score: 1
      I am going to assume there are some rounding errors in your 8+3 years because you are going back to a time prior to the first Java release.
      Java was publicly released 23 May 1995, just a hair over 11 years ago.
      --
      If a job's not worth doing, it's not worth doing right.
    12. Re:High-level languages have an advantage by rpg25 · · Score: 1

      I'm a high-level language lover --- for work I mostly use Common Lisp, with some side trips into perl, prolog and domain specific languages that are ultra-high level. I do agree that these languages can let you get efficient use of programmer cycles.

      But it's also worth keeping in mind Alan Perlis' old adage "Lisp programmers know the value of everything and the cost of nothing." All too often programmers, especially novice programmers, write terrible code in ultra high level languages, because they don't have good mental models of how the expressions in the languages are executed. Yes, the compiler can be clever, but for places where the compiler can't do the job, novices may get into trouble. For example, I have looked at Lisp code from a very respected source that kept a queue of objects that got to be 10,000s long, implemented as a list, and doing a lot of appends. This involves a simply horrific amount of pointer-chasing.

      Programming environments that simulate non-determinism (e.g., prolog, many AI programs) can be even worse, since it's hard to envision how programs that search and backtrack will work.

      So, "yes," but also "yes, but."

    13. Re:High-level languages have an advantage by IamTheRealMike · · Score: 1

      Hmm, well they may perform well on your computer, unfortunately every Java based IDE I have ever used was slow even on very fast corporate machines. On my old 256mb RAM/1.2ghz chip they are all unusable. In the end I always went back to emacs because it beat waiting for 10 seconds every time I invoked a command whilst the machine thrashed around.

      Any language in which "Hello World" takes more than quadruple the storage space of the raw ASCII string has got serious performance problems in my books ...

    14. Re:High-level languages have an advantage by the_greywolf · · Score: 1
      no matter how good a programmer you are, Java client side apps will always suck, it is inherant to the design of the platform.

      Nonsense! My Java IDE is 100% pure Java and performs to a level that I am completely satisfied with. If it did not, I would not pay the license fee. I have personally written applications in Swing that perform. It takes a little more than Sun might have you believe and you need a little experience of the platform but do not assume that just because you cannot do it, that it cannot be done.

      When I tried Eclipse for the first time (fairly recently, shortly after Eclipse 3.0's release), I found it to be too slow on my system (Athlon XP 2100+, 512MB RAM at the time) and dropped it in favor of other, more responsive IDEs. (...I've since dropped IDEs entirely and have resigned myself to Vim.) I was completely disillusioned by everything I had heard about Eclipse. By all rights, I expected it to be the best IDE out there.

      Now, I admit that I did like the featureset (despite my misgivings about the GUI). And, despite my difficulty in getting the C/C++ plugins working (import errors galore), I honestly did think it was the best IDE I'd ever seen. It's certainly superior to Visual Studio, IMO. However, I was constantly frustrated by the slow response (~1 second for a keystroke response) and the apallingly slow load/save.

      Now, because of my horrible experience with Eclipse and Azureus (both rather large codebases), I have completely written Java off for any client-side development. JVM startup, IMO, makes it useless for small tools, and I have yet to see a reasonable CLI utility written in Java.

      If Java really does have a niche where it actually fits, I'd like to see it.

      --
      grey wolf
      LET FORTRAN DIE!
    15. Re:High-level languages have an advantage by E++99 · · Score: 1
      If you write out one instruction in a high-level language that does the same thing, the compiler can decide how best to get that result...
      Yes, but if the "high-level compiler" has a single instruction to do the thing you want to do, then is a programmer really needed?

      The more abstract a language is, the better a compiler can understand what you are doing.
      No compiler ever written can understand what you are doing. (Aside, arguably, from the single-instruction example.) The very best a compiler can hypothetically do is modify your instructions into their faster-running logical equivilents. In my experience, the best that can be hoped for from optimization (at any level language) is it that implements your instructions in a way that isn't overtly stupid. When something truely needs to be optimized, (at any level language) it means a programmer needs to optimize it -- which means either rethinking the implementation or dropping down to a lower level. Well, in theory. In real life it very often means discovering the bone-headed way that the compiler (or OS API, etc) implements the instruction you were using and switching to a different instruction.
    16. Re:High-level languages have an advantage by Anonymous Coward · · Score: 0

      Just a quick plug for those who would like to study how compilers generate machine code so they can produce better (machine) code from their HLLs:

      http://www.amazon.com/gp/product/1593270038/ref=pd _bxgy_img_b/104-8691495-4337534?ie=UTF8

    17. Re:High-level languages have an advantage by Ambassador+Kosh · · Score: 1

      I want to add to this that most high level languages have highly optimized primatives and large standard libraries. While it is true that about 99% of the time is spent in 5% of the code it often works out that the 5% of code can be handed off to built in language features and standard libraries. For example it is unlikely that you will be able to beat the built in dictionary code in python or the sorting routines. Also there are many language structures which sure make it easier to write more efficient code.

      1 So what I suggest is first write your code in a high level language
      2 Profile the code
      3 Find the slower parts and see what there is built into the language that can handle that problem
      4 Profile the code
      5 Replace algorithms with more efficient ones
      6 Profile the code
      7 Find external libraries in wide usage that you can pass off work to
      8 Profile the code
      9 Hand Code your own optimized functions for what is left

      Most applications don't get beyond step 3 and very few get beyond step 5. Also as you get more experience you learn more about what language features you should always hand off to and what algorithms are more appropriate for a situation so you find yourself coding around step 5 anyways but that takes experience. I have found this leads to code that executes quickly, has vastly fewer bugs, and is easier to maintian long term.

      I know there are a lot of slow programs written in python but there are also many fast ones. The biggest issue I see for faster programs in higher level languages is people that don't learn them. What I mean is that you find many people that say they know 20 different languages but they really write the same code the same way in all of them. The most obvious example I can think of in python is that strings are immutable. Building up a large string by adding a lot of little strings together is extremely expensive. I have worked with people that came from c/c++ backgrounds and they would just always do things that way no matter how often they where shown better ways to do the same thing. As a result, depending on the size of the dataset, their programs would run 10 to 1000x slower then they should have, they also used more memory which further slowed things down. Heck I have even watched someone spend several days writing a custom sorting routine in python instead of using the built in sort. Their code was buggy, did not sort correctly in many cases and ran about 100x slower then the built in sort.

      So I do agree that higher level languages can give you faster performance in most general purpose applications, ie don't write device drivers in it. However the actual performance of a given solution is mostly based on how good a programmer is. Well written python will run faster then badly written c. Well written c will run faster then badly written python etc.

      --
      Computer modeling for biotech drug manufacturing is HARD! :)
    18. Re:High-level languages have an advantage by Anonymous Coward · · Score: 0

      I found it to be too slow on my system (Athlon XP 2100+, 512MB RAM at the time)

      *Wince* Can Xp do anything worthwhile in 512Mb?

    19. Re:High-level languages have an advantage by the_greywolf · · Score: 1
      *Wince* Can Xp do anything worthwhile in 512Mb?

      ...XP being the nomenclature for this particular Thoroughbred-B processor, not the name of the operating system (or distro) in question: Gentoo Linux.

      --
      grey wolf
      LET FORTRAN DIE!
  14. Typical Java Handwaving by mlwmohawk · · Score: 5, Insightful

    The first mistake: Confusing "compile" performance with execution performance. The job of maping C/C++ code to machine code is trivial.

    I've been programming professionally for over 20 years, and for those 20 years, the argument is that computers are now fast enough to allow high level languages and we don't need those dirty nasty assemblers and low level languages.

    What was true 20 years ago is still true today, well written code in a low level language tailored to how the computer actually works will always be faster than a higher level environment.

    The problem with computer science today is that the professors are "preaching" a hypothetical computer with no limitations. Suggesting that "real" limitations of computers are somehow unimportant.

    If computer science isn't about computers, what is it about? I haate that students coming out of universities, when asked about registers and how would they write a multiply routine if they only had shifts and adds, ask "why do I need to know this?"

    Software sucks today because software engineers don't understand computers, and that's why languages and environments like Java and .NET will make software worse.

    1. Re:Typical Java Handwaving by lukas84 · · Score: 1

      I don't have as much experience as you do, and iam not a software developer either.

      But i would like to offer an alternative point of view to the one you have.

      I certainly don't understand everything my computer does. The main reason for this is because computers today are more complex then ever.

      Several years ago, a system administrator might have known how a file is written to a hard disk, and how the hard disk calculates the appropiate checksum for the data it writes.

      This is no longer the case, because these problems have been completely abstracted from us. The hard disk gets an amber light, and if that amber light is lit, the disk is broken.

      This is so, because we can afford to have redundancy in our hard disks, and we no longer need to understand how they work exactly.

      Why would this be any different for software developers? Many things can be abstracted, if you can afford the abstraction (which always comes at a cost). I don't think that this is wrong, because it helps us to create even better systems.

      Take a look at todays cars. A few decades ago, you had a "trained" driver, which usually could dismantle the entire car, and then build it up again. This is no longer the case. Many things in cars have been abstracted, you just need to turn a key in order to start your engine, or just press the gas, the gears get shifted automatically, and when breaking the ABS handles distribution automatically.

      This is the same as newer environments like Java and .NET. Of course, an Idiot might write nonsense code in .NET, but that doesn't mean .NET is a bad thing. An idiot can also crash his ESP controlled car into the next tree, if he goes into a curve with 150km/h.

    2. Re:Typical Java Handwaving by iotaborg · · Score: 2, Insightful
      If computer science isn't about computers, what is it about?

      I was rather under the impression that computer science was the theory of computation, where the computer is simply a tool; just as much as a soldering iron is a tool in electrical engineering.
    3. Re:Typical Java Handwaving by cain · · Score: 5, Insightful
      If computer science isn't about computers, what is it about?

      "Computer science is no more about computers than astronomy is about telescopes" -- Edsger Dijkstra quotes (Dutch computer Scientist. Turing Award in 1972. 1930-2002)

      Sorry, you're arguing against Dijkstra: you lose. :)

    4. Re:Typical Java Handwaving by rbarreira · · Score: 2, Insightful
      Of course, an Idiot might write nonsense code in .NET, but that doesn't mean .NET is a bad thing.

      I think his point was not that abstractions are bad, but that not knowing what's happening behind the scenes isn't good.
      Even to optimize .NET code, sometimes it's good to inspect the generated CIL (or even asm!) code in order to know why something isn't going fast.
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    5. Re:Typical Java Handwaving by rayzat · · Score: 1

      I see what you're saying and some people need to learn how to do the add-shift multiplier, I believe these are your Computer Engineers today, not your software engineers, they tend to be the ones involved in you're low level voodoo, but think of it like this. 20 years ago when you were in school you spent 4 years learning how to program in C and assembly in order to execute add-shift multipliers. Today students still go to school for 4 years but have so much more to learn about. Where is the time for object oriented programming techniques, advanced data structures, multi-threaded software design, comm. theory, vector programming, and everything else if people are spending their time learning about add-shift multipliers or whatever archaic multi-step register operation you can think of.

    6. Re:Typical Java Handwaving by Jeff+DeMaagd · · Score: 1

      I think the point was that computing performance is scaling up so much that the time laboring over human obtimization isn't well-spent if one can upgrade to a faster server/desktop/workstation for less money than the developer's time is worth. This is particularly true for small projects, where maintainability is important. Next year, we will see two four core CPUs on a workstation, the following year or two, it may be a single eight core chip. How do you take good advantage of that in C? I don't know, and I've done a fair share of C programming. I know it can be done, but I think there are better ways to spend a developer's time.

    7. Re:Typical Java Handwaving by rbarreira · · Score: 1

      Sorry, but in the context of a rational argument, appeal to authority is a logical fallacy. I respect Dijkstra a lot but that quote doesn't seem particularly accurate. Telescopes appeared to help astronomers. The case with computers/programming and computer science is the opposite.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    8. Re:Typical Java Handwaving by arevos · · Score: 4, Insightful
      The first mistake: Confusing "compile" performance with execution performance. The job of maping C/C++ code to machine code is trivial.

      I've designed compilers before, and I wouldn't class constructing a C/C++ compiler as "trivial" :)

      If computer science isn't about computers, what is it about? I haate that students coming out of universities, when asked about registers and how would they write a multiply routine if they only had shifts and adds, ask "why do I need to know this?"

      One could also make the opposite argument. Many computer courses teach languages such as C++, C# and Java, which all have connections to low level code. C# has its pointers and gotos, Java has its primatives, C++ has all of the above. There aren't many courses that focus more heavily on highly abstracted languages, such as Lisp.

      And I think this is more important, really. Sure, there are many benefits to knowing the low level details of the system you're programming on; but its not essential to know, whilst it is essential to understand how to approach a programming problem. I'm not saying that an understanding of low level computational operations isn't important, merely that it is more important to know the abstract generalities.

      Or, to put it another way, knowing how a computer works is not the same as knowing how to program effectively. At best, it's a subset of a wider field. At worst, it's something that is largely irrelevant to a growing number of programmers. I went to a University that dealt quite extensively with low level hardware and networking, and a significant proportion of the marks of my first year came from coding assembly and C for 680008 processors. Despite this, I can't think of many benefits such knowledge has when, say, designing a web application on Ruby on Rails. Perhaps you can suggest some?

      Software sucks today because software engineers don't understand computers, and that's why languages and environments like Java and .NET will make software worse.

      I disagree. I think software sucks because software engineers don't understand programming

    9. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      You wrote:
      "Computer science is no more about computers than astronomy is about telescopes" -- Edsger Dijkstra quotes (Dutch computer Scientist. Turing Award in 1972. 1930-2002)

      There is a LOT of debate about computer science, and while Dijkstra is well respected, he is certainly not the only source of wisdom on the subject. Computer science MUST include the real-world functioning of computers, otherwise it is merely calculus.

    10. Re:Typical Java Handwaving by rbarreira · · Score: 1

      The computer isn't simply a tool for helping computer scientists, it's much more than that. Nowadays, I'd say that it's much more important to have computer science helping computer-related endeavors, than the opposite.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    11. Re:Typical Java Handwaving by Oligonicella · · Score: 4, Insightful

      "The job of maping C/C++ code to machine code is trivial."

      Which machine, chum?

      "I've been programming professionally for over 20 years..."

      OK, bump chests. I've been at it for 35+. And? Experience doth not beget competence. There are uses for low-level languages and those that require them will use them. Try writing a 300+ module banking application in assembler. By the time you do, it will be outdated. Not because the language will change, but because the banking requirements will. Using assembler to write an application of that magnitude is like trying to write an Encyclopedia article with paper and pencil. Possible, but 'tarded.

      "Software sucks today because software engineers don't understand computers, and that's why languages and environments like Java and .NET will make software worse."

      More like, 'software sucks today for the same reason it always has -- fossized thinkers can't change to make things easier for those who necessarily follow them.' Ego, no more.

    12. Re:Typical Java Handwaving by rbarreira · · Score: 1

      Ultimately, I'd say not knowing what happens behind the abstractions is bad. I know (or can at least easily research and think about) everything what happens behind every line of .NET or Java code that you show me, and that is crucial for understanding debugging and optimization techniques. Can you say the same about most programmers out there?

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    13. Re:Typical Java Handwaving by cain · · Score: 1
      Hmmm. Heard of emoticons? They look like this :) . That partiular one means "smile," as in this is a little joke.

      Appeal to authority is not always a logical fallacy. It can also be a valid tool for supporting an argument. Why just see this page for proof. :) If the authority is an actual authority on the topic at hand, then it increases the power of the argument. Are you suggesting that Dijkstra isn't an authority in CS? Good luck arguing that one. :)

      (Note the smiley). :) Heh.

    14. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      >Sorry, but in the context of a rational argument, appeal to authority is a logical fallacy.

      As opposed to appeal to random /. posters? Considering the cluelessness displayed around here, I wouldn't be so quick to appeal to that if I were you.

      Unless you have an actual response to Dijkstra's objections, I'll agree with the OP: you lose, hard.

    15. Re:Typical Java Handwaving by cain · · Score: 1

      I 3 calculus! Yay calculus!

    16. Re:Typical Java Handwaving by mrchaotica · · Score: 1
      Telescopes appeared to help astronomers. The case with computers/programming and computer science is the opposite.

      No, it's exactly the same: computers arrived to help mathematicians (and scientists, and engineers, and writers, and everyone else).

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    17. Re:Typical Java Handwaving by rbarreira · · Score: 1

      That doesn't mean that computer science doesn't, in a big sense, exist to support programmers today. Computer science isn't just an end in itself (although it can be in some ways).

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    18. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0
      He did have a response to Dijkstra's objection, and I thought it was actually pretty good:
      Telescopes appeared to help astronomers. The case with computers/programming and computer science is the opposite.
    19. Re:Typical Java Handwaving by rbarreira · · Score: 1

      The meaning of smileys is a bit dubious sometimes, but here are some for you then ;)

      Are you suggesting that Dijkstra isn't an authority in CS?

      Yes, and I have a proof for it! A dead person isn't an authority in anything else than being dead :P

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    20. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0
      > What was true 20 years ago is still true today, well written code in > a low level language tailored to how the computer actually works will > always be faster than a higher level environment.

      No. Computer AI is not there yet but we are slowly getting there (CPU & techniques). My guess is that computer AI in a specific topics like compilation will defeat humans in ~ 20 years.

      You also didn't read the article. It was mostly about the vectorization (SIMD). C/C++ don't provide native vector operations when compared to higher level languages like FORTRAN which have proper high level primitives for efficient compilation for nowadays machines.

    21. Re:Typical Java Handwaving by mlwmohawk · · Score: 1

      "Experience doth not beget competence."

      One may observe this is is absolutely true, your post makes this perfectly clear. (OK, enough insulting)

      Nice strawman argument about the assembler, it has, of course, no impact on this discussion.

      "More like, 'software sucks today for the same reason it always has -- fossized thinkers can't change to make things easier for those who necessarily follow them.' Ego, no more."

      My favorite Einstein quote is "It should be as simple as possible, but no simpler." There is a point at which over simplifying something inherently complex is counter productive.

      High level languages have always had a place between fundimentally more complex concepts and mere user interfacing. What I have a problem with is the ignorance of "real" computers in supposed "computer scientists," who, in the course of their careers, will make poorly informed decisions and cause software to suck even more.

      We can't forget that software which we write must eventually run on a real computer.

    22. Re:Typical Java Handwaving by 14CharUsername · · Score: 1
      Compiled languages are always faster than VMs. if they make a computer 100 times more powerful, the compiled language will still be faster than the VMs.

      How do you take advantage of multi-cores in C/C++? Same way you take advantage of them in a VM. Someone makes an API for it. you read the docs and figure it out. Anything that can be done in a VM can be done in native code, only native code will be faster.

    23. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      Go back to school dinosaur!
      Ever heard of an 'operating system'
      You are wasting your time building low level programs on computers with 'operating systems' since the 'operating system' is utimatley in control anyway.

    24. Re:Typical Java Handwaving by 14CharUsername · · Score: 1
      That low-level stuff is important if you have code that needs to run fast. Need to multiply a number by a constant? You can use shifts and adds instead. Does the same thing, but takes the processor less time.

      But you don't need to do that often. But knowing how to shift and use the bitwise AND and OR and XOR, is still important. Why? because this is how the computer thinks. It's good enough for a secretary to click an icon and have stuff work without knowing how, but a computer programmer? Sorry, if you don't know "add-shift multipliers or whatever archaic multi-step register operation you can think of" you aren't a programmer. You're something approaching the secretary that just clicks icons. You may know when to use this object or that function, but you don't know why.

      Would you trust an engineer that knew to use X number of steel beams, but had no idea why?

    25. Re:Typical Java Handwaving by cain · · Score: 1

      Holy crap! You got me there. I surrender. :P

    26. Re:Typical Java Handwaving by eraserewind · · Score: 1

      Not knowing what's happening behind the scenes (withing reason) is the whole point of abstraction. They aer hiding it, so they can change it! Just because you know today, doesn't mean you know tomorrow when you have to rewite all that code that takes advantage of how it really worked yesterday. Tomorrow will come sooner than you think for any given application domain, so unless you absolutely must really truly have fast code, it's best to stick with the generic portable way.

    27. Re:Typical Java Handwaving by zettabyte · · Score: 1
      mlwmohawk said: "If computer science isn't about computers, what is it about?"
      cain said: "Computer science is no more about computers than astronomy is about telescopes" -- Edsger Dijkstra
      rbarreira said: "Sorry, but in the context of a rational argument, appeal to authority [wikipedia.org] is a logical fallacy."

      rbarreira, I believe you skipped out of that wikipedia article before reading the last sentence:

      "However, referencing authority may carry a high enough probability of truth that it would be correct to base decisions on it."

      Considering Djikstra's authority in the field, I'd would claim that the statement's probability of truth is quite high, or at least higher than mlwmohawk's. I mean, come on, when was the last time you used MlwMohawks Algorithm to calculate anything?

      Having gutted out a Master's Degree in Computer Science, I know I come down on the side of Dijkstra. Most of the professors I encountered weren't about programming, they were about theory and algorithms.

      mlwmohawk sounds a little curmudgeony, that's all.

    28. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      > Go back to school dinosaur!

      You tell him, you super-educated AC!

      > Ever heard of an 'operating system'

      Oh, shouldn't that have a question mark at the end?

      > ... the 'operating system' is utimatley in control anyway.

      Bugger, you mis-spelled "ultimately". Shit!

    29. Re:Typical Java Handwaving by masklinn · · Score: 0, Troll

      You can't, you're not french and we've patented surrendering in the US!

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    30. Re:Typical Java Handwaving by istartedi · · Score: 1

      "Computer science is no more about computers than astronomy is about telescopes"

      I love this quote. It can be read by snobby theorists to justfiy their ignorance of current hardware issues. It can also be read by technicians to justify their disdain for academic theories. At various times and places, both points of view have their value. I'm glad I've learned some theory. I'm also glad I know well enough not to believe anything until I've coded the solution and tested it. A lot of time, theory loses for reasons having to do with hardware, e.g., Quicksort is not the fastest sort in theory (surprised?) but it is used because it runs well on CPUs that use cacheing.

      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    31. Re:Typical Java Handwaving by rbarreira · · Score: 1

      That's exactly the kind of thinking which sometimes leads to bad programs and systems. Black-boxes are very nice but aren't the answer for everything, and on those cases (which are much less rare than most people think), knowing what's behind the abstractions is more than nice; it's often necessary.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    32. Re:Typical Java Handwaving by rbarreira · · Score: 1

      Probabilities, probabilities...

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    33. Re:Typical Java Handwaving by rs79 · · Score: 0

      "I disagree. I think software sucks because software engineers don't understand programming"

      A programmer that understands assembler and understands how the cpu works will always have a competative advantage to one that doesn't in any language. To quote Andrea Frankel from a couple of decades back oft quoted in cookie files "Always hire a programmer that knows assembler no matter what language they're writing in"

      The flip side is any programmer who REALLY understand programming will know what the machine is doing.

      Most modern client side software is just SO BAD it makes me gag. The server side stuff is still, for the most part, pretty good. Except for the MS garbage.

      Hello world should be 20 bytes or so, not 7 MB. Christ...

      --
      Need Mercedes parts ?
    34. Re:Typical Java Handwaving by arevos · · Score: 1
      A programmer that understands assembler and understands how the cpu works will always have a competative advantage to one that doesn't in any language.

      Can you give me an example of the benefits such knowledge has when programming in a high level language such as, say, Python or Ruby? I can't think of any significant benefits, but perhaps you can?

    35. Re:Typical Java Handwaving by arevos · · Score: 1
      Ultimately, I'd say not knowing what happens behind the abstractions is bad. I know (or can at least easily research and think about) everything what happens behind every line of .NET or Java code that you show me, and that is crucial for understanding debugging and optimization techniques.

      Can you give me an example? Can you give me an example in a more abstracted language than .NET or Java?

    36. Re:Typical Java Handwaving by Erich · · Score: 1
      Quicksort is not the fastest sort in theory (surprised?)

      I am. Show me a sorting algorithm that has better than O(N*log(N)) worst case behavior. You might be able to scrape off a few compares by adjusting the algorithm but the order of the algorithm doesn't get better than N log N. And that's really what matters.

      There are sorting algorithms that work better in the real world, like Timsort.

      The reason brilliant algorithm folks are necessary is that they can figure out how to turn algorithms from N^2 to N log N or N. Djikstra, for instance, figured out an N-order algorithm for determining if two circular lists are equivelant, much better than the N^2 method that probably comes to your mind first. And of course he is most famous for his graph traversal algorithm, which is used all over the internet for Open Shortest Path First routing.

      And, of course, the reason that engineers are necessary is to keep the algorithm guys in the real world, to know what algorithms to pick, and to be able to invent systems that efficiently implement algorithms that solve problems.

      --

      -- Erich

      Slashdot reader since 1997

    37. Re:Typical Java Handwaving by Beek · · Score: 1

      He made that claim, but did little to back it up.

    38. Re:Typical Java Handwaving by Drunken+Priest · · Score: 1
      I disagree. I think software sucks because software engineers don't understand programming

      And I disagree. I think software sucks because programmers don't understand psychology.

      Programmers don't understand that real users will trade control for simplicity.

      If programmers designed cars, there wouldn't be automatic transmissions. There'd probably even be all sorts of gauges displaying like fuel-pressure and things I don't understand about cars...

      Of course, the world has gear-heads who think I ought to be able to fix my own car. Because they don't realize that $20 for an oil change is more worth it for me, than getting under the car (I don't even have an appropriate space to work on my car in).

      Programmers are like gear-heads. They think their assumptions are universal.. not so..

    39. Re:Typical Java Handwaving by Bastian · · Score: 1
      And I think this is more important, really. Sure, there are many benefits to knowing the low level details of the system you're programming on; but its not essential to know, whilst it is essential to understand how to approach a programming problem. I'm not saying that an understanding of low level computational operations isn't important, merely that it is more important to know the abstract generalities.


      Amen. If the classes some people I've programmed with took spent half as much time teaching computer science as they did about teaching random minutia of specific platforms (registers, API calls, whatever - none of that is computer science, it's stuff some would-be textbook author cut-and-pasted from a tech manual), I wouldn't have to spend nearly as much time each day wondering if today is the day that I finally post something to TheDailyWTF. And they wouldn't have to spent quite so much time staring blankly at me every time I say things like "finite state machine."
    40. Re:Typical Java Handwaving by Erich · · Score: 2, Insightful
      That low-level stuff is important if you have code that needs to run fast. Need to multiply a number by a constant? You can use shifts and adds instead. Does the same thing, but takes the processor less time.

      INCORRECT

      . Shifts and adds are sometimes faster for certain constants. Power of two, maybe power-of-two plus one. But for any arbitrary constant, this is false on most processors. Multipliers are much faster than a stream of many shifts and adds. Furthermore, the compiler should hold the knowledge of when a shift-and-add is better-performing than a multiply for what constant values. And, if you're not using MyPrettySchoolProjectCC, it probably does.

      Now what your compiler *really* hopefully knows about is how to make division by a constant into a multiply. That can really save time. Division is an iterative process and is very hard to make fast. Multiplies are highly parallel; you can do large multiplies fully pipelined and with pretty low latency. And you can typically turn a 32 bit / 32 bit divide into a 32x32->64 multiply with the reciprocal. Since you can determine the reciprocal at compile time this is probably a win.

      Maybe you just went to a school where they didn't show you how multiplies are actually implemented on modern hardware. Shift registers with accumulators they aren't. This is also potentially a reason why the professor will tell you that you can't outsmart the compiler. The typical college student can't, because he or she doesn't understand enough about how things really work. But any engineer with a decent amount of experience -- or most grad students -- can outsmart a compiler easily.

      --

      -- Erich

      Slashdot reader since 1997

    41. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      Quicksort is worst case N^2. In typical cases it is N log N with a low coefficient (which is why it is so common). You can sort in order N time (radix sort), but in this case your space needs increase.

    42. Re:Typical Java Handwaving by masklinn · · Score: 1

      WTF? troll? who's the anal retentive mod who did that? I thought that french could at least mock each other...

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    43. Re:Typical Java Handwaving by tomee · · Score: 1

      I see things differently. Sure, low level code is more efficient than high level code if you put a lot of effort into the code, which you probably do in the important core routines of an application where the graphics need to be smooth. But in most other applications and in most of the code of even that application, performance isn't as critical, and what is usually much more important is clean, maintainable and readable code. I contend that a lot of software sucks because people don't write maintainable code, which leads to more bugs, and high level languages with integrated bounds checking and garbage collection tend to reduce the number of bugs. And on the topic of performance, just out of interest, I'm looking forward to seeing how fast applications will run once more and more software is optimized for multi core systems, since high level languages like Java have very neat thread safety features integrated into the language.

    44. Re:Typical Java Handwaving by StrawberryFrog · · Score: 1

      The job of maping C++ code to machine code is trivial.

      Oh ,is it?

      If computer science isn't about computers, what is it about?

      "Computer Science is no more about computers than astronomy is about telescopes." - - E. Dijkstra

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    45. Re:Typical Java Handwaving by arevos · · Score: 1
      If programmers designed cars, there wouldn't be automatic transmissions. There'd probably even be all sorts of gauges displaying like fuel-pressure and things I don't understand about cars...

      In much of the world, there aren't automatic transmissions. In much of Europe, automatics are rather rare. However, that's somewhat beside the point.

      Look at any technology, and you'll see that initially there are more dials and buttons than strictly necessary. Early radios, for instance, had many dials that eventually merged into just two: frequency and volume. One can see similar trends with cars; witness the disappearence of the choke, and in some cases, the gear stick and clutch.

      I think eventually we'll see computing technology become more simplistic. Unfortunately, it's probably all downhill from there, as after simplicity, the trend tends to be toward maximum features (witness the amount of buttons and gizmos on a modern radio, or the number of computerized buttons and gadgets loaded into new cars).

      But yes, I agree with you broadly: the inmates are running the asylum, to borrow a title from a relevant book. However, I don't think that's the primary reason for software sucking. Remember that shrink-wrapped, off-the-shelp desktop software makes up only a minority of the software industry.

    46. Re:Typical Java Handwaving by rayzat · · Score: 1

      Depending on the situation, yes I would trust the engineer if it's SOP. I have a processor manual in front of me, and for some reason it has more commands then shift, and, or, and xor. It has an int mult command, that only take two clock cycles, so any mult done by any other means except a bit shift power of two mult is going to take longer then just executing the mult command. You don't need to know how every low level function works, that's how we make progress. We use the work that other people have done and build off of it. Granted there are specialty positions where in depth knowledge of the use of processor level instructions is necessary, and these people should know how to do that but they learned those skills through special classes, such as a compilers class, an embedded programming class, or etc etc etc. You could also take this to the next level, you're not a computer programmer unless you know how the underlying logic works to execute an add or shift, or you're not a computer programmer unless you know how to design a CMOS circuit in a particular technology to implement a shift register. To say anyone that doesn't know how to do assembly level add-shift multiplies or basic logical operations is just a secretary pushing buttons is wrong. I know many a gifted programmer who write awesome code that does awesome things, and have no idea how this works. I write device drivers on occasion and I need to do things like this on occasion for performance, but I do it so other people don't need to think about how the real interface works. I write the low level code so some other person can write the higher level stuff.

    47. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      Theoretical computer science is an important branch of both mathematics and CS that most CS studnets know far too little about.

      If a software engineer does not understand computers, he has slept through the entire hardware/assembly half of his degree program and ignored those chapters in the back of CLRS that deal with hardware. I don't think a language distancing itself from the hardware is a problem; well written Java/.NET code now runs very quickly. The problem is that code is not being written well because people learn to code without knowing anything about the machine.

    48. Re:Typical Java Handwaving by poot_rootbeer · · Score: 1

      I haate that students coming out of universities, when asked about registers and how would they write a multiply routine if they only had shifts and adds, ask "why do I need to know this?"

      Are you interviewing them for a job coding on a processor that only has shift and add operations?

      If not, why do they need to know this?

    49. Re:Typical Java Handwaving by napir · · Score: 1

      You can use an O(n) median algorithm to choose a pivot at each step so that the worst case complexity of quicksort is \Theta(n \log n). This adds significant overhead, so nobody does it in practice. Radix sort is not a comparison sort, so it is applicable in fewer situations than quicksort. It assumes something about the input (i.e. limited domain) and uses operations other than simple comparison.

    50. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      You went to MIT too? My freshman computer course used Scheme, which is a LISP derivative. I have never seen a better language for teaching hand-waving, "elegant" computer programming and completely ignoring the actual performance or the consequences of your programming. Ignoring the costs of recursions or subroutines is fine on hte blackboard, but when you need something that doesn't suck up every bit of RAM or every cycle on your computer, you need to think about the costs of hiding the ugliness under a coat of Rust-oleum called a subroutine.

    51. Re:Typical Java Handwaving by rbarreira · · Score: 1

      Well, the author of the article linked to in this slashdot article has some examples himself, but I can give some other... Ask someone the possible reasons behind the performance differences between calls to interface methods, virtual methods and regular methods in C#. Or ask why generics in C# can overcome the overhead of virtual method calls. Or (regarding debugging now), ask how a mutex works and why it's needed.

      About higher level languages (for example, Python), some of those questions are still valid, but I'm not really an expert on any of them so I'll pass that one for someone else.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    52. Re:Typical Java Handwaving by Erich · · Score: 1
      You are right, I am wrong. I was confusing with heapsort I think. My bad! :-) Intro to computing was so very long ago...

      --

      -- Erich

      Slashdot reader since 1997

    53. Re:Typical Java Handwaving by arevos · · Score: 1
      Ask someone the possible reasons behind the performance differences between calls to interface methods, virtual methods and regular methods in C#. Or ask why generics in C# can overcome the overhead of virtual method calls.

      How much overhead are we talking about?

      Or (regarding debugging now), ask how a mutex works and why it's needed.

      I wouldn't class mutual exclusion as a low level concept. I'd class it as an abstract concept found in almost all languages that can deal with concurrent programming, whether they be high level or low level.

      About higher level languages (for example, Python), some of those questions are still valid, but I'm not really an expert on any of them so I'll pass that one for someone else.

      I don't think any of the questions you listed are valid (which the possible exception of mutex, which I don't see as a low level concept). For instance, in Python all methods are virtual, and there is no concept of interfaces. However, since you're not an expert in such languages, I'll take your advice and leave that for someone else :)

    54. Re:Typical Java Handwaving by FiloEleven · · Score: 1

      If computer science isn't about computers, what is it about? I haate that students coming out of universities, when asked about registers and how would they write a multiply routine if they only had shifts and adds, ask "why do I need to know this?"

      The term "computer science" is really a misnomer. A better term, perhaps, is Informatics, or "computing science." The reason is that as programmers, our main interest should lie in manipulating information. While writing a multiply routine using only shifts and adds is certainly a way of manipulating information, at this point it is equivalent to building a house (and cutting the lumber for it) with nothing but unpowered hand tools. Certainly, a working knowledge of assembly has its uses, but these are increasingly specialized. Is it any wonder that it's not being taught extensively in a general CS track when only 3-5% (warning: made up statistic) of coders actually need it?

      The advances we have made in computing allow us to more easily and quickly map what's in our heads to executable code. This is why the core of CS is (or should be) conceptual. Face it: we have better tools now than we did in your heyday, and this is a good thing. The current crop of high-level languages is wonderful, but we're still not "there" yet, which shouldn't be surprising considering how young our line of work is. I look forward to the day when I can write a full-featured GUI word processor in <5,000 LOC because I can focus even more on what I want the machine to do rather than on how to make the machine do it.
      -f

    55. Re:Typical Java Handwaving by Bob+Uhl · · Score: 1
      There aren't many courses that focus more heavily on highly abstracted languages, such as Lisp.

      I'll just note that while Lisp can be highly abstract, it need not be. I'd post the full disassembly listing for a function I just wrote, but the accursed lameness filter won't let it remain. So here're the first few opcodes anyway: mov ebx, esp; mov edx, [#xA8CFE04]; mov edi, [#A8CFE08].

    56. Re:Typical Java Handwaving by Cyno · · Score: 1

      If computer science isn't about computers, what is it about?

      Like all other education, its just there to prepare you for work.

      Why so many people think so highly of this is beyond me..

      On the other hand I write most of my stuff in OO Perl

    57. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0
      I've designed compilers before, and I wouldn't class constructing a C/C++ compiler as "trivial" :)
      You've designed compilers and you're lumping C and C++ together? Don't you think that hurts your credibility just a little?

      Many computer courses teach languages such as C++, C# and Java, which all have connections to low level code. C# has its pointers and gotos, Java has its primatives, C++ has all of the above. There aren't many courses that focus more heavily on highly abstracted languages, such as Lisp.
      Scheme has its continuations... (move along, no actual point here :)

      I think software sucks because software engineers don't understand programming.
      That just needs to be repeated.
    58. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      In German computer science is called "Informatik", a contraction of "Information" and "Automatik" (automaton, automaticity). IMHO that's a very fitting name. Most computer science courses are about the automated (algorithmic) processing of information. A computer is the the tool of the trade, but it is not what computer science is about. Astronomers might be interested in telescopes and how they work, but only because that helps them get a better image of the universe. Astronomy is done with telescopes, but telescopes are not what astronomy is about. Computer science is just a very misleading name. Imagine how much explaining astronomers would have to do if their field of work was called "telescope science".

    59. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      "If computer science isn't about computers, what is it about?"
      "Computer science is no more about computers than astronomy is about telescopes." (Edsger Dijkstra)
      Actually, most languages don't even use the term "computer science", for example you call it Informatik in german, Informatica in Italian and so on...

    60. Re:Typical Java Handwaving by geophile · · Score: 1

      If computer science isn't about computers, what is it about?

      I agree, but Dijkstra said: "Computer science is no more about computers than astronomy is about telescopes."

    61. Re:Typical Java Handwaving by arevos · · Score: 1
      You've designed compilers and you're lumping C and C++ together?

      Insofar as neither a C compiler nor a C++ compiler is particularly trivial to construct, yes.

    62. Re:Typical Java Handwaving by mlwmohawk · · Score: 1

      "Are you interviewing them for a job coding on a processor that only has shift and add operations?"

      Oh the irony. Say, you are working on a display driver, which do you do? divide by 2 or shift once? Why?

    63. Re:Typical Java Handwaving by mlwmohawk · · Score: 1

      "The job of maping C++ code to machine code is trivial."

      I didn't mean this in the sense that the task was trivial, but that it has a trivial on development.

    64. Re:Typical Java Handwaving by tbradshaw · · Score: 1

      I think the relavent quote you're looking for is:

      "Computer science is no more about computers than astronomy is about telescopes."
      - Edsger Dijkstra

      (http://www.answers.com/topic/edsger-dijkstra)

    65. Re:Typical Java Handwaving by mlwmohawk · · Score: 1

      Dijkstra is not the last word on the subject. A snappy quote does not an argument make.
      This is not a closed debate at all.

    66. Re:Typical Java Handwaving by zettabyte · · Score: 1

      We can't all live in an absolute world like yourself. You know, the one where you're absolutely right all the time...

    67. Re:Typical Java Handwaving by tbradshaw · · Score: 1

      No, he's not.

      I think it was a helpful illustration to note that computer science isn't about programming (and especially not computer hardware). Computer science is a math degree with emphasis on computing, logic, and algorithms.

      If you want someone to know specific programming techniques, really you're looking for a software engineer. The good news is that software engineering is developing as a discipline of it's own and hopefully relatively soon we'll see more programs that split the two. (Our program mixes CS and SE until the masters program, at which time it is formally split.)

      The (hopeful) advantage of a CS degree is a theoretical understanding of languages and techniques that should lead to an ability to pick up and understand new techniques very quickly. I know my usual ramp up time for any language or project is pretty short, a matter of hours for a new language and usually only a couple months before I'm very familiar with a given project. I certainly wouldn't expect an expert in implimentation from a CS graduate, instead it should be a well-rounded student well versed in computing that can adapt and learn to whatever you throw at him/her.

    68. Re:Typical Java Handwaving by mlwmohawk · · Score: 1

      The whole "computer engineering" vs "computer science" is a red herring. The difference between engineering and science is that engineering is the application of theory where as the science is the research of the theory. What "hypothetical computer" proponents fail to understand is that there is "real science" in understanding how "real" computers work. To address Dijkstra, it is like astronomers bitching about the speed of light not being infinite, and preferring to work in a hypothetical universe because it is more perfect. The limitations of computers and designing algorithms that can accomidate real limitations is the difference between playing with toys and real science.

    69. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      Computer science (the "science", not the name) came long before computers and computers would not have been possible without it. It just wasn't called computer science. Many theoretical achievements and many algorithms predate the first electronic computer. Anybody who has been to a computer science course other than programming easily understands how that isn't unbelievable at all. Algorithmic processing of information has been important centuries ago, even if it was done by people, not machines.

    70. Re:Typical Java Handwaving by C+Joe+V · · Score: 1

      I haate that students coming out of universities, when asked about registers and how would they write a multiply routine if they only had shifts and adds, ask "why do I need to know this?"

      As a college-level CS instructor, I desperately hope none of my students ever says that. The answer is: You're not supposed to know it. You're supposed to understand numbers, algorithms and computers well enough that you can figure it out if someone asks you. You're supposed to be familiar with the concept of sometimes having to do things you're accustomed to having done for you, whatever they might be, sometimes unexpectedly. You're supposed to be smart.

      CJV

    71. Re:Typical Java Handwaving by Trogre · · Score: 1

      If computer science isn't about computers, what is it about? I haate that students coming out of universities, when asked about registers and how would they write a multiply routine if they only had shifts and adds, ask "why do I need to know this?"

      "Computer Science is no more about computers than astronomy is about telescopes."
              -Edsger Wybe Dijkstra

      --
      "Nine times out of ten, starting a fire is not the best way to solve the problem." - my wife
    72. Re:Typical Java Handwaving by mlwmohawk · · Score: 1


      "Computer Science is no more about computers than astronomy is about telescopes."
                      -Edsger Wybe Dijkstra

      I wonder how many times will people will bring this up? A cute quote does not an argument make.

      In reference to this quote, which I disagree with, its like astronomers choosing to study a hypothetical universe because the real universe, with "constant" light speed is imperfect and not condusive to cleaner formula.

    73. Re:Typical Java Handwaving by tbradshaw · · Score: 1

      The limitations of which computers?

      The human computers that calculated lookup tables for early engineers?

      Analog computers, like those that calculated missle trajectories in early wars?

      Digital computers, like those in our desks?

      Molecular computers, which use single molecules to recreate the logic gates that we are so familiar with?

      Quantum computers, which may have more than 2 states rather than just on and off?

      Computer science as a field started long before anything that we currently call a computer could have possibly existed, and as time and technology have marched on we have become closer and closer to that mythological computer that you seem to despise so much.

      Theoretical science has always been ahead of physical science and (especially) practical implementation. Computer science is exactly one of those theoretical sciences.

    74. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      Software sucks because today's software engineers don't engineer software. Except for the very small minority, most of it is just hacked together in the first place, or, even if it was designed "right" the first time, hacked apart later. It will take a long time before the business world allows the engineering world to produce software.

    75. Re:Typical Java Handwaving by cryptoluddite · · Score: 1

      My favorite Einstein quote is "It should be as simple as possible, but no simpler." There is a point at which over simplifying something inherently complex is counter productive.

      Yeah I know, originally Einstein thought it should be Java = MC^2, but then decided it was just a tad bit too simple. Maybe he wanted the giants standing on his shoulders to actually have to work at a grand unified theory...

    76. Re:Typical Java Handwaving by donaldm · · Score: 1

      I think you really hit the nail on the head with this comment.

      I think the best way to describe many languages today is "Bloatware" a term I heard coined back in the early 1980's. Once you get into serious maths then you really get to see how inappropriate many languages are. While I am no fan of FORTRAN it is possible to write controlling code in C or C++ and link to the appropriate FORTRAN library. Of course I normally code in a Unix environment so I mainly use scripts, Perl and C.

      --
      There ain't no such thing as proprietary standards only proprietary formats. Standards are by definition open.
    77. Re:Typical Java Handwaving by rbarreira · · Score: 1
      How much overhead are we talking about?

      Interface calls are about 4 times slower than normal method calls, and about 2 times slower than virtual method calls.

      I wouldn't class mutual exclusion as a low level concept.

      But the way it works is. Of course, you don't need to know exactly how it works, but that knowledge might help to understand why a distributed application is not working. My point is - a good craftsman has to know the most possible about his tools. First of all, it helps him/her to work, and second, just the understanding of it helps to evolve the knowledge of his art in general.
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    78. Re:Typical Java Handwaving by rbarreira · · Score: 1
      Show me a sorting algorithm that has better than O(N*log(N)) worst case behavior.

      Here you have. Of course, it's a number sorting algorithm, but in the context of this discussion it doesn't matter a lot since even just for numbers, radix sort can be outperformed in practice, even though its complexity is better, so the original poster's point is illustrated.
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    79. Re:Typical Java Handwaving by rbarreira · · Score: 1

      OK, here it is spelled out for people who couldn't think:

      Even if computer science appeared before computers, nowadays the largest (and most practically relevant) part of computer science is about trying to find new and better ways of processing data on computers, which more often than not has nothing to do with computer science but with other interesting fields such as maths, engineering, biology etc etc.

      Most of computer science isn't an end in itself, but a means to achieve better solutions with computers. Now if Mr. Dijkstra was alive I wonder what he would say if I asked what that has anything to do with the relationship between astronomy and telescopes. Because I really can't see it.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    80. Re:Typical Java Handwaving by arevos · · Score: 1
      Interface calls are about 4 times slower than normal method calls, and about 2 times slower than virtual method calls.

      Which is useful to know, but not essential.

      I agree that it's a good idea to know something about the low level details of a computer. However, such low level details become increasingly irrelevant the more abstract the language you use. Once you start using Python or Ruby, then the level of abstraction is so high that I can't see any advantage to knowing the low level details.

      Concepts such as mutual exclusion, semaphones, and other abstract computer science concepts are only low level if you implement them in a low level language. So sure, a implementation of them might be, but only in a language that is not particular very high level. For instance, C# has primatives and pointers, and differentiates between at least three different types of method call. Sure, it runs off a platform independant virtual machine, but the level of abstraction in C# is still far lower than in a language like Python.

    81. Re:Typical Java Handwaving by rbarreira · · Score: 1

      What you say is true, but computer science nowadays is very different. Most of it is dedicated to find better solutions for data processing in computers. http://it.slashdot.org/comments.pl?sid=191465&cid= 15741831

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    82. Re:Typical Java Handwaving by rbarreira · · Score: 1
      agree that it's a good idea to know something about the low level details of a computer. However, such low level details become increasingly irrelevant the more abstract the language you use. Once you start using Python or Ruby, then the level of abstraction is so high that I can't see any advantage to knowing the low level details.

      But we were talking about the education of engineers, not some damn "Learn Web Programming in 2 weeks" course...
      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    83. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      No, computer science is not different today. It is still about algorithmic processing of information. We can process more information faster with computers, but computers are nevertheless just the tool, not the object of computer science. Most computer scientists are not in the business of making better computers. Computer science is done with computers, not about computers. Key difference.

    84. Re:Typical Java Handwaving by rbarreira · · Score: 1

      Do you understand the difference between hardware and software? Computer science is much more concerned with software than hardware.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    85. Re:Typical Java Handwaving by geggo98 · · Score: 1
      If computer science isn't about computers, what is it about?
      "Computer science is no more about computers than astronomy is about telescopes" -- Edsger Dijkstra [...]
      Sorry, you're arguing against Dijkstra: you lose. :)

      Ahem, since about the 13th century, astronomy is all about telescopes. Gallileo, Keppler, Cassini, Hyuygens -- all the great astronomers built their own telescopes. Even today are radio telescopes, the Hubble space telescopes and the VLT more than just a tool for astronomie. Perhaps in a thousand years, when peple can travel to the stars, telescopes might become obsolete. Until then, astronomie will stay all about telescopes.

      It's the same with computers in computer science: binary functions, parallel algorithms, resource bounded complexity and so on are all about computers. Computers are mor than a tool, they are the heart of computer science. Without computers, their wouldn't be much progress beyond the description of the Turing machine. In computer science most problems deal with limitations of existing computers. E.g. on a turing machine, you can use one sorting algortihm for everything; in the real world there is a huge difference, if you want to sort 10 Bytes or 10 Terrabytes.

      So Dijkstra is right: In a thousand years, when astronomers won't deal with telescopes anymore, computer science won't be about computers. Until then, both devices might be at least as important for innvoation as improvements in the theoretical world are.

    86. Re:Typical Java Handwaving by arevos · · Score: 1
      But we were talking about the education of engineers, not some damn "Learn Web Programming in 2 weeks" course...

      Oh dear. Let me guess; you have no substantial experience with either Python or Ruby, and yet you hold the opinion that they are not languages suitable for use by "real" software engineers. Am I close?

    87. Re:Typical Java Handwaving by rbarreira · · Score: 1

      No. But I hold the (easily accepted) opinion that a real software engineer knows much more than what you learn in 2 weeks of a crappy programming course.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    88. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      "about". That word doesn't mean what you think it means.

    89. Re:Typical Java Handwaving by arevos · · Score: 1
      But I hold the (easily accepted) opinion that a real software engineer knows much more than what you learn in 2 weeks of a crappy programming course.

      Okay... But what does that have to do with the discussion? We were discussing high level languages, not crappy two week programming courses. If you accept that high level languages are not the sole domain of crappy two week programming courses, then I fail to see the connection. What point are you trying to make, exactly?

    90. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      So? How is that different from the time before computers? "Software" back then was exactly what it is today, it just ran on different "hardware". I think people have a problem with the word about. If you say "it's about that", the meaning is that that is the object of it, that that is primarily what you're trying to create, improve or understand. In the case of computer science, that is not computers. In the case of astronomy, that is not telescopes. In the case of math, that is not calculators or computer algebra systems. Many computer scientists have much experience with computers and can tell you how to improve them software- and hardware-wise, but even though carpenters could tell you a thing or two about hammers, that doesn't mean carpenting is about hammers.

    91. Re:Typical Java Handwaving by rbarreira · · Score: 1

      More specifically, we were discussing if decent programmers should know low level details or not. The "crappy two week programming courses" was just an extreme example of "programmers" who know the least possible about what is really happening behind the scenes. Sadly, I know some people who go out of university with a too fragmented knowledge of computing, and that was what my point was about. But I think you can read the posts on the thread.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    92. Re:Typical Java Handwaving by arevos · · Score: 1

      One can spend years studying high level languages constructs without touching the low level details. Just because a programmer doesn't know what is "really happening behind the scenes", doesn't automatically imply that they are not a skilled and experienced developer. My contention is that learning programming in an abstract sense, i.e. taking a problem and producing a good solution in code, is more generally more important than learning about low level systems. In my experience, this is far more of a problem than lack of low level knowledge.

      Efficiency and ease of debugging is one thing, but if you don't know how to effectively design software in the abstract sense, then no amount of low level knowledge will help you. And as I've remarked previously, there's a lot less use for low level knowledge in high level languages that remove themselves as far as possible from the internal workings of the system they execute upon.

    93. Re:Typical Java Handwaving by brpr · · Score: 1

      That doesn't mean that computer science doesn't, in a big sense, exist to support programmers today.

      No, no, no! It's a terrible mistake to imagine that academic disciplines exist for any other purpose than advancing knowledge. It is not the business of a Comp. Sci. Professor to help professional programmers. His business is to do original research and get it published in peer-reviewed journals. Nothing else.

      A focus on researching areas which are thought to have "practical applications" tends to lower the overall quality of research, and indeed its practical use in the long run. (For example, prime number theory was studied for centuries before any practical application for it was found.)

      --
      Freedom is not increased by mere diminuation of government. Anarchy is freedom for the strong and slavery for the weak.
    94. Re:Typical Java Handwaving by cain · · Score: 1
      Nice post. This is well reasoned, well thought out, and well written.

      What the hell is it doing on slashdot?!?

    95. Re:Typical Java Handwaving by rbarreira · · Score: 1

      I didn't say theoretical research was useless. I said that, many times, its intent is to produce research which can (right now or in the future) be applied in practice. Which needn't be always the case.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    96. Re:Typical Java Handwaving by jrentona · · Score: 1

      This anti-Java poster is right on the money. This language tower of babel is destroying software.

      Here is the source (Compiled in MSVC6):

      #ifdef WIN32
      #define HYPER __int64
      #else
      #define HYPER long long
      #endif

      HYPER mxy( long x, long y )
      {
          long shift = 1;
          char iShift = 0;
          char bNeg = 0x0;
          if( x==0 || y==0 )
              return 0;
          else if( x0 )
          {
              ++bNeg;
              x = -x;
          }
          for( ;(shift1)x;shift=shift1 )
                ++iShift;
          if( bNeg )
                return -( mxy( x-shift, y ) + ((HYPER)yiShift) );
          else
                return mxy( x-shift, y ) + ((HYPER)yiShift);
      }

      This problem is actually pretty cool (at least I think so). As far as relevance, I have seen at least one DSP processor without an integer divide. Not certain about multiply.

      My point is that java programmers look down on a problem like this as beneath them somehow. While C and assembly programmers love the challenge (or at least I do). This foolish quote about Comp Sci not being about computers is self serving. It was obviously written by some over-hyped professor whose job hinges on writing books and lectures rather than effective software.

      Fact is I'd rather travel to Mars on a spacecraft whose software was written by C and assembly programmers than a bunch of academic java guys too smart to understand the underlying hardware.

      James A. Renton
      Beverly, MA.

    97. Re:Typical Java Handwaving by jrentona · · Score: 1

      The comment submission process filtered the shift operator << from the code.  I selected "Code" format this time.

      Revised below:

      HYPER mxy( long x, long y )
      {
          long shift = 1;
          char iShift = 0;
          char bNeg = 0x0;
          if( x==0 || y==0 )
            return 0;
          else if( x<0 )
          {
             ++bNeg;
             x = -x;
          }
          for( ;(shift<<1)<x;shift=shift<<1 )
             ++iShift;
          if( bNeg )
              return -( mxy( x-shift, y ) + ((HYPER)y<<iShift) );
          else
              return mxy( x-shift, y ) + ((HYPER)y<<iShift);
      }

      -James

    98. Re:Typical Java Handwaving by Anonymous Coward · · Score: 0

      This foolish quote about Comp Sci not being about computers is self serving.

      People simply don't get it. Computer science really isn't about computers. If you enroll in a computer science curriculum and expect to learn about computers, you'll be sorely disappointed. Consider yourself warned. There is definitely value in learning about the ins and outs of computer programming too, but that isn't called computer science. The quote is a demarcation of the topic of computer science, not a statement about what people should and shouldn't learn. If you want to primarily learn the theory of automated processing of information, computer science is for you. If you want to primarily learn programming, computer administration or how computers do what they do, it isn't. I wouldn't want to travel in anything designed by someone whose closest encounter with engineering is a proof of some property of a differential equation, but that doesn't mean that the study of math as a theoretic construct isn't useful and valuable.

  15. Yes, but is it worth it? by Toreo+asesino · · Score: 2, Informative
    Of course, lower-level languages can be faster, but I'd suggest that writing code at a very low-level is rarely worth the extra effort.

    Take Quake II for instance; as quoted from the article 'the managed version initially ran faster than the native version' - which would suggest higher-level languages are certainly capable of comparing to that of their lower-level siblings.

    Also, take into account the added developer time gained from factors like memory-management being, well, managed, and ever-falling processor & memory prices, and the logical conclusion is usually "write at a higher-level".

    There are of course more considerations than these when deciding on a development platform, but essentially, I think there'd have to be very good reasons for writing green-field projects too close to the machine.

    --
    throw new NoSignatureException();
    1. Re:Yes, but is it worth it? by Anonymous Coward · · Score: 0

      Sure, maybe the managed Quake II ran faster *on modern hardware* - but how does it compare when the comparison is done using an average PC from 1997?

    2. Re:Yes, but is it worth it? by cryptoluddite · · Score: 1

      But consider that the actual engine for quake is quite small and deals with simple concepts (polygons, quad/octtree, textures). At some point a program can get so large and complicated that a person simply can't grasp enough of it at a low level to optimize it well. A JVM for instance can inline a set of functions 6 levels deep or deeper even and then optimize that entire section of code as a unit. But as a person try optimizing 100k of assembly code that has basically no relationship other than that 95% of the time the code follows this particular call sequence (for the other 5% you branch out into non-inlined code).

  16. Speed of programming by Anonymous Coward · · Score: 0

    People who are good at C will insist that they can code something as quickly as anyone else can code the same thing in a higher level language. Well, maybe. I got my own awakening when I watched two students struggling to write something in C that they could have written in ten lines of Basic (it was a while ago).

    In the embedded world, programming DSPs is a wonderful example. We used to write assembly code for the parts that had to be fast because we could get tighter code than a compiler could produce. Now the tools are so good that even good programmers are better off letting the tools do the work.

    So, is there any point writing in a low level language, even where speed matters? I don't think. In any event, it will take longer to write the code. It just doesn't seem like a winning proposition.

    1. Re:Speed of programming by rs79 · · Score: 1, Interesting

      "People who are good at C will insist that they can code something as quickly as anyone else can code the same thing in a higher level language. Well, maybe. I got my own awakening when I watched two students struggling to write something in C that they could have written in ten lines of Basic (it was a while ago).

      In the embedded world, programming DSPs is a wonderful example. We used to write assembly code for the parts that had to be fast because we could get tighter code than a compiler could produce. Now the tools are so good that even good programmers are better off letting the tools do the work.

      So, is there any point writing in a low level language, even where speed matters? I don't think. In any event, it will take longer to write the code. It just doesn't seem like a winning proposition"


      I would never say it's jut as quick to write stuff in C. But I will say the code runs faster and you can support higher loads than if it was written in something else.

      A 10 line basic program isn't a good example. Rewrite, say, Apache, or a unix kernel in something besides C (or assembler) and watch it suck, bad.

      There's a reason all the important stuff is in C. I should have thought this was obvious. What should be obvious too is that it doesn't all need to be in C. The 80/20 rule applies someplace, the config/startup struff in, say, Apache dosn't really matter what it's written in. Use LISP and it wouldn't matter. But the task spawning and http sevice parts damn well better be in C. Even better in Asselbler but here portability goes out the door.

      C may not be perfect but it's less imperfect than anything else. It's about the optimal compromise between portability and speed.

      --
      Need Mercedes parts ?
  17. Single Page Version of the Article by jaaron · · Score: 2, Informative

    Here's a print view of the article so that you don't have to keep moving through the pages. Despite that annoyance, it was a good article. I wish there had been more concrete examples though.

    --
    Who said Freedom was Fair?
  18. high level vs. low level 101 by 192939495969798999 · · Score: 1, Informative

    The criteria for a high-level language are: 1) you aren't allowed to do direct memory register manipulations (i.e. cant run of the end of an array into other areas), and 2) you are interpreted. Either of these can qualify a language as high-level. C has direct memory register manipulation and it is not interpreted, therefore it cannot be a high-level language.

    --
    stuff |
    1. Re:high level vs. low level 101 by Anonymous Coward · · Score: 0

      (1) No it doesn't. The fact that C has no input, output, assembly or registry access whatsoever is one of its distinguishing features. The closest thing to direct memory manipulation is typecasting an int to a pointer - a kludge well outside of normal language use.
      (2) That's not even a real criterion. Besides, that's outside the scope of programming languages.

    2. Re:high level vs. low level 101 by s31523 · · Score: 1

      Direct memory access has almost nothing to do with the language being used. This is a funciton of the underlying machine and OS. A protected mode OS running with a MMU won't let you directly manipulate anything without going into "privaledged mode". Sure, some languages might facilitate this better than others, but the ability to do it is provided by the OS and machine.

    3. Re:high level vs. low level 101 by backwardMechanic · · Score: 2, Insightful

      I love these hard definitions of soft concepts. Just because you write down some rules, it doesn't mean we follow them. Any programmer understands roughly what 'high level' and 'low level' mean, but I'm sure we'll all argue over where the boundaries are - they're not well defined. I guess you stopped at 101?

  19. Some comments on the article by rbarreira · · Score: 4, Insightful
    OK, the article isn't bad but contains a few misleading parts... Some quotes:

    one assembly language statement translates directly to one machine instruction

    OK, this is nitpicking but there are some exceptions - I remember that TASM would convert automatically long conditional jumps to the opposite conditional jump + an unconditional long jump since there was no long conditional jump instruction.

    Other data structures work significantly better in high-level languages. A dictionary or associative array, for example, can be implemented transparently by a tree or a hash table (or some combination of the two) in a high-level language; the runtime can even decide which, based on the amount and type of data fed to it. This kind of dynamic optimization is simply impossible in a low-level language without building higher-level semantics on top and meta-programming--at which point, you would be better off simply selecting a high-level language and letting someone else do the optimization.

    This paragraph is complete crap. If you're using a Dictionary API in a so called "low-level language", it's as possible for the API to do the same optimization as it is for the runtime he talks about; and you're still letting "someone else do the optimization".

    When you program in a low-level language, you throw away a lot of the semantics before you get to the compilation stage, making it much harder for the compiler to do its job.

    That's surely true. But the opposite is also true - when you use an immense amount of too complex semantics, they can be translated into a pile of inefficient code. Sure, this can improve in the future, but right now it's a problem of very high level constructs.

    Due to the way C works, it's impossible for the compiler to inline a function defined in another source file. Both source files are compiled to binary object files independently, and these are linked.

    Not exactly true I think. Yes, the approach on that page is not standard C, but on section 4 he also talks about some high level performance improvements which are still being experimented on, so...
    --

    The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    1. Re:Some comments on the article by mparker762 · · Score: 1

      This "one assembler statement maps to one instruction" line hasn't been true for nearly 50 years. Assembler developers use macros heavily, and assemblers typically came with large libraries of macros. They've even had if/then/else and while and for loops for decades (at least the better assemblers did).

      Hand-written assembly doesn't look like compiler-generated assembly any more than hand-written C code looks like cfront-generated code.

  20. Optimised compilers by axlash · · Score: 1

    Interesting article... the main point seems to be that compilers have grown better at producing the most efficient machine code for particular processor. Perhaps there's a market out there for processors that are optimised for specific languages (like C, given that there still is a lot of C code out there)?

    --
    Deal with reality - the world as it is - rather than ideality - the world as you would like it to be.
    1. Re:Optimised compilers by Anonymous Coward · · Score: 0

      There are processors optimizeed for C. Take a look at the Cris processor from Axis

    2. Re:Optimised compilers by anothy · · Score: 1

      this has been tried several times by several different folks. the most famous examples, i think, are AT&T's Hobbit processor and the various efforts at a Java processor or JVM-on-silicone. the Java case is interesting, since the design of the virtual machine is particularly mismatched from that of most modern processors (note the comment comparing the JVM and Dis, the Limbo/Inferno VM, at the end of the wikipedia article; it's maybe a little misleading now since the JVM's had millions of dollars worth of effort poured into optimization, but it's still mostly true).
      in every case, the outcome has been the same: the market simply doesn't support the effort. every once in a while, someone with the resources to do chip design and fab stumbles upon this idea and has a go of it, but it always works out the same: the incentive to switch - increased performance for applications written in a particular language - simply isn't worth the costs - mostly, toolchain development/maintenance and porting costs, along with the usually-tremendous performance hit running applications in any other language.

      --

      i speak for myself and those who like what i say.
    3. Re:Optimised compilers by masklinn · · Score: 1

      This has been existing for dozens of years, see Lisp Machines such as MIT's CADR Lisp Machine

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    4. Re:Optimised compilers by sbrown123 · · Score: 1

      C also serves as the "base" for many higher level languages. So, a good C compiler can produce better higher level languages.

  21. Typical "/." Handwaving by Anonymous Coward · · Score: 5, Insightful

    "I've been programming professionally for over 20 years, and for those 20 years, the argument is that computers are now fast enough to allow high level languages and we don't need those dirty nasty assemblers and low level languages."

    The "appeal to an expert" fallacy?

    "What was true 20 years ago is still true today, well written code in a low level language tailored to how the computer actually works will always be faster than a higher level environment."

    It also means that portability becomes ever harder, as well as adaptability to new hardware.

    "If computer science isn't about computers, what is it about? I haate that students coming out of universities, when asked about registers and how would they write a multiply routine if they only had shifts and adds, ask "why do I need to know this?""

    It's about algorithms. Computers just happen to be the most convienent means for trying them..

    "The problem with computer science today is that the professors are "preaching" a hypothetical computer with no limitations. Suggesting that "real" limitations of computers are somehow unimportant."

    With the trend towards VM's and virtualization, that "hypothetical" computer comes ever closer.

    "Software sucks today because software engineers don't understand computers, and that's why languages and environments like Java and .NET will make software worse."

    Now who's handwaving?

    1. Re:Typical "/." Handwaving by 14CharUsername · · Score: 3, Insightful

      Now who's handwaving?

      I'd say you are. His first statement wasn't a logically fallacy, he was just pointing out this argument has been going on for a long time.

      You made a good point about portability, but I think that was your only point. And its easily shot down byt the fact that its just as easy to port a standard C/C++ API to a new environment as it is to port Java/.NET to a new environment.

      He made an excellent point about many new graduates not knowing how the CPU actually works and you replied with: "It's about algorithms. Computers just happen to be the most convienent means for trying them.." ??? What the hell does that mean? Handwaving indeed.

      His main point was that VM's are always slower compiled machine code. Even if computers are doubling in speed every 18 months or whatever, native machine code will still be faster than virtual machine code.

      With the trend towards VM's and virtualization, that "hypothetical" computer comes ever closer.

      Right there you have just proven yourself to be an academic. Trends do not make reality. Besides that, what about gcj? If VMs were so great, why would anyone want to compile java to native code? In the real world, people care about performance. Academics are satisfied that a problem has a solution. In the real world we need to be able to get a solution in the minimum amount of time. VMs always take more time.

      Now you may continue your handwaving.

    2. Re:Typical "/." Handwaving by Azarael · · Score: 2, Insightful
      The "appeal to an expert" fallacy?
      I've never come across that fallacy in philosophy class, however, if you mean the "Improper Appeal to Authority" fallacy then it isn't. If the above poster was a movie star or a well known public figure and their comments about the article are being referenced to prove a point (assuming said movie star or public figure isn't an expert programmer), then that would be an improper appeal to authority. In any case, the insight and experience of long time programmer is valuable. Sure they can be wrong but, they still know their stuff front to back. Likely the GP poster knows very well that you can through as much virtualization as you want at a problem, but no matter what, you're still bound to the limitations of the underlying hardware. Maybe at some point hardware with almost infinite flexibility will exist and I'd be surprised if that happened any time soon.
    3. Re:Typical "/." Handwaving by rs79 · · Score: 0

      "I've been programming professionally for over 20 years, and for those 20 years, the argument is that computers are now fast enough to allow high level languages and we don't need those dirty nasty assemblers and low level languages."

      The "appeal to an expert" fallacy?"


      No, a fact. An empirical observation. I've seen the same thing but over 30 years, not 20. In the PDP-11/20 era you wrote assembler, period. Somewhere in the 11/45 to 11/34 era it was actually not stupid to use C all of a sudden. (C did exist in the 11/20 era)

      Keep in mind parts of AltaVista were in Assembler. If you want to optimize stuff real good like you use assembler or go fish. One cannot say the original cluster AV ran on wasn't "fast enough" but, fastest != fast enough.

      "What was true 20 years ago is still true today, well written code in a low level language tailored to how the computer actually works will always be faster than a higher level environment."

      It also means that portability becomes ever harder, as well as adaptability to new hardware."


      I've done a very large amount of what you're describing and from where I sit I can not agree with your guess.

      "The problem with computer science today is that the professors are "preaching" a hypothetical computer with no limitations. Suggesting that "real" limitations of computers are somehow unimportant."

      With the trend towards VM's and virtualization, that "hypothetical" computer comes ever closer."


      Oh please. I've been hearing this for 25 years. It's no more a practical real world truth than it was then.

      --
      Need Mercedes parts ?
    4. Re:Typical "/." Handwaving by mlwmohawk · · Score: 1

      >> "The "appeal to an expert" fallacy?" Absolutely not, simply stating that this is not a new argument and it has continued as long as I've been doing this stuff professionally and the same arguments are the same arguments, they weren't right 20 years ago any more than they are today. >> "It also means that portability becomes ever harder, as well as adaptability to new hardware." Nonsense, your "VM" will be written in a low level language. >> "It's about algorithms. Computers just happen to be the most convienent means for trying them.." That is the most ignorant statement I have ever read, and it is likely you take offense to my previous statements because they are aimed directly towards your "education." Have you ever written graphic manipulation and animation code? Without full understanding of HOW your computer works, your system won't work acceptably. You need to be aware of virtual memory pages especially when you need to do things like matrix transforms of large blocks of memory. There are whole papers dedicated to the study of this topic. It can mean the difference between smooth graphics and horribly choppy ones. Obviously, there are classes of applications which do not require being tailored to real-world computers, and in these one should use a higher level language if convenient. That being said, one MUST have the knowledge of how computers work to be able to best judge which is correct. >> "With the trend towards VM's and virtualization, that "hypothetical" computer comes ever closer." We will *never* have a hypothetical computer any more than we will have a paperless office or a 4 day work week. As long as there is benefit to coding to the computer, people will take this advantage against their competition. You tell the game industry to use Java!

    5. Re:Typical "/." Handwaving by IamTheRealMike · · Score: 1
      With the trend towards VM's and virtualization, that "hypothetical" computer comes ever closer.

      There is no such trend. Many new apps where performance is critical - such as desktop applications - are still being written in C++. Microsoft now routinely encourage people to "ngen" their code - a fancy name for compiling it before it's run. Mono has a special AOT mode which produces better code "ahead of time".

      This is because people are waking up from their dream-like state in which just in time compiling virtual machines make sense: there are far too many useful optimisations you can do a program that are too slow to do in real time. Even if there weren't, it makes zero sense to do extra work in a time critical context (when the user is waiting for the program to respond) if you don't have to. Given that we exist largely in an architecture monopoly even on the server side these days targetting a non-existant (hence virtual) machine is folly.

      I suspect you are getting confused with the fact that VMware and such are fashionable these days. These virtual machines have nothing in common with programming language VMs.

    6. Re:Typical "/." Handwaving by Surt · · Score: 1

      VMs always take more time.

      That doesn't have to be the case. VMs can (and do) make execution decisions using information collected from a running instance where the data is known, optimizations that are impossible at compile time.

      --
      "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
    7. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 0

      Please, wake me up when you see something like office, photoshop, maya, illustrator, Cubase, your desktop (be it explorer.exe, gnome, kde, CDE, Aqua..) or any "big" software package used by graphists written in Java, C# or any real high level language.

      I hate those "high level language" evangelists. There's no real world, used by millions people, example, of a successful *big* app written in Java/C#/Python/Ruby or any other hyped thing. The real tools i use day to day are all written in C or C++. Add some perl scripts, caus', well they are handy.

      Java and c# will never hit my computer in my lifetime. Better be dead than using sloware.

    8. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 0
      Does software suck today? I mean more people are doing meaningful work with computers than ever before. What specifically sucks these days? Things are certainly better than they ever were in the 80's. At least on the desktop. Are the numbers just too big for you? Megs and Gigs instead of Kilos? Ghz? Or is there some fundamental trend you can point to. I have an advanced degree in computer science, I can write assembly on a handful of chips and I can write smalltalk and java, I worked through the 80s and 90s and I remember exactly how things were with DOS and the older versions of UNIX and VAX. You're smoking crack if you don't think things are way way way better. Are you thinking about running one application really reliably on a VAX or mainframe and that's better?

      As for programming and the highlevel vs. lowlevel thing. Discarding the "if you're not bitbanging and poking registers, you're not low level" argument, they are all pretty much "lowlevel." The differences are static vs. dynamic typing, strong vs. weak typed, etc. Python and Ruby kind of do more for you automatically, but not much, a runtime buys you a lot less boiler plate to deal with the OS and such that you have to do with C/C++. Bounds checking isn't a "high level" language feature. D,Ada, Pascal, and other low level languages can do that. Exceptions aren't. I don't think runtimes are really either, C++ has a runtime, C has a minimal one to load it up. Basically when you start splitting those hairs, you can write everything in C or assembly and you just end up with a lot less features, a lot less code but it's "fast." You write in Java or something else and you're code will do more stuff. Performancewise? In the real world? Closer than you might think. Are the features worth it? Sure, if we're focused on an inner loop, an mp3 encoder or something, maybe sorting a list, your handed coded assembly will be faster, but is that all that your software is going to do?

      I'm of the belief that the shittiness of software these days has less to do with engineers not understanding chips than it does with engineers being too focused on chips. I'll gladly give up some "performance" if the program does what I want it to do better or in a more friendly way. I don't know how many times I've heard some old guy who doesn't do UIs say "anyone can write a GUI" or something to that effect, rather than actually making a killer application. If what you say is true, then why don't you start up a company and show us all up? Likewise, I've never seen one of those guys produce something that was so radically good that it didn't need a nice UI or something else to actually sell. To make competitive software today, it has to actually work, it has to be easy and clean to use, it has to do something interesting and it has to perform, simply having one of those isn't enough. On top of that, you can't be a one trick pony, you need to support your product, update it and continue to innovate. To some degree you need some portability too.

    9. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 3, Insightful

      "In the real world we need to be able to get a solution in the minimum amount of time. VMs always take more time."

      I'd argue that in the real world (or at least business world) we need the solution to be developed in the shortest amount of time, with the most amount of security. While a VM based language is not guaranteed to provide quicker time / security, in most cases it probably will.

    10. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 0

      No matter who the authority is, Appeal to Authority is a logical fallacy in that no necessary proposition can come from it.

      Of course, logic is hardly the only game in town -- I can also construct perfectly logically valid arguments about God or unicorns. They're just not sound.

    11. Re:Typical "/." Handwaving by Dausha · · Score: 1

      "I've never come across that fallacy in philosophy class . . . " is itself an appeal to your authority. Of course, I've never taken a philosophy class, so I can also say I've never come across such a fallacy in philosophy classes. :-)

      " . . . however, if you mean the 'Improper Appeal to Authority' fallacy then it isn't. . . . In any case, the insight and experience of long time programmer is valuable."

      You're right and wrong. This is an appeal to authority fallacy. Regardless of the accuracy of the authority, it remains a fallacy. However, the appeal to authority is always a logical fallacy. Wikipedia points out that this appeal can be used as shorthand in an argument rather than forcing the individual to fully develop his arguement--which makes sense in /. "Any argument should ideally be based solely on direct evidence and the argument itself, not on the authority of the messenger drawing the conclusion from the evidence."[1]

      While appeal to authority is a logical fallacy, it does not mean that such an appeal is without merit. As the Wikipedia points out, those in greater authority are less likely to be wrong---this allows the reader to make a better informed decision.[1] I started programming in 1982, but nearly a quarter century does not make me an authority as far as logic is concerned. Logic is not the only way to reach an informed decision, which you rightly pointed out when you stated the experience is very relevant, especially when discussing long-term trends.

      As an aside, my uncle spent nearly 40 years as a doctor. He said that there were certain ideas put forward when he was a young doctor that proved to be false. As he retired, he noticed the same ideas were resurfacing by the younger generation. My point in this is that there are few truely original thoughts floating about. We might think there's a new way of doing things, but it might in actuality be an approach that failed and was forgotten. Thus, while a logical fallacy, we should still listen to credible sources of experiences so we don't simply pound sand at bad ideas.

      Of course, I never took a class in philosophy (your appeal to authority); I am a law student in his ultimate semester (my appeal to authority).[2] And, I stayed in a Holiday Inn Express last night (Appeal to Commercials)

      [1]: http://en.wikipedia.org/wiki/Appeal_to_authority. This seems to be a fairly accessible source of information--it would be hard to show you the page I refer to from a book in my library.
      [2]: That is, I engage in applied philosophy of logical legal arguments on a routine basis.

      --
      What those who want activist courts fear is rule by the people.
    12. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 0

      Java in general is a novel idea. The implementation of it's bytecode interpretation or even a translating to C is really a personal preference on the part of the person who's got to run it. GCJ's primary use is to lower memory consumption and provide marginally faster code than what the Java interpreter can...interpret.

      GCJ doesn't exist out of necessity, it's there as an important tool. I have used GCJ only once, and it pointed out I shouldn't deviate from Sun Java's core technology with the kind of development I'm doing.

      GCJ also happens to be the only way to get any sort of Java to work on Redhat/CentOS/other variants. I suppose that'll change when the Sun Java interpreter is open-sourced, but...

      Well, that's why people use GCJ and Java.

    13. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 0

      Algorithms for perfoming aggressive runtime optimization of code streams are often incompatible with the latency requirements of programs. Various algorithms may take quadratic time which may be tenable for static compilation but completely unrealistic for runtime optimization. The end result is often quite obvious, where most runtime optimization essentially comes down to inlining trivial cases. This is why you can obtain similar levels of performance on certain numeric codes and obtain suboptimal performance elsewhere. Static and dynamic optimization should of course be used together, which is why Dynamo obtains both the benefits of aggressive static compilation and runtime inlining. No, don't go into any hand-waving about off-loading expensive optimization to other threads in the background. People don't buy SMP machines to let processors go to waste. No extant implementation performs such optimizations.

    14. Re:Typical "/." Handwaving by Azarael · · Score: 1

      All reasonalbe points, I'm referring to the 2nd form in the Wikipedia article which you have pointed out.

    15. Re:Typical "/." Handwaving by Reverend528 · · Score: 1

      Well, nowadays, many programs, even those written in C, have some higher-level language built in to them. If you want a good example, look at firefox.

    16. Re:Typical "/." Handwaving by CaffeineAddict2001 · · Score: 1

      The reasons universities don't teach people to most effectively code for a given platform is because it will be next to worthless 10 years down the road. You say they need to know "how computers work", but computers never work the same way one year to the next. The hypothetical high level stuff doesn't change.

      I have sitting on my shelf at home Michael Abrash's infamous "Black Book of Graphics Programming". Is any of the code in there relevant to graphics\animation coding today? Not at all. However, the high level concepts it explains are still useful.

    17. Re:Typical "/." Handwaving by mlwmohawk · · Score: 1

      "The reasons universities don't teach people to most effectively code for a given platform is because it will be next to worthless 10 years down the road. You say they need to know "how computers work", but computers never work the same way one year to the next. The hypothetical high level stuff doesn't change."

      I never mentioned "platform" and explicitly did not. Believe it or not, computers have not changed very much in the last 20 years. They've gotten bigger and faster, but they basically work the same way. There have been some cool "new" things, like SMP, NUMA, instruction pipelining, etc but computers, themselves, have remained fairly simple devices upon which more complex paradigms are implemented.

      The fact that technologies and theories change over the years is nothing new to science, string theory?

      Ignoring that "real" computers have real limitations, and that these limitations require advanced algorithms to over come, is not the answer. In reference to Djikstra, it is like an astronomer ignoring the "real" universe because fixed light speed makes his formula more complex. Real life is a bitch.

      "I have sitting on my shelf at home Michael Abrash's infamous "Black Book of Graphics Programming". Is any of the code in there relevant to graphics\animation coding today? Not at all. However, the high level concepts it explains are still useful."

      I'm not familiar with that book, but if it is any good and it describes how this is done, it would be a great foundation for technology to come.

    18. Re:Typical "/." Handwaving by Dausha · · Score: 1

      I thought you were probably referring to the second form. I should have stated that explicitly in my response, but I suppose I did not (or at least not effectively). This is probably the most common fallacy we use in /.--I know I'm guilty. So, I thought I'd put a bit more information. Hope I didn't come off hostily.

      --
      What those who want activist courts fear is rule by the people.
    19. Re:Typical "/." Handwaving by Azarael · · Score: 1

      Meh, it's all in the interest of getting the message across, which should be the point IMO.

    20. Re:Typical "/." Handwaving by ishepherd · · Score: 1

      There's no real world, used by millions people, example, of a successful *big* app written in Java/C#/Python/Ruby or any other hyped thing.

      There certainly are; here's one I use daily.

      But judging by your last sentence, you must be trolling.

      --
      fud, notfud, yes, no, maybe
    21. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 0

      I use Epiphany because XUL is slow and sucks.

    22. Re:Typical "/." Handwaving by Tim+Browse · · Score: 1

      The reasons universities don't teach people to most effectively code for a given platform is because it will be next to worthless 10 years down the road.

      I think you underestimate the longevity of computer architectures. Look at Intel x86 - basically, the code has got cleaner (no horrible segmenty stuff) and some new instructions, wider registers, but essentially it's the same basic model as the clunky PCs that were knocking around when I went to university nearly 20 years ago.

      I also remember being really interested in a new CPU that came out around the time I went to Uni, and had bought a book to learn about it - the ARM CPU. That was 20 years ago. But guess what I'm doing at work at the moment? I'm examining the output of a C++ compiler generating machine code for an ARM target to see how I can optimise the results/replace specific parts of C++ with assembler routines.

      As an aside, I'm also using C#/Windows Forms to write a GUI application, so I don't stay stuck in assembler land all day/all of my career.

      But as a general rule of thumb, I've noticed that the less a programmer knows about the underlying architecture, the less good they are at programming. YMMV.

    23. Re:Typical "/." Handwaving by Anonymous Coward · · Score: 0

      LOL I was reading a very disparaging article the other day about how badly CS teaching sucks in this country because CS professors regard it as being about algorithms and not about computers.

      The OP has a valid point. Computers have limitations and when you're taught that HLL compilers can optimize just as well as assembly coders you're hearing a theoretical belief based on algorithmic logic - not a practical reality based on actual computers or compilers.

      The fact is that modern CPUs are way too complex for a modern compiler to understand; while modern assembler coders can get their heads around them in a few months. Every trick the assembly coders learn has to be taught to the compiler. In practical terms, unless a CPU architecture is decades old (x86, I'm looking at you), the compiler technology always trails behind best practice in assembly optimization.

      I'll leave the discussion about whether CS should be about algorithms, or about computers, to another day ;)

  22. What I didn't see in TFA... by s_p_oneil · · Score: 4, Insightful

    I didn't see anything mentioning that many high-level languages are written in C. And I don't consider languages like FORTRAN to be high-level. FORTRAN is a language that was designed specifically for numeric computation and scientific computing. For that purpose, it is easy for the compiler to optimize the machine code better than a C compiler could ever manage. The FORTRAN compiler was probably written in C, but FORTRAN has language constructs that are more well-suited to numeric computation.

    Most truly high-level languages, like LISP (which was mentioned directly in TFA), are interpreted, and the interpreters are almost always written in C. It is impossible for an interpreted language written in C (or even a compiled one that is converted to C) to go faster than C. It is always possible for a C programmer to write inefficient code, but that same programmer is likely to write inefficient code in a high-level language as well.

    I'm not saying high-level languages aren't great. They are great for many things, but the argument that C is harder to optimize because the processors have gotten more complex is ludicrous. It's the machine code that's harder to optimize (if you've tried to write assembly code since MMX came out, you know what I mean), and that affects ALL languages.

    1. Re:What I didn't see in TFA... by sayn_''Hello'' · · Score: 1

      > Most truly high-level languages, like LISP (which was mentioned directly in TFA),
      > are interpreted, and the interpreters are almost always written in C.

      While Lisp is frequently interpreted, nearly all major implementations of Common Lisp provide a compiler as well. Scheme, another Lisp dialect, also has implementations that compile to native code and/or C.

    2. Re:What I didn't see in TFA... by mrchaotica · · Score: 1
      It is impossible for an interpreted language written in C (or even a compiled one that is converted to C) to go faster than C.

      No it's not, because it's possible to optimize the interpreted language using information that's only known at runtime.

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    3. Re:What I didn't see in TFA... by Anonymous Coward · · Score: 0

      Most truly high-level languages, like LISP (which was mentioned directly in TFA), are interpreted, and the interpreters are almost always written in C.


      Bollocks! A decent implementation of LISP is compiled (as in: generates native machine code), and its compiler is typically written in LISP.
      The same is true for many other high-level (some may say: even higher-level than LISP) languages such as Haskell or ML.
    4. Re:What I didn't see in TFA... by Tyler+Eaves · · Score: 1

      Actually, most lisp code is COMPILED to native code, and in most implentations the majority of the code, including the interpreter and compiler, are infact written in lisp.

      --
      TODO: Something witty here...
    5. Re:What I didn't see in TFA... by masklinn · · Score: 1

      The FORTRAN compiler was probably written in C, but FORTRAN has language constructs that are more well-suited to numeric computation.

      Are you an idiot? The birth of FORTAN predates C by more than 10 years (work started in 1953, first manual in 1956, first compiler in 1957. C was somewhat officially released [as in "C got powerful enough to rewrite the UNIX kernel in C] in 1973, and the K&R was only published in 1978...)

      Most truly high-level languages, like LISP (which was mentioned directly in TFA), are interpreted, and the interpreters are almost always written in C.

      Failed, most Lisp code is actually compiled before gettting in test or in production, and Lisp compilers are usually written in Lisp (and then you use macros to build your own Lisp dialects on top of existing ones). C is usually used to bootstrap the initial compilers though.

      Haskell is another example of a very high level language whose compilers can be written in itself, and which can be both compiled and interpreted.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    6. Re:What I didn't see in TFA... by gnasher719 · · Score: 1

      '' The FORTRAN compiler was probably written in C, but FORTRAN has language constructs that are more well-suited to numeric computation. ''

      And the reply to this was:

      ' Are you an idiot? The birth of FORTAN predates C by more than 10 years (work started in 1953, first manual in 1956, first compiler in 1957. C was somewhat officially released [as in "C got powerful enough to rewrite the UNIX kernel in C] in 1973, and the K&R was only published in 1978...) '

      Well, I have my own opinion who is the idiot here.

      Apart from the fact that there are various versions of Fortran (II, '66, '77, '90, '95 and 2003), of which at least four are newer than the first C language, the Fortran language has lots of features that allow generation of more efficient code for mathematical problems.

      1. DO-Loops vs. for-loops: In a DO loop, the number of iterations can _always_ be determined before the loop starts executing. For example, in DO 10 I = 1, N the number of iterations is N if N > 0 and 0 otherwise; this does NOT change if N is modified within the loop. In the C loop for (i = 0; i n; ++i) the compiler has to check whether n is constant within the loop which might be difficult.

      2. Less strict rules for evaluation: A Fortran compiler is allowed by the language to replace any computation with a mathematically equivalent one, unlike C. For example, in x = a + b + c + d, the Fortran compiler is allowed to replace this with x = (a + b) + (c + d), which has lower latency than x = ((a + b) + c) + d which the C compiler is forced to do. More extreme, if you calculate x [i] = x [i] / z in a loop, a Fortran compiler is allowed to calculate 1 / z once and multiply each element by that value, which could be ten times faster than the division.

      3. Aliasing rules: In Fortran, modifying the same variable through two different names leads to undefined behavior (unlike C), so the compiler can assume that the programmer doesn't do this. This leads to much more efficient code. For example, it makes vectorizing much easier (a C compiler would often have to do runtime checks that vectorizing is really allowed and have two versions of the code ready). This has just become part of C99 with the "restrict" qualifier.

      4. Vector operations are built into the language of newer Fortran versions. Semantics of these vector operations allows faster code to be generated.

    7. Re:What I didn't see in TFA... by s_p_oneil · · Score: 1

      Did you finish reading my post? I mentioned that some languages which are often interpreted can also be compiled. And if you write a LISP compiler in LISP, what do you compile the compiler with? Since the new compiler hasn't been built yet, you would have to compile it with a different LISP compiler, and I doubt that one was written in LISP. All compilers can be traced back to machine language, and most take advantage of assembler before that, and most of those take advantage of another language, like C, before that.

      I would be very surprised if there's anything LISP can do that can't be done just as fast (or faster) in C. A poster before you mentioned that many LISP compilers convert the LISP code to C to compile it, and C can't go faster than C (though some C code is definitely better than others). Even if LISP is compiled directly to machine language, it's more a question of which compiler optimizes the code better, and not about which language is better. FORTRAN is a special case because it can take advantage of specialized machine language instructions, like MMX and SSE.

    8. Re:What I didn't see in TFA... by Ignignot · · Score: 1

      It is impossible for an interpreted language written in C (or even a compiled one that is converted to C) to go faster than C.

      This is untrue. Almost any vectorized operations can go faster with an interpreter than in C because a programmer in C can't tell C that an operation is vectorized easily, while the interpreter can. For example, if you just want to add all the elements of one vector to all of the elements of another vector, in C you would need a loop and the compiler might not recognize it as a vector operation. If you use an interpreter, it knows it is vectorized and it can optimize accordingly. In this case the language has made it much easier for a programmer to let the compiler (or interpreter) know what he or she wants done. I'm not saying it is impossible for a programmer to write some code in C which acts just as quickly on vectors, but it is much more difficult. The whole point of languages is to make the job of programming easier for a specific task. C is great for some things, but not everything.

      --
      I submitted this story last night, and it didn't get posted.
    9. Re:What I didn't see in TFA... by masklinn · · Score: 1

      gosh...

      My reply was obviously to the "the fortran compiler is written in C" part, I forgot to remove the latter part of the quote.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    10. Re:What I didn't see in TFA... by Anonymous Coward · · Score: 1, Interesting

      Did you finish reading my post? I mentioned that some languages which are often interpreted can also be compiled. And if you write a LISP compiler in LISP, what do you compile the compiler with? Since the new compiler hasn't been built yet, you would have to compile it with a different LISP compiler,


      This, obviously, goes for all compiled languages whose compiler is written in the language in question. In particular, it is true for C. LISP pre-dates C by a significant number of years (2 decades, in fact), so LISP compilers definitely do not have to go back to C. I am involved in work on a native-code compiler for a high-level language that is written in the language itself. Yes, there once was an "ur-version" of the compiler written in a different language. But that was more than 20 years ago, and the other language was not C. In fact, that language was LISP...


        and I doubt that one was written in LISP.


      Why do you doubt that? It certainly wasn't written in C either. Moreover, all this is completely orthogonal to the discussion. A compiler does not have to be efficient in order to produce efficient code.

      The main reason for C's popularity these days is that it is self-sustaining: You can always count on having a C compiler at hand, and since C is important, even hardware designers take some pains in making sure that C can be compiled at least semi-efficiently. But, as the article points out correctly, the efforts involved are becoming more and more heroic.
    11. Re:What I didn't see in TFA... by s_p_oneil · · Score: 1

      Sorry, I mis-spoke. I didn't mean that the original FORTRAN compiler. I meant to say that "a" FORTRAN compiler could be written in C, and still produce code that was faster than C for the numerical computations. I didn't get much sleep last night, which is pretty much my normal state. ;-)

      And even if a LISP compiler is written in LISP, it had to be compiled by a LISP compiler that wasn't written in LISP. If it was, then its parent wasn't written in LISP, or its parent. My point was that the original LISP compiler wasn't written in LISP. It would be a very neat trick indeed if it was. ;-)

      I never said that LISP was slow, or that LISP was always interpreted. I only used it as an example, and the only reason I mentioned LISP at all was because it was in TFA. Most people either love or hate LISP, and I hate it. Some higher-level languages I'm more familiar with are Java, Ruby, Perl (shudder), Python, PHP, Lua, etc. There are a plethora of high-level languages that I can download the source code for. Most of them are written in C, and the extensions for those languages are also written in C. And as a hobbyist graphics/game developer, I can't get any of them to come close to the performance I get with C/C++. Sorry, I never tried LISP because I can't stand it. I never tried FORTRAN either, also because I can't stand it. I know every language has places where it shines. A language like Java would probably make a great MMO server, but there are a number of things it really sucks at, and a game client is one of them.

      The TFA mentions vectoring as a "simple" example, but from where I sit, it looks like the only example with any real merit (on x86). Dealing with branch prediction, instruction pipelining, and things like that are just as much of a pain to get right in high-level languages as they are in C. And there's a lot of code out there that wouldn't benefit at all from SIMD. Game clients can benefit from it, but there's always inline (or even out-of-line) assembler for that. Game clients can also benefit from slower high-level languages, as long as you fall back to C/C++ in critical areas.

    12. Re:What I didn't see in TFA... by m_mauz · · Score: 1

      >Most truly high-level languages, like LISP (which was mentioned directly in TFA), are interpreted, and the interpreters are almost always written in C. It is impossible for an interpreted language written in C (or even a compiled one that is converted to C) to go faster than C. Completely not true. To start with Lisp is usually compiled. For more on the topic see: "How to Make Lisp Go Faster than C" http://www.lrde.epita.fr/~didier/comp/research/ver na.06.imecs-slides.pdf

    13. Re:What I didn't see in TFA... by kaffiene · · Score: 1

      JITting can produce higher performance than ahead-of-time compiled code, which is one of the ways in which a language coded in C can run faster than the same code in C. All you need is a problem with a lot of runtime constants in big oft-repeated loops and you're there.

    14. Re:What I didn't see in TFA... by s_p_oneil · · Score: 1

      I know that it "can", but I've written a good bit of both Java and C/C++ code, and all those times it can don't seem to add up to offset all those times it can't. I think Java is great for writing scalable back-end (and possibly distributed) server processes, but I wouldn't use it to write a game client that needs to push the CPU and GPU to their limits.

      One of the best things about high-level languages is that it's generally more difficult for inexperienced (or in some cases just plain terrible) developers to screw things up. Programmers usually work on teams, and unless you're very lucky, your team will almost always have a few developers who aren't very sharp. In situations like this, I'd much rather use Java that C/C++ (though it would still depend on what you're trying to write). I'm not sure I'd go with a full scripting language in a situation like that, because I've seen people do some really stupid things with scripting languages. Some people need at least a little bit of structure forced onto them. ;-)

    15. Re:What I didn't see in TFA... by s_p_oneil · · Score: 1

      Oh, I almost forgot. I think that Java would be very close to perfect if they added a way to create "unmanaged" classes, structures, and arrays. An unmanaged class/structure/array would essentially be a C++ class/structure/array. It would be compiled to machine code, and you could choose for that to happen at compile time, at install time, or at run time. It would be manually allocated/deallocated (outside Java's managed heap), and it would remove most of Java's seat belts (probably not the exception handling). Sun could probably make it even better than C/C++ by adding constructs that allow vectoring to be taken advantage of (I'm still a bit surprised that a new C/C++ standard isn't in the works to provide a way to do that). High and low-level classes would be able to call each other, and of course a debugger should be able to step between them seamlessly. That's what I'd love to have, seamless integration between high-level and low-level code, where I can get close to the hardware when I need to and still keep my high-level perks when I don't. I can create a project that uses two languages, but it's not seamless. I'd love to be able to do it with one language, one IDE, and one debugger.

    16. Re:What I didn't see in TFA... by kaffiene · · Score: 1

      I fully agree with that. The fact is that, on average, Java is still a wee bit slower than C++ (ranging between 70-105% last time I micro benchmarked - which was with Java 1.4) My point was only that it is not true by definition that something written in C cannot be faster than an ahead-of-time compiled C program. And in fact, in some (admitedly small) cases that actually happens right now.

  23. fundamental proof by Anonymous Coward · · Score: 0

    The author comes up with a bunch of half-ass arguments of why higher level languages aren't necessarily slower and can be faster given certain condition. Before we abandon all our C programs, where is the proof that this is true? I mean, there are things that you just can't do with C that higher level languages fundamentally can't do, e.g. write a garbage collector.

    1. Re:fundamental proof by squiggleslash · · Score: 1

      Never underestimate what you can do in a high level language if its responsible for generating its own assembler code. I can actually see a few ways of implementing a Java like language (whose compiler generates assembler code) that can implement its own GC in high level code. And that's ignoring the obvious possibility of giving your garbage collection a big ass "byte[] ProcessMemory" object to work with.

      For example, the base Object type can have some base methods including "long AddressOf", "long SizeOf", "void RelocateTo(long)", and "Object[] GetObjectsIReferTo". Add to that an object that abstracts the stack, and ensure your generated code conforms to certain conventions so object addresses are only ever located in certain positions on the stack or certain registers, or in objects themselves.

      Now, at this point this is pretty low level. You're still working with addresses. And there's still the realistic possibility of screwing up and causing object corruption. You can, of course, simply prevent other classes from using the methods available to the garbage collector at a low level. But if you're really smart, you can do the above without the AddressOf or RelocateTo things using addresses. You ensure you know the order of the objects on the heap, and replace RelocateTo with some form of "DropDown" object. You also abstract the heap (or heaps, in the case of more recent Javas whose GC strategy involves three heaps.)

      That's just the beginning, but you can probably figure out from the above that an unmanaged language (I hate the term "low level language" when applied to C. Stop redefining terms people! C is a high level language) or some very convoluted, self contained, assembly is a necessary component of the implementation of a managed language.

      --
      You are not alone. This is not normal. None of this is normal.
    2. Re:fundamental proof by Anonymous Coward · · Score: 0
      I mean, there are things that you just can't do with C that higher level languages fundamentally can't do, e.g. write a garbage collector.
      s/just can't do/can do/g

      (from the original author).

    3. Re:fundamental proof by napir · · Score: 1

      This is exactly what JikesRVM does. It's a (almost completely) Java-in-Java VM implementation. There are certain methods which the compiler knows about and generates assembly which specifically breaks the Java semantics. This is all done in a type-safe manner... there are intrinsic types Address and ObjectReference instead of just using longs.

  24. Crap by MarkSyms · · Score: 1

    I might give you 1 but 2 is complete crap. There are plenty of high level languages that are not interpreted. I don't think anyone will call Ada anything but high level.

    1. Re:Crap by masklinn · · Score: 1

      It's 1 OR 2, not 1 and 2...

      Ada doesn't allow direct memory register manipulation ergo it's high level, even though it's compiled. Likewise for languages such as Haskell or Common Lisp (even though they can also be interpreted)

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    2. Re:Crap by Anonymous Coward · · Score: 0

      You are an idiot, just like the GP.

      Any language can be run through an interpreter just like you can compile any language. If you want to argue this, feel free to point out any interpreted language that can't ever be compiled or vice versa.

    3. Re:Crap by drxenos · · Score: 1

      Ada doesn't allow direct memory register manipulation

      Oh no?

      function read_register(Addr : System.Address) return Integer is
      R : Integer;
      for R'Address use Addr;
      begin
      return R;
      end read_register;

      --


      Anonymous Cowards suck.
  25. They put the D in DUH by billcopc · · Score: 2, Informative

    The main reason C is "faster" than high level languages is because C doesn't cover bad programmers' butts with elaborate type checking, ref counting and garbage collection. Take a properly designed C app with graceful error handling and secure inputs, and you will take a performance hit. Let's face it, most of the code we write in C involves error handling and idiot-proofing, things that most high-level languages have built-in functionality for these boring, repetitive slabs of code we all hate writing.

    I see no reason why a high-level application couldn't be compiled as skillfully as a feature-equivalent low-level application. It's just a matter of breaking down the code into manageable building blocks.

    --
    -Billco, Fnarg.com
    1. Re:They put the D in DUH by bytesex · · Score: 1

      Yeah, because being able to directly push bits over in memory in any place that you like (and that is yours to touch) can't have possibly anything to do with it. Or having an API that is the same one that your OS uses (which is mostly the case), which allows you to do all sorts of system calls without checking or conversion; that can't have anything to do with it either.

      --
      Religion is what happens when nature strikes and groupthink goes wrong.
  26. Inline functions by amightywind · · Score: 1
    The claim that C cannot inline functions from another source file is also wrong. This is a limitation in gcc, but other compilers can do it, and IIRC the intel compiler can.

    GCC supports inline functions and most other aspects of C99.

    --
    an ill wind that blows no good
    1. Re:Inline functions by Anonymous Coward · · Score: 0
      The claim that C cannot inline functions from another source file is also wrong. This is a limitation in gcc, but other compilers can do it, and IIRC the intel compiler can.

      Recently I found that g++ 3.4.x inlines methods from other (.cpp) source files! I thought that it only inlined methods declared and defined as "inline" in the .h header files, but not! It can even inline static methods! Playing with -finline-limit= I can control the amount of inlining. My GB emulator runs pretty fast on my PDA (Tungsten T2) thanks to inlining!
    2. Re:Inline functions by amightywind · · Score: 1

      I was talking about the C language. I didn't know about the static inline thing. That could be very useful. Except for that, in my mind, an inline function appearing anywhere other than a .h file is a bug. I also prefer to put them after, not in the class declaration in C++ and not implicit within.

      --
      an ill wind that blows no good
  27. Professionals use C for everything by Anonymous Coward · · Score: 0

    C is portable, fast, very complex and since 35+ years the leading standard for professional OS and APP development.

    C is so successful that C++ had to be invented to get more people into OO style C programming. C++ was designed as an syntax aid for people who lacked the skill writing OO in C by disciplined use of structs and func pointers.

    C is obviously too complex for the average CS student who crouch from one alternative to the next.

    Java? .NET??? ...amusing.

  28. Doesn't help me by denjin · · Score: 1

    I found low-level languages work better with speed. I get too confused with a higher-level one when I use it. :(

  29. Assembler by backwardMechanic · · Score: 4, Insightful

    Every serious hacker should have a play with assember, or even machine code. There is real magic in starting up a uP or uC on a board you built yourself, and making it flash a few LEDs under the control of your hand assembled program. I found a whole new depth of understanding when I built a 68hc11 based board (not to mention memorizing a whole bunch of op-codes). Of course, I'd never want to write a 'serious' piece of code in assembly, and it still amazes me that anyone ever did!

    1. Re:Assembler by Anonymous Coward · · Score: 0

      Yup, right on the money. There's a lot to be learned by programming a few micro controllers. It's farily easy to get started too, especially if you go for common hardware such as PICs. Just grab a PICkit 2, an assembler and some software to get your programs onto the chips and you're set.

      Doing a search for "PIC projects" on Google should give you some fun ideas to work towards. If you've done at least two years of computer science you should have all the knowledge of assembly you need.

    2. Re:Assembler by Anonymous Coward · · Score: 0

      Ever did? Still do! We wrote 30% of Jak & Daxter in assembler because the compilers weren't good enough. You'll notice that J&D was PS2-only and Sony first-party so we didn't care about portability.

      The other 70% was written in LISP, btw.

  30. Re:Article is theory not practice - no measurement by mrchaotica · · Score: 3, Informative
    The proof is in the pudding as they say

    No, what they say is "the proof of the pudding is in the eating." (Just pointing it out because most people get it wrong.)

    --

    "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

  31. See the language shootout by Anonymous Coward · · Score: 0

    http://shootout.alioth.debian.org/

    You'll notice that C does pretty well. Note also however that several other high level languages come in pretty close in terms of performance (of course they usually win on program length). In particular 3 modern functional languages (Clean, OCaml and Haskell) come in just behind gcc and well before your jited or bytecode languages.

    So yes, high level languages that compile to native machine code are fully competitive with C and that's not even considering important things like programmer time, safty, maintanability etc.

    I'm currently working on a new String and IO library for Haskell and we're getting idiomatic one line programs that are within a few % of equivalent C programs. This is nice because typically you have to uglify your high level code to become more competitive with C performance.

  32. Along those lines... by tgd · · Score: 1

    Back in the 80's and early 90's I was doing a lot of programming using Modula-2 as well. (To be honest, I still miss the language to this day... I wish I knew why it never took off the way it seemed it should've). One interesting feature the compiler/IDE system I was using at the time (TopSpeed's) had was this concept that all their language compilers (M2, C, C++, etc) all compiled into an intermediate binary form, and their final compiler did very heavy optimizations on that "byte code".

    It always tended to crank out really bizarre code, but usually at least as good as I could've hand-optimized directly in assembly.

    I wonder what ever happened to them...

    1. Re:Along those lines... by LizardKing · · Score: 2, Informative

      One interesting feature the compiler/IDE system I was using at the time (TopSpeed's) had was this concept that all their language compilers (M2, C, C++, etc) all compiled into an intermediate binary form, and their final compiler did very heavy optimizations on that "byte code".

      That's no different to most compilers. GCC for instance parses the "frontend" language (C, C++, etc) into an intermediate language and performs most optimisations on that intermediate language before translating it to assembler instructions. Optimisation can be performed in the high level language, and even the assembler, but most is performed at the intermediate level as this way all frontends can potentially benefit.

    2. Re:Along those lines... by pfdietz · · Score: 2, Informative

      The more recent versions of GCC also perform transformations on a tree-based intermediate form, before converting that into the older RTL form. There are certain high level optimizations that just work better on abstract syntax trees.

    3. Re:Along those lines... by orthogonal · · Score: 4, Interesting
      Here's an actual data point:

      I sped up some C code by unrolling a loop with Duff's Device. Duff's Device, for those who haven't encountered it, makes an ingenious use of the often-maligned C behavior that case statements, in the absence of a break or return statement, fall-through.

      Duff's Device takes advantage of the fall-through by jumping into the middle of an unrolled loop of repeated instructions. If eight instructions are unrolled, Duff's Device iterates the loop

      count divided by eight (count / 8 )

      times, but enters the loop by jumping to the

      count mod eight (count % 8)

      'the unrolled instruction from the end of the loop. (This sounds complicated, but isn't; just look at the code and it becomes clear.)

      The whole point of Duff's Device is speed and locality of code. Speed: because the loop is unrolled, more instructions are executed for each jump back to the top (and jumps are, relatively, expensive, because they mean any preloaded instructions must be tossed out ans re-read. Locality: (hopefully) all the instructions can be cached, so the processor doesn't have to re-read them from memory.

      But what gcc does with Duff's Device on ARM targets is just bizarre. gcc uses a jump table (good) to directly change the Program Counter (good, so far). But instead of jumping into the loop (which would be good), gcc uses the jump table to jump to ...

      a redundant assignment and ...

      an unconditional jump.

      Yes, gcc very smartly makes a jump table (which directly changes the Program Counter, just like a jump would) to jump to a jump. This is simply a waste of code and time:

      I'd show you the entire assembly code gcc produces, but slashdot won't let me: "Your comment violated the "postercomment" compression filter. Try less whitespace and/or less repetition. Comment aborted."
      cmp r2, #7
      ldrls pc, [pc, r2, asl #2] <-- directly modify the Program Counter making it pc + ( r2 << 2 )
      b .L70
      .p2align 2
      .L79: <-- jump table
      .word .L71
      .word .L72
      .word .L73
      .word .L74
      .word .L75
      .word .L76
      .word .L77
      .word .L78
      .L72: <-- first jump table destination
      mov r1, lr <-- redundant assignment made at every destination
      b .L80 <-- actual jump into unrolled loop
      [ 7 repeats of the above, with differnt branch targets elided]
      .L87: <-- for each iteration of the loop, we're moving exactly 8 halfwords = 4 words
      ldrh r3, [r0], #2 <-- what would be fastest is to load multiple four words,
      <-- then shift high words down
      strh r3, [ip, #0] @ movhi
      [6 repeats of the above elided]
      .L80:
      ldrh r3, [r0], #2
      strh r3, [ip, #0] @ movhi
      sub r1, r1, #1 <-- a subs instruction here would obviate the need for the
      cmp r1, #0 <-- cmp instruction that follows it, saving a cycle per iteration
      bgt .L87

      Why a jump table just to set up an unconditional jump? Why the redundant mov, which could have been done once, prior to the jump table jump? Who knows, that's what gcc does.

      In this particular case, the object is to copy halfwords to a memory address, which address is really mapped to an output device. ARM processors, of course, are optimized for word addresses, so the "best" way to do this would be to load multiple words (LDM), shift the upper

    4. Re:Along those lines... by stonecypher · · Score: 1

      You would do well to toy with your optimization settings; GCC can be coerced into doing the right thing here. Do not forget that a compiler's behavior when creating machine code is heavily human-governed.

      --
      StoneCypher is Full of BS
    5. Re:Along those lines... by orthogonal · · Score: 1

      Oh course, you're right. And yeah, I give gcc a pass on the loading of halfwords. But I have to ask, why would gcc produce the sub-optimal sub; cmp instructions rather than just subS, regardless of the optimization level?

      (Also, and I admit this isn't the best excuse, I was compiling with a make file calls a bunch of other make files that compile a bunch of other files (.C and assembly) with the same, project-wide compiler options. Changing the optimization level for one file, while certainly possible, wouldn't have been something easy to pack up in a patch for other developers on this shared, open source project. Changing the optimization level for all files might have broken other parts of the project. Again, it's not the best excuse, but it's a real-world one.)

    6. Re:Along those lines... by SLOGEN · · Score: 1

      Often, the code generated by compilers can be improved, but:

          1. Does it really matter? will *anyone* notice the hours you spent optimizing?
          2. How does it work on another CPU (family)? it's *really* hard to know these days, all your work may very well be in vain, or even harmfull on another CPU, especially in the IA32 architecture

      Is ASM/CPU-level optimization *really* the way that you get the best competitive edge for the application/lib/...?

      I enjoy doing optimizations (I'm a computer scientist with a interest in algorithms, datastructures, type-theory and all those wonderfull theoretic branches) but when working in the "software-industry", factors to success are different, and in my book they are something like:

              1. Ability to fullfill customer needs
              2. Ability to fullfill customer requirements (not the same as needs :)
              3. Amount of bugs, and to some extent their "severity" (small bugs can easily kill large apps, not because the program crashes, but because of the human nature)
              4. Time it takes to fix bugs

      ASM- or CPU-level optimizations is *very* rarely the place where you can compete with others. Before *any* optimizations on the syntax level: run a profiler. A profiler gives you an idea of which part of your program (or, more likely, datastructures) you should be focusing on.

      Some core math-processing, like compression/decompression, bigints and the like may benefit from ASM-level optimization but they are often outdated within a few months by newer CPU's so even there it's best to defer ASM-optimization untill the last possible minute.

      If you find yourself cursing over a bad OSS compiler you may wish to contribute an analysis and optimization for it, although it's sometimes hard to get under the skin of them quickly.

      --
      SLOGEN [ http://ungdomshus.nu : Sebastian cover music]
    7. Re:Along those lines... by orthogonal · · Score: 1

      You make some great general points, and I completely agree.

      In this particular case, what I was trying to optimize with Duff's device was a low level video driver. And yes, profiling had indicated that was sucking down a good bit of the total time.

      (Some other things were sucking down time too -- one was how screen updates worked, which I optimized in platform-independent C; the other was memcpy, which I optimized in assembly.)

      Speaking directly to your first two points:
      1. Does it really matter?
      Answer: Yes, significantly. Under the right conditions, the assembly takes half the time the C code does. Screen updates take a good proportion of total CPU time, and there's no good substitute for doing screen updates.

      2. How does it work on another CPU (family)?
      Answer: that's why I went with Duff's device first; it works on all platforms, and on my particular platform, it gave about a 5% increase in speed (from a less unrolled loop). ...especially in the IA32 architecture
      Just to be clear, this is on an ARM architecture.

    8. Re:Along those lines... by Anonymous Coward · · Score: 0

      Duff's Device? Someone gets credit for writing in C, in the early 80s, what every assembly programmer has done since forever?

      Man, it pays to be in the right place at the right time.

      The people who do the real inventing never goddamn get the credit.

      I swear by the Apple ][ Reference Manual that I saw this exact form of loop unrolling in 6502 at least five years before Duff reinvented it.

    9. Re:Along those lines... by djeca · · Score: 1

      Anyone can unroll a loop in assembler (well, anyone who can program in assembler in the first case).

      Tom Duff's innovation was to discover how to do it in C, combining two warts - switch can be interleaved with other control flow constructs, and case statements fall through - to create an idiom that is at once supremely elegant and unutterably hideous.

      Of course, anyone who implements a Duff's Device for loop unrolling in C nowadays is an idiot who hasn't discovered -funroll-loops. (Sure, if your compiler isn't optimizing - but the parent specifically mentioned gcc.) The money with Duff's Device nowadays is for writing poor man's coroutines (although odds are your platform has setcontext, even if it is a bitch to use).

    10. Re:Along those lines... by Tim+Browse · · Score: 1

      Yay! JPI TopSpeed :-)

      I used to use that to annoy people who used to explain to me that C was significantly faster than Modula-2.

      The debugger (VID?) was awesome for the time, too, iirc.

    11. Re:Along those lines... by statusbar · · Score: 1

      Interesting to note that Duff's device causes enormous slow downs on different architectures. The real problem here is that duff's code is too low level for any compiler to properly infer the original purpose, and the manual pointer arithmetic makes it tough because of the aliases problems that C has. Things are a bit better with the 'restrict' keyword, but it still limits you to optimise only on architectures that have one execution unit.

      As an example, I wrote My Little Article on Duff's Device for you to read. I specifically tested it on a platform that has 8 explicit execution units and software pipelining, and duff's version is 48 times slower than the simpler for loop with array indexing if count is much larger than 5.

      With the array indexing, the compiler can be smart about re-ordering the calculations. With the pointer arithmetic it is forced to not be!

      --jeffk++

      --
      ipv6 is my vpn
    12. Re:Along those lines... by Anonymous Coward · · Score: 0

      Incidentally, Google Groups has Tom Duff's original post archived.

  33. OCaml by Richard+W.M.+Jones · · Score: 1
    I was playing around with a neural network simulator in C and OCaml the other day, and was pleasantly surprised to find that the optimised OCaml version was just 3% slower than the optimised C version (using gcc, so perhaps the Intel compiler would have done better).

    Thread on OCaml-beginners newsgroup here.

    Rich.

    1. Re:OCaml by masklinn · · Score: 1

      OCaml is a fairly good example because it doesn't even aim for speed that much (OCaml's lead motto is "never more than twice as slow as C")

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
  34. Flawed Argument by logicnazi · · Score: 3, Interesting

    The fact that C code is not as close to assembely code as it once was isn't the relevant issue. The question is whether C code is still closer to the assembely than high level languages are. This is undoubtedly true. If you don't believe this try adding constructs to ruby or lisp to let you do low level OS programming and see how difficult it would be.

    I'm a big fan of high level languages and I believe eventually it will be the very distance from assembely that high level languages provide that will make them faster by allowing compilers/interpreters to do more optimization. However, it is just silly to pretend that C is not still far closer to the way a modern processor works than high level languages are.

    If nothing else just look at how C uses pointers and arrays and compare this to the more flexible way references and arrays work in higher level languages.

    --

    If you liked this thought maybe you would find my blog nice too:

    1. Re:Flawed Argument by Anonymous Coward · · Score: 0

      I'm not exactly sure what you're trying to argue for here.

      The question is whether C code is still closer to the assembely than high level languages are. This is undoubtedly true. If you don't believe this try adding constructs to ruby or lisp to let you do low level OS programming and see how difficult it would be.

      I hate to burst your bubble, but it's been done.

      As a measure of how "difficult" it was: "Despite being modest in number (perhaps 7000 units total as of 1988[1]), many now-commonplace technologies (including effective garbage collection, laser printing, windowing systems, computer mice, high-resolution bit-mapped graphics, computer graphic rendering and a number of networking innovations) were all first developed on Lisp machines".

      Sounds to me like it must have been a dream machine.

      Anyway, I see no reason why writing "low level OS programming" would be harder in Lisp. Based on my experience writing large programs in both C and Lisp, it seems like it would be much easier. At worst, you'd need to take advantage of implementation-specific inline assembler (which pretty much every Lisp implementation supports) for a few glue pieces, just as you do with C. If you think that's cheating, remember that ANSI C doesn't allow inline assembler, either, which is part of the reason that Linux won't compile with every C compiler out there.

      Can you name some specific part of an OS kernel or libraries that you think would be harder to write in Lisp, and why you think so? I'm genuinely curious.

  35. Imaginary history by dpbsmith · · Score: 5, Interesting

    Whoa! This article seems to be making up history out of whole cloth. I'm not even sure where to begin. It's just totally out to lunch.

    C was not a reaction to LISP. I can't even imagine why anyone would say this. LISP's if/then/else was an influence on ALGOL and later languages.

    C might have been a reaction to Pascal, which in turn was a reaction to ALGOL.

    LISP was not "the archetypal high-level language." The very names CAR and CDR mean "contents of address register" and "contents of decrement register," direct references to hardware registers on the IBM 704. When the names of fundamental languages constructs are those of specific registers in a specific processor, that is not a "high-level language" at all. Later efforts to build machines with machine architectures optimized for implementation of LISP further show that LISP was not considered "a high-level language."

    C was not specifically patterned on the PDP-11. Rather, both of them were based on common practice and understanding of what was in the air at the time. C was a direct successor to, and reasonably similar to BCPL, on Honeywell 635 and 645, the IBM 360, the TX-2, the CDC 6400, the Univac 1108, the PDP-9, the KDF 9 and the Atlas 2.

    C makes an interesting comparison with Pascal; you can see that C is, in many ways, a computer language rather than a mathematical language. For example, the inclusion of specific constructs for increment and decrement (as opposed to just writing A := A + 1) puts it closer, not to PDP-11 architecture, but to contemporary machine architecture in general.

    1. Re:Imaginary history by masklinn · · Score: 3, Informative

      LISP was not "the archetypal high-level language." The very names CAR and CDR mean "contents of address register" and "contents of decrement register," direct references to hardware registers on the IBM 704.

      You forgot "CONS" which comes from the IBM cons cells (a 36bit machine word on the 704), which is the block holding both a CAR and a CDR.

      The thing is, the names only existed because no one found any better name for them, or any more interresting name (Common Lisp now offers the "first" and "rest" aliases to CAR and CDR... yet quite a lot of people still prefer using CAR and CDR).

      LISP has always been a high level language, because it was started from mathematics (untyped lambda calculus) and only then adapted to computers.

      And the fact that Lisp Machines (trying to get away from the Von Neumann model) were built doesn't mean that Lisp is a low level language, only that IA labs needed power that the Lisp => Von Neumann machines mappings could not give them at that time.

      Lisp is a high level languages, because Lisp abstracts the machine away (no memory management, not giving a fuck about registers or machine words [may I remind you that Lisp was one of the first languages with unbound integers and automatic promotion from machine to unbound integers?])

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    2. Re:Imaginary history by vtcodger · · Score: 1
      ***C might have been a reaction to Pascal, which in turn was a reaction to ALGOL.***

      According to the introduction to K&R, C is descended from B and BCPL. I strongly suspect that B was influenced mostly by the problems of getting any computer language more abstract than assembler to fit onto and actually do useful work on a PDP-7.

      --
      You can't see ANYTHING from a car, You've got to get out of the goddamned contraption and walk...Edward Abbey
    3. Re:Imaginary history by Anonymous Coward · · Score: 0

      As someone who gets paid to program in Scheme (by choice, I might add), I have to respectfully disagree.

      Scheme (and the functional subset of Lisp) is a low-level language. It is to the lambda calculus what C is to a Von Neumann machine; anything which is computable on the machine is expressible in the language, but not necessarily conveniently.

      There are, however, two senses in which Scheme is a high-level language.

      First, Von Neumann machines actually exist, and in most cases, they are significantly harder to use than the lambda calculus. Since Scheme is a lambda calculus VM running on top of a Von Neumann machine, it acts like a high level language, since many of the things which you would normally have to worry about -- memory, for example -- are managed for you.

      Second, because Scheme is so blissfully simple and powerful, you can make it do virtually anything. An object system far more powerful than Java's is part of the library. So is anything involving state, including all forms of I/O. As a result, most implementations of Scheme provide enough functionality that it feels like you're writing in a high-level language.

      But step back for a minute. High-level constructs are ones that allow you to think about what you want to do instead of how to do it. I think recursion is one of the most important constructs in computer science, but it's still a how. The "what" counterparts of recursion are array programming languages. Being able to say Table1 + Table2 and getting the right answer? Now that's high-level.

      Obviously, you can't write data structures in a language like this, but that's not the point. The best language for most uses is generally not the most powerful, but rather the least powerful that will do what you want. When speed is not an issue, Java is better than C++ for many tasks (networking?), and Python is better still (one-line webserver?). For certain applications, such as databases and business rules, the best languages to use aren't even Turing-complete.

      Scheme is an amazing language, and the only one I've encountered that I would consider beautiful (although, with a different syntax, the functional subset of ML would be pretty close). But I've used real high-level languages -- Python, Ruby, Qt's UI XML -- and Scheme doesn't come close.

  36. I call... by raz0 · · Score: 1

    ... bullshit. These are purely artificial limitation you've put on high-level languages yourself. There are no clearly defined rules that divide low-level languages from high-level languages like that - it's just plain silly. The terms high- and low-level language are inherently relative and depend heavily on the context. To name an example, say we are talking about the field of Machine Architecture. In this field C is clearly a high-level language, since it's on top of assembly level, which is on top of the OS level, which is on top of the absolute machine code level, which is on top of the micro-code level, which again is on top of the actual hardware level. Actually you can continue futher down through the abstraction levels even further, but then you'd be leaving the field of Computer Science.

    Now if we're speaking in the field of programming languages actually used today, you could surely argue that C is one of the lower-level languages out there, and hence call it a low-level langauge. Personally, I prefer to always look at it from the Machine Architecture viewpoint, but I guess it's a matter of preference.

  37. Dude can't even write a clear sentence by Rinzai · · Score: 2, Insightful
    From TFA: The closer to the metal you can get while programming, the faster your program will compile -- or so conventional wisdom would have you believe. In this article, I will show you how high-level languages like Java aren't slow by nature, and in fact low level languages may compile less efficiently.

    I believe the phrase the faster your program will compile means "the faster the compiler will translate your program into machine-executable code." Apparently the author means "the compiler will generate faster code." He then makes the same mistake again, equivocating between the process of compilation and the quality of the compiled output.

    If you can't manage to write a clear sentence defining what topic you're exploring...what else might you be getting wrong?

    1. Re:Dude can't even write a clear sentence by TheRaven64 · · Score: 1

      The introductory paragraph is written by a sub-editor, not by the person who wrote the rest of the article.

      --
      I am TheRaven on Soylent News
    2. Re:Dude can't even write a clear sentence by Rinzai · · Score: 1

      I took the quote entirely from the first paragraph of the article in question. It even says "In this article, I will show you how..." so how do you conclude that was written by a sub-editor? Even if that assertion turns out to be true, wrong is still wrong, isn't it?

    3. Re:Dude can't even write a clear sentence by TheRaven64 · · Score: 1
      how do you conclude that was written by a sub-editor?

      Because I am the author of the article, and I did not write that paragraph. Looking back, it turns out that wasn't added by a sub-editor, it was added by the editor. This was added after the sub-edit had been approved by me.

      --
      I am TheRaven on Soylent News
  38. badly researched blather by Anonymous Coward · · Score: 1, Informative

    Badly researched to the point of being irresponsible.

    1. Unsupported implication that 'C' was created in response to PDP-11 assembly language.

    2. Using vector attached processors as evidence of HLL obsolescense. First, the Altivec/MMC unit is not the entire processor, it doesn't even do most of the work, it's an *attached* unit. There is still a main MPU to do the spaghetti code. Second, they are easily used by HLL's via optimized LIBRARIES, that's the beauty and breakthrough of 'C' that has become a model for HLL's.

    3. JIT examples fail to include the runtime of the JIT compiler itself. The program may speed up by 10%, but running the JIT before the program will blow that time out of the water.

    4. Article totally ignores the "RISC revolution" of the 80's where processors were actually designed based on HLL's, designed specifically to speed them up, acting in consort with the compilers & linkers. This concept is now old hat. Maybe the author wasn't born yet.

    Need I continue??

    1. Re:badly researched blather by Anonymous Coward · · Score: 0
      JIT examples fail to include the runtime of the JIT compiler itself. The program may speed up by 10%, but running the JIT before the program will blow that time out of the water.
      My own personal semi-high level language/compiler uses JIT compilation from bytecode to machine code. The JIT phase runs faster than the bytecode verification phase, and it produces machine code that generally runs 2-10x faster than bytecode interpreter and only about 2-5x slower than fully optimized C code (note: that's not a contradiction: the performance level of the bytecode interpreter varies depending on the task).

      In my humble opinion, spending a few milliseconds to at least double the performance is worth it if the code is going to run for more than the blink of an eye.
  39. Java vs C# -- flame on! by Anonymous Coward · · Score: 0

    C# is more strongly typed than Java.... :D

    1. Re:Java vs C# -- flame on! by andrewman327 · · Score: 1
      Oh no, only on /. could a comment about programming languages have the potential of starting another epic flame war... sigh.


      I would like to see the latest work on legacy C compared to the speed of a more modern language. TFA doesn't seem to give a point of reference, it only says that it is still fast.

      --
      Information wants a fueled airplane waiting at the hangar and no one gets hurt.
    2. Re:Java vs C# -- flame on! by chthon · · Score: 1

      I did some work in comparing Common Lisp compilers with C, and wrote some small benchmarks, and SBCL and CMUCL are capable of generating code that runs as fast or even faster than code which does the same in C.

      Afterwards (using 'Common Lisp' by Paul Graham) I discovered some other tricks with which it should be possible to align the Common Lisp and C benchmark code more, for getting to the most out of them. I haven't found time yet to do that.

      I should also find some larger benchmarks to write, to have a better comparison about optimisation of larger chunks of code.

  40. When do people care? by 91degrees · · Score: 1

    What are these high perfomance applications that really need the sheer speed provided by a Java JTI? Is speed really an issue these days? Most of the time, if things are working too slow, people are just going to throw some more hardware at it.

    1. Re:When do people care? by kpainter · · Score: 1

      Look out your office window and read what you see. Does the sign out front say Microsoft?

    2. Re:When do people care? by 91degrees · · Score: 1

      What's your point? Most people use resource hungry applications, including those people who buy from Microsoft, and they consider the investment in hardware to be worth it for the other benefits that the sub-optimal code provides.

    3. Re:When do people care? by kpainter · · Score: 1

      Microsoft products get more and more bloated all the time. They have an seemingly institutionalized attitude that it is ok to just require the user to continually buy faster hardware to run their bloatware.

    4. Re:When do people care? by 91degrees · · Score: 1

      Erm. Yes. As does most of the software industry. Have you tried running the latest version of Mac OSX on a G3? How about KDE on a Pentium? Since this is the way the software industry works, and most customers seem to be quite happy to buy faster hardware rather than allow for longer development times for more highly optimised software, why does it matter which programming language we use? The vast majority of applications will run at a perfectly acceptable speed on a reasonably cheap PC whatever language they're written in? Only a few applications (e.g. games and video compression) will show a noticable speed difference even if the performance is halved.

  41. Gentoo Stage 1 FTW! by Anonymous Coward · · Score: 2, Funny

    I thought this was the exact reason that Gentoo Linux exists.

    A stage 1 install will do the following:
    1) Compile glibc from source using architecture specific optimizations
    2) Compile gcc using the previously compiled optimized glibc and optimize gcc for the architecture
    3) Compile everything else using said architecture specific optimized tools
    4) ???
    5) Profit!

    And before all the trolls come in and say how long it takes to compile things, the Gentoo Handbook has several tricks like compiling from RAM, etc... to speed up compile times. I normally don't waste my time with Stage 1 because there are plenty of Stage 3 tarballs I can grab for whatever architecture I may be using at the time.

    Back to the point, if your glibc is compiling your code using the MMX registers for memcpy(), memset(), etc... it completely invalidates the point in the article about how those extra registers go unused. Additionally the point he makes about data structures, while valid, is a non-issue given that most serious programmers have taken a Data Structures and Algorithms course where you learn that O(n Log n) is less than O(n^2), and will choose to use trees and hash tables where appropriate.

    [sarcasm]Nevermind, he's dead on, no one ever implements a spanning tree in C code[/sarcasm]

    I see your point about the vectorization of library code, but point me to a high level language which does not suffer from that flaw given your assertion of closed source libraries. That is true across the board regardless of the language used.

  42. Re:Student Perspective by embracethenerdwithin · · Score: 4, Informative

    I thought it might be helpful for a current student to let you know what it is we learn today at my college. I'm a senior Software Engineering major, not a comp sci major. Comp Sci is another department and has a totaly different focus. They focus on super efficent algorithms, we focus on developing large software projects.

    My software engineering program has been very Java intensive. My software engineering class, object oriented class, and software testing class were all java based. We dabbled in C# a bit as well.

    However, I also had an assembly class, a programming languages class where we learned perl and scheme(this language sucks) and about five algorithms classes in C++. I also had an embedded systems class in both C and assembly(learned assembly MCU code, then did C).

    I feel like this is all pretty well rounded; I've learned a bunch of languages and am not really specialized in one. I'd say I am best at Java right now, but I can also write C++ code just fine.

    I've never been told a computer has any kind of crazy limitless performance. In embedded systems, I learned about performance. Making a little PIC microcontroller calculate arctan was fun(took literally 30 seconds without a smart solution). I also learned that there is a trade off between several things such as performance, development time, readability, and portability.

    We are taught to see languages as tools, you look at your problem and pull a tool out of the tool box that you think fit the problem best. You have to weigh whats important for the project and chose based off of that.

    The final thing I'd like to point out is that one huge issue with software today is it is bug ridden. How easy something is a test makes a big difference in my opinion. Assembly and C will pretty much always be harder to test than languages like Java and C#.

    I don't think the universities are the problem, at least not in my experience.

  43. good in some ways, painful in others by Anonymous Coward · · Score: 0

    My pet peeve with the article is "(...) at which point, you would be better off simply selecting a high-level language and letting someone else do the optimization."

    Translation: "I'm not able to do something like that, so you can't either because I'm smarter than you, so let's just keep advanced features out of the programming language altogether."

    If language designers argued that way, we wouldn't have Loki.

    Other than that, the article raises a few good points in that there are _some_ ways in which high-level languages can be better optimized than low-level ones. Hand-optimized loops nowadays can easily get in the way of the (better) optimizations the compiler would perform.

  44. Fruit salad again! Where's the computer science? by mcoon · · Score: 1

    Yet another apples to oranges comparison of language features and performance numbers. When are we going to start to see reporters getting up close and personal with real tests and numbers which attempt to compare task based operations on optimally tweaked code from various languages. I've had just about enough of someone saying that poorly written code in this language was slower than optimally written code in this other.

  45. Nooooooooo..... by hummassa · · Score: 1

    Maybe I didn't express myself well, but... yes, it's possible but normally it's not viable. Optimization (global optimization especially) is a repetitive, mechanical, task... which is best and fastest made by a computer than by a human being. Yes, I can think of clever ways for tweaking every part of a 1,000,000 LOC C (10M - 100M LOC asm) system, BUT I would take 100 years to do that! And an optimizing compiler in a fast machine will do a job 99% as good as I would in one hour -- two tops.

    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    1. Re:Nooooooooo..... by jallen02 · · Score: 1

      Thats not a fair way of how you optimize things in my experience. The old rule of thumb that 10% of the code does 90% of the work holds true for most large systems still. Then you consider that you could probably rewrite a small subset of that 10% in an optimized fashion to achieve good performance gains. You are looking at much, much less than 1,000,000 lines to review and optimize. A good profiler and a little patience will help you find that small subset that may have performance issues. A good compiler that optimizes everything at a global is still a valuable tool, but a good compiler can only do so much. You still need the right data structures and algorithms. Those are quite a bit more important than compiler choice in most cases. I see your point about the futility of coding an entire system in assembly, but it is a good idea to keep an eye on the larger picture of how the software evolves.

      Jeremy

    2. Re:Nooooooooo..... by mparker762 · · Score: 1

      Well, back in the day when we wrote large programs in assembly, we didn't optimize every line of code either. It's no different than C or other language, you only optimize the parts you need to. But back then even casually-written assembly was smaller and faster than the C and Pascal compilers generated, and if you buffed the code a bit you could really make it scream. But this was done only in certain places (video routines, memory management, etc). Nowadays we don't worry so much about size, so we code the non-critical bits in a higher-level language, and we don't worry so much about speed so we code the quick bits in C or C++.

      I've seen this attitude a lot in recent years that assembly is something separate from the rest of computer science, and I'm curious where it's coming from. Assembly is just another language family, and it can be learned and programmed in like any other language, and the same principles of programming apply to it like any other language, you use design patterns similarly, etc. It's a bit verbose, and reads vertically instead of horizontally, but you get used to these quirks pretty quickly.

    3. Re:Nooooooooo..... by hummassa · · Score: 1
      You are looking at much, much less than 1,000,000 lines to review and optimize.
      Which is exactly my point. If you are coding 10-100 million lines of assembly, you will only look at a small fraction of them to optimize, and you'll do a crappier job in years that the optmizing compilers would do in hours. A good optimizing compilers will do global register usage information, for example, that could keep a lot of variables in registers or at least in the processor cache; things HARD to do by humans, EASY to do by computers.
      --
      It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    4. Re:Nooooooooo..... by laffer1 · · Score: 1

      It comes from the movement to be specialized. In order to code in assembly, you need to have an understanding of the hardware. (at least a little) Most people i've had classes with think everything is drag and drop c# crap. One guy would only code in C++. Heck I had to buy a book on design patterns myself as they aren't part of any course. I recently transfered to another university which pushes java, patterns and makes assembly optional.

      In order to solve the problem, cs cirriculum needs to be standarized. Not only would it help with the new programmers, but it would make it easier to transfer to a new school and keep your credits. My old university was accredited by the ACM and still didn't talk about patterns.

    5. Re:Nooooooooo..... by pthisis · · Score: 1

      It doesn't necessarily have to be standardized completely, but there are some language bases that any reasonable CS curriculum will cover:

      * At least a semester of a lower-level EE course working with basic architecture (logic gates, VHDL or similar)
      * Assembly coding in at least one assembly language
      * At least one lower-level statically typed language (C, Fortran, C++, etc)
      * At least one strictly, statically typed language (ML, Haskell, etc)
      * At least one dynamically-typed language (scheme, smalltalk, lisp, python, etc)
      * At least one static class-oriented language (C++, Java, etc)
      * At least one more dispatch-oriented OO language (smalltalk, CLOS, python, etc)

      [My personal preference would be to cover these with some RISC assembly, C, ML, lisp, python, and java; lisp especially gives you a lot of other features that are worth discussing.]

      There are other language niches that are arguably important to cover, arguably stack-based languages (Forth, Postscript), non-class-oriented OO languages (self, JavaScript), etc. But at least the ones above deserve to be addressed in any respectable CS course.

      Patterns aren't core CS, they're just a jargon that Java programmers use to describe common program designs. Some of them aren't often applicable to all languages or have different, older names used by non Java-heads that predate the Gang of Five's choices. They're certainly worth covering if you're going to do a lot of class-oriented programming but think of them as more of a common lexicon than anything deeper.

      --
      rage, rage against the dying of the light
  46. Just one abstraction of many... by cardpuncher · · Score: 1

    A long time ago, until the idea of the stored program came along, computers were programmed with patch leads, so programs were little more than knitting patterns. The instruction sets of early stored program computers were developed around the hardware and were typically pretty chaotic. Then computers came along with consistent instructions sets that were specifically designed to assist compiler-writers (eg the VAX), but they no longer mapped terribly efficiently to hardware operations (as I recall, a single VAX instruction could cause over 50 page faults before completing!), so the "machine code" was a kind of intermediate language which was then interpreted by the instruction unit of the particular piece of hardware the program ran on. We're now kind of going back to the hardware-led instruction set (out-of-order execution, vector instructions, etc) simply because the balance of performance in the various parts of the computer (execution unit, memory, etc) has shifted again.

    The purpose of human-oriented programming languages (and I guess C just about qualifies...) is partly to make it easier to express the problem (and perhaps this is where we stop talking about C) and partly to provide a level of abstraction so that you don't have to rewrite the program for every piece of hardware. You can, of course, get the same effective abstraction from an intermediate language (such as the Java or .net virtual machine languages).

    But notice the number of abstractions we may have - high level language is compiled to an intermediate language that is then compiled to a CPU instruction set that is then interpreted by microcode. And don't forget the abstractions taking place in the CPU hardware - the addresses are virtualised, memory is cached, instructions are re-ordered.

    If you could control every aspect of the placement of your data, the use of the address-translation caches, the individual gates of the CPU, then your program would no doubt be very efficient. It would also run on only one piece of hardware.

    There's always going to be a loss of potential performance if you don't code down to the gate level, but there are compensating benefits in productivity and the longevity of the solution, providing you choose a level of abstraction that is a natural fit for the problem you are trying to solve. If you try to use C to write a program for which it isn't particularly well suited (and that's a long list), then it's unlikely the compiler or anything else can help you!

    1. Re:Just one abstraction of many... by tarpitcod · · Score: 1

      Exactly! C when designed showed a close match to the underlying architecture of common machines. Contrast this with a modern microprocessor - RISC - Really Post RISC now, or CISC. Consider the underlying microarchitecture of an OOO 4 way superscalar MPU. What would a programming language look like if we took away the ever futher from the metal ISA and wrote much closer to the metal? Itanium perhaps?

      How many physical registers in a Core duo / Athlon 64, what does the cache behave like, what groups of instructions can execute simultaneously? Would C translate well to this model? Would you really want to treat arrays and pointers the same on a machine with memory protection? What considerations would you want to make about function calls, memory allocation, stack usage? What language details would you want to add to handle the prevalence of SIMD instructions?

      If C compilers could write to the metal on modern CPUs what would performance be like? I wish the Nx586 had been more successful, and we had all gotten a chance to turn off that x86 translation layer...

      I think half the problem is some programmers have never worked at the embedded level, or only early processors where an instruction could be shown to be a set sequence of logical events. The disparity between modern ISA's and what is going on at the low level is growing all the time.

    2. Re:Just one abstraction of many... by linuxrocks123 · · Score: 1

      > There's always going to be a loss of potential performance if you don't code down to the gate level, but there are compensating benefits in productivity and the longevity of the solution, providing you choose a level of abstraction that is a natural fit for the problem you are trying to solve.

      Actually, going down to the gate level isn't a sure way to get maximum performance too, unless you're talking about modeling the code versus designingthe processor. You can get a higher clock rate by designing application-specific gates from transistors, and CPU designers sometimes do for critical paths.

      --
      vi ~/.emacs # I'm probably going to Hell for this.
  47. "The Truth about C++ Revealed" by Rod,+Hot · · Score: 5, Funny
    Dusted this off from the rec.arts.humor archive... It seemed appropriate.

    From:

    Subject: The truth about 'C++' revealed

    Date: Tuesday, December 31, 2002 5:20 AM

    On the 1st of January, 1998, Bjarne Stroustrup gave an interview to the IEEE's 'Computer' magazine.

    Naturally, the editors thought he would be giving a retrospective view of seven years of object-oriented design, using the language he created.

    By the end of the interview, the interviewer got more than he had bargained for and, subsequently, the editor decided to suppress its contents, 'for the good of the industry' but, as with many of these things, there was a leak.

    Here is a complete transcript of what was was said, unedited, and unrehearsed, so it isn't as neat as planned interviews.

    You will find it interesting...

    __________________________________________________ ________________

    Interviewer: Well, it's been a few years since you changed the world of software design, how does it feel, looking back?

    Stroustrup: Actually, I was thinking about those days, just before you arrived. Do you remember? Everyone was writing 'C' and, the trouble was, they were pretty damn good at it. Universities got pretty good at teaching it, too. They were turning out competent - I stress the word 'competent' - graduates at a phenomenal rate. That's what caused the problem.

    Interviewer: problem?

    Stroustrup: Yes, problem. Remember when everyone wrote Cobol?

    Interviewer: Of course, I did too

    Stroustrup: Well, in the beginning, these guys were like demi-gods. Their salaries were high, and they were treated like royalty.

    Interviewer: Those were the days, eh?

    Stroustrup: Right. So what happened? IBM got sick of it, and invested millions in training programmers, till they were a dime a dozen.

    Interviewer: That's why I got out. Salaries dropped within a year, to the point where being a journalist actually paid better.

    Stroustrup: Exactly. Well, the same happened with 'C' programmers.

    Interviewer: I see, but what's the point?

    Stroustrup: Well, one day, when I was sitting in my office, I thought of this little scheme, which would redress the balance a little. I thought 'I wonder what would happen, if there were a language so complicated, so difficult to learn, that nobody would ever be able to swamp the market with programmers? Actually, I got some of the ideas from X10, you know, X windows. That was such a bitch of a graphics system, that it only just ran on those Sun 3/60 things. They had all the ingredients for what I wanted. A really ridiculously complex syntax, obscure functions, and pseudo-OO structure. Even now, nobody writes raw X-windows code. Motif is the only way to go if you want to retain your sanity.

    [NJW Comment: That explains everything. Most of my thesis work was in raw X-windows. :)]

    Interviewer: You're kidding...?

    Stroustrup: Not a bit of it. In fact, there was another problem. Unix was written in 'C', which meant that any 'C' programmer could very easily become a systems programmer. Remember what a mainframe systems programmer used to earn?

    Interviewer: You bet I do, that's what I used to do.

    Stroustrup: OK, so this new language had to divorce itself from Unix, by hiding all the system calls that bound the two together so nicely. This would enable guys who only knew about DOS to earn a decent living too.

    Interviewer: I don't believe you said that...

    Stroustrup: Well, it's been long enough, now, and I believe most people have figured out for themselves that C++ is a waste of time but, I must say, it's taken them a lot longer than I thought it would.

    Interviewer: So how exactly did you do it?

    Stroustrup: It was only supposed to be a joke, I never thought people would take the book seriously.

  48. Programs don't need optimization... by aadvancedGIR · · Score: 2, Insightful

    as much as development process.

    CPU power is available and cheap but time to market is critical. Most of the time, you don't need to do the fastest program ever, but to do a program that works reasonably well and that you can debug easily (some may say it is the same requirement).

    C may not be the best tool for any given task but it is a pretty decent swiss army knife that most people know how to use reasonably well.

    Disclaimer: I'm not in web devmnt but in embedded real time on DSP. With 8 dedicated ALU (2 mul, 2 add/sub, 2 logic and 2 load/store) running at the same time on the chip, there is still not many good alternatives to C (let the compiler optim and pray) and ASM (massive headhache).

    1. Re:Programs don't need optimization... by masklinn · · Score: 1

      Unless you develop your language/dialect that is, I know that a game studio had developped it's own Lisp dialect to write PS2 games.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
  49. Focus on triviality weakens argument by amightywind · · Score: 1
    The very names CAR and CDR mean "contents of address register" and "contents of decrement register," direct references to hardware registers on the IBM 704. When the names of fundamental languages constructs are those of specific registers in a specific processor, that is not a "high-level language" at all. Later efforts to build machines with machine architectures optimized for implementation of LISP further show that LISP was not considered "a high-level language."

    To make judgements on a language based such trivialities is ludicrous. For all we know car and cdr where retained for sentimental reasons. Lisp is far more influenced by the abstract lambda calculus than by specific machine instructions. Lisp is a high level language by any sane definition.

    C makes an interesting comparison with Pascal; you can see that C is, in many ways, a computer language rather than a mathematical language. For example, the inclusion of specific constructs for increment and decrement (as opposed to just writing A := A + 1) puts it closer, not to PDP-11 architecture, but to contemporary machine architecture in general.

    Again you focus on the trivial. No sane person would judge Pascal by increment/decrement idioms. Focusing on Pascal's type system, parameter passing, lexically scoped functions and procedures would be more useful.

    --
    an ill wind that blows no good
  50. Tommy Boy Analogy by suggsjc · · Score: 1
    Software sucks today because software engineers don't understand computers, and that's why languages and environments like Java and .NET will make software worse.

    Let's see what Tommy Boy has to say about this statement:

    Tommy: Hey, I'll tell you what. You can take a good look at a butcher's ass by sticking your head up there. But, wouldn't you rather to take his word for it?
    Mr. Brady: [confused] What? I'm failing to make the connection here son.
    Tommy: No, I mean, you can get a good look at a T-bone by sticking your head up a butcher's ass, but then..no. It's gotta be your bull.
    --
    When I have a kid, I want to put him in one of those strollers for twins and then run around the mall looking frantic.
  51. Take a deep breath and look up "still" by p3d0 · · Score: 1
    So we "still can get good performance" from C? The implication is that C will somehow become overcome by some unnamed high-elvel language soon.
    When I see that we "still can get good performance", all that means to me is that we used to get good performance, and we continue to do so today. If I say "cars are still a convenient way to travel", I'm not implying that something else is about to overtake them. When I say "my children are still my two favourite people" that doesn't mean some new people are right around the corner.
    --
    Patrick Doyle
    I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    1. Re:Take a deep breath and look up "still" by Anonymous Coward · · Score: 0

      No, he's right. "Still" implies the possibility of change.

    2. Re:Take a deep breath and look up "still" by p3d0 · · Score: 1

      I'm not disputing the implication that change is possible; I'm disputing the implication that change is likely.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
  52. Quoted often, but still wrong by Qbertino · · Score: 2, Insightful

    Computer science is no more about computers than astronomy is about telescopes" -- Edsger Dijkstra quotes (Dutch computer Scientist. Turing Award in 1972. 1930-2002)

    I see this quote everywhere, and just because it's by some semi-famous academic, nodody questions it and takes it for granted. The quote is utter rubish.

    With astronomy you have stars, which aren't man made and thus only scarcely understood and the tools we use to look at them, teleskopes, which are man-made. We understand them.

    Computers and Computer Science are both things that are entirely man-made. There is no natural phenomenon that we call 'computer' and a science that studies this natural phenomenon called "computer science". It's all one thing. The quote is rubbish and contains no usefull information whatsoever. On the contrary: the conclusion it draws in abolutely false.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:Quoted often, but still wrong by Pendersempai · · Score: 1

      "There is no natural phenomenon that we call 'computer'"

      So? It's a theoretical construct. There's no natural phenomenon that we call "integers" either, and yet the number theorists don't need to feel constrained by the limitations of computing hardware. Most mathematicians believe that there are prime numbers of a googol digits, for example, even if modern hardware couldn't hope to find them.

      Computer science is not an empirical science, at least not generally; like mathematics, it is axiomatic. In this sense it is not constrained by the physical limitations of the current iteration of computer hardware, and (as usual) Dijkstra is absolutely right.

    2. Re:Quoted often, but still wrong by Beek · · Score: 1

      Computer Science is a study of math, not computers. Computers are the the tool that enables you to carry out the algorithms that Computer Scientists discover.

      If you're saying math is entirely man-made, that's a bit of a stretch. The properties of numbers, the algorithms are out there, we just have to discover them.

      Telescopes are not necessarily the only to view space. Computers aren't the only to find the results of an algorithm. They're the best tools for the job, but they aren't the only ones.

    3. Re:Quoted often, but still wrong by Anonymous Coward · · Score: 1, Informative
      I see this quote everywhere, and just because it's by some semi-famous academic, nodody questions it and takes it for granted. The quote is utter rubish.

      I agree. Why should we give any weight to the sayings of some random guy. What the hell would he know know about computer science?

      The quote is rubbish and contains no usefull information whatsoever. On the contrary: the conclusion it draws in abolutely false.

      It seems to me that you are good example of the type of person that the OP was complaining about (ie. not knowing much about computer science). If you read about the history of computer science you would see that it started as a pure mathematical discipline that just happened to use computing devices because the algorithms were too complex to be solved quickly by hand. The early computer was just a tool that made things easier for mathematicians, much like a telescope for astronomers. Of course, modern computer science focuses much more on algorithms specifically related to computer functions like disk caching, task scheduling, etc. So Dijkstra's comment may not be as relevant today but at the time he said it was pretty accurate.

    4. Re:Quoted often, but still wrong by Anonymous Coward · · Score: 0

      You really should explain your post to 14CharUsername (972311) Apparently he didn't understand that particular point. Of course Surt took care of the other point.

    5. Re:Quoted often, but still wrong by drew · · Score: 1

      Math is entirely man made. It's an entirely artificial construct that can be used to help convey ideas. Yes, there are a great many properties of numbers and algortihms that we have yet to discover, but all of those properties derive from a much smaller set of properties that we have agreed upon. Take geometry, for instance. There are hundreds of geometric theorems, and probably hundreds more that have yet to be proven, but they all trace back to a dozen or so postulates that can't be proven because they are the definitions that we have agreed to base everything else off of.

      --
      If I don't put anything here, will anyone recognize me anymore?
    6. Re:Quoted often, but still wrong by Anonymous Coward · · Score: 0

      Math is used extensively in computer science, but math is rarely the object of computer science. My personal definition of the object of computer science is this: Computer science is about formalizing information processing problems such that a machine can solve them and about the limits of that endeavour. The tools of the trade are computers (for the practical part) and math (for the theoretical part), but computer science is not primarily about improving either (only in the sense that everybody seeks better tools).

    7. Re:Quoted often, but still wrong by StrawberryFrog · · Score: 2, Informative

      The quote is utter rubish. ... With astronomy you have stars, which aren't man made ... Computers and Computer Science are both things that are entirely man-made. There is no natural phenomenon that we call 'computer' and a science that studies this natural phenomenon called "computer science".

      Not. Even. Wrong.

      If astronomy was called "telescope science" you'd also forget that it was about ways of looking at the skies. Computers are more flexible that that - they are used to model and study all kinds of natural phenomena. Algorithyms are strictly speaking mathematics, which is a feature of the universe and not "man made" if anything ever was. Computers are used to store and manipulate data about all kinds of things, most of which are not about computers. learning how to do all that is computer science.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    8. Re:Quoted often, but still wrong by awol · · Score: 1

      e^(i*pi) + 1 = 0
      Now if that ain't natural I don't know what is. It is about 4 aspects of the "unit" combined into one relationship. That is, the "unit logarithm" raised to power of the "first root" of the "negative unit" times the ratio of the locus about a point and the unit of [the "unit circle"] plus the "unit" equals nothing. There are no "man made" constructs and it is definitely mathematics.

      --
      "The first thing to do when you find yourself in a hole is stop digging."
    9. Re:Quoted often, but still wrong by treeves · · Score: 1

      Seems like we've gone from "appeal to authority" to "false dichotomy" in our range of logical fallacies here. The quote ISTM is a bit hyperbolic, but neither completely right nor completely wrong. It illustrates some truth about what computer science is/is not, but ignores the link between computers and computer science, a link not quite the same as the link between telescopes and astronomy, but quite similar.
      In a way, astronomy is about telescopes, in that you can't do it without them.

      --
      ...the future crusty old bastards are already drinking the Kool-Aid.
    10. Re:Quoted often, but still wrong by drew · · Score: 1

      That equation only has any meaning because of the meaning that man has chosen to assign to pi and e (and for that matter 1).

      --
      If I don't put anything here, will anyone recognize me anymore?
    11. Re:Quoted often, but still wrong by ClamIAm · · Score: 1

      Congrats on getting hung up on the implementation. The "conclusion" that Dijkstra is trying to get across is that the point of a discipline is not to study the tools it uses to get its job done. Claiming that astronomy is somehow SOOO DIFFERENT because it involves natural phenomena completely misses the point.

    12. Re:Quoted often, but still wrong by Anonymous Coward · · Score: 0

      There is no natural phenomenon that we call 'computer'

      Turing machine. It is, almost by definition, "The Computer".

      Yeah, it is not "natural phenomenon" ...

    13. Re:Quoted often, but still wrong by rbarreira · · Score: 1

      But how can someone claim that computers in computer science are merely a tool, if so much of computer science is about trying to find ways to use computers to do stuff which doesn't even have anything to do with either computers or computer science??

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    14. Re:Quoted often, but still wrong by ClamIAm · · Score: 1

      That's a nice assertion you got there. Too bad you can't come up with any examples to back it up.

    15. Re:Quoted often, but still wrong by rbarreira · · Score: 1

      Just look around you, software is everywhere. Are you stupid or just a troll?

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    16. Re:Quoted often, but still wrong by Anonymous Coward · · Score: 0

      The most failsafe cure for the belief that computer science is about computers is to enroll as a student of computer science. It shouldn't take you more than a year to realize that there are much faster and efficient ways of becoming a good programmer or learning how computers work.

    17. Re:Quoted often, but still wrong by ClamIAm · · Score: 1

      Just look around you, software is everywhere. Are you stupid or just a troll?

      What the fuck are you talking about? Let's look at what my last post was replying to:

      But how can someone claim that computers in computer science are merely a tool, if so much of computer science is about trying to find ways to use computers to do stuff which doesn't even have anything to do with either computers or computer science??

      You are claiming here that much of computer science has to do with "stuff that doesn't have anything to do with computers or computer science". Okay, I'll accept this claim, as long as you provide examples and a logical argument to back it up.

      This then raises the question: have you provided any examples or logical arguments to back up this claim? The answer is no, you have not. You stake a claim yet fail to provide any reasons as to how this claim relates to reality. That is why I replied in the manner I did.

      To summarize: unless you get around to doing the above, your claim is bullshit. And I'm not going to waste any more time holding your hand through Writing A Coherent Argument 101. Have a nice day.

  53. the author... by ynohoo · · Score: 2, Insightful

    the author is only a couple of years out of college and he is already well on his way to be becoming a professional troll. I see a bright future for him...

  54. Whaaa! My language is better. by Anonymous Coward · · Score: 2, Insightful

    People will always argue over 3 things:
    1) whether assembly is faster than C
    2) whether interpreted languages are faster than C/C++

    The real question here is - which type of language does well for your application?

    Ultimately C will be faster if a good programmer, who understands the language and the application. However, will he be more productive? I'd never write a third person shooter in python, perl, or java. However, what I might do is add a 3d engine to a python statistics modeling program that's already written in one of those languages. Most people would agree, writing a web interface in C is just insane if you have anything particularly useful you want to write. However, I'll probably write a multi-process webserver in C, just because it makes sense for speed (I know python has a built-in webserver, but there are features it doesn't have. You may be able to write it in python, but will all those features that apache have be fast?).

    The bottom line is:
    - Define the application you want to build.
    - Define your requirements (responsiveness, rhobustness [security,reliability,etc], extendability, deadlines).
    - Do a little research with a few languages (just experimentation). Write prototype interfaces in the language, do a little benchmarking, just play with it.
    - Make a decision on a language based on what you've found and what's required.

    As more high level languages appear (functional languages look very promising), see what those languages have over what's already out there. If it has an applicability to what you're doing, use it.

    I'm tired of seeing everyone beat a dead horse. Yes, I know the two arguments:
    - X is faster
    - Y is just as fast as X, but can do it in less lines of code.

    X & Y are different, there's no ignoring it. There's more dimensions to languages than speed and time to market, don't ignore them.

    1. Re:Whaaa! My language is better. by Anonymous Coward · · Score: 0
      People will always argue over 3 things:
      1) whether assembly is faster than C
      2) whether interpreted languages are faster than C/C++

      ...and how to count to 3?

  55. Re:Student Perspective by mlwmohawk · · Score: 1

    Sorry, I have to laugh at this one (at your expense)

    >> "I don't think the universities are the problem, at least not in my experience."

    Do you *have* any experience?

    >> "The final thing I'd like to point out is that one huge issue with software today is it is bug ridden. How easy something is a test makes a big difference in my opinion. Assembly and C will pretty much always be harder to test than languages like Java and C#."

    What makes you think that Assembly and C are harder to test? Have you ever used a debugger? I step through code, I can even see the assembler being executed. There are FAR better tools for debugging "real" compiled code than there are interpreted code. If the program is hung, I can stop a program excatly where it is and see my stack and my actual code path. I can even send it a SIG_INT and break into the debugger. With a core dump I can do a post-mortum on a crash.

  56. C and Smalltalk is what happened. by LWATCDR · · Score: 4, Informative

    C became popular because of Unix. Since you could get the source code for Unix most big universities used Unix in there OS courses. And since it was written in c you where going to learn C if took Computer Science. Textbooks started to assume you knew c. Magazines started to assume you knew c. People wrote free small c compilers and then came GCC, so now you could have a good free c compiler for just about any system. But before GCC all the buzz was about Smalltalk. Smalltalk was the future. OOP was going to replace structured programing. The problem was very few people has a computer that could run Smalltalk. So C++ was born.
    A final blow to Modula-2 was simply Borland didn't create a Modula-2 compiler. For many years when you said Pascal you reall meant Turbo or Borland Pascal. Borland was the Pascal company and they add objects to pascal and eventual created Delphi.
    I am sure Topspeed has closed up shop. There just isn't much room for compiler makers anymore. You have the free software at the bottom end and the Microsoft Monster at the top. Only a few niche players are left. Ada seems to be a place where a good compiler company can still make a few dollars.

    --
    See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    1. Re:C and Smalltalk is what happened. by glindsey · · Score: 3, Interesting

      Well, that's not entirely true: compilers for PCs may not be a big business anymore, but compilers for embedded systems are still a huge business, despite the availability of GCC for many platforms. You need only look at IAR to confirm that...

    2. Re:C and Smalltalk is what happened. by Wudbaer · · Score: 2, Informative

      Borland didn't create a Modula-2 compiler

      Small nitpick: They did indeed create a Modula-2 compiler - I think even called Turbo Modula-2 - at the end of the 80s for CP/M. I purchased it back then for my C-128 (those where the days *looks at current laptop* - not). However, CP/M then already had begun its way into obsolecence, and Borland's German division needed almost 6 months to deliver the damn thing. When I finally got it it was more or less unusable, as the IDE froze or something like that when you tried to compile something. In that respect it's better to think they never had released this abomination.

    3. Re:C and Smalltalk is what happened. by belmolis · · Score: 2, Interesting

      This seems generally to be true, but some small outfits are apparently still making money selling compilers. In the early 90s I used the Power C compiler for DOS. It was a nice compiler and cheap ($20). Recently I was amazed to see that the company, Mix Software, is still in business, with the same low prices. How they do this I have no idea.

    4. Re:C and Smalltalk is what happened. by Anonymous Coward · · Score: 2, Informative

      Further: Topspeed was a suite of compilers by JPI (the split away group of Borland -> JP Jensen Partners), They ended up writing the compiler for Clarion (well reused their existing compiler technology as all their compilers: c/c++/pascal/modula2 shared the same obj format and as such they could mix and match languages within a single exe/dll - sound familier!!!), after providing this compiler, they merged with Clarion to form TopSpeed the company, whose main product was Clarion...

    5. Re:C and Smalltalk is what happened. by Anonymous Coward · · Score: 1, Interesting

      Quality of generated count still counts for a lot in embedded systems. GCC generates significantly worse code than commercial alternatives for ARM. And it doesn't have good support for some processors, like the 68HC11 or 8051, still important in the embedded world even if the desktop PC crowd has long since moved on.

      GCC's long suit is portability to new architectures, at which it is unparalleled. However, for any particular processor architecture, the specialist compilers generally do better. And the cost of the compiler is small compared to the cost of the programmer or the cost of high-volume manufacturing. Saving some flash and RAM space adds up to a lot of money.

      Of course, the compiler is only a small part of the whole toolchain. Embedded systems also need to be debugged. You can't download a free JTAG emulator to go with GCC. Information might want to be free, but hardware doesn't.

    6. Re:C and Smalltalk is what happened. by LWATCDR · · Score: 1

      Your right. I should have said that they didn't create a Turbo Modual-2 for the PC. For the life of me I can not figure out why Borland released anything for CP/M at that date.

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    7. Re:C and Smalltalk is what happened. by LWATCDR · · Score: 1

      Simple.
      I don't think they have any new products. Looks like the same stuf the sold 15 years or so ago. All there product look to be for DOS or are ansi c libraries.
      It is probably little more than a hobby now. It doesn't a lot of sales to make a simple webpage and a phone on an answering machine worth while.

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    8. Re:C and Smalltalk is what happened. by harryjr · · Score: 1

      The FAA uses assembly languag for radar real time processing and analysis. Their RISK and Mainframe (IBM-390) use C++ and ADA for part of the processing and links to assembly language for radar data processing (RDP). Air Traffic Controllers need to know where the aircraft in their sectors are positioned within seconds rather than minutes for 5 mile seperation. The problem with ADA is too few programmers know how to code it though it is similar to Pascal. I used hardware logic analyzers (Tektronix)to measure the throughput for the differnt languages for each data type; ie radar, tabular (flight info), beacon (transponder info), keyboard (controller input) etc.

  57. The myth of assembly performance by p3d0 · · Score: 4, Insightful
    Well, generally you'll have faster code if you code it in assembly.
    No, generally you'll have slower code. In a few specific, well-chosen places, you may get faster code. If you had unlimited time, patience, and performance tuning expertise, then you could beat the compiler on a large application, but how realistic is that?

    Coding large apps in assembly is usually way beyond the point of diminishing returns in terms of performance.

    --
    Patrick Doyle
    I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    1. Re:The myth of assembly performance by Anonymous Coward · · Score: 0

      Generally you have faster code because generally someone writing in assembler knows what he's doing. But let's not generalize in such a stupid way. Fools can make an HLL program that's really slow too. There's nothing in HLL vs LLL that inherently speaks to final speeed. Too many other factors contribute.

      The reason people like assembler is that there are many functions in many application domains which can't be made sublinear, which get iterated 100,000s of times, and which therefore need to run in the minimum number of CPU cycles per iteration. You cannot get past a certain point with the speed of this code in any given HLL/compiler pairing. In assembler you can reach the processor's theoretical limit on that code.

      The only likely difference between you and I is in our estimation (which is industry specific) of how often code like that comes up.

      I work in the games industry, and we have a lot of code like that.

      We also have a lot of code that's just spaghetti and for that we like to use domain scripting languages.

      Common knowledge on how you should only use assembly in "well chosen" hot spots of code is so much bunk when 50% of your system code is hot.

    2. Re:The myth of assembly performance by p3d0 · · Score: 1

      Ok, that is interesting. Games are a domain I'm not familiar with. Thanks.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    3. Re:The myth of assembly performance by Anonymous Coward · · Score: 0

      >> Well, generally you'll have faster code if you code it in assembly.
      > No, generally you'll have slower code. In a few specific, well-chosen places, you may get faster code. ...
      > Coding large apps in assembly is usually way beyond the point of diminishing returns in terms of performance.

      There are some general principles that still ring true:
        - the only way to make a program faster on the same hardware is to make it do less
        - parallelization is a special case of this (where you do more in each step, requiring fewer steps)
        - the first optimization you should try to make is to find a faster algorithm
        - assembly allows finer-grained instructions, so if you need to "trim the fat" you have more places you can do it
        - this doesn't imply that any given program will have ANY trimmable fat whatever!

  58. The era of High-Level Languages is ending by skeptictank · · Score: 1
    Modelling and code generation tools have reached the point where they actually work. These tools can generate the same cookie-cutter/boiler-plate code as high-level languages. In addition, the tools can handle task and data dissemination/recombination across multiple processor.

    I can't speak to other industries, but in the aerospace segment of the embedded market the trend is clear. Future development will be model-driven.

    1. Re:The era of High-Level Languages is ending by arevos · · Score: 1
      Modelling and code generation tools have reached the point where they actually work. These tools can generate the same cookie-cutter/boiler-plate code as high-level languages.

      The benefits of high level languages go far beyond boiler plate code. If you want these benefits, you need more than a basic code generation tool - you effectively need a compiler. Then the question becomes; does my Python-to-C compiler generate code that's any faster than native Python bytecode?

  59. Re:Student Perspective by Anonymous Coward · · Score: 0
    ...scheme(this language sucks)...
    /me makes a note never to hire someone with the nickname "embracethenerdwithin".
  60. I disagree by Sun · · Score: 1

    But it's rather long. I posted the detailed reasons in my blog.

    In a nutshell:
    - Intel has put lots of optimizations into the actual CPU. The author did not account for those.
    - Future proof - C is a simple language, for which it is simple to write complex optimizers.

    Shachar

  61. Don't be so sure by overshoot · · Score: 3, Insightful
    Well, generally you'll have faster code if you code it in assembly.
    I wouldn't even grant that in the general case.

    Amazingly far back (try the 80s) a professor friend of mine had a marvelous example of compiler-generated code where the compiler had done such an amazing job of optimising register use that you had to trace through more than 20 pages of assembler output with colored markers to trace from where the register was loaded to where it was used.

    No way I would ever have the huevos to code that way in assembler. On a RISC machine or (Heaven help us) the Itanic it gets lots worse.

    --
    Lacking <sarcasm> tags, /. substitutes moderation as "Troll."
    1. Re:Don't be so sure by Anonymous Coward · · Score: 0

      Wow, the compiler tied up such a limited resource as a register for over 20 pages of code? That doesn't sound very good to me. A *better* compiler would have figured out a way to use that register during the intervening lines of code. Either the code was especially simplistic (not requiring much in the way of registers), the machine had an extreme abundance of registers, or the compiler probably could have done a better job of register allocation. Given that this is back in the 1980s, I would assume the latter. Of course, it could also be (being a 1980s era compiler) that a "register" keyword was being strictly adhered to.

  62. Re:Student Perspective by Just+Some+Guy · · Score: 1
    /me makes a note never to hire someone with the nickname "embracethenerdwithin".

    You beat me to it. What you just said, innernerd, was that you consider yourself a jack-of-all-imperative-languages and that you hate things that don't look like Algol. That's like saying that you're a linguist because you can speak American, British, and Australian English (but never really tried Spanish, Russian, or Japanese).

    It's too bad, really, because there's a lot of fun and profit to be had in the non-imperative realm. I hope you can see that some day.

    --
    Dewey, what part of this looks like authorities should be involved?
  63. Java. . . by Bastian · · Score: 1

    I had the sneaking suspicion from the first page of this article that Java was going to be trotted out.

    I think possibly the most boring tech article genre ever is "Person who likes Java writing yet another essay about how great Java is." To be quite honest, I'm not interested. I agree, high-level languages are great. That's actually a lot of why I don't like Java-the-language. Sure, it's got a garbage collector, but its syntax and semantics are those of C. C syntax is like the QWERTY of programming languages - it may not have been explicitly designed to slow you down when it was first created, but bugger if that isn't the main thing it's good for nowadays.

    I'm also rather tired of the Java-isn't-really-slower thing. Folks make the argument, they trot out all sorts of benchmarks that are great at proving that Java is wonderful for running benchmarks. At least this article admitted what everyone already knows from experience - that Java bytecode running on the virutal machine produces apps that are slower and eat more memory than equivalent apps that run native. GCJ evades that problem, but otherwise, why should I care about it? If I'm compiling to native code rather than to the JVM, I'm suddenly presented with the option of using a whole host of other programming languages that blow Java out of the water in the ease-of-programming department.

    1. Re: Java. . . by fury88 · · Score: 1

      This is the exact same reason why I can't believe that Micro$oft moved to .NET. Writing windows applications with managed code is got to be slow as hell. Java Swing is a perfect example.

    2. Re: Java. . . by Bastian · · Score: 1

      .NET really isn't quite as bad, from what I can tell. I'm not a Windows user, so I don't have nearly as much experience with .NET apps as I do with Java ones, but from what my not-entirely-informed brain can tell, what hurts Java most is that its virtual machine is designed for really small apps. As I understand it, Java was originally designed for embedded applications (JINI being an example of a great idea for how to use Java.), and then Sun figured out it would also be great for making Web applets. I agree; Java is great for those purposes. .NET, on the other hand, was designed from the ground up for desktop applications, so I would hope that Microsoft managed to come out with a product that works reasonably well in that domain. There's a lot of leeway for designing bytecode virtual machines, and I'm sure some design decisions can have a huge impact on performance. For example, I'm not sure the stack-based nature of the JVM is all that great of an asset when it's being used to run a word processor.

    3. Re: Java. . . by nasch · · Score: 1

      The question is, who cares? If database traffic (fetching, not db server processing) is 75% of the app's time, what does it matter how fast the rest of the code is? Substitute whatever else your app spends its time doing, unless it's processor-bound. Choice of language simply will not have an effect on performance. Pick your language based on what you know how to do, what you would like to learn, what your other apps are written in, just don't do it based on performance. I don't recall ever needing to optimize anything besides database calls in business software. That doesn't mean I've never done it, but it hasn't happened often enough to stand out.

    4. Re: Java. . . by Bastian · · Score: 1

      Y'see, this is what I'm talking about. If I'm talking about the performance of the JVM, of course I'm talking about situations where the task is processor-bound. Do you really think I'm so clueless that I'd believe that my choice of development platform has an effect on, say, network latency?

    5. Re: Java. . . by Anonymous Coward · · Score: 0

      The reason real life java programs are in many cases so much slower, while benchmarks of just in time jvm's show a different result, is because java invites a style where lots of objects are created while running the main program logic. Using a gcj in this case doesn't really help. It is possible to rewrite those programs in another style but doing could take more time than coding the program in the first place. Finding the troublespots and only rewriting part of the program to fight object creation really takes some talent and also a lot of time, so that is rarely done for inhouse java programs. The end result being that the java program is just slow, users have to live with it and java keeps its reputation of creating slow memory hogs.

    6. Re: Java. . . by nasch · · Score: 1

      I have no idea how clueless you are. For one thing, it wasn't clear that you were talking about the performance of "the" JVM, as you said "Java". Java, as we know, is not the same thing as the JVM. Secondly, my point is that even if the performance of the JVM is substantially worse than that of a C++ executable (even 50-100% worse) it probably will have NO effect on the performance of most applications most of the time. If someone tells me that Java is 5-10% slower than native compilation, my response is "OK, but so what?" If someone tells me it's 500-1000% slower (ie slow enough to make a real difference), my response is "I don't believe you." So yeah, Java may very well be slower most of the time, but IMO that just isn't relevant.

  64. Trust me, I'm an expert by overshoot · · Score: 1
    What was true 20 years ago is still true today, well written code in a low level language tailored to how the computer actually works will always be faster than a higher level environment.
    And what was true 20 years ago was for a different world.

    You may have the time to lovingly hand-code an initialization routine, making sure at each line to check the scoreboard for the multiple execution engines on each stage of the CPU's pipeline so as to avoid congestion stalls. I'm sure that you can crank out as many as ten lines a day that way.

    Similarly, Bob Pease also lovingly calculates the equations for analog circuits, eschewing the use of simulators.

    The rest of us are content to let that massive bookkeeping chore to computers, because hand-calculating the intersymbol interference in a multi-gigabit signaling environment (with adaptive decision-feedback equalization) in the face of multiple parametric variables would take until the next millennium.

    The same goes for scoreboarding multiple-issue deep-pipeline processors with branch prediction. You just do not want to go there by hand, but compilers do it easily.

    --
    Lacking <sarcasm> tags, /. substitutes moderation as "Troll."
  65. Re:Student Perspective by embracethenerdwithin · · Score: 1

    I was not talking about industry experience, I was talking about univesity experience. I figured this would be helpful, as it has been many years since many people on \. went to a university. It's easy to talk about what is supposedly being taught, but unless you are currently in a university how can you know? The simple fact is the supposed univeristy experience the parent talks about is not realistic, at least nto for me. I am not saying I am some software expert or even know all that much, I am just giving the observations of a student. I can't say I will learn everything I need to know, but I think it will be pretty close. A big problem today is that computer majors are gettign really hard to squeeze into 4 year programs. As far as the testing remark, I have used the Visual Studio debugger to trace through C, C++, assembly. It wasn't all that bad. However, in my Software Tetsing class we actually created testing tools in Java and C#, it was pretty cool I actually made my own java debugger quite easily. Java has some cool features that actually let you talk to the virtual machine. This can be very helpful. We made one tool that let you see how many times every line of code was executed, that way you could make sure you covered them all in test cases. Maybe C and assembly have this, I don't know.

  66. tradeoffs by b17bmbr · · Score: 1

    I program mostly with java and python, and php for web sites. I'll probably agree(though I can't actually verify it myself) that C/C++ programs will run faster. However...I can accomplish alot more in a much shorter amount of time, and do so much safer in java. Java's object serialization, I/O, and networking for example make so many projects much faster and easier. Sure, they don't run as fast as a native program, but that's not the point. There are tradeoffs to any language/platform one chooses.

    --
    My problem? I was perfectly gruntled, until some numbnuts came by and dissed me.
  67. Um no. by wonkavader · · Score: 2, Informative

    No, what they SAY is "The proof is in the pudding" --

    From google:

    Results 1 - 10 of about 326,000 for "the proof is in the pudding". (0.47 seconds)
    Results 1 - 10 of about 118,000 for "the proof of the pudding is in the eating" [definition]. (0.30 seconds)

    They're not right, of course, but then, sadly, you're not either, since what people say has changed. It's changed to something nonsensical, which people quote without understanding, which is annoying, like "I could care less!":

    Results 1 - 10 of about 2,180,000 for "I could care less". (0.28 seconds)
    Results 1 - 10 of about 776,000 for "I couldn't care less". (0.22 seconds)

    But "the proof is in the pudding" kind of rolls off the tongue better... like a pudding which tastes nasty and you are therefore gently, but suavely, spitting out.

    1. Re:Um no. by Anonymous Coward · · Score: 0

      >They're not right, of course, but then, sadly, you're not either, since what people say has
      >changed. It's changed to something nonsensical, which people quote without understanding,
      >which is annoying, like "I could care less!":

      Actually, "I could care less" is not nonsensical at all; it is a polite shortening of a sarcastic comment, leaving the sarcasm itself just implied. I could care less what you think about this, if I were dead and distracted by a nuclear war.

  68. C was never that fast by e1618978 · · Score: 1

    I coded the same CPU-intensive program in both Fortran and C on a DEC microvax back in 1988 - the Fortran program was about twice as fast. I tried every trick that I could think of to get the C code to improve - in the end it was still a little slower than the Fortran code (2%-10% slower), and the speed optimization had reduced the code to an unsupportable mess.

  69. Re:Student Perspective by embracethenerdwithin · · Score: 1

    Here is the reason I hate scheme. Compare these two lines and tell me which makes you're head hurt really bad. Java, C++, C#, C: (3+4) *5 -6 /2 +3 Scheme: (+ (/ (* (+ 3 4) 5 ) 2) 3) I thought the functional thing was cool, I just think they went a bit too far.

  70. LANGUAGES are not interpreted by alispguru · · Score: 2, Informative

    Most truly high-level languages, like LISP (which was mentioned directly in TFA), are interpreted, ...

    Programming languages are not "interpreted". A language IMPLEMENTATION may be based on an interpreter. Every major implementation of Common Lisp today has a complier, and most of them don't even have an interpreter any more - everything, including command-line/evaluator input, is compiled on-the-fly before being executed.

    ... and the interpreters are almost always written in C. It is impossible for an interpreted language written in C (or even a compiled one that is converted to C) to go faster than C.

    Again, this is a property of implementations, not of languages. The highest-performance Common Lisp implementations have scaffolding written in C and assembly, but they do not use a C compiler when they compile Lisp code. They often use non-C ABI conventions for argument passing and stack handling, to make their style of function calling faster.

    I don't mean to be harsh, but the "Lisp is slow because it's interpreted" meme is about twenty years out of date. It tends to be spread primarliy by college professors whose last exposure to Lisp was pre-1980, and it really grates on those of us who know better.

    --

    To a Lisp hacker, XML is S-expressions in drag.
    1. Re:LANGUAGES are not interpreted by hyc · · Score: 1

      And my Lisp professor was always harping on "Lisp is not slow" in my college days, trotting out the multi-precision arithmetic support and such as ready examples to prove his point. Granted, getting pi to 100 digits faster than my HP41CV was impressive by human standards, but that in no way proved that Lisp in general was slower than C or some other language.

      --
      -- *My* journal is more interesting than *yours*...
  71. Initially by Vexorian · · Score: 3, Insightful

    The article later points out that the native version was running slower due to not using optimization options correctly. And later the native version was running 15% faster than the managed version

    --

    Copyright infringement is "piracy" in the same way DRM is "consumer rape"
  72. C = Mid-Level language by DeadCatX2 · · Score: 1
    And as far as this high-level/low-level thing goes, I'd call C a "mid-level" language.

    I agree entirely, and I'm glad I'm not the first person to have thought so. Rather than shifting low level around to encompass C, why not make a mid-level classification and shove C in there? After all, it helps a bit to know about the architecture you're compiling to when writing C, but it's not necessary like assembly.
    --
    :(){ :|:& };:
  73. Re:Student Perspective by Erich · · Score: 1
    scheme(this language sucks)

    yodav("That is why you fail.");

    I like C, and I tend to write imperative Python. But for what I do, that's very appropriate.

    But if you are referring to a dialect of Lisp as a language that "sucks", you need more in your brain before you open your mouth.

    --

    -- Erich

    Slashdot reader since 1997

  74. Disassemble a windows DLL... by skids · · Score: 1

    ...then come back and tell me if you still believe this after reading the result.

    I recently came across code that essentially did this to test for a power of two and then multiply by it:

    if (var == 1 || var == 2 || var == 4) {
            switch (var) {
            case 1: var2 = var2; break
            case 2: var2 = var2 + var2; break;
            case 4: var2 = var2 << 2 break;
            default:
    }

    Given the sheer number of assembly instructions (+jump table) needed for the above, I don't think anyone could make the case that this is more efficient than if (var == 1 || var == 2 || var == 3) var2 <<= var

    (and no, the effects on the flags register were not being used.)

    Just because it is technically possible to have compilers that optimize well doesn't mean our compilers actually do so.  Now granted this was probably made by a lame MS compiler, but it shows that faith in compilers may be misplaced, and most certainly should not be transferred from one compiler to another.

    (Aside... sometimes I think some people who code compilers have absolutely no idea of the price of code/data cache/bus bandwidth.)

    1. Re:Disassemble a windows DLL... by skids · · Score: 1


      Well obviously I should proofread as my susbstitute code is wrong -- but the point stands, there are much more efficient ways to implement the above.

    2. Re:Disassemble a windows DLL... by p3d0 · · Score: 1

      I'm not saying that compilers are really great. Just that it's infeasible to do a good job optimizing a large application manually, and that the quality of code you could produce with a reasonable (ie. commercially competitive) amount of manpower would be inferior to that produced by a compiler.

      In response to your aside, I am a compiler writer, and I sometimes thing the same thing about people who write applications. :-)

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    3. Re:Disassemble a windows DLL... by Anonymous Coward · · Score: 0

      A stupid compiler is no proof for compilers beeing stupid in general. And the changes to the resulting code from a simple -O can be amazing ;-)

      All the best,
      rob

  75. Lisp and operating systems by alispguru · · Score: 2, Insightful
    Existing high-level languages, such as LISP, provided too much abstraction for implementing an operating system

    Huh? I would argue that commercially successful (as in boxes sold to Fortune 500 companies and used in production) operating systems have been written in three languages:

    * Assembly

    * C

    * Lisp

    Are there any commercially successful OSs written in C++ yet?

    (revealing my ignorance and posting flamebait, all in one)

    --

    To a Lisp hacker, XML is S-expressions in drag.
    1. Re:Lisp and operating systems by gregarican · · Score: 1

      What were Microsoft Windows 3.1, 95, 98, ME, etc. coded in? I thought it was C++, but perhaps I am ignorant...

    2. Re:Lisp and operating systems by mparker762 · · Score: 1

      Assembly and C, just like Unix.

    3. Re:Lisp and operating systems by wandazulu · · Score: 1

      They're all coded in straight C with assembly where appropriate. I read somewhere that part of the graphics engine in Win2000 was written in C++, but I can't find any claim to back that up.

      Apart from BeOS and OS/400, which were written in pure C++, I believe most operating systems are written in C...as difficult it is to write and debug an operating system in any language, adding a more complex language to the mix will make it that more difficult to track down bugs; I don't think it's explicitly mentioned in Brook's Mythical Man Month, but OS/360 was written in PL/I and that was apparently a very heavyweight language, which added to the complexity and difficulty in getting it out the door.

    4. Re:Lisp and operating systems by Anonymous Coward · · Score: 0

      While a lot of it is pseudo-C (i.e. C-style argument, return and error semantics), much of Windows is written in C++ (technically object oriented, uses classes and the like).

    5. Re:Lisp and operating systems by Guy+Harris · · Score: 1
      I don't think it's explicitly mentioned in Brook's Mythical Man Month, but OS/360 was written in PL/I

      I suspect it wasn't explicitly mentioned in The Mythical Man-Month, given that it's not true. OS/360 was largely written in assembler.

    6. Re:Lisp and operating systems by wandazulu · · Score: 1

      Perhaps, but I'm guessing the other part was PL/I: http://en.wikipedia.org/wiki/PLI/

    7. Re:Lisp and operating systems by wandazulu · · Score: 1

      Hmm...seems to be a problem with the URL tag...remove the trailing slash that was not added by me from the URL and it will go to the right page:

      http://en.wikipedia.org/wiki/PLI

    8. Re:Lisp and operating systems by Guy+Harris · · Score: 1
      Perhaps, but I'm guessing the other part was PL/I: http://en.wikipedia.org/wiki/PLI/

      More like PL/S. It was not one of the original OS/360 languages, however; see, for example, slide 20 of this presentation for an OS class, which says "In mid-1970s, IBM migrated to PL/S, a medium-level language".

    9. Re:Lisp and operating systems by todorb · · Score: 0

      Symbian is written in C++.

  76. given the difficulty by Lawrence_Bird · · Score: 1

    of finding a good Algol compiler these days one is forced to use FORTRAN 77 for speed.

    1. Re:given the difficulty by Doctor+Faustus · · Score: 1

      Given the difficulty... of finding a good Algol compiler these days
      Forget good. Are there *any* Algol 60 compilers available for a PC?

    2. Re:given the difficulty by Lawrence_Bird · · Score: 1

      I only know of one http://www.angelfire.com/biz/rhaminisys/algol60.ht ml

      there is an interpreter here:
      http://www.xs4all.nl/~jmvdveer/algol68g-mk9 /doc/install.html

      Jovial which is a variant used by the military in embedded systems will cost you
      many $$$.

      There also appears to be an algol compiler on the twenex.org "machine" but I've
      not used it yet.

  77. Parts of the OS X kernel are written in C++ by porkchop_d_clown · · Score: 1

    I want to say "all the OS X kernel" but I'm not sure that's true.

    1. Re:Parts of the OS X kernel are written in C++ by Guy+Harris · · Score: 1
      I want to say "all the OS X kernel" but I'm not sure that's true.

      I'm absolutely certain it's not true. Sign up for a free Apple Developer Connection "online" membership and you can look at the kernel source and be absolutely certain too.

    2. Re:Parts of the OS X kernel are written in C++ by porkchop_d_clown · · Score: 1

      And yet... I have an ADC membership, and I've written all this Cocoa Objective-C USB code that's definitely interfacing with C++ constructs in the IOKit. Which is a major PITA. And there's the little complaint that - I've also had to write device drivers for OS X, and they are also written in C++.

      I may, of course, have been mistaken in thinking that simply because the IO subsystem is written in C++ that that meant that portions of the kernel were also written in C++

    3. Re:Parts of the OS X kernel are written in C++ by Guy+Harris · · Score: 1
      And yet... I have an ADC membership, and I've written all this Cocoa Objective-C USB code that's definitely interfacing with C++ constructs in the IOKit.

      If it's Cocoa, it's userland. There's both userland and kernel IOKit code.

      And there's the little complaint that - I've also had to write device drivers for OS X, and they are also written in C++.

      The kernel IOKit code is in C++ (and I never said it wasn't; I said that it's not the case that all OS X kernel code was in C++).

      I may, of course, have been mistaken in thinking that simply because the IO subsystem is written in C++ that that meant that portions of the kernel were also written in C++

      The kernel-mode IOKit code is C++. However, not all of the kernel code is in C++; assuming that because IOKit is in C++ the entire kernel in C++ is, indeed, a mistake.

    4. Re:Parts of the OS X kernel are written in C++ by porkchop_d_clown · · Score: 1

      Ah. Sorry - I misread your comment; I thought you were saying that none of the kernel was written in C++ - my bad.

  78. An expert assembly programmer in a CPU... by Terje+Mathisen · · Score: 4, Insightful

    I've probably written more assembly than most slashdot readers, and most of what you say is true:

    It used to be the case that I could always increase the speed of some random C/Fortran/Pascal code by rewriting it in asm, parts of that speedup came from realizing better ways to map the current problem to the actual cpu hardware available.

    However, I also discovered that much of the time it was possible to take the experience gained from the asm code, and use that to rewrite the original C code in such a way as to help the compiler generate near-optimal code. I.e. if I can get within 10-25% of 'speed_of_light' using portable C, I'll do so nearly every time.

    There are some important situations where asm still wins, and that is when you have cpu hardware/opcodes available that the compiler cannot easily take advantage of. I.e. back in the days of the PentiumMMX 300 MHz cpu it became possible to do full MPEG2/DVD decoding in sw, but only by writing an awful lot of hand-optimized MMX code. Zoran SoftDVD was the first on the market, I was asked to help with some optimizations, but Mike Schmid (spelling?) had really done 99+% of the job.

    Another important application for fast code is in crypto: If you want to transparently encrypt anything stored on your hard drive and/or going over a network wire, then you want the encryption/decryption process to be fast enough that you really doesn't notice any slowdown. This was one of the reasons for specifying a 200 MHz PentiumPro as the target machine for the Advanced Encryption Standard: If you could handle 100 Mbit Ethernet full duplex (i.e. 10 MB/s in both directions) on a 1996 model cpu, then you could easily do the same on any modern system.

    When we (I and 3 other guys) rewrote one of the AES contenders (DFC, not the winner!) in pure asm, we managed to speed it up by a factor of 3, which moved it from being one of the 3-4 slowest to one of the fastest algorithms among the 15 alternatives.

    Today, with fp SIMD instructions and a reasonably orthogonal/complete instruction set (i.e. SSE3 on x86), it is relatively easy to write code in such a way that an autovectorizer can do a good job, but for more complicated code things quickly become much harder.

    Terje

    --
    "almost all programming can be viewed as an exercise in caching"
  79. More Myth here by wonkavader · · Score: 2, Informative

    It's possible to say everything siad in this article -- vaugely, as it is said in this article -- and be right, and yet still dance around the reality.

    Take a look yourself on http://shootout.alioth.debian.org/

    C's faster than Java. It will probably always generally be so, unless you're trying to run C code on a hardware Java box.

    This article says Java, for example, CAN be faster. But it doesn't say "C is almost always faster than Java or Fortran, usually faster than ADA, and C can be mangled (in the form of D Digital Mars, for instance) to be faster than C usually is. Often, Java is a pig, compared to C, BUT THERE ARE TIMES WHEN IT ISN'T. Really. There are times, few and far between, when it's actually, get this, FASTER. It's fun to look for those few times. And if you write programs which do that, that'd be cool. And as processors get wackier and wackier, there will be more and more times where this is true. Meanwhile, if your developers write good code, Java's easier to develop in and debug." Which would be more completely correct.

    Excuse, me, now. I have to go back to my perl programming.

    1. Re:More Myth here by Nicolay77 · · Score: 1

      Java can be faster in some things.

      In my benchmarks, java is faster than C++ in method invocation, and in object instantiation with new (heap instantiation).

      Method invocation is so fast in both languages than it contributes very little to running time.

      Object instantiation however does, but then you can do stack instantiation of objects in C++ that is then much faster than Java. And you can overload new and delete operators in C++.

      For everything else Java is slower.

      --
      We are Turing O-Machines. The Oracle is out there.
  80. SW Industry - Down The Drain by smcdow · · Score: 2, Informative
    With the trend towards VM's and virtualization, that "hypothetical" computer comes ever closer.

    Yay. With continued displays of attitudes like that, I'm going to leave the industry.

    It is getting increasingly difficult to hire S/W engineers that understand that there is an operating system and also hardware beneath the software they write. I need people NOW that can grok device drivers, understand and use Unix facilities, fiddle with DBs, write decent code in C, C++, Java, and shell, and can also whip together a decent WS interface. Someone who does all of those.

    WhyTF has the S/W industry become so compartmentalized? I can hire a device driver person, but he won't know anything about web services. I can hire a DB person, but she won't know a damn thing about poking values into registers. I can hire a web-services person, but he will have never worked on a Unix platform before. WTF? Really, WTF?

    In short, I can't hire someone who can take ownership of an entire system. It's always, "Well, that's a hardware thing, go ask Foo", "Oh, it looks like the database, need to talk to Bar", "The Web interface is borked, we'll need to bring Baz in", "Hm, it doesn't do this when we run it on Windows" (this one always pisses me off, because they can never explain why, and that's because they know nothing about Unix). How come I can't hire someone who could understand a whole vertical stack (and maintain it, and provide analysis and fixes when something breaks)?

    I do this kind of thing now. If I can do it, it can't be that hard. But everybody thinks they have to specialize. THIS IS WHAT'S WRONG WITH THE INDUSTRY.

    --
    In the course of every project, it will become necessary to shoot the scientists and begin production.
    1. Re:SW Industry - Down The Drain by Cutting_Crew · · Score: 1

      It's because people are solidifying their skills and becoming good at they know what they are good at. I sure hope you arent one of those people that place ridiculous job ads looking for a Software Engineer that somehow has the skill set that rivals Superman's..wanting one person to know c++, java, db, unix, html etc etc. With outsourcing going on people are honing in on their best skill and getting good at it. Yes a few people will be good at 2 things, maybe 3 but never as good as the ONE thing that they have the most experience and training with...and the other 2 or 3 things they will only have basic knowledge of.. not mastery skill.

      I am sure there are a few wonder boys out there that can do all you ask but they probably already have jobs and if they dont they are running their own gig making a lot more money than you can pay them. If they are looking they are going to cost.

    2. Re:SW Industry - Down The Drain by Anonymous Coward · · Score: 0

      I bet that I know more about my specialty than you do. I bet that I am better at applying it, too. Really there's nothing worse than a two-bit hack who has a superficial understanding of a lot of things but no substantive knowledge of anything. I have to correct your stupid mistakes because you don't know nearly as much about the subject as you think you do, but that doesn't keep you from spreading your stupidity and pounding your chest like you're the alpha geek. I deal with retarded shits like you all of the time, and honestly I wish that you would leave the industry. You don't need one person to do everything. He won't do it well. You don't hire an IP attorney to defend you at a criminal proceeding. You don't go to a heart specialist to get plastic surgery. If you can do everything yourself then what you're doing clearly isn't very difficult.

    3. Re:SW Industry - Down The Drain by Anonymous Coward · · Score: 0

      One of the greatest replies I've read in a long time. I wish I had points today.

    4. Re:SW Industry - Down The Drain by Teckla · · Score: 1
      I need people NOW that can grok device drivers, understand and use Unix facilities, fiddle with DBs, write decent code in C, C++, Java, and shell, and can also whip together a decent WS interface. Someone who does all of those.

      If you find someone who can do all those things, they're either (a) lying, or (b) do all those things poorly.

    5. Re:SW Industry - Down The Drain by spedrosa · · Score: 1

      Amen!

      The problem is that this is not marketable. I could probably do most of that, and more. As could many slashdotters, no doubt.

      Now, try to write a résumé, including everything you've already had experience with, or that were interesting enough for you to learn, if you are that talented. Recruiters are either going to think you are crazy, lying, or something in-between. If not, there's always the argument that "you're a jack of all trades but master in none". Which might, or might not be the case. People tend to assume the former.

      Besides, most people I know aren't in computer science for fun. They're doing what they do because it's a profitable market. Why spend your nights studying when you can focus on Java/.NET + a couple of frameworks and make just as much money?

      Businesses need to change. They are the ones going down the drain.

      Specialization is for ants.

    6. Re:SW Industry - Down The Drain by spedrosa · · Score: 1


      A person with that profile can't expect to challenge an expert in the field. However, so-called "experts" can be just as a "retarded shit" as everyone else, completely oblivious and unable to even pinpoint problems that are outside their field of knowledge.

      Taking your medicine example, that's what General Practitioners exist. They are supposed to have a broad field of knowledge, to correctly diagnose diseases and bodly malfunctions. *THEN*, if the problem is serious, the patient gets referred to an specialist.

      What's the equivalent computer scientist? There's none. Remember the saying, when you've got a hammer on your hand, everything look like a nail. If you're implying that people like that do not always have the necessary humility to ask others for help, than I couldn't agree more.

      Knowledge is never wasted.

    7. Re:SW Industry - Down The Drain by smcdow · · Score: 1
      I bet that I know more about my specialty than you do. I bet that I am better at applying it, too.

      Probably so. But you missed my point. Your being a specialist means that you're useless to me.

      --
      In the course of every project, it will become necessary to shoot the scientists and begin production.
    8. Re:SW Industry - Down The Drain by smcdow · · Score: 1
      If you find someone who can do all those things, they're either (a) lying, or (b) do all those things poorly.

      Unfortunately, I agree with you completely. And this is the problem with the industry.

      --
      In the course of every project, it will become necessary to shoot the scientists and begin production.
    9. Re:SW Industry - Down The Drain by Anonymous Coward · · Score: 0

      Heh, tell me about it. I was just dumbfounded one day when I noticed our Java guys having a client side app throwing about 300-400 dinky little queries at the database for a trivial operation. They just didn't realize that this might be kinda slow as the client side app had to construct and then send each query individually.

      I hovered over the one that would take direction, had them throw one (slightly) larger query at the DB, and it "amazingly" cut about %60 of the overhead for the client. Did close to the same amount for the DB op too - and allowed our clients to continue processing their data. :P

      Idiot Java devs that didn't know anything about dbs and apparently didn't even think about the code they were writing, and idiot dba that was in a panic because he couldn't figure out a way to 'fix' the database...

      sighs

  81. Oh my god... by rbarreira · · Score: 1
    If your assembly was better than his C, then you must have a forgiving definition of the term "good".

    My assembly code was done from his C code, I couldn't have done it easily without having the C code first. And the algorithm came from a scientific paper, having been benchmarked against many other algorithms for doing the same thing. Even if it wasn't optimal (as the other guy proved later), it wasn't sloppy or anything like it.

    Did you misunderstand me? I alluded that most speedups come from algorithmic shifts, rather than implementation shifts

    It WAS a different algorithm for the same routine, not simply a recoding of the same algorithm. Sorry for not having said it so explicitly the first time. Of course algorithms are more important than implementations, which doesn't mean that the effect of the implementation isn't important as well. Everyone with serious knowledge of software performance knows that.

    Check the source. It wasn't written in assembly. The entry you point to: Don't modern compilers take care of instruction scheduling? is highly revealing. The fact that djbfft was written in C demonstrates it's still possible to handle these things from C code. It demonstrates that there are more valuable speedups gained from a better algorithm.

    Now you start to seem like you have a too broad view of what algorithmic improvement is. Algorithms have nothing to do with code, they're a level of abstraction above (as you can see in any scientific paper presenting a new algorithm, they rarely give anything more than pseudocode). Instruction scheduling is NOT an algorithmic improvement, it's an platform dependent implementation detail. Their FAQ answer which says compilers aren't good at it just shows that they also think a human is better at optimizing code.

    So the author knows how to improve the algorithm.

    This is, again a sentence coming from your broad view of what algorithmic improvement is.

    You'll note that only one of them suggests writing assembly code, and it's to handle an obsolete case.

    I didn't paste the whole TODO file, and even on the part I pasted ALL the references are to assembly code. Look at them please. Even the only one which doesn't mention asm explictly is speaking about registers, which you can't manipulate directly in C. I don't want to sound like an ass but at least show some knowledge regarding what we're talking about...

    And to clarify: my point is there a good assembly programmer can often do much better than any compiler, and that things will stay that way for some time to come. Eventually the situation may be the opposite, but right now it surely isn't!
    --

    The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
    1. Re:Oh my god... by mrsbrisby · · Score: 1
      Now you start to seem like you have a too broad view of what algorithmic improvement is. Algorithms have nothing to do with code, they're a level of abstraction above (as you can see in any scientific paper presenting a new algorithm, they rarely give anything more than pseudocode). Instruction scheduling is NOT an algorithmic improvement, it's an platform dependent implementation detail.
      I think this is our sticking point then, because I do view instruction scheduling as an algorithmic improvement. I don't think I'm alone on this, djb has written a large number of papers regarding algorithm in this way, and he refers to other papers by other authors that regard algorithm in this way.

      I think the reason many papers come with pseudocode has to do with the attention of the paper, and that many processes are improved with algorithms that produce big results in pseudo-code. Can you tell me that you never see a paper on processor scheduling algorithms? Or what about new circuits to take advantage of, or in the development of new scheduling algorithms?

      Their FAQ answer which says compilers aren't good at it just shows that they also think a human is better at optimizing code.
      I did not disagree with this. I only state that choice of language is a much smaller part of code optimization than is stated.

      Even the only one which doesn't mention asm explictly is speaking about registers, which you can't manipulate directly in C. I don't want to sound like an ass but at least show some knowledge regarding what we're talking about...
      First of all, the compiler can be instructed to use a register-passing ABI instead of using the stack. This is incompatible with other libraries, which is probably why he didn't use -mregparm so easily.

      Secondly, he's talking about examining the assembly output, and tuning the input to tune the output. Look at the source, it's all C. It's layout is based heavily on the assembly that is produced by the compiler- but because it's C, it still _works_ on platforms that it hasn't been explicitly optimized for.

      The assembly he's talking about is the MMX operations- he's used them in other projects.

      And to clarify: my point is there a good assembly programmer can often do much better than any compiler, and that things will stay that way for some time to come. Eventually the situation may be the opposite, but right now it surely isn't!
      I'll agree with this to a point: There are so few good assembly programmers, that anyone who says they are almost certainly is not. Furthermore, so few problems benefit the most from this method, that it is almost always prudent to disclaim any demonstrated improvement. Changing the algorithm almost always helps more.
    2. Re:Oh my god... by Anonymous Coward · · Score: 0

      Can you tell me that you never see a paper on processor scheduling algorithms?

      I see an implied non-sequitur here: Just because something can be altered BY an algorithm, it doesn't follow that the alteration represents a change OF an algorithm. (I'm not attacking the rest of that argument though)

    3. Re:Oh my god... by mrsbrisby · · Score: 1
      I see an implied non-sequitur here: Just because something can be altered BY an algorithm, it doesn't follow that the alteration represents a change OF an algorithm. (I'm not attacking the rest of that argument though)
      Fundamentally? Probably not.

      I think while it's helpful to point at an implementation and say "That is the PATRICIA algorithm" to mean it's the algorithm Morrison described, but what if they change some aspect? Maybe reorder some steps? Some algorithms - even presented in "formal papers" - are extremely sensitive to changes.

      It may be helpful to say they model the same original function - that is, given the same inputs this new algorithm produces the same outputs as the original, but it can hardly be said that it's the same algorithm if it performs so differently.
    4. Re:Oh my god... by Anonymous Coward · · Score: 0

      You are correct. Don't feed the trolls.

    5. Re:Oh my god... by Anonymous Coward · · Score: 0

      I think while it's helpful to point at an implementation and say "That is the PATRICIA algorithm" to mean it's the algorithm Morrison described, but what if they change some aspect? Maybe reorder some steps? Some algorithms - even presented in "formal papers" - are extremely sensitive to changes.

      This is essentially what I meant by "rest of that argument" :)

  82. Re:Student Perspective by Anonymous Coward · · Score: 0

    Well, the first AC got it right. You're scared of syntactical differences. That's really bad. I was going to suggest that you read "On Lisp" and "Structure and Interpretation of Computer Programs" for enlightenment, but it's apparent that you're beyond help.

  83. The advantage of Fortran is purely coincidental. by master_p · · Score: 2, Insightful

    When Fortran was made, nobody thought that CPUs of 30 years in the future will have vector processing instructions. In fact, as Wikipedia says, vector semantics in Fortran arrived only in Fortran 90.

    The only advantage of current Fortran over C is that the vector processing unit of modern CPUs is better utilised, thanks to Fortran semantics. But, in order to be fair and square, the same semantics could be applied to C, and then C would be just as fast as Fortran.

    The fact that C does not have vector semantics reflects the domain C is used: most apps written in C do not need vector processing. In case such processing is needed, Fortran can easily interoperate with C: just write your time-critical vector processing modules in Fortran.

    As for higher-level-than-C languages being faster than C, it is purely a myth. Code that operates on hardware primitives (e.g. ints or doubles) has exactly the same speed in C, Java and other languages...but higher level languages have semantics that affect performance as much as they can help performance. All the checks VMs do have an additional overhead that C does not have; the little VM routines run here and there all add up to slower performance, as well as the fact that some languages are overengineered or open the way for sloppy programming (like, for example, not using static members but creating new ones each time there is a call).

  84. Aliasing rules... by porkchop_d_clown · · Score: 1

    n Fortran, modifying the same variable through two different names leads to undefined behavior

    So, COMMON blocks have been removed from the language?

    1. Re:Aliasing rules... by Aardpig · · Score: 1

      No, they're still there, since to remove them would break backward compatibility. But there are better ways of achieving the same functionality, via derived data types and modules.

      --
      Tubal-Cain smokes the white owl.
    2. Re:Aliasing rules... by joib · · Score: 1


      So, COMMON blocks have been removed from the language?


      No, they're still there although "modern Fortran" programming style doesn't use them.

      But more to the point, what are you babbling about? You were never allowed to access a variable both via a procedure argument and via a common block in the same procedure.

  85. Re:Student Perspective by mlwmohawk · · Score: 1

    I'll stop being hard on you, but you REALLY need to get a clue about what you don't know. Believe me, this is not intended as an insult, you are a student, you couldn't possibly know.

    >>"I can't say I will learn everything I need to know, but I think it will be pretty close"

    You best lose that attitude right now. It is wrong on almost every level. Pretty much every word, as ordered in that sentense, is wrong. You don't really learn until you leave school. School gives you foundation so that you are not utterly lost in the real world.

    The smartest thing you wrote was this:

    >> "Maybe C and assembly have this, I don't know."

    You really don't, and that's sad. Whats even more sad is you don't realize that you do not know. For instance, you wrote: "We made one tool that let you see how many times every line of code was executed," that's called a profiler and they've been around for years (decades?), and, yes, they have them for C and assembly.

    Listen, I don't want to play bash the nubee all day, while it is sort of fun, it isn't very nice, your arguments are making my point. You claim that java and .net have better debugging tools, but you don't even know what debugging tools are currently available. The little you think you know is be better than the rest that you don't, and that is not an informed way of approaching problems.

  86. I knew it - java apologist., 4 pgs into RTFA by oldwarrior · · Score: 0

    Yes, yes, quite, uhhuh... virtual code based programming languages are nice but once cannot scientifically show them to be faster than or even equal to machine-code based programming languages for most operations. Everything else is design fluff. I would much rather write a payroll system in Java (or COBOL) but will stick to C or Assembler for drivers, realtime graphics, or significant byte manipulation. True believers in JVM's should not feel threatened by this observation. Java is still cool but its not C.

    --
    If it were done when 'tis done, then t'were well it were done quickly... MacBeth
    1. Re:I knew it - java apologist., 4 pgs into RTFA by Drasil · · Score: 1

      Never trust anyone who would rather write anything in COBOL ;)

  87. Re:Student Perspective by Anonymous Coward · · Score: 0
    ...makes you're head hurt...
    That particular spelling mistake makes my head hurt much more than Java, C++ or C#.
  88. modern processors are designed with C in mind. by lophophore · · Score: 1
    The article states that "The task of mapping C code to a modern microprocessor has gradually become increasingly difficult."


    While this is true, it's not an impediment for 99.9% of programmers. Many modern microprocessors are not only designed to be programmed in C; they are optimized for it.

    The key to fitting the code to the target CPU is in the tools. The hard part is in the optimizer, and that's where some OSS tools may be weak. It's one thing to generate code that will execute on a platform, but a completely different (and far, far more difficult) thing to generate code that will coax the maximum performance from a given CPU.

    --
    there are 3 kinds of people:
    * those who can count
    * those who can't
  89. Uh, what? by porkchop_d_clown · · Score: 1

    This paragraph is complete crap. If you're using a Dictionary API in a so called "low-level language", it's as possible for the API to do the same optimization as it is for the runtime he talks about; and you're still letting "someone else do the optimization".

    That makes no sense. TFA says " This kind of dynamic optimization is simply impossible in a low-level language without building higher-level semantics on top..." and you say "this is crap because all I have to do is call a 3rd party API to get the same thing."

    In other words, you're saying it's not true that you have to add another layer of abstraction to C to get dynamic dictionaries because all you have to do is add dynamic dictionaries.

    Huh?

    1. Re:Uh, what? by rbarreira · · Score: 1

      It makes no less sense than what the article said. Which may have confused me, that's true :)

      I really see no difference between the two cases:
      1- On both languages, it's obvious that you can't have dynamic dictionaries appearing by magic.
      2- On both languages, you can have someone else dealing with them instead of you.
      3- On both languages, they aren't part of the core language but are instead an external API anyway, so it's really not a language/runtime issue, but an API one!

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
  90. Re:Article is theory not practice - no measurement by Surt · · Score: 1

    No, what they say is 'the proof is in the pudding' as you admit when you point out that most people get it 'wrong'. If most people say 'the proof is in the pudding' then that is what they say, by definition.

    --
    "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
  91. let's not forget UCSD P-system on AppleII by oldwarrior · · Score: 0

    was a fine virtual machine and UCSD Pascal (with the CPM board) was actually productive years before java brewed it's first cup.

    --
    If it were done when 'tis done, then t'were well it were done quickly... MacBeth
    1. Re:let's not forget UCSD P-system on AppleII by Megane · · Score: 1

      That's the other kind of virtual machine, a software VM, more akin to what is commonly called an emulator, and which I think postdates hardware virtual machines (VM/CMS, VMware, etc.)

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
  92. Software sucks today? by localman · · Score: 1

    I just want to question that one assumption, which seems to get thrown around a lot. "Software sucks today". Really? My path was C64, Amiga, Win95, Linux, OSX. I feel that software became notably more powerful, less buggy, and easier to use over my computer experience. People love to say things suck, compared to some hypothetical (and quite possibly unrealistic) idea of how things should be. But by any measure that matters in practice, software today seems eons ahead of where it was two decades ago.

    Cheers.

  93. Isn't that one of the original article's points? by porkchop_d_clown · · Score: 1

    the compiler wouldn't have generated better code anyway since it wouldn't use MMX opcodes

    Wasn't that a point of the original article - that languages that are "higher level" than C support constructs that could be mapped right onto MMX (now SIMD) instructions?

    The lack of sophisticated data types in C is a consequence of the abilities of the machines C was originally designed to run on. While that was C's greatest strength of many years, someone starting from scratch could certainly design a new language that had a better mapping to the current generation of processors.

  94. Depends on the job... by porkchop_d_clown · · Score: 2, Interesting

    C is best at what it was designed for - controlling the computer. It used to be that people chose the language to match the app they were writing: For math, use Fortran or APL. For reports use Cobol or RPG. C for flipping bits. Pascal for teaching.

    We're where we are today because, for many years, C was the one you could get for free. The others cost hundreds of dollars.

    I remember the first time I encountered a computer that shipped from the vendor with GCC instead of a proprietary compiler - it was like seeing a death sentence for Abacus, Lightspeed, and all those other little compiler companies.

  95. I still don't get it. by porkchop_d_clown · · Score: 1

    "On both languages" - what languages are you talking about? The original statement didn't mention any languages by name. I can easily imagine a Lisp compiler that dynamically decides how to store the data in a complex list, or a Fortran compiler that takes advantage of SIMD. The point is that a language that has a built-in Dictionary type allows the compiler to make optimizations that aren't possible in a language that doesn't.

    In other words, none of your three points make any sense.

    1. Re:I still don't get it. by rbarreira · · Score: 1

      OK I should have clarified better (maybe I got confused with the language issue because I was replying to multiple threads at the same time). By the two languages I mean something like C and Java, which the author seems to talk about the most in his article.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
  96. Forth by Drasil · · Score: 2, Interesting

    It can be made to be fast, and it can be made to be as high level as you want. I ofter wonder what the world would have been like if more programmers had gone the Forth way instead of the C/*nix way.

  97. Moot point by ajs · · Score: 1

    This is all relatively moot right now, as it is hard to tell what the impact of the new generation of Intel (and presumably, soon, AMD) processors will have. As languages have evolved, so have processors. When C became popular, it was possible to optimize the common case of C-style function call conventions. As C++ and other langauges that used vtables became popular, processors had to re-align their optimization strategies (and in fact, were defeating compiler optimizations for years with respect to C++). Now that high-level virtual machines are the norm, another wave of processor optimization is about to kick in. From what I've heard, high-level languages such as Perl, Java and Lisp are substantially improved by the newest round of Intel processors, but it will be a while longer before we have enough experience with these new processors to be sure of what impact they have had.

  98. New debate by Dzonatas · · Score: 4, Interesting

    High level languages have always been compared to cognitive semantics and grammatical styles. That is the higher the level of the language the easier it is for us humans to read and write it. Conversely, the lower the level the language is the more discreet steps are needed to describe an instruction or data.

    Speed of program languages or machine languages are not measured by how high or low level they are to us. They are also measured by time to develop and implement the program. The article basically makes a point of it, that it's "better to let someone else" to optimize the low-level code while you write with the high-level language. You could write a super fast machine coded program, but it'll take you much longer to write it than with a simpler higher level language.

    The new debate is over datatypes and the available methods to manipulate them. Older hardware gave us the old debate with primitive datatypes and a general set of instructions to manipulate the data. Newer hardware can give us more than just primitives. For example, a unicoded string datatype seen by the hardware as a complete object instead of an array of bytes. With hardware instructions to manipulate unicoded strings, that would pratically take away any low-level implementation of unicoded strings. The same could be done for UTF-8 strings. We could implement hardware support for XML documents and other common protocols. How these datatypes are actually implemented in hardware is the center of the debate.

    Eventually, there will be so many datatypes that there will be seperate low-level languages specifically designed for a domain a datatypes. The article makes the point there exists an increase in complexity for newer compliers to understand what was intended by a set of low-level instructions. Today's CPUs have a static limit of low-level instructions. The future beholds hardware implemented datatypes and their dynamic availability of low-level instructions. Newer processors will need to be able to handle the dynamic set of machine language instructions.

    Does the new debate conflict with Turing's goal to simply make a processor unit extensible without the need to add extra hardware? For now, we have virtualization.

    1. Re:New debate by renoX · · Score: 1

      >The future beholds hardware implemented datatypes

      Uh? If history is an indication, the future belongs to:
      1-x86-64
      2-low power RISCs, such as ARM for embedded target and even in this space if Intel build 0.5W x86 as they've planned to do, x86 may won again a lot of marketshare..
      3-special purpose vectors CPU: GPUs, Cell.

      The only one you could consider to have 'hardware implemented datatypes' is type 3 if one consider vectors and textures as datatypes.

    2. Re:New debate by Dzonatas · · Score: 1

      Example one and two are of the old debate. They would need external resources to implement the hardware datatypes, like example three being added on. They use primitive datatypes. They contain a subset of instructions to transfer data to external hardware like the GPU. The instruction set is still static for the processor.

      The GPU demonstrates an unit that uses another low-level/machine language, like shaders, to process the graphics, but those processes aren't part of the CPU. Mainframes have done such off-loaded work from the processor for years. However, the GPU has a much more visible role.

      The key here is to make an extensible processor without the extra hardware, like the GPU, mainframe, or other microcontrollers, being accessed externally.

      Instead of the new processor every succession of instructions, like the 8086 being replace with another x86 family cpu for new abilities and instructions sets, the processor itself would remain the same. A set of new instructions would not require require a new processor itself. It would be quite a bit different from the typical register based processor.

      These kind of systems are being modeled under virtual systems. The main processor uses just enough instructions to control the flow of programs and pass on the data to the subprocessor that handles it for any given datatype. If the subprocessor doesn't exist for certain datatypes, a generic processor (like the x86), could handle it. Hence, it doesn't need extra hardware and keeps Turing's goal true, but it can have subprocessors plugged-in to handle the non-primitive datatypes that generic processor can't handle. The virtual system shows it is practical.

      Your right that today's market share still leans towards a common selection of hardware. Under the available hardware we have today, however, we are able to virtually model newer hardware. It is actually more than practical.

  99. Medical Industry - Down The Drain by Anonymous Coward · · Score: 0

    "I do this kind of thing now. If I can do it, it can't be that hard. But everybody thinks they have to specialize. THIS IS WHAT'S WRONG WITH THE INDUSTRY."

    So does it bother you that medicine has specialized then?

  100. Re:Old debate (The Computer Language Shootout) by Anonymous Coward · · Score: 0

    A number of the implementations at the Computer Language Shootout leave a great deal to be desired. I
    am most familiar with the C and C++ ones, and know firsthand that many of them can be improved with respect
    to performance (the C++ examples are particularly poor). They often aren't just "flawed"-- they aren't even
    doing the same thing. This is not very easy to achieve.

    Furthermore, they are microbenchmarking. I am not against this, but it has to be pointed out that they don't
    take into consideration concurrency and other such issues. Of course, design and choice of correct algorithms
    in a real application are where your biggest gains are going to come from-- saving some times with a "fast"
    language is almost never as initially significant as doing the right thing to the data, in any language.

  101. there is no difference between theory and practice by aevans · · Score: 1

    So, in theory, higher level languages could be faster than lower level ones, but in practice...

  102. Re:Student Perspective by Senzei · · Score: 1

    So your problem with Scheme is that it uses prefix notation for mathematical operations? If someone did not immediately answer the question of why the hell this is done by citing the "(function argument1 .. argumentN)" style of Scheme code then they did a shit job of teaching it. Prefix notation is useful in Scheme for two things: 1) It makes figuring out order of operations dead simple, and 2) It matches the style in which every other bit of code is written. No wonder software sucks today, the people that actually bother to go to school and learn it can't get competent treatment of the subject.

    --
    Slashdot: Where anecdotes and generalizations can be freely substituted for facts, logic, or intelligence
  103. 10,000 times faster computers hides lots of sins by peter303 · · Score: 1

    All these "twenty years ago" debates are to valid to some degree. However, during that time performance and storage has increase an order of magnitude every five years.
    But there are still some apps where you hit the wall, e.g. gaming graphics. Coding efficiency still matters in some cases.

  104. The Free Lunch is Over by Anonymous Coward · · Score: 1, Informative

    I'm not sure that this has to do with a low-level/high-level language debate any more. Consider, for example,
    that C++ offers both very low and very high-level semantics. When properly used, this yields high level
    programs with excellent performance.

    But, so what? Neither C++ today, or any other very widely-used programming language adequately manages the
    real problem, which is concurrency.

    Herb Sutter has written an excellent paper on this topic, called "The Free Lunch is Over". Let's get off this
    hobby horse and on to some real (and interesting) problems!

    Here is Mr. Sutter's article: http://www.gotw.ca/publications/concurrency-ddj.ht m

  105. Re:Article is theory not practice - no measurement by LiquidFaction · · Score: 1

    I just hope theres no meat in my pudding.

    --
    Wherever i go, There i am.
  106. OpenMP by Corngood · · Score: 1

    It's pretty ugly, but it is possible to hint some compilers about such things using OpenMP, etc.

  107. High level vs. low level 102 by Anonymous Coward · · Score: 0

    What is the difference between an actual language feature and an implementation detail? Give an example of each. (5p)

  108. Typical "/." Handwaving-Intent by Anonymous Coward · · Score: 0

    "I suspect you are getting confused with the fact that VMware and such are fashionable these days. These virtual machines have nothing in common with programming language VMs."

    Um, no. The trend in question is "abstraction" (when was the last time you toggled switches to program a computer? Miss it?). Now we're past the point of high-level languages, and onto frameworks and toolsets which are a layer above high-level. I see this continuing, AND I see CPU designs adjusting to accomodate this trend. As some of the posts here have pointed out, the path to productivity isn't "toggling switches"*, but programming your "intent" in a high-level language, and letting the middle-layers translate.

    *The people who DO need to know about "toggle switches" are in the minority (those interpreters, compliers, VM's).

    1. Re:Typical "/." Handwaving-Intent by IamTheRealMike · · Score: 1

      A fine point, if that had been what he said. It wasn't.

  109. Imperative programming for the win (NS) by Anonymous Coward · · Score: 0

    Nuff Said.

  110. wasted ink by m874t232 · · Score: 1

    It's pointless to try and reason with these people: the idea that C and C++ are "efficient" has become an article of faith. This problem will only solve itself the way all such problems solve themselves: the generations brought up on C and C++ need to die out, and they need to get replaced by a new generation of people brought up with more rationally designed languages. We're going to be stuck with C and C++ as mainstream languages, and all the bloat and inefficiency that that entails, for at least another two decades.

    1. Re:wasted ink by SanityInAnarchy · · Score: 2, Insightful

      Unfortunately, just because a new generation is growing up doesn't mean we'll want to rewrite absolutely everything. It'd be much better if things were developed rationally as soon as possible -- that reduces the total amount of legacy c/c++ code which will ultimately have to be rewritten later.

      Besides, it's not a new concept, and if this generation of programmers didn't get it, neither will the new generation, because among the very first generation of programmers were people who understood Lisp machines. Of course, if a new generation really does start using mostly Ruby when the current one can't handle Lisp, we'll know it was those darned parentheses. Just as any sufficiently advanced technology is indistinguishable from magic, any sufficiently advanced language is indistinguishable from Lisp.

      It will be funny to see this turned on its head, if there are ever enough, say, Python or Ruby programmers to improve python/ruby compilers/runtimes to where, a couple generations of processors later, it's C that has a lack of optimizations and is actually farther from the hardware. We may actually see a C virtual machine as a necessity!

      More practically, I try to work with languages that suit the task at hand, which is really never C unless I'm dealing with a huge existing C codebase.

      --
      Don't thank God, thank a doctor!
    2. Re:wasted ink by m874t232 · · Score: 1

      Well, the current generation of programmers is being educated in Java. Java itself is pretty awful, but at least people are getting used to programming in something other than C/C++.

    3. Re:wasted ink by SanityInAnarchy · · Score: 2, Insightful

      Oh, hell no.

      Java feels way slower than anything else. My college courses were mostly in Eclipse. It runs fast enough, but it takes forever to start, which is true of many, many Java apps.

      Which means that when these same programmers end up learning C/C++, they'll think Java is slow because it's "interpreted". I guess there's at least the hope that they'll wind up using C#, and thinking Java is slow because it sucks. Which is good enough, because Java sucks for other reasons, even though it isn't really slow.

      But really, with Generics, Java has basically picked up most of the features and syntax of C++, added garbage collection and much more anal retentive restrictions, and called it a whole new language. The bytecode and virtual machine is really not relevant to the awfulness of the language itself -- you can write a perfectly good language for the JVM -- but the JVM, specificalyl, has its own drawbacks, in that it's hard to write more libraries for Java, and many of the existing libraries suck in profound ways compared to C/C++ alternatives, or even .NET.

      Frankly, the only good thing about them learning Java is that at least for awhile, their code may be portable, because it's so hard to make OS-specific or arch-specific Java.

      --
      Don't thank God, thank a doctor!
    4. Re:wasted ink by m874t232 · · Score: 1

      Oh, hell no.

      Oh? Which of my two statements do you disagree with? That Java is awful, or that people are learning something other than C/C++ when they're learning Java?

      When you respond to something, at least take a second to read it, and respond to what people said, not what you thought they said.

    5. Re:wasted ink by SanityInAnarchy · · Score: 1
      Oh? Which of my two statements do you disagree with? That Java is awful, or that people are learning something other than C/C++ when they're learning Java?

      Actually, it was this one:

      Java itself is pretty awful, but at least people are getting used to programming in something other than C/C++.

      Emphasis mine. You say that like it's a good thing. I don't really think it is.

      It would be a good thing if they were learning both, but getting used to programming in nothing but Java is almost certainly worse than getting used to programming in nothing but C++.

      --
      Don't thank God, thank a doctor!
    6. Re:wasted ink by m874t232 · · Score: 1

      It would be a good thing if they were learning both, but getting used to programming in nothing but Java is almost certainly worse than getting used to programming in nothing but C++.

      I disagree. C and C++ warp people's minds. The fact that C and C++ have been useful only means that they have been able to do even more damage.

      In contrast to C and C++'s design flaws, Java's design flaws are self-correcting because they actually get in the way of getting work done. That's why it's OK when people grow up with Java; they'll start looking for something better on their own.

      We are better off if C and C++ aren't taught anymore. Teach people assembly language instead of C, and then teach them a decent high level language.

    7. Re:wasted ink by SanityInAnarchy · · Score: 1
      Java's design flaws are self-correcting because they actually get in the way of getting work done.

      Except the entire time in college, they'll be learning the reasons for these design flaws that are really "features". For instance, always forcing that explicit "throws" keyword, or not supporting multiple inheritance, or operator overloading -- all kinds of things left out to protect you from yourself, and the manager types especially will appreciate that.

      Teach people assembly language instead of C, and then teach them a decent high level language.

      What, with nothing in the middle? But I'd teach them something like Ruby, and also teach them C and Assembly. The insanely widespread use of C means that even in a higher-level language, you'll still need an occasional syscall or something.

      No, the point is to teach so many languages that no one language limits them, especially if you're using the Algol-derived ones. It wouldn't take much to go from C++ to Java, or from either of those to, say, Perl, Python, and Ruby. Especially Python should give people a compelling reason to not use C++. But even Ruby could be good -- there's a fairly usable Ruby-to-.NET compiler, meaning you get all the rapid development of Ruby, but all the speed of C#, for what that's worth.

      --
      Don't thank God, thank a doctor!
    8. Re:wasted ink by m874t232 · · Score: 1

      It wouldn't take much to go from C++ to Java,

      In my experience, people raised on pointers and low-level tricks rarely succeed at writing decent, clean, efficient code in languages like Java; they have never learned how to, and when their code runs slowly, they tend to blame the language instead of recognizing their own lack of skill.

      What, with nothing in the middle [between assembly and Java]?

      There isn't anything "in the middle"; Java is already a pretty low-level language as far as languages go. C isn't significantly lower level, it is simply different (and in a bad way).

      But I'd teach them something like Ruby,

      Ruby is a great language, but it's a very high level language--it's far more high level than Java.

    9. Re:wasted ink by SanityInAnarchy · · Score: 1
      There isn't anything "in the middle"; Java is already a pretty low-level language as far as languages go.

      Oh wow...

      The structure of the JVM does kind of prevent you from either including assembly in your Java, or easily hooking into things written in non-JVM languages.

      C#, at least, allows you to easily call out to other C/C++ libraries.

      Ruby is a great language, but it's a very high level language--it's far more high level than Java.

      Exactly the point. Teaching Java exposes them to complexity they shouldn't have to see. Kind of like teaching Assembly would. Not that you shouldn't teach them lower level stuff also...

      And knowing how pointers work is generally a good thing, especially if you've started with a language like Ruby, and don't have all the bad habits.

      In my experience, people raised on pointers and low-level tricks rarely succeed at writing decent, clean, efficient code in languages like Java; they have never learned how to, and when their code runs slowly, they tend to blame the language instead of recognizing their own lack of skill.

      I was raised on auto_ptr and other high-level techniques in C++, so switching to Java was pretty natural for me. The trick is to not start them out on the lower level arrays until they already know vectors...

      --
      Don't thank God, thank a doctor!
  111. Re:Article is theory not practice - no measurement by PitaBred · · Score: 3, Funny

    How can you have any pudding if you don't eat your meat?

  112. Some of the real optimization issues by Animats · · Score: 4, Interesting

    The article is a bit simplistic.

    With medium-level languages like C, some of the language constructs are lower-level than the machine hardware. Thus, a decent compiler has to figure out what the user's code is doing and generate the appropriate instructions. The classic example is

    char tab1[100], tab2[100];
    int i = 100;
    char* p1 = &tab1; char* p2 = &tab2;
    while (i--) *p2++ = *p1++;

    Two decades ago, C programmers who knew that idiom thought they were cool. In the PDP-11 era, with the non-optimizing compilers that came with UNIX, that was actually useful. The "*p2++ = *p1++;" explicitly told the compiler to generate auto-increment instructions, and considerably shortened the loop over a similar loop written with subscripts. By the late 1980s and 1990s, it didn't matter. Both GCC and the Microsoft compilers were smart enough to hoist subscript arithmetic out of loops, and writing that loop with subscripts generated the same code as with pointers. Today, if you write that loop, most compilers for x86 machines will generate a single MOV instruction for the copy. The compiler has to actually figure out what the programmer intended and rewrite the code. This is non-trivial. In some ways, C makes it more difficult, because it's harder for the compiler to figure out the intent of a C program than a FORTRAN or Pascal program. In C, there are more ways that code can do something wierd, and the compiler must make sure that the wierd cases aren't happening before optimizing.

    The next big obstacle to optimization is the "dumb linker" assumption. UNIX has a tradition of dumb linkers, dating back to the PDP-11 linker, which was written in assembler with very few comments. The linker sees the entire program, but, with most object formats, can't do much to it other than throw out unreachable code. This, combined with the usual approach to separate compilation, inhibits many useful optimizations. When code calls a function in another compilation unit, the caller has to assume near-unlimited side effects from the call. This blocks many optimizations. In numerical work, it's a serious problem when the compiler can't tell, say, that "cos(x)" has no side effects. In C, it doesn't; in FORTRAN, it does, which is why some heavy numerical work is still done in FORTRAN. The compiler usually doesn't know that "cos" is a pure function; that is, x == y implies cos(x) = cos(y). This is enough of a performance issue that GCC has some cheats to get around it; look up "mathinline.h". But that doesn't help when you call some one-line function in another compilation unit from inside an inner loop.

    C++ has "inline" to help with this problem. The real win with "inline" is not eliminating the call overhead; it's the ability for the optimizers to see what's going on. But really, what should be happening is that the compiler should check each compilation unit and output not machine code, but something like a parse tree. The heavy optimization should be done at link time, when more of the program is visible. There have been some experimental systems that did this, but it remains rare. "Just in time" systems like Java have been more popular. (Java's just-in-time approach is amusing. It was put in because the goal was to support applets in browsers. (Remember applets?) Now that Java is mostly a server-side language, the JIT feature isn't really all that valuable, and all of Java's "packaging" machinery takes up more time than a hard compile would.)

    The next step up is to feed performance data from execution back into the compilation process. Some of Intel's embedded system compilers do this. It's most useful for machines where out of line control flow has high costs, and the CPU doesn't have good branch prediction hardware. For modern x86 machines, it's not a big win. For the Itanium, it's essential. (The Itanium needs a near-omniscient compiler to perform well, because you have to decide at compile time which instructions should be executed

    1. Re:Some of the real optimization issues by hyc · · Score: 1

      The AIX linker is fairly intelligent, and its object file format preserves function boundaries so that the distribution of functions over object files is largely irrelevant. (Contrast this with the typical dumb Unix linker that includes an entire object file if any symbol inside it is referenced; the AIX linker only includes the actual referenced symbols, not the entire object file.)

      The MIPS toolchain was pretty smart along these lines too. I also developed M68K tools for gcc on the Atari ST that did the same thing, to allow globally optimizing address references to use (base register)+16 bit offset addressing modes wherever possible (which offered about a 10% speedup overall vs 32bit absolute addressing in most programs, as well as more compact code. It also allowed shared-text without needing an MMU, which was very handy...). All this was in the late 80s - early 90s. A lot of these ideas didn't get much traction in x86 land because the architecture was so abysmally bad that the space/performance payoff was in the noise. Oh well.

      --
      -- *My* journal is more interesting than *yours*...
    2. Re:Some of the real optimization issues by njh · · Score: 1

      This blocks many optimizations. In numerical work, it's a serious problem when the compiler can't tell, say, that "cos(x)" has no side effects. In C, it doesn't; in FORTRAN, it does, which is why some heavy numerical work is still done in FORTRAN. The compiler usually doesn't know that "cos" is a pure function; that is, x == y implies cos(x) = cos(y). This is enough of a performance issue that GCC has some cheats to get around it; look up "mathinline.h". But that doesn't help when you call some one-line function in another compilation unit from inside an inner loop.

      C++ has "inline" to help with this problem. The real win with "inline" is not eliminating the call overhead; it's the ability for the optimizers to see what's going on.


      C++ also provides const, which I've found has given measurable performance increases (possibly because it can be used for CSE?) as well as making programs more type safe.

  113. What Languages Fix by npsimons · · Score: 1
    What's wrong with Ruby, as a replacement for a very ugly language called Perl?

    What's wrong with Perl, as a very powerful and flexible replacement for C?


    Seriously, Perl can be ugly, but that's mostly the language revealing the real programmer inside, and being flexible enough to be ugly or pretty. I think it's also informative to try and compare languages another way: what do they fix?

  114. C evolved from BCPL and PL/I by Anonymous Coward · · Score: 1, Informative

    C was a reaction to both BCPL (via the language B) and PL/I. The UNIX designers, Thompson, Ritchie, et. al., came from the Multics project, and Multics was mostly written in PL/I with some BCPL. Most (but not all) of the BCPL code was written by the Bell Labs members of the Multics team. BCPL was a completely type-less language. C introduced a few rudimentary types.

    By contrast, PL/I had a much more complete type system, although it was not even close to "strongly typed".

    PASCAL was still very very new when C was designed.

    In particular, PL/I strings and arrays were first class data types with compiler-known lengths,
    and buffer overflows were MUCH MUCH less common. (not impossible - just much less common).

    Full PL/I was an enormous language and hard to compile, but the ANSI G subset was actually quite
    reasonable and not hard to compile for. The DEC PL/I (ANSI G subset) and C compilers for the VAX used the same code generator back-end (written by Dave Cutler who also designed RSX-11/M, VMS, and Windows NT), but the PL/I compiler produced better code for string and array handling, precisely because the compiler knew more about what the programmer actually intended. It could take better advantage of the VAX instruction set, particularly for strings of maximum known length. String instructions, such as on the VAX or the IBM System/360 could easily handle PL/I strings, but null-terminated C strings were much harder to compile for. This is not surprising, since IBM designed PL/I as a language for the System/360.

  115. Re:Student Perspective by Anonymous Coward · · Score: 0

    You are a tool

  116. Re:The advantage of Fortran is purely coincidental by joib · · Score: 1


    The only advantage of current Fortran over C is that the vector processing unit of modern CPUs is better utilised, thanks to Fortran semantics.


    The reason why Fortran often vectorizes better is not that Fortran has array ops (in reality, modern Fortran compilers actually scalarize array expressions before handing the code over to the middle end tree optimizers), but due to different aliasing rules than C. This was the main reason why Fortran 77 (with no array ops) often was an order of magnitude or so faster than C on old vector supercomputers.

    Sure C can get the same kind of thing with const and restrict, but googling reveals that ironically one of the very few places where it's actually used is in the runtime library of the GNU Fortran compiler.

  117. Did you even look at the link? by Anonymous Coward · · Score: 0

    How about the fact that ruby is very significantly slower than perl and python? How about the fact that depending on your personal preferences, you could easily argue that perl or python are elegant too.

    1. Re:Did you even look at the link? by nrrd · · Score: 1

      Well, raw code performance is less and less important. Computers are getting faster and memory is cheap. I'm not saying that a language can be a complete *slug*, but raw performance isn't so important compared to time-to-market, overall design and long-term maintenance.

      I'd argue that Perl/Python/Ruby are only *potentially* elegant. You can write crap in any language. Perl just make it easier.

      Jeff P.

      --
      "Eye halve a spelling chequer, It came with my pea sea, It plainly marques four my revue, Miss steaks eye kin knot sea"
  118. Re:Article is theory not practice - no measurement by Magius_AR · · Score: 1
    The proof is in the pudding as they say
    No, what they say is "the proof of the pudding is in the eating." (Just pointing it out because most people get it wrong.)
    Well, if it's true that most people get it wrong, then the original poster is correct...that is indeed what they say :)
  119. Bad example. by Anonymous Coward · · Score: 0

    If you actually paid attention, you would notice that there are webserver written in high level languages that perform far better than 99% of people need. In fact, I wrote a webserver in kornshell that easily saturates a 100Mbps pipe. Using a webserver written in a high level language instead of apache is not a problem at all.

  120. Holy christ. by Anonymous Coward · · Score: 0

    Your illiterate, incoherant rambling has given me a "massive headhache".

  121. Binary by Anonymous Coward · · Score: 0

    You people with your "languages". I write a program by randomly typing 1's and 0's. I'm half-way done with PONG.

  122. Re:The advantage of Fortran is purely coincidental by Anonymous Coward · · Score: 0

    Should I be ashamed that I graduated with a B.S. in computer science and still can't follow what discussions like these are talking about?

    Maybe this is Ph.D stuff... ?

  123. Too about this wonder I by Anonymous Coward · · Score: 0

    Too about this wonder I

  124. Apples and Oranges by acaeus · · Score: 1

    I can think of several general applications that could NOT or at least should NOT be developed in a truly high-level language like Java:

      - Real Time Client/Server programs
      - Gaming (intensive CPU/Graphics)
      - Servers that deal with large amount of data/connections/transactions

    *** Not to mention any application that should run for a long period of time and thus must not "trust" OS's memory management and the inherent cost of memory fragmentation.

  125. Helpful, yes, but sad by Anonymous Coward · · Score: 0

    You claim that in your department you "focus on developing large software projects", and then say you "hate" Scheme (and it "sucks") because a simple arithmetic problem is written differently than C? *sigh*

    I work at a company maintaining and developing medium-to-large (hundreds of thousands of LOC) systems. We're not using Scheme (we're using Python), but it would have been a good choice as well.
    - Number of times I've had to do arithmetic on 6 small numbers: zero.
    - Number of times I'm glad Python at least has first-class closures, bignums, map/apply, and gobs of other Scheme features: every day.
    - Number of times I wished I had real macros: once or twice a week. (Decorators help a bit, and the with-statement in 2.5 -- which looks just like Lisp -- will make it even nicer.)
    When you graduate to writing real programs, young one, you'll realize that there's more to programming than addition and multiplication.

    We are taught to see languages as tools, you look at your problem and pull a tool out of the tool box that you think fit the problem best. You have to weigh whats important for the project and chose based off of that. [sic]

    Sounds reasonable. Are all of your "large software projects" simple arithmetic, then?

    My software engineering program has been very Java intensive. My software engineering class, object oriented class, and software testing class were all java based. We dabbled in C# a bit as well. [...] I feel like this is all pretty well rounded; I've learned a bunch of languages and am not really specialized in one. I'd say I am best at Java right now, but I can also write C++ code just fine.

    If you know Java, C#, some C++, and have done just enough Scheme to not get it, then no, you are not "pretty well rounded". Go back to Start, do not collect $200.

    I don't think the universities are the problem, at least not in my experience.

    Uh...

  126. C is not a good language? by General+Lee's+Peking · · Score: 1
    Since a lot of legacy C code is still around...
    Is this really the only reason to continue using C? Personally, I think it's an excellent language in which to program. I don't feel entirely comfortable with what appears to be the author's dim view of the language.
    1. Re:C is not a good language? by Anonymous Coward · · Score: 0

      C really isn't a very good language. It's success is nothing more than an historical accident. As languages go, no C isn't a very good one. It is useful though, but that's a product of its success (e.g. unix), not of the qualities of the language itself.

      There's plenty of material dealing with language design, and some of them discussing C specifically, I liked the one referenced by Code Complete called "C in Education and Software Engineering" by R.P.Mody. I think a lot of people grow "blind" about the language they currently used and are unable to spot quite obvious deficiancies, so I'd encourage anyone to read critiques of their favourite languges (and better yet, learn many widely different langauges!). I have a hard time seeing how anyone could think C is a good language after having its (quite serious) flaws pointed out, I do understand how someone would miss them in the first place though - languages have a tendency to indoctrinate its users to not spot its misstakes.

  127. ruby backlash by 5n3ak3rp1mp · · Score: 1

    dude, i've coded in a lot of languages and ruby is the coolest so far, by far.

    yeah i write rails apps but I also use ruby for admin type stuff and it's great.

    the test suite stuff alone is a HUGE sell. i don't give a fuck how fast it is, the CPU bandwidth is hardly ever the bottleneck. I'm faster at coding and fixing, that's for sure.

    1. Re:ruby backlash by bloodredsun · · Score: 1

      I don't want to flame you (although having said that it kinda means that I'm going to!) but I don't pick languages for being either "cool" or slow. I pick them for a number of reasons: ease and speed of development, performance, ease of maintenance, vendor independence and scalability amongst others.

      Maybe it is great for the admin and DBA work that you specialise in but it seems to be limited to that area. I'm more than happy to be corrected as I've only done some test work in Ruby but it doesn't appear expressive enough for admin scripting nor useful for applications that don't follow a certain set type such as RoR.

      As for speed not being an issue, that's blatantly wrong. Speed is always an isssue, it's just what level of speed is acceptable in a trade off to development speed. If I'm working on a web app that will have maybe 1 or 2 concurrent users then speed isn't an issue. If I'm working on an app that will have hundreds of concurrent users, then yes it is an issue. Throwing extra hardware is a lazy solution to this and can lead to other problems (sessions being one of them) and I can't imagine telling the people who pay the bills that the app I originally wrote for 1 to 2 people can't scale up.

  128. Runtime code optimization? by nolsen · · Score: 1

    It will be interesting to see when and how runtime code optimization affects the high vs. low-level language debate. Systems like HP's Dynamo http://www.hpl.hp.com/techreports/1999/HPL-1999-77 .html show there's gains to be had here, but afaik these techniques are not being used by major language runtimes.

  129. Ugly? Idiomatic! by Paolone · · Score: 2, Insightful

    Perl is not ugly, just really really idiomatic. As with all idiomatic languages, you can't grok what something means if you're not exposed to it.
    It's just a matter of "if you can't stand the line noise, get out from the code-kitchen!". :)
    Even if I can understand easily Perl code, what I can't really stand is C pointer arithmetic if it steps too far...

  130. Here's a few. by Grendel+Drago · · Score: 1

    for some odd reason, I'm having a very hard time thinking up a non-C based language that's compiled to an actual binary and not interpretted or run by a virtualmachine...

    Typically compiled languages include Ada, ALGOL, BASIC, COBOL, FORTRAN, ML, Pascal and others. I think those mostly qualify as being non-C based.

    --
    Laws do not persuade just because they threaten. --Seneca
  131. Same issue, new situation... by PhotoGuy · · Score: 1

    In the early days of C on PC's, it wasn't the most efficient language in the world. Thankfully there were good profilers. And I quickly learned to utilize those. Analyze your program, and you find that 90% of the time was spent in one area. So I'd optimize that one section by recoding the CPU-intensive bits in assembly, and *wow*, the program would fly. Profile it again, and I'd find that most of the time was spent in a very mundane and efficient outer loop, and I'd know the program was near optimal.

    Fast forward 10 or 20 years, and I'm coding in Java. I find one section takes 90% of the CPU time, I recode that as a native method and things fly.

    Same with my new favorite language, Perl, although I find there are native methods for most libraries that would otherwise be inefficient.

    It's a simple technique, that can make almost any language fly, tweaking around the odd spot where there's a bottleneck.

    --
    Love many, trust a few, do harm to none.
  132. Hundreds of instructions? by Grendel+Drago · · Score: 1

    What sort of line of C code (not using some sort of insane preprocessor macro expansion) can map to hundreds of assembler instructions?

    --
    Laws do not persuade just because they threaten. --Seneca
    1. Re:Hundreds of instructions? by lgw · · Score: 1

      Arithmatic expressions in C or C++ can generate a bunch of assembly, especially if the machine language division doesn't map to C division well. I've always seen this as a feature, myself: complex arithmatic expressions are just a huge pain in the ass to maintain in assembly.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    2. Re:Hundreds of instructions? by erc · · Score: 1

      Like what?

      i++, i-- map to just one ASM instruction. Depending on the processor, i*x maps to two or three. Hundreds? I think not.

      --
      -- Ed Carp, N7EKG erc@pobox.com PGP KeyID: 0x0BD32C9B What I'm up to: http://intuitives.mine.nu
    3. Re:Hundreds of instructions? by lgw · · Score: 1
      I haven't seen hundreds, but dozens aren't uncommon, e.g.
      if ( sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) > sqrt(x1*x1 + y1*y1)/scale ) DoSomething(x1, y1, x2, y2)
      Will generate a bunch of assembly on a machine with few registers, especially if optimization is off (the usual case when stepping through the resulting assembler in a debugger). Just the division can be 6-12 instructions if the types of the variables don't match up well with the processor's division instructions, as a bunch of register juggling usually ensues.

      Also consider that
      rotate = (rotate << 13) | (rotate >> 19)
      should generate a single assembly instruction on most 32 bit platforms with optimization on. C isn't all that close to assembly, though I'd still say it's a low level language, because otherwise there are no modern low level languages, which would be a silly way to define the term.
      --
      Socialism: a lie told by totalitarians and believed by fools.
    4. Re:Hundreds of instructions? by letxa2000 · · Score: 1
      You're very much right. And, yes, you can easily get hundreds of instructions if you're working on an 8-bit platform. And most price-critical embedded applications still are done on 8-bit processors. Anyone that's doing "embedded development" and working with some version of Windows or Linux have a humorous definition of "embedded." They're either selling just a few of the products so the hardware cost doesn't matter, or they're being awfully lazy by using Linux/Windows to save them the effort of having to do any real embedded development which, God forbid, might mean they have to leave their 'C' compiler behind and get down in the mud in an 8-bit instruction set and get the job done without any crutches.


    5. Re:Hundreds of instructions? by cagle_.25 · · Score: 1
      I was wondering that, too. The examples provided by your respondents are unconvincing ... printf() is resolved by a call to (gasp!) printf(), and calls are just one instruction.

      Similarly, if you are doing 64-bit multiplication on an 8-bit system (and why?! for crying out loud, 16-bit Atmel chips are certainly cheap enough!), you will not have enough memory to "inline" every multiplication -- it'll be a function call, which means that you'll have something like 18 instructions pushing the operands to the stack, one instruction for the call, and 9 instructions popping the result.

      Like anyone really does 64-bit arithmetic on an 8-bit system anyways...

      --
      Human being (n.): A genetically human, genetically distinct, functioning organism.
  133. While we're at it by Trogre · · Score: 1

    Could someone please, please, PLEASE rewrite yum in C or at least point me to a python compiler.

    There's a time and a place for interpreted languages, and package managers isn't one of them.

    --
    "Nine times out of ten, starting a fire is not the best way to solve the problem." - my wife
    1. Re:While we're at it by moro_666 · · Score: 2, Insightful

      the problem of yum is in the design of the application, not the language.

      python is fast enough for almost any package management quest, but yum is the worst piece of ... that i have seen on that frontier. proper indexes and logical stops would make it much faster. there's your chance to write it. choose whatever language you want. design has to be good.

      --

      I'd tell you the chances of this story being a dupe, but you wouldn't like it.
  134. Less space for alternative vendors by EmbeddedJanitor · · Score: 2, Insightful

    I do stuff in embedded space using IAR or GreenHills and gcc. For the most part, the proprietary vendors are losing ground to gcc. The proprietary advantage is shrinking, especially with more modern micros and as gcc improves. For the most part, code that comes out of gcc is no worse than code coming out of IAR or GreenHills. Where the priopritary guys have a real advantage is in better Clib implementations. The Clib, and newlib, that are normally used with gcc are huge and bloaty in comparison.

    --
    Engineering is the art of compromise.
  135. Debunking the debunker... by sarkeizen · · Score: 1

    Take a look at the first sentence:

    The closer to the metal you can get while programming, the faster your program will compile -- or so conventional wisdom would have you believe

    As others have already mentioned he seems to use the term 'compile' oddly. This sentence would say to me that the time to take program and turn it into object code (assembly, byte-code, etc) is smaller the more similar your language is to the object code. I think it's difficult to disagree with that statement. However since the author seems to spend most of his time talking about program execution speed (and by the look of the comments here on SD that's what everyone else thought too) it seems safe to assume that he meant 'The more similar your language is to object code the faster it will run'.

    In this article, I will show you how high-level languages like Java aren't slow by nature, and in fact low level languages may compile less efficiently.

    The wierd bit here is he seems to take the idea 'high-level languages are slower than low-level languages' and assume it's being stated in the ABSOLUTE case. In other words that there is no case where a high-level language can be faster than any low-level language. I doubt even the hardest of the hard-core assembly language folk would say that. Now like his mistake above we might be tempted to believe that he isn't saying something so ridiculous. The problem with that POV is that he only provides a few cases where he believes his thesis is true (at least one of which is wrong). The only argument a minority of cases can refute is the absolute one above. So either he doesn't make his case or his he's attacking an argument that could hardly be called common wisdom.

    But hey you might just say that he's giving a few examples for the sake of brevity. Except that...

    Now consider a slightly higher-level language, FORTRAN (which predates C by more than two decades, incidentally). FORTRAN has a vector datatype, and operations on it.

    The problem here is if we take what appears to be his definition of a high-level language. FORTRAN could (AFAIK he's speaking hypothetically) produce faster object code than his C implementation because it implements a abstraction that is close to object code. IOW it is (in that instance) operating at a low level. How does this make his point?

    A lot of people complain about the overhead of Java bytecode being interpreted. This argument isn't entirely fair, for two reasons. The first is that Java doesn't have to be interpreted at all

    Again this is just odd reasoning. True it doesn't have to be but for the most part it is. So again it seems like he's trying to refute kind of an odd case.

    The reason for this improvement is that a virtual machine could perform some categories of optimization that weren't available to a static compiler.

    Anyone else amused that his first reason and second reason are mutually exclusive? ( IOW: You can't compile Java AND have JIT optimizations).

    Now here at least is something that approaches a useful argument. Sure there are kinds of optimization that can only be done at run time but the question of what is generally faster isnt' really answered. For example an in-lined function can easily cause performace to drop if the inlining also causes a cache miss. I'm also somewhat skeptical of this auto-inlining being 'impossible' to implement in C. It would appear that some people have discussed it at least : http://citeseer.ifi.unizh.ch/chang92profileguided. html

    His final idea about compilers becoming more advanced is true. However again we run into the issue of "What argument does this actually refute?". Is it the general case? It's hard to say, it's also hard to say how this aligns with his thesis. One example of a compiler that can produce pretty significant speed increases is Intel's C compiler. So it would seem that 'lower le

    1. Re:Debunking the debunker... by cryptoluddite · · Score: 1

      What's really amusing is for real programs Java is within 1.2-2x of C speed despite having array bounds checks, no pointer arithmetic, type safety, garbage collection, etc. Java is doing so much more than C by all rights it should be ridiculously slow, but it's actually in the same ballpark.

      Try taking some real C program and for every structure add an id to the beginning. Turn every array into a struct with array and length. Turn every array access into a bounds check followed by access. Turn every free into a no-op and every malloc into a memory request from a garbage collector. Turn every cast into a type check (for that matter turn every pointer assignment into a type check).

      Now compare their performance. C is a dog performance wise, but you can make it really fast at something specific and with a lot of work by ditching any high-level language features. That does not make it a 'fast' language or 'faster', it just makes it another assembly language.

  136. M2's sibling COMAL-80 by Burz · · Score: 1

    ...COMmon Algorithmic Language, also had this pre-compile bytecode stage and was jaw-dropping, blazing fast.

    I think what happened at some point was that the parent, Pascal, came back in the form of TurboPascal and Delphi and killed off its more advanced progeny before they could reach critical popularity.

  137. High- vs. low-level structure by Todd+Knarr · · Score: 1

    I think the author uses a confusing definition of high-level vs. low-level language. I've always thought of it as a matter of structure: a low-level language's constructs map relatively directly to hardware or machine-language constructs, a high-level language's constructs don't. The level of abstraction of the constructs doesn't matter, only the mapping between them and the hardware. So while vector operations may be a more abstract (higher level) concept than C's primitive arrays and loops to operate on them, a language implementing vectors and vector operations directly in the syntax would be a lower-level language (as far as vectors go) than C on hardware with a vector unit because it's vector construct maps directly to a hardware operation. His discussion seems to be that C and it's relatives don't map closely to hardware operations anymore, so they may not perform as well as languages that do map more closely. Well, duh. We knew that from the Lisp Machine where LISP was a low-level language and C wasn't.

    The point about optimizations is more productive. The whole "interpreted languages are slower than compiled languages" deal came from a time when it wasn't feasible to compile at run-time. Bytecode blows that whole theory out of the water, but until Java bytecode wasn't thought about much (UCSD Pascal and Icon and possibly Forth are the only bytecode-based languages I know of that pre-date Java). You still can't compile Java on-the-fly feasibly, but you can compile Java bytecode in close enough to real-time to not make a difference. C++ programmers have been doing that for ages with inlined member functions, but that comes with all manner of headaches when classes change and inlined code elsewhere doesn't. Bytecode doesn't suffer from that. That's something a lot of programmers steeped in the advantages and limitations of C and C++ don't think about.

  138. The language doesn't matter... by FlyingGuy · · Score: 1

    What matters is the compiler or the interpreter.

    In C...
    for(i=1,i<=100;i++){
    // Do something
    }

    In Pascal...
    for i := 1 to 100 do
    begin
      // Do something
    end;

    In Basic...
    100 for i% = 1 to 100
    110 Do Something
    120 next i%

    All of these are lexicaly different, yet all result in the same set of assembler instructions when the complier or interpreter is well designed and written.  The issue is not <b>language</b> rather the issue is the supporting compiler and linker.  I could easily write the following, call it a new language, say "Slash":

    Perform
    //Do Something
    100 times

    Lexicaly different from C, Pascal or Basic but it performs the function and with a compiler I wrote for "Slash" I would make sure it generated the appropriate assembler or machine code.

    What all of this boils down to is what people find either interesting, challanging, or fun to frustrate others with.  The <b><i>implementation</i></b> makes all the difference.  If the implementation of your development environment is bad, then the C,C++,VB,Delphi,.Net,FORTRAN,COBOL,ADA,LISP,Modula 2,Prolog,Turbo Prolog, etc. etc your writing in will also be bad when the end result is executed.

    My personal preference is Delphi, I can X-Compile it without too many headaches to Linux.  I can write in C,Assembler, Basic ( Basica,Vbasic,Qbasic,DBasic ) and am thinking of learning ADA just for the sake of learning it.  When I do a programming task I pick the lanugage that makes sense for what I am doing, although I will admit I find java rather distastefull.

    --
    Hey KID! Yeah you, get the fuck off my lawn!
  139. Re:The advantage of Fortran is purely coincidental by Anonymous Coward · · Score: 0

    The fact that C does not have vector semantics reflects the domain C is used: most apps written in C do not need vector processing. In case such processing is needed, Fortran can easily interoperate with C: just write your time-critical vector processing modules in Fortran.

    Who's to say they don't need vector processing? That's a decision for the compiler, not the programmer. It sounds to me like saying "most apps written in Python do not need a compare-less-than instruction". Do they? Do they not? Beats me.

    On some CPUs (esp. with 387-derived FPUs), it's even faster to use the vector hardware if you're only doing a single operation. So it's hard to say that a given program wouldn't benefit from a vectorizing compiler. Pretty much every program iterates over a list of items at some point.

    As for higher-level-than-C languages being faster than C, it is purely a myth.

    Evidence, please?

    Code that operates on hardware primitives (e.g. ints or doubles) has exactly the same speed in C, Java and other languages

    Strictly speaking *all* code "operates on hardware primitives". I think what you mean is that if they all use the CPU's 32-bit signed integer ADD instruction, that instruction takes the same time from any language it was compiled from, which is true, but only matters if you're writing code for one of the few apps that does only number crunching.

    All the checks VMs do have an additional overhead that C does not have; the little VM routines run here and there all add up to slower performance

    Now you're just being silly. A VM has lots of opportunities for optimization that a C compiler doesn't have, and the "additional overhead" that scares you usually isn't that bad. HP's Dynamo project showed that running HP/UX binaries on an HP/UX emulator on HP/UX hardware was faster than running them natively, for most applications, which is good evidence that the "overhead" isn't so bad. See also the 90/10 rule -- ask a programmer, they'll know what it is.

    the fact that some languages are overengineered or open the way for sloppy programming

    Ah, see, here's the real problem: you're a C programmer, and you feel contempt for people who don't have to go through the pain that you do. You have my sympathy ... but we still don't believe you just because you call the truth "a myth".

  140. java jesus by pyrrho · · Score: 1

    not very long in to find this is the same "Java really is (well, can be) faster" article I've been reading the past 10 years.

    lord

    I don't like java. Don't try to make me. I'm sick of it. And I don't want to marry your sister, yes, she's very nice, I'm sure, and no way is she as stupid as I think she is, we just don't connect, you understand... I know she has a PhD, but I'm tired of you telling me I'm stupid not to be attracted to her.

    Besides, you two are already married and that's not even legal in my state, let alone polygamy.

    --

    -pyrrho

  141. Induce? by tepples · · Score: 1
    I wrote in ARM assembler a blitter routine that draws an 8-bit bitmap scaled 2X times (from 160x144 to 320x288 pixels). That was 1 week ago. My emulator now runs 15-20% faster than before on my PDA!

    Yeah, but what ROMs did you use to test your Game Boy or Game Gear emulator? Does easy hobbyist access to assembly language induce piracy?

  142. Tens of millions of "a specific chip" by tepples · · Score: 1
    A well-seasoned assembly programmer can absolutely write faster code than a C compiler -- for a specific chip.

    And when that chip is deployed in millions of units of a handheld system, and your app targets that system, anyone can see the point of profiling your app and then putting the inner loops in the hands of an assembly expert. This is why the audio mixers in most Game Boy Advance games are written in ARM7 assembly language.

  143. Perl has scalar, array, and dictionary by tepples · · Score: 1
    On both languages, they aren't part of the core language but are instead an external API anyway

    O RLY? The Perl 5 language has three main data types: scalar, array, and dictionary.

    1. Re:Perl has scalar, array, and dictionary by rbarreira · · Score: 1

      So what? First of all, I wasn't talking about Perl. Second, I don't see how that's a performance advantage anyway, since in C there is no built-in dictionary (C++ already has is on STL). So you need to get an external dictionary API. Which can do exactly the same trick as the fantastic runtime he talks about.

      --

      The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
  144. naughty dog by Anonymous Coward · · Score: 0

    It was naughty dog. They built an alternative runtime engine that was about on the level of C++, but written in a lisp-ish dialect. The win for them was that they could upload code to the game on the fly, which was / is an advantage that most other game studios still can't match. Gamasutra.com has some articles on it somewhere. Clever stuff, that.

  145. Single pass principled search beats CPU knowledge by shapr · · Score: 1

    In Relating FFTW and Split-Radix Oleg describes how to generate an optimal FFT from Scheme in a single pass. The secret is not repeated optimization passes or in-depth CPU knowledge, but instead to know exactly which identities (i.e., axioms) contributed to the optimum solution. I believe that in the future it will not be rare to generate optimal solutions, thus making choice of programming language a matter of personal taste or developer speed.

    --

    Shae Erisson - ScannedInAvian.com
  146. Re:Isn't that one of the original article's points by rbarreira · · Score: 1

    Yes, and it's a valid point. But we were discussing whether compilers are better at optimizing code than people or not. And, nowadays, they aren't.

    --

    The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
  147. C++ machine code trivial? Remember smart pointers! by gigi · · Score: 1

    One counterexample that keeps me busy:

    In C++, one line of code such as 'a = smartPtr->b;'
    can have a whole smart-pointer mess behind it.
    That can be an endless pain to debug, when it goes wrong (think large destructor chains).

    I would argue instead that Java and C#, with their garbage collection,
    have a more trivial mapping of the same line: Just a plain assignment.

    Just my five cents :-}

    http://code2code.net/ - Migrate your C++ to C#

  148. Re:C++ machine code trivial? Remember smart pointe by mlwmohawk · · Score: 1

    >>In C++, one line of code such as 'a = smartPtr->b;'
    >>can have a whole smart-pointer mess behind it.
    >>That can be an endless pain to debug, when it goes wrong (think large destructor chains).

    >>I would argue instead that Java and C#, with their garbage collection,
    >>have a more trivial mapping of the same line: Just a plain assignment.

    Any language can be made to have horrible constructs. One line of code is by no means any measure of how destructive something can be.

    IMHO, Garbage collection is for bad programers. When I teach C/C++ my mantra is "If you didn't do it, it didn't happen." This applies to memory allocation as well as freeing. I can't tell you how many times I've hit GC problems, objects not freed fast enough, GC running at the *WORST* time for performance, etc.

    High level languages have a place where the specifics of program operation and performance don't matter. The problem shows up when people don't know enough to know that their language of choice isn't appropriate for a specific task.

    As more and more people leave the McCS courses that focus on hypothetical computing, Java, .NET, etc. because "real computers" are somehow less than hypothetical ones, they become less qualified to judge. To address Djikstra, no astronomer would construct a hypothetical universe because finite light speed made observable universe less perfect.

    In electronics, think of the OPAmp circuit. It is taught as a "perfect" linear amplifier for theory, then it is beaten into the students heads that it is imperfect and where and how and why it is imperfect.

    In McCS school, real computers are seen as bad and hypothetical computers are seen as good. That isn't science, that's kinderarten.

  149. So Java is cool? by whitroth · · Score: 1

    The only thing that slows down languages like C is damn eye candy.

    Java, on the other hand... at work, running a (dual core? dual processor?) pentium, connected to a fast RISC 6000 AIX box, a small Java app I wrote takes nearly half a minute to come up.

    But then, halfway up the lerning curver for Java, I'm also working on an article entitled "The Failure of Java", and one insight I've had, just last week, while looking at some professional code that's production at a Fortune 50 company: Java, at least in a class, not only actively, but agressively encourages global variables. Staring at this, it struck me that I *have* worked in a language like that... except we call them subroutines... in COBOL.

            mark "Java: COBOL in a sexy suit"

  150. Dennis Ritchie told me personally by peccary · · Score: 1

    that C was a reaction to PL/1 - the "everything plus the kitchen sink" language. Just as Unix was a reaction to Multics. This isn't really a topic for argument, I'm sure it's written down somewere. On paper.

  151. Re:Typical Java Handwaving - EWD quote by rmadhuram · · Score: 1

    EWD: Computer science is no more about computers than astronomy is about telescopes

  152. Give Djikstra 's stuid quote a rest, its wrong. by mlwmohawk · · Score: 1

    Sigh: "Computer science is no more about computers than astronomy is about telescopes"

    You are, like what, the 100th person to use that quote?

    I counter that an astonomer does not work on a hypothetical universe because the real observable universe is limited by an imperfect finite speed of light.

    But, technically, that quote is a bad analogy. Astronomy is the study of the universe, not the study of telescopes. The corrected Djistra analogy should be computer science is more about keyboards than astronomy is about telescopes.

    Sorry, Djikstra is wrong.

  153. "Legacy" by Anonymous Coward · · Score: 0

    You can thank hardware/software vendors for perverting the word. They couldn't just say "old" or "obsolete" (regarding support or compatibility) so they twisted "legacy" their way.

    It used to be a purely positive concept -- now the word kinda appears positive but is really used for a pejorative purpose. Marketing as usual... don't get suckered in in their shenanigans.

    In other words: "You keep using that word. I don't think it means what you think it means." :-)

  154. closer to the metal = faster compile by krischik · · Score: 1

    "The closer to the metal you can get while programming, the faster your program will compile -- or so conventional wisdom would have you believe"

    Well actually I can disaggree here - Because for C there is the issue of

    #include

    Includes need to be read and parsed over again and over again. Most other compiled high level languages use modules or packages where the specification is read and parsed once. (On top of that they can determine the compilations order and package dependencies theself - almost no need for make)

    Ohh shure, some clever C compiler builder thought of copy cating that feature and called it "precompiled header file". Only they don't work because of:

    #if defined(....)
    #endif

    I the programm becomes complex enough then other high level languages start to outperform C in terms of turn around (edit - compile - debug - edit) speed. Apart from beeing more high level and therefore beeing easier to understant by humans.

    Martin

    PS: all that is even more true for C++ and it magic STL.

  155. How very true! by krischik · · Score: 1

    If you would not have said it I would have done so.

    Martin

    PS: If you do get around trying to learn Ada here my shamless plug:

    http://en.wikibooks.org/wiki/Ada_Programming

  156. unsigned int i = -1; by krischik · · Score: 1

    Do I have to say more?

    Martin

  157. Re:Student Perspective by Anonymous Coward · · Score: 0

    No real difference in testing compiled vs interpreted code really - both have great tools, run time debugging, variable tracing, breakpoints, etc, etc, ad nauseum.

  158. Lisp can be faster than C by Anonymous Coward · · Score: 0

    > I would be very surprised if there's anything LISP can do that can't be done just as fast (or faster) in C.

    http://www.cons.org/cracauer/lisp.html

    "The CMUCL system produces overhead-free code (that means, it is as fast or even faster than C) for a large number of computation constructs."

  159. it's not by m874t232 · · Score: 1

    The article addressed this point by mentioning that the definitions of high and low level language are a moving target.

    No, it's not. I was there for most of the evolution of C, since the K&R days. C has always been considered a "low level language". Nor are the problems with it news. Strange as it may be to believe, there were decent and efficient high level languages in the 70's and 80's.

    C caught on because it shipped free with UNIX, because it was easy to write compilers for it, because Microsoft adopted it, and because a "full" compiler for it fit on the PDP-11 and happened to generate OK code for that machine.

    If you're going to go with the jargon as it's most often used nowadays (which is a perfectly reasonable thing to do), then C would certainly be about as low as you can get without manipulating individual registers - i.e., without being assembly language.

    If you bother to read the C language specs, you'll see that the C language guarantees very little of the things you may think of when you say that "C is low level". ANSI C implementations can legitimately prevent you from doing any kind of low-level pointer manipulation or bit access; they can garbage collect and ignore "free" if they like. And there have been implementations like that. What you think of as "low level" is a particularly common set of implementation choices, not a part of the C language.

  160. Symbian by alispguru · · Score: 1

    Yeah, I had a feeling that if any OS were in C++, it would be something in the embedded space.

    --

    To a Lisp hacker, XML is S-expressions in drag.
  161. Re:C++ machine code trivial? Remember smart pointe by jrentona · · Score: 1

    As far as I am concerned, smart pointers have become a decisive breakthrough in software development. It basically removes the garbage collection advantage of VIMs. Intelligent application of smart pointers, including extensions of the basic std::auto_ptr to include smart arrays and reference counting gives C++ programmers all the benefits of garbage collection without dedicated processes wasting MIPS monitoring your code. All of this VM background bookkeeping is not free; and is above all not perfect. I have witnessed first hand cases of the Microsoft VM taking hours to cleanup wrapped resources for DLLs I've developed. Just because the language prevents you from worrying about freeing heap blocks and handles doesn't mean it gets done right. And worse, if there is a bug in the VM; one's only recourse is to guess at a possible work around and hope it triggers the GC to do its job. -James

  162. Re:Student Perspective by Anonymous Coward · · Score: 0

    Heres the resun I hayte edumacation... compare these too lines and tell me which makse YOUR (not "you're") head hurt really bad:

    1) you ain't got no grammar

    2) you don't have no grammar

    good grief... now their all illiterate...

  163. Silly. by warrax_666 · · Score: 1

    It would have been extremely silly to write the first LISP compiler in C when LISP interpreters were readily available at the time. The usual method of bootstrapping a language is to first write an interpreter for (a possibly simplified version of) the language, and then use that interpreter to develop/run the compiler until the compiler can compile itself.

    There are other high-level languages besides the standard imperative ones, btw. Those languages typically have much stronger type systems (or computational models) that can be leveraged to provide higher-level optmization opportunities that are simply not possible in C for computability/decidability reasons. Granted, there aren't that many languages that actually do this today, but one example would be Occam where logically separate processes can be mapped to a single "hardware" process doing voluntary multitasking without violating process isolation and preemption at the logical level. This allows the system to replace expensive "hardware" context switches with two unprivileged instructions -- thus making running, say, 100000 threads on a single machine a pracical proposition.

    --
    HAND.
  164. Re:Student Perspective by Anonymous Coward · · Score: 0

    Clearly, you've never used an HP calculator.

    Seriously, though, the reason Scheme is so awesome is precisely because it has no syntax and the most minimalist semantics you'll find anywhere. Things that are part of other languages are libraries in Scheme, such as the class system:


    (module test mzscheme
        (require
          (lib "class.ss")
          (lib "mred.ss" "mred"))
        (define my-frame@
            (new frame%
                      [label "My Frame"]))
        (define my-button@
            (new button%
                      [parent my-frame@]
                      [label "My Button"]))
        (send my-frame@ show #t))


    Type that code into DrScheme in module mode, and it'll show you a frame with a button. Nothing too amazing there. But see how it requires the library "class.ss"? What errors do you think you get if you remove it?


    expand: unbound variable in module in: new


    Yep; the new operator -- so essential to writing anything in Java -- is part of the library.

    If there was more syntax built into Scheme, this kind of stuff wouldn't be possible. It's precisely because of this simplicity that Scheme is so awesome.

    On a side note, if you really want to, you can define Scheme macros which will let you write normal arithmetic expressions. But most professional Scheme programs have very little in the way of long strings of arithmetic, and so it's pretty irrelevant.

    That said, you might be interested in Scala. It has much (though certainly not all) of the power of Lisp/Scheme, but its syntax is more expansive. For example, any member function can be used infix, simply by dropping the dot. So 5 + 4 is equivalent to 5.+(4) (obviously, either one is optimized out to pure arithmetic by the compiler), and myList.filter(isOdd?) is equivalent to myList filter isOdd?. Very clean and straightforward, to a non-Lisper, most programs will look much simpler.