Slashdot Mirror


Gosling Claims Huge Security Hole in .NET

renai42 writes "Java creator James Gosling this week called Microsoft's decision to support C and C++ in the common language runtime in .NET one of the 'biggest and most offensive mistakes that they could have made.' Gosling further commented that by including the two languages into Microsoft's software development platform, the company 'has left open a security hole large enough to drive many, many large trucks through.'" Note that this isn't a particular vulnerability, just a system of typing that makes it easy to introduce vulnerabilities, which last time I checked, all C programmers deal with.

484 of 687 comments (clear)

  1. Phew! by rackhamh · · Score: 5, Funny

    Good thing Linux isn't written in...

    Oh. Never mind!

    1. Re:Phew! by DrLZRDMN · · Score: 1

      Its good to run c code on your machine. You don't want applets running it.

    2. Re:Phew! by Anonymous Coward · · Score: 2, Funny

      How exactly would you program an operating system that runs behind a virtual machine? And it what language would the virtual machine be programmed?

      C and C++ are necessary for systems programming. Java, C#, and VB (.net version) are only useful for applications programming since they run behind a virtual machine.

      Oh, by the way, assembly language is a necessary evil as well. While some microprocessors may be developed that can directly read the bytecode, they still won't have a virtual machine running (just a real one).

    3. Re:Phew! by ArbitraryConstant · · Score: 2, Insightful

      C/C++ programs have terrible security track records. They're behind basically every arbitrary code exploit out there. That class of bug just doesn't happen in managed languages. And I don't mean just Java and .NET. An open source example is Python.

      --
      I rarely criticize things I don't care about.
    4. Re:Phew! by DrLZRDMN · · Score: 3, Informative

      Id like to see a kernel written in either language.

    5. Re:Phew! by Anonymous Coward · · Score: 1, Informative

      Not possible. By definition a virtual machine must run as a process.

    6. Re:Phew! by bnenning · · Score: 2, Insightful

      Id like to see a kernel written in either language.

      Fair enough, but at least 90% of the stuff written in C and C++ doesn't need to be.

      --
      How to solve most of our problems: 1.Lots of nuclear plants. 2.Cure aging.
    7. Re:Phew! by Lord+Kano · · Score: 2, Funny

      Good thing Linux isn't written in...

      What Visual Studio .NET? Yep. Good thing it isn't.

      LK

      --
      "Hi. This is my friend, Jack Shit, and you don't know him." - Lord Kano
    8. Re:Phew! by abigor · · Score: 3, Insightful

      You're entirely correct. But in the real world, systems programming accounts for only a small portion of written software. Most is firmly at the application level.

      I feel confident in predicting that most of userland will eventually run in the context of some virtual machine or other. Of course, that doesn't exactly make me a prophet, since that's the plan for Longhorn, but I think it will become the norm on other platforms as well.

      It would be nice if, in the long run, operating systems became irrelevant when it comes to choosing applications. You go with whatever has the best track record for speed, security, or whatever, and then just choose whatever applications you like. Since the virtual machine runs everywhere, so will your software.

    9. Re:Phew! by andreyw · · Score: 5, Insightful

      No offense, but give a fool a hammer and he'll crack his skull. C is not inherently insecure. C++ is not inherently insecure. If you don't know how to program, please step aside and let others through. I am not some sort of anti-managed-language zealot, I love Python, but to claim that C *as a language* has a terrible security track record is ridiculous. The applications, not the language, might have a terrible track record due to the ineptness of the programmer.

      I mean seriously, this is like claiming ASSEMBLY is a worthless insecure language because you can hang the system while in supervisor mode, due to ineptness? Sheesh.

    10. Re:Phew! by ArbitraryConstant · · Score: 2, Insightful

      Fair enough, but how often does the kernel do things like parsing strings?

      --
      I rarely criticize things I don't care about.
    11. Re:Phew! by pivo · · Score: 4, Interesting

      I think the point is that it's much easier to inadvertently create security holes when you write code in lower level languages like C. Lots of excellent programmers have written code with security problems, simply because they're focusing on making their code work and not thinking about security. It's an extremely common problem, and while it may be a problem with the developer's focus, it's not generally a problem of low skill levels.

    12. Re:Phew! by Anonymous Coward · · Score: 2, Interesting

      Congratulations. You have just described Microsoft's worst case scenario. They will never let this happen, so long as they have any say.

      You are correctin saying that Microsoft wants userland running in a virtual machine - specifically THEIR virtual machine. And ONLY their virtual machine. This will become evident as soon as the gloves come off with .NET.

    13. Re:Phew! by SnapShot · · Score: 1

      I second that emotion. Except for some games and hardware specific tasks (like device drivers and oeprating systems) most tasks should not be done in C or C++. Building a front end GUI for a database in C++ is like hanging a picture on your wall with a nailgun. Don't get me wrong. Four years after work made me switch from C++ to Java, I still think of C++ as "real" programming. Probably because it was so much harder to do right.

      --
      Waltz, nymph, for quick jigs vex Bud.
    14. Re:Phew! by owlstead · · Score: 4, Insightful

      Pffft, I am working with a couple of high grade C++ programmers. When they go down using pointers etc. you can be sure they introduce some overflow errors. You need at least a code checker to make sure that the most common mistakes are avoided. This is like saying that Internet Explorer is not insecure, as long as you visit the right web-sites.

      For most applications assembly is a worthless insecure language, and you should stick to a higher level language if you don't want to introduce problems (for anything larger, but probably including "hello world").

    15. Re:Phew! by That's+Unpossible! · · Score: 2, Funny

      No offense, but give a fool a hammer and he'll crack his skull.

      Give a man a gun, and he can kill many people with it.

      Give that same man a pencil and... eh, not so much.

      --
      Ironically, the word ironically is often used incorrectly.
    16. Re:Phew! by ArbitraryConstant · · Score: 5, Insightful

      "No offense, but give a fool a hammer and he'll crack his skull. C is not inherently insecure. C++ is not inherently insecure. If you don't know how to program, please step aside and let others through. I am not some sort of anti-managed-language zealot, I love Python, but to claim that C *as a language* has a terrible security track record is ridiculous. The applications, not the language, might have a terrible track record due to the ineptness of the programmer."

      That's just restating the question.

      If managed languages make a certain class of exploits impossible or very unlikely while C doesn't, then C is insecure relative to those languages.

      A good C programmer might be able to cut the exploit rate down to some very small value, but they're going to work pretty hard to get to that point while people in managed languages get it for free. And good C programmers still fuck up sometimes.

      Of course, there's other ways to screw up. No language is immune from security problems. Using a "managed" language is nothing more than risk management, but it's pretty effective.

      --
      I rarely criticize things I don't care about.
    17. Re:Phew! by CastrTroy · · Score: 1

      No, complicated programs have had terrible security track records. Everything that was ever written and wanted to do anything truly useful was written in C/C++ because at the time it was the best thing available, considering all things. The reason you don't hear about all the security exploits in Java, .Net or Python programs is because there are actually very few apps that use these.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    18. Re:Phew! by timeOday · · Score: 5, Insightful
      No offense, but give a fool a hammer and he'll crack his skull. C is not inherently insecure. C++ is not inherently insecure. If you don't know how to program, please step aside and let others through.
      No, the programmer is irrelevant to this argument. Pick any programmer you like, any one in the world. He will make mistakes at some rate. In C, those bugs will translate directly to security holes, whereas in a typesafe language they will not. It's just that simple.

    19. Re:Phew! by Transcendent · · Score: 3, Insightful

      Pffft, I am working with a couple of high grade C++ programmers. When they go down using pointers etc. you can be sure they introduce some overflow errors.

      Are they really that high grade then?

    20. Re:Phew! by bluGill · · Score: 2, Informative

      I'd like to point out that in this day and age most C programmers have heard about the problems and make some effort to prevent them. While programmers in "safe" languages (VB) generally have not heard of these problems, so while they are harder to create, those programmers are also less likely to recognize them. In fact problems in C are generally minor mistakes that are easy (though tedious) to fix, while in the other languages the same problem tends to be major design level issues that are hard to correct.

    21. Re:Phew! by nwbvt · · Score: 1
      Apples and oranges. Linux (like Windows) is an operating system. .NET is a software platform.

      No one is complaining that operating systems (like Linux or Windows) are written in languages such as C or C++ because an operating system written in Java or C# is not feasible.

      --
      Mathematics is made of 50 percent formulas, 50 percent proofs, and 50 percent imagination.
    22. Re:Phew! by relay_mod · · Score: 2, Insightful
      • In C, those bugs will translate directly to security holes, whereas
      • in a typesafe language they will not. It's just that simple.

      Bullshit. The rate of security holes will be lower, yes. But type safety never guarantees correctness. As such, it never guarantees security.

    23. Re:Phew! by jtshaw · · Score: 2, Insightful

      It is true, any programmer, no matter how good, will make a mistake here and there. However, buffer overflows and such in a single program don't have to be the security nightmare that they often are these days.

      It all comes down to bad OS design in general. Take the IE exploits for example. Why the heck can you get so much system access through an exploit in a web browser?!? Lets be honest here, the security model employed in most of today's OS's is mind boggling in it's ineptness.

      Linux is not immune either. Many distributions out there still have absolutely retarded setup's like having server daemons running as the root user. You run each server daemon under it's own user account and give the user no permissions on anything that it doesn't need for that particular daemon and you can at least save the rest of the system if the deamon is hacked.

      I love linux, but I'm sick of having to apply SELinux patches, Pax/Grsecurity patches, ACL patches, and setup complicated user jails just to feel like my system is safe.

    24. Re:Phew! by dasunt · · Score: 2, Funny

      Just imagine how secure the world would be if we wrote everything in PHP! :)

    25. Re:Phew! by teknomage1 · · Score: 1

      Insightful, bah. You can write innapropriate checks or have if statements with bad logic that create security holes whether it's typesafe or not. Shifting the hole to another spot in the hull doesn't make the boat stop taking on water.

      --
      Stop intellectual property from infringing on me
    26. Re:Phew! by andreyw · · Score: 2, Insightful

      Did I just DROP an important SQL table? ;-) ;-)

    27. Re:Phew! by andreyw · · Score: 1

      Obviously they aren't any bloody good if they keep tripping over pointers?

      Wait wait wait. Assembly may be
      a) Tedious
      b) Non-portable across architecures AND operating systems.
      c) Cause ABI issues during programming, complicating design.
      d) Very low-level.

      But how is it an "insecure" language? Once again - any tool in an idiot's hands will have adverse effects.

    28. Re:Phew! by andreyw · · Score: 1

      Hello world is pathetically easy to write in assembly. IA-32 w/ Linux. -------------- .data # section declaration msg: .ascii "Hello, world!\n" # our dear string len = . - msg # length of our dear string .text # section declaration # we must export the entry point to the ELF linker or .global _start # loader. They conventionally recognize _start as their # entry point. Use ld -e foo to override the default. _start: # write our string to stdout movl $len,%edx # third argument: message length movl $msg,%ecx # second argument: pointer to message to write movl $1,%ebx # first argument: file handle (stdout) movl $4,%eax # system call number (sys_write) int $0x80 # call kernel # and exit movl $0,%ebx # first argument: exit code movl $1,%eax # system call number (sys_exit) int $0x80 # call kernel

    29. Re:Phew! by theshowmecanuck · · Score: 1

      Thanks for listing SELinux and the others. If I had mod points, I would have given you an 'informative'. Now I have some new stuff to play with on my Linux boxes.

      --
      -- I ignore anonymous replies to my comments and postings.
    30. Re:Phew! by Brandybuck · · Score: 1

      You're right. Those languages are popular for small applications, but very rare for large applications or systems software.

      --
      Don't blame me, I didn't vote for either of them!
    31. Re:Phew! by Brandybuck · · Score: 1

      To be fair, 90% of what's written in Java doesn't need to be either. When you get right down to it, choice of language is STILL 100% personal choice, and arguments about garbage collectors and dynamic typing are for the sole purpose of self-justification.

      --
      Don't blame me, I didn't vote for either of them!
    32. Re:Phew! by malfunct · · Score: 2, Insightful

      If you examine the fault model for C/C++ programs as compared to managed programs you will find that the classes of errors are very different. Its much easier to overflow buffers and overflow integers in an unmanaged language. These types of errors lead to exploitable holes and are just way more common in C/C++ programs.

      --

      "You can now flame me, I am full of love,"

    33. Re:Phew! by Brandybuck · · Score: 2, Interesting

      All programming mistakes are security holes, because any software that doesn't behave as intended is a security hole. They might not all grant root access to random passerbys, but they are security holes nonetheless.

      Anecdote time. After five years of working on a million+ line C/C++ codebase, I ran across my first buffer overflow last monday. I've seen many potential buffer overflows (and fixed them when I found them), but this was the first I've seen actually get thrown over the wall to QA.

      If buffer overflows are getting past your unit tests, it's because you're not writing proper unit tests. Using a language as a substitute for proper testing is pathologic. If a tenth the energy spent proselytizing for certain languages was spent on proselytizing for correct software testing, we wouldn't have this problem. Of course, I don't always do unit tests myself, so remember to do what I say and not what I do...

      --
      Don't blame me, I didn't vote for either of them!
    34. Re:Phew! by Brandybuck · · Score: 4, Insightful

      Then they're not "high grade". If you need to use strings, you use the string class. If you need to use a bounded array you use the STL vector. If you can't use the STL, you guard your arrays. Those three things, which are normal "high grade" C++ coding style, avoids the vast majority of potential overflows.

      --
      Don't blame me, I didn't vote for either of them!
    35. Re:Phew! by verus+vorago · · Score: 1

      Java and python are interpreted.

      Guess what the interpreters are generally written in?

    36. Re:Phew! by HiThere · · Score: 1

      Other examples include Ada and Pascal. Not ALL languages that use bounded arrays have garbage collection.

      Another one that comes to mind is Common Lisp. (Probably Scheme, too.)

      Note that each of these languages have their own set of problems, but the are the *same* problems. (And they may not be as damaging to security.)

      Another good contender (soon) will be D. (Digital Mars D, dmd. http://www.digitalmars.com/d/index.html ) It hasn't hit the 1.0 release yet, but it's a nice looking language. It's main problem appears to be a lack of libraries.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    37. Re:Phew! by HiThere · · Score: 2, Insightful

      Actually, C *is* inherrently insecure. You are required to use unbounded pointers. And, yes, assembly language is insecure in exactly the same way.

      It would help if C automatically initialized ram (and I've known at least one C that did, but it isn't a part of the language specs), just like it helps not to be able to use 0 as a pointer address. But the only thing that would make C safe would be to put it in a box, and not let it look outside. Even then you'd get buffer overflows within the code, but if it was restricted to not use pointer references outside the bounds of the program that would help.

      Saying that "C is not inherently insecure" is like saying a sharp knife without a hilt isn't dangerous to the user. With reasonable care one can usually insure that nothing adverse happens to one, but it always takes a lot of care and attention, and the time that you slip can hurt you badly.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    38. Re:Phew! by ArbitraryConstant · · Score: 1

      "Java and python are interpreted."

      That's not true. Both are compiled to bytecode (Python does this in memory even if it doesn't create .pyc files), and the bytecode is run by a VM.

      But anyway...

      "Guess what the interpreters are generally written in?"

      The VM doesn't touch input directly. The bytecode program does all the work, and the bytecode program can't directly address memory, which makes stack smashing a bit difficult. That's one security advantage of managed languages.

      The other advantage is that things like strings and arrays are sized in managed languages. They'll throw exceptions in either language if an attempt is made to go out of bounds. And if you could go out of bounds, it wouldn't help that much because these things live on the heap and not the stack.

      --
      I rarely criticize things I don't care about.
    39. Re:Phew! by jilles · · Score: 4, Insightful

      ASSEMBLY is a totally inappropriate language for the vast majority of applications, including operating system kernels, video card drivers and games. The complexity and security tradeoff simply doesn't justify the performance gains. That's why it isn't used anymore in most of the software industry. The same is true to a lesser extent for C and C++.

      These languages are inherently insecure because they allow for mistakes that other languages do not allow for. Combine this with the fact that it doesn't take a fool to make mistakes and you have the perfect proof that C is inherently insecure. Refute either of those arguments and you might have a point.

      The problem with C is that it takes the inhuman capability to not make mistakes to end up with secure software. That's why all of the long lived C software projects have to be constantly patched to correct mistakes. Buffer overflows are no accidents, they are the predictable result of using C. Use C -> expect to deal with buffer overflows, memory leaks, etc. Every good C programmer knows this.

      The difference between good C software and bad C software is that in the latter case the programmers are surprised whereas in the first case the programmers actually do some testing and prevention (because they expect things to go wrong). Mozilla Firefox comes with a talkback component because the developers know that the software will crash sometimes and want to be able to do a post mortem. The software crashes because the implementation language of some components is C. IMHO mozilla firefox is good software because it crashes less than internet explorer and offers nice features.

      Of course we have learned to work around C's limitations. Using custom memory allocation routines, code verifiers and checkers, extensive code reviews we can actually build pretty stable C software. The only problem is that C programmers are extremely reluctant to let go of their bad habits. Some actually think they are gods when they sit down behind their editors and do such stupid things as using string manipulation functions everyone recommends to avoid like the plague, trying to outsmart garbage collecting memory allocaters by not using them, etc. If you'd build in a switch in the compiler which enforces the use of the improvements listed above, most of the popular C software simply wouldn't compile. But then it wouldn't be C anymore because the whole point of C is to allow the programmer to do all the bad things listed above, even accidentally.

      IMHO programmer reeducation is an inherently bad solution to inherent security problems of the C language. You can't teach people not to make mistakes. You need to actively prevent them from making mistakes. You can make mistakes in other languages but they are a subset of the mistakes you can make in C. Therefore you should use those languages rather than C unless you have a good reason not to. Any other reason than performance is not good enough.

      --

      Jilles
    40. Re:Phew! by tomstdenis · · Score: 1

      ...And these same people won't write robust Java, Python or ... programs either.

      Stack/buffer overflows aren't the only security flaw in the world. Look at SSLv2 where the hello's weren't MACed properly and people could rollback the crypto. That had NOTHING todo with what language SSL was written in and more of people who don't understand security or to develop correctly.

      So no, Java + crappy programer != success.

      That's like saying newbie + nail gun == master carpenter. Or how about newbie + steinway == pianist? Why not newbie + ginsu == master chef ...

      Tom

      --
      Someday, I'll have a real sig.
    41. Re:Phew! by Billly+Gates · · Score: 1

      Its not C/C++ code that is insecure.

      Its the resulting assembly.

      What do you expect? Have all the programmers check the assembly code for holes?

      Sure a programmer could do things like use different string libraries (non ansi) assuming they are writing something new rather than maintaning an old code. But really there is only so much you can do.

      In the workplace they want results as fast as possible for the cheapest cost. If that means using insecure widgets from vc++.net so be it.

    42. Re:Phew! by tomstdenis · · Score: 2, Insightful

      How did your post get insightful?

      buffer overflows are not the only kind of bug that plagues development. quite a few "plain old logic errors" or "insecure designs" are source of problems.

      I mean I just reinstalled pam last night [for the second day in a row... diff versions] with maybe 20 patches applied to it. I doubt all 20 [or any at all] were due to buffer overflows.

      A proper programmer would do proper bounds checking on their own [e.g. I need to store N bytes, do I have N bytes available]. People who don't shouldn't be writing software. Period.

      And yes, "shit happens" but you can just as easily screw up the logic or other aspects in a typesafe language and end up with lowered security.

      SSL rollback anyone?

      Tom

      --
      Someday, I'll have a real sig.
    43. Re:Phew! by tomstdenis · · Score: 1

      "but it always takes a lot of care and attention" ...

      And this is a problem? Who wants programs [even in Java] written by people who can't take the time to audit their code?

      And besides "unbounded" arrays are a function of lazy programmers. You can get bounded arrays in C quite easily.

      Tom

      --
      Someday, I'll have a real sig.
    44. Re:Phew! by amberp · · Score: 1

      But when some people have a Hammer in their hand, every problem looks like a nail to them.

      Allthough .NET has support for over a score of languages, but C and C++ are among the most popular prog. langauges of all times. So with thier support in .NET, they are likely to be used most.

    45. Re:Phew! by Decameron81 · · Score: 1
      A good C programmer might be able to cut the exploit rate down to some very small value, but they're going to work pretty hard to get to that point while people in managed languages get it for free. And good C programmers still fuck up sometimes.


      A good programmer knows that any program he writes needs to be carefully debugged. No program is going to come out of the mind of a programmer without bugs unless it is the "hello world" type. And this is the same no matter the language.

      You should also not forget that sometimes the "managed" solutions are not good enough when it comes to scalability and speed. Sure simple programs can be coded in Java and friends but simple programs are seldom target of attacks. How many successful browsers do you know that are written in Java for example? How many server programs? How many mail clients?

      There are some for sure, but do they deserve to win a first prize?
      --
      diegoT
    46. Re:Phew! by Anonymous Coward · · Score: 1, Insightful

      "If you don't know how to program, please step aside and let others through."

      Ah...another one that has never been a novice.

    47. Re:Phew! by Anonymous Coward · · Score: 1, Funny

      most of today's OS's

      "OSes".

      mind boggling in it's ineptness
      under it's own user account

      "its".

      absolutely retarded setup's

      "setups".

    48. Re:Phew! by DerWulf · · Score: 1

      No, you are incorrect. Not all programming mistakes are securtiy holes in the traditional meaning of security. And by the way, saying 'oh well, you should test for it, so the language is not insecure' misses the point. There is no way that anyone could inject code in java written server programs and execute it, unless the java programs' purpose is explicitly to load classes and run them. In this sense, a whole category of security related mistakes just can't happen in java (or .net). If it can't happen, you wouldn't need to check them and unit test for them. ++productivity. ++languageSafety

      --

      ___
      No power in the 'verse can stop me
    49. Re:Phew! by Taladar · · Score: 1

      The most common security problem in "managed" languages being that people thing by using them they are safe from security exploits.

    50. Re:Phew! by Taladar · · Score: 1

      And this "box" you propose should be written in which language?

      I agree with you that lots of apps are written in C when it would not be necessary but C is the lowest level platform independent language (something like portable assembler) and in this role no managed language can replace it.

    51. Re:Phew! by Taladar · · Score: 1

      It is much safer to assume there will be errors when it is possible there are none that it is to assume there are no errors in your code. If you don't expect errors in your own code irregardless of how "high grade" you think you are you are simply a fool.

    52. Re:Phew! by Taladar · · Score: 1

      I don't think games need C either. A speed optimized language especially for the things needed most in games would probably be exactly what game programmers needed. Sadly game companies don't invest much in this kind of reusable code. Otherwise most game engines would be used by more than 1 or 2 games (at least in the genres where you can impress your players without pushing the graphics quality with every game).

    53. Re:Phew! by Taladar · · Score: 2, Insightful

      The problem with .NET as I see it is that VMs don't make much sense if they only run on one platform. They are just an additional layer of crap that slows down your program.

    54. Re:Phew! by duder · · Score: 1

      STL vectors are not bound-checked. Was considered too much a performance hit.

    55. Re:Phew! by SilverspurG · · Score: 1

      When they go down using pointers etc. you can be sure they introduce some overflow errors

      Well, yes. But you can't slow down corporate profits or quarterly reports just because you need to go back and double-check a few mathematical idiosyncracies that _might_ happen sometime in the mysterious future. Progress. Come on. Let's go. Get that product out the door and...

      Profit!

      --
      fast as fast can be. you'll never catch me.
    56. Re:Phew! by Q+Who · · Score: 1

      They are when you use

      .at()
      member functions.
    57. Re:Phew! by c++ · · Score: 1
      He will make mistakes at some rate. In C, those bugs will translate directly to security holes, whereas in a typesafe language they will not.

      So you're saying that managed languages won't let programmers send passwords over a socket in the clear? Or use a predictable psuedo-random source for key generation? Or store credit card numbers in a folder served up by http? Wow! I'm drooling over managed languages already!
    58. Re:Phew! by ArbitraryConstant · · Score: 1

      "A good programmer knows that any program he writes needs to be carefully debugged. No program is going to come out of the mind of a programmer without bugs unless it is the "hello world" type. And this is the same no matter the language."

      Agreed.

      "You should also not forget that sometimes the "managed" solutions are not good enough when it comes to scalability and speed. Sure simple programs can be coded in Java and friends but simple programs are seldom target of attacks. How many successful browsers do you know that are written in Java for example? How many server programs? How many mail clients?

      There are some for sure, but do they deserve to win a first prize?
      "

      Well there's no denying that C/C++ are still necessary, particularly in very performance sensitive areas like servers or browsers or (my favorite) OSes, but on the flipside now many dynamic web sites do you know that are written in C?

      Now obviously dynamic websites are not without their holes, but I shudder to think what would happen if C/C++ were the dominant language. For dynamic content it's not even in the top 5.

      Uhg.

      That's not to say I relish the thought of dropouts excreting PHP.

      --
      I rarely criticize things I don't care about.
    59. Re:Phew! by Tom7 · · Score: 1

      It might be true that C is not "inherently insecure," if we give it the benefit of the doubt. But there are surely languages that are inherently *more* secure, so why prefer C if security is your goal?

      If you don't know how to program, please step aside and let others through.

      Name a hero programmer, and his C program has had security holes in it. It's not really a question of only allowing "good" programmers to use C.

    60. Re:Phew! by ArbitraryConstant · · Score: 1

      "Other examples include Ada and Pascal. Not ALL languages that use bounded arrays have garbage collection.

      Another one that comes to mind is Common Lisp. (Probably Scheme, too.)
      "

      Lisp has garbage collection... I'm not sure if you meant to say that it didn't but that's how I parsed your post. :)

      There's lots of languages with and without bounded arrays, and with and without garbage collection. Java and Python are just examples that I happen to know.

      C has stack protection these days, which OpenBSD and probably others make use of. It's a bit of a hack but there's been a bunch of patches for OpenBSD (again, just the example I happen to know) where an aribtrary code exploit became a DoS. Indeed, some of those those bugs were arbitrary code exploits on NetBSD, as the code was common to both.

      "Another good contender (soon) will be D. (Digital Mars D, dmd. http://www.digitalmars.com/d/index.html ) It hasn't hit the 1.0 release yet, but it's a nice looking language. It's main problem appears to be a lack of libraries."

      I don't think there's room for another language of that type, even if it's better than the alternatives.

      --
      I rarely criticize things I don't care about.
    61. Re:Phew! by Ed+Avis · · Score: 1

      I think it is fair to say that the C standard library has a terrible track record on security - at least, it has some abominations like gets() that are impossible to use safely, and string handling like sprintf() that is almost as bad. The standard library is part of the ANSI C standard so it is almost fair to say that C itself has a bad security record.

      The core language, together with a more sensible library that was written with a bit more paranoia (for example, not assuming unlimited size buffers, and preferably not using 0-terminated strings, which themselves can cause gotchas), would make it easier to write secure code.

      Similarly, well-written C++ using the C++ standard library (string, vector, ostreams, helpful memory management like auto_ptr, and so on) is unlikely to suffer buffer overruns, format string vulnerabilities or many other classes of security holes. Badly written C++ has all the same problems as badly written C.

      No language is inherently insecure, but it can make it hard to do the right thing or too easy to do the wrong thing.

      BTW - do you ever think about integer overflow when writing in C or C++? Sometimes there are overflow exploits. It would be most handy if the C++ standard library had a 'safe integer' class that would throw an exception or do something sensible when a value gets out of range, rather than wrapping around. Yes, you can explicitly check the result of each integer computation, but does the language make it easy?

      --
      -- Ed Avis ed@membled.com
    62. Re:Phew! by 0111+1110 · · Score: 1

      Any other reason than performance is not good enough.

      So then I take it you would recommend C (perhaps with inline assembly?) for anyone who cares about performance? That should be all of us now that CPU tech has slowed nearly to a halt.

      --
      Quite an experience to live in fear, isn't it? That's what it is to be a slave.
    63. Re:Phew! by ArbitraryConstant · · Score: 1

      "The most common security problem in "managed" languages being that people thing by using them they are safe from security exploits."

      Inasmuch as that's the most common security problem anywhere, yes.

      --
      I rarely criticize things I don't care about.
    64. Re:Phew! by Brandybuck · · Score: 1

      There is no way that anyone could inject code in java written server programs and execute it, unless the java programs' purpose is explicitly to load classes and run them.

      The exploits you are talking about have NOTHING to do with the language, and everything to do with the run time environment.

      --
      Don't blame me, I didn't vote for either of them!
    65. Re:Phew! by andreyw · · Score: 1

      All uninitialized variables get cleared when the BSS gets zeroed. This is true both of GCC and MSVC.

    66. Re:Phew! by Brandybuck · · Score: 1

      I must be using a different STL than you, because I can index off the end of a vector without any memory errors. Of course, if I don't manually check this, my program isn't going to be running the way I expect it to, but that's hardly a problem limited to C++. Even the sacred Java and C# don't prevent this.

      --
      Don't blame me, I didn't vote for either of them!
    67. Re:Phew! by andreyw · · Score: 1

      www.jillesvangurp.com/)
      ASSEMBLY is a totally inappropriate language for the vast majority of applications, including operating system kernels, video card drivers and games. The complexity and security tradeoff simply doesn't justify the performance gains. That's why it isn't used anymore in most of the software industry. The same is true to a lesser extent for C and C++.


      This is insightful?! I'd like to see you write a kernel without having any pieces of assembly. No really - enjoy writing your VMM, exception/interrupt handling, multitasking, system protection code and port-based/DMA I/O code in C.

      Your BS is not true for C or C++ either. Show me ONE kernel thats not written in C or C with a dab of C++?
    68. Re:Phew! by 0111+1110 · · Score: 1

      Saying that "C is not inherently insecure" is like saying a sharp knife without a hilt isn't dangerous to the user.

      A sharp knife with a hilt is also very dangerous. And the sharper it is the more dangerous it is. However I'll take the sharp knife over the dull (and safer) knife every time because my goal in even having the knife is to cut things as cleanly and efficiently as possible and that is precisely what the sharper, "unsafe" knife is good for. I don't need someone to protect me from myself. Any motor vehicle that travels in excess of 30 mph could also be (justifiably) called unsafe, but that does not mean they are not useful. And the faster they go the more useful they tend to be.

      --
      Quite an experience to live in fear, isn't it? That's what it is to be a slave.
    69. Re:Phew! by dgatwood · · Score: 1
      The problem isn't that C is inherently a bad language. The problem is that the designers of C, in an effort to get maximum performance, designed really poor string handling. Using pointers for strings was a terrible idea, and now we're largely stuck with it.

      Computers would be orders of magnitude more secure if we would just replace the use of C strings with a more sane mechanism in which strings are a handle. That handle points to a pointer to the actual data, thus allowing string routines to change the backing storage without updating pointers all over the code. (Use a read-write lock around the handle if you have multiple threads.)

      The data structure should include a representation of the current length of the string as well as the length of the buffer. A garbage collector could periodically shrink the allocation size to something closer to the string length. The strcat equivalent could then add len1+len2 and if it is greater than buflen1, realloc(buf1, len1+len2) or better, buflen1+buflen2 to leave some growing room.

      The point is that these problems could be easilly solved, but only if somebody has the guts to A. design this into their libc, B. license it under a BSD-style license so it can be picked up by the corporate world, and C. make their compiler issue warnings every time you compile something that uses char. I don't see that happening any time soon, so....

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    70. Re:Phew! by RevMike · · Score: 1

      If buffer overflows are getting past your unit tests, it's because you're not writing proper unit tests.

      Unit tests? I've never heard of that before. Can you tell me more?

      Seriously, though, that is an excellent point. In the real world, large C codebases are going to have security holes because some part of the system, be it the C code itself or the libraries, was not sufficiently unit tested. In a Java environment, insufficiently tested code is likely to abend but is less likely to open a security hole, where in a C environment insufficiently tested code is a security risk.

    71. Re:Phew! by duder · · Score: 1

      That's right. I feel stupid- but I never used at- but read plenty about it and vector that I should of known better.

    72. Re:Phew! by Brandybuck · · Score: 1

      Google it. Unit tests are automated white box tests typically written at the same time the code is written. They don't test the program as a whole, but test the functions and objects within the program.

      When the program is finished you end up with a complete automated test suite. It won't be an integration test, that's still a separate task. But it's going to catch a heck of a lot more errors than if you sit in front of the program for five minutes manually fiddling with it.

      Put "test" targets in your make files, and make them part of your nightly builds. Do you perform a complete comprehensive low level test of your code every time you check something in? No you don't. But a suite of unit tests can.

      The key is to write you unit tests at the SAME TIME as you write your productive code. If you wait till later you'll forget some of the boundaries.

      --
      Don't blame me, I didn't vote for either of them!
    73. Re:Phew! by HiThere · · Score: 1

      I'm not disagreeing with your point, exactly. Assembler needs to be used for certain purposes, and those programs need to be tested with exquisite care. But you don't use it for most things. And needing something for a purpose doesn't make it safe. Our bodies make extensive use of hydrogen peroxide. They use it to kill cells that are out of place, or that appear to be invaders, or infected by viruses. This is necessary, but that hardly makes it safe.

      C is 3/4 step up from assembler. It's description as "a portable assembler" is actually quite good, even if not technically correct. It describes the areas in which it is appropriate to use C.

      Note that I'm not claiming that C++ is any better than C. The decision to maintain backwards compatibility, while it contributed greatly to the success of the language, kept the language from including necessary safety features, like bounded arrays, garbage collection, managed pointers (restricted pointers, bounded pointers...I don't know a generalized name), etc.

      Java, et al., which require interpreters to execute couldn't step into the role of C's proper successor. Eiffel MIGHT have, but at first it was too expensive, and later was too late.

      Ada isn't too complex, for all they say, and could have been the appropriate successor, but they goofed in their design of string handling. Even now I can see why they made the mistake they did, and from a high level consistency approach it looks reasonable. But it's wrong! Strings should by default be either bounded or unbounded. Having fixed length strings as the default was a bad mistake. And they SHOULD have included a garbage collector. Not haveing those two features makes Ada much more difficult than C++, even though there are ways around both of the problems. (And the Ada proponents still don't see the problem, because they are self selected to be those that AREN'T bothered by these omissions. So the Ada 2005 revision specs still don't appear to call for garbage collection, though I believe that they are going to deal with the fixed length string problem ---somehow.)

      To me Eiffel would be a decent successor to C, but it has effectively sidelined itself. So the new choice is D, which looks good as a language, and which is available "free". (i.e., there is a version in process, calling itself gdc, that is designed to integrate with the gcc, and there's another version from Digital Mars calling itself dmd, which doesn't cost anything, but which isn't open.) And the D community seems more focused on "How do we get it to work properly?" and "What's the best practical design?" than the Eiffel community is (which tends to be more focused on "What's the theoretically soundest approach?").

      It may well be too late for a new language of this type, though I hope not. Signs that it is come from the currently existing Pyrex "extension of" Python. Pyrex is both a subset and a superset of Python, i.e., while it implements most of Python, it doesn't cover all of it, but it includes some extensions that allow it to specify certain variables as being C variable types. And it compiles to C code (or straight to either an executable or a linkable library). Pyrex classes can be handled by Python just as if they were Python classes. And THIS may be the true successor to C. (Note that C code is still being generated, but it's generated automatically by a program, so it's as safe as that program's design.)

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    74. Re:Phew! by scotch · · Score: 1

      If you need overflow checking, write a trivial checked integer class. The language makes it easy. Since your definition of "do something sensible" is sure to differ from mine, custom classes are basically required for things like this. This is a good exercise for someone trying to learn policy based design and template programming.

      --
      XML causes global warming.
    75. Re:Phew! by Pseudonym · · Score: 1
      Fair enough, but at least 90% of the stuff written in C and C++ doesn't need to be.

      Sturgeon's Law states that 90% of the stuff written in C and C++ would still be crap if translated to another language.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    76. Re:Phew! by MrResistor · · Score: 1

      No, they're completely ignoring that fact and simply declaring C/C++ shouldn't be used.

      --
      Under capitalism man exploits man. Under communism it's the other way around.
    77. Re:Phew! by nwbvt · · Score: 1

      Sorry about that, I must have missed that quote. I'm always bad at finding statements when they don't exist in the first place.

      --
      Mathematics is made of 50 percent formulas, 50 percent proofs, and 50 percent imagination.
    78. Re:Phew! by m50d · · Score: 1
      And of course far more work needs to be done on the interpreter than on programs which run in it.

      You can't escape using low level languages entirely, but you should avoid them whenever you can. It's like if you're an electrician, you have to work on a live circuit sometimes, but you avoid it whenever possible.

      --
      I am trolling
    79. Re:Phew! by buckminsterinsd · · Score: 1

      andreyw spoketh thusly:

      "Show me ONE kernel thats not written in C or C with a dab of C++?"

      I recall that these operating systems had kernels NOT written using any C or C+:

      Digital VAXVMS - MACRO32 and some BLISS
      Apollo Domain - some subset of Pascal
      Tandem Guardian - TAL which was "Tandem ALGOL"

      I think HP and Data General used some dialect of ALGOL for their OS offerings, too.

      Yeah, I know these are proprietary operating systems written for a specific architectures back in the late 1970's - early 1980's. One thing I really liked about "old school" systems was they didn't go tits up on ya all that often.

    80. Re:Phew! by Steven+Reddie · · Score: 1

      Fair enough, but at least 90% of the stuff written in C and C++ doesn't need to be.

      Yes it does. The newer languages that you're thinking these 90% of programs should be written in just didn't exist when they were written. When your choice for a programming language is between C, C++ and the-not-yet-invented-Java, what are your real options? However, I agree that for a large number of spanking new projects there are better mixed-language options which would still often include C/C++ code.

    81. Re:Phew! by DerWulf · · Score: 1

      run time enviroment? You mean, java specific or in general?

      --

      ___
      No power in the 'verse can stop me
    82. Re:Phew! by leuk_he · · Score: 1

      loosing portability is one thing (but don't forget windows is supposed to run on itantium & alpha too). Security is the name of the game. If you run the application in a VM sandbox, with no escape possible, this might be an argument.

    83. Re:Phew! by rjshields · · Score: 1

      As someone else rightly said, another one who has never been a novice. Presumably your leap to knowledgeability has been overnight, and you have not had to deal with the consequences of the kinds of problems that arise when using these kinds of languages. If you had, you would know that 99 times out of 100 you will ship a better product faster with less stress when working in a managed environment.

      Why anyone would deliberately choose to program in such inherently insecure environments, and further advocate their use for day to day development is beyond me. It sucks of masochism and intellectual snobbery.

      --
      In this world nothing is certain but death, taxes and flawed car analogies.
    84. Re:Phew! by PureCreditor · · Score: 1

      Perhaps because females on Slashdot aren't anything close to the 50% distribution of the general population =)

    85. Re:Phew! by ebyrob · · Score: 1

      Fair enough, but at least 90% of the stuff written in C and C++ doesn't need to be.

      Is that as in: 90% of applications that run blazing fast on an old 486 could easily be re-written to barely run fast enough on a monster 1Ghz/1gig system?

      There are some tradeoffs here... And last I checked Java *still* doesn't seem to have snappy GUIs for lightweight apps. (Just loading up the runtime and necessary static portions of the standard library is major overhead, maybe if there was a system that could share runtimes transparently and effectively...) Yes, I'll admit for "heavy weight" GUI apps with OpenGPL support Java's come a long way, but I've yet to see anything that can even perform as well as Notepad in the lightweight arena. (And notepad is a sorry competitor by C standards)

      C#? Well... The integration issue is more or less solved from the get-go on that one, but memory waste is still an issue. It's also still pretty immature to go around claiming a hardened security record.

    86. Re:Phew! by ebyrob · · Score: 1

      This would all massively reduce performance (especially in terms of memory use) and make things more like a managed language. So, you'd wind up with some kind of bastardized hybrid of C and a managed language?

      No thanx. Use C for stuff its good at. Use a managed language for stuff its good at. And whenever possible, keep the bridge between the two as efficient as possible.

      As to warnings for using "char"? There's no way I'd want to have my boss breathing down my neck about warnings when I'm trying to write efficient I/O code just because those doing text manipulation can't even choose the right library...

    87. Re:Phew! by ebyrob · · Score: 1

      I think the definition of "introduce" may be at issue here. Are we talking about during the code/debug cycle? After initial CVS checkin? After acceptance testing before release? Post-release once software is out in the field?

      Each of those has a track record. A developer with 1-2 errors found during acceptence testing in say a 6 month period and none in the field would certainly be "high grade". I guess the question is how that type of developer compares with managed developers with similar (and worse) track-records in terms of securuty problems introduced.

      A bigger question is which apps even need security conscience. Leaving network access out of apps that don't need it, and miniimizing it where possible, would probably go at least as far towards securing systems as choosing a managed langauge (most of which have a track record of networking everything to death and destruction then calling it "best practices").

    88. Re:Phew! by ebyrob · · Score: 1

      Unless the reason the hole popped in the first place was overpressure... Better a small hole than a burst seam.

      Analogies can be fun but... they're still just analogies.

    89. Re:Phew! by bpettit55 · · Score: 1

      Unless were are talking about higher level languages written on a different planet for different computers, then at the heart of these languages are routines written in C++/C and yes, even Assembler. What seems to be assumed here, is that the programmers that wrote THIS code never left any holes; never made any mistakes, never freed a previously freed pointer. Am I wrong? Do the god's among us migrate to writing higher level languages, blessing the unwashed with cloaks of invulnerability? Bad Code is Bad Code. Most programmers using these "higher level" languages can't write bad code, becaue they can't write good code in an actual language.

  2. Advertisement? by nuclear305 · · Score: 4, Insightful

    I actually RTFA since it included a sensationalistic phrase like "biggest and most offensive mistakes that they could have made."

    To me, it sounded like a big advertisement for Java.

    It's the developers decision to use unsafe code in the .NET platform. I certainly wouldn't call this a huge mistake made by MS.

    A hunting rifle can be used to kill people. Does that mean the trigger should only work after inserting a valid and current hunting license?

    1. Re:Advertisement? by haystor · · Score: 2, Insightful

      I'm just curious, but what language(s) of ultimate security is Java and Solaris written in?

      --
      t
    2. Re:Advertisement? by TWX · · Score: 5, Insightful

      As much as I think his presentation method is tacky, I can agree with some of what he says.

      C and C++ allow for buffer overflows. They allow for improper or intentional coding to cause software to try to violate memory space of other functions or programs. They allow for memory allocation without necessarily providing any cleanup later. In the hands of bad, sloppy, lazy, or malicious programmers these traits have always proven to be a problem time and again on many different platforms. This doesn't mean that these languages are the wrong tool; I'd argue that part of Linux's success is because the kernel and most of the GNU-implemented services are written in these languages, which are flexible. Too much flexibility for the wrong purpose leads to problems though, just as too much rigidity leads to problems when things need to be flexible.

      --
      Do not look into laser with remaining eye.
    3. Re:Advertisement? by rackhamh · · Score: 1, Insightful

      A hunting rifle can be used to kill people. Does that mean the trigger should only work after inserting a valid and current hunting license?

      DISCLAIMER: COMPLETELY OFF-TOPIC

      I don't know what the law is, but if a hunting rifle can only be legally used for hunting, this actually a pretty good idea. The card mechanism could also be used to enforce hunting seasons.

      I realize this offends some people's sense of rights, but I'm not particularly inclined to defend somebody's "right" to use a firearm outside its intended purpose.

    4. Re:Advertisement? by andalay · · Score: 1, Offtopic

      "Damn, husband is going to beat me again. This time I'm going to kill him." < cocks rifle> "What the fuck? Rabbit season! Duck season! Rabbit season!" "Like this honey" "Thank you, you can now hunt deer"

    5. Re:Advertisement? by Anonymous Coward · · Score: 1, Funny

      > A hunting rifle can be used to kill people.

      Well, Visual Basic won't kill people, but it surely can drive them insane!

      > Does that mean the trigger should only work after inserting a valid and current hunting license?

      You usually need a license to instal VB.NET ...

    6. Re:Advertisement? by miu · · Score: 4, Insightful
      I think he is talking about the fact that the type system of managed code itself could potentially be subverted by unmanaged code added by other developers.

      The article is heavy on sensationalism and short on content so it is difficult to tell what is actually being debated here, but I think that Gosling is claiming that support of C type handling in itself creates a chink in the armor of the CLR, regardless of any particular project's use of that feature.

      --

      [Set Cain on fire and steal his lute.]
    7. Re:Advertisement? by rackhamh · · Score: 1

      I can't tell if you're being serious or joking, but in case you are...

      Your post suggests that a card security mechanism on hunting rifles would somehow impede a woman's ability to defend herself. A couple of points:

      1) Murder is still illegal, even if your husband is an abusive asshole.

      2) Hunting rifles aren't intended for self-defense.

      3) In your story, the woman died because she tried to kill her husband. If she hadn't tried to use the rifle, she would have lived to see another day.

      So basically what I'm trying to say is that your story is interesting but generally unconvicing in any way, shape or form. But thank you for your contribution!

    8. Re:Advertisement? by n0-0p · · Score: 5, Insightful

      He's not wrong about the pitfalls of C/C++. It's just that his argument is downright silly when taken in the appropriate context. The .NET "unsafe" code segments are really no different than JNI, except that they integrate much more cleanly into the platform. As much as I dislike Microsoft in general, .NET is an extremely well designed and secure platform. I say this as someone who has spent almost a decade making a living performing software security assessments and developing secure architectures. If you take the time to research it you will find that .NET really feels like the next incremental step after Java, and it takes advantage of a decade's lessons learned in Java.

    9. Re:Advertisement? by fm6 · · Score: 1
      It's the developers decision to use unsafe code in the .NET platform. I certainly wouldn't call this a huge mistake made by MS.
      Except that a primary purpose of .NET is to create a security layer, so that badly-written applications don't screw up your system. This is why Microsoft is telling developers to stop using native Windows APIs and code to .NET instead -- it's supposed to be safer.
    10. Re:Advertisement? by gstoddart · · Score: 1
      It's the developers decision to use unsafe code in the .NET platform. I certainly wouldn't call this a huge mistake made by MS.


      Ummm ... are you saying if a developer chooses to write unsafe code on .NET it is the fault of the developer that he can do so? By it's very name it implies that remote computers are going to connect to it, so one would hope it's not built to be too riddled with security holes or potential to be 'dangerous'.


      A hunting rifle can be used to kill people. Does that mean the trigger should only work after inserting a valid and current hunting license?


      Sounds more like the barrel exploding to me than needing a hunting license.

      --
      Lost at C:>. Found at C.
    11. Re:Advertisement? by damiangerous · · Score: 2, Insightful
      I don't know what the law is

      Obviously.

      but if a hunting rifle can only be legally used for hunting

      A hunting license licenses the owner to take a certain type of game (deer season, etc) on certain land (assigned state land, private land, etc) during certain times (hunting seasons, obviously) with certain tools (shotgun only, bow, etc). It only grants this, in the case of firearms, to people who already legally own them. A "hunting rifle" is simply a subset of rifle suitable for a certain task (which varies for the types of game). In every case the "hunting rifle" set overlaps other sets such as the "target shooting" set or "clay pigeon" set.

      this actually a pretty good idea. The card mechanism could also be used to enforce hunting seasons.

      No, it's a terrible idea. Even suspending basic rights and also assuming for a moment that a "hunting rifle" with no other legitimate purpose exists you're proposing that it be completely inoperable for 11 months (or whatever) of the year? And you see nothing wrong with forbidding use of a dangerous tool except for the brief times we let people loose in the woods with them? Not allowing people to become comfortable, or even passingly familiar with it until they're hopped up on adrenaline in the forest? You see nothing inherently dangerous with that at all?

    12. Re:Advertisement? by Zeinfeld · · Score: 4, Insightful
      The problem here is that it will be very difficult to take Gosling seriously when he talks about anything in future. This does not make me think any better of Sun.

      Nobody is going to use C or C++ to write a completely new program under .NET. There are occasions where I might use C for something I wanted to make cross platform but no way would I ever go near C++.

      Most people who are going to use the new .NET support are people who have legacy C programs and want to gradually transition them to the .NET base in stages. The makes a good deal of sense.

      The other constituency is folk who are writing stuff that is almost but not quite at driver level.

      --
      Looking for an Information Security student project suggestion?
      Try http://dotcrimeManifesto.com/
    13. Re:Advertisement? by mikerozh · · Score: 1

      Don't tell me that this is impossible in java.

    14. Re:Advertisement? by MerlinTheWizard · · Score: 3, Interesting
      C and C++ allow for buffer overflows.

      It's irrelevant, actually. A bug is a bug. You can make them in any language. The consequences of the potential bugs are what matters. But only the implementation defines what a "buffer overflow" will actually do. Granted you can try and write past some allocated buffer in C (and C++). That doesn't mean the write should actually occur. That's the responsibility of the implementation, and mostly of the underlying operating system. I already said that earlier: the major problem we have been facing for decades on mainstream systems (and even some critical servers) is, in my opinion:

      Allowing executing code from a purely 'data memory' space. That should never, ever be possible under any circumstances. I'll fight for that cause if I have to.

      Poor 'data memory' protection. Ideally, the OS should be able to protect individual data areas, down to application buffers and variables. There is nothing that would prevent from writing a C or C++ compiler for such an environment. Absolutely nothing.

      You may not be able to "overflow" some data buffer in Java, but you can always write garbage to it. That's the same. As I said, the languages need not be fixed. The systems and the memory models do.

    15. Re:Advertisement? by clem.dickey · · Score: 2, Funny

      A few years ago a non-techie friend mentioned that he had read an interviewer with the creator of Java.

      Me: "Oh, that would be, umm, James Gosling."

      He: "No, that's not the name. It was a lady. Let me check ... Gina Centoni."

      Me "Who?"

      A web search revealed that Ms. Centoni's position was "Director of Java Marketing." Out of the mouths of babes come all wise sayings.

    16. Re:Advertisement? by iabervon · · Score: 2, Insightful

      His point is essentially that .NET does not protect the user against untrusted code, while Java does. If you run .NET code, you have to trust the developer, because the system won't protect you against a malicious or careless developer. If you run Java code in a sandbox, you're safe, because the system will watch what's going on and can be sure of the safety of its information.

      A hunting rifle is fine for some purposes, but decorating your house with them is unwise. Java, effectively, has support for making absolutely certain that the rifle cannot be fired, and therefore you can feel okay about having it on your mantle.

      Of course, he's theoretically wrong; the C standard actually does not exclude the possibility of preventing programs from doing bad things, by, for example, giving a bus error if you dereference a pointer to freed memory. You could have garbage collection in C if you really wanted, because there is a limited amount you can do to pointers and still be necessarily able to use them again. It's just that C implementations almost never do anything like this, because it would be slower and more resource-hungry than Java (because Java has limitations which then permit optimizations by the system). On the other hand, it might be worthwhile having such an environment, so that you could run untrusted code by developers who expect to be trusted.

    17. Re:Advertisement? by andreyw · · Score: 2, Interesting

      C is a language. Its not an OS executive. It can't stop you from overwriting 0xdeadbeef with gobbledygook if your OS has no VMM.... which unless you're still running DOS, writing a kernel, or programming an embedded device... is not a problem as you might imagine.

    18. Re:Advertisement? by Fermier+de+Pomme+de · · Score: 1

      No, but someone might use it to write an exploit that will magically get loaded over the wire by the CLR because the nextgen IE told it to.

    19. Re:Advertisement? by clem.dickey · · Score: 1

      > C and C++ allow for buffer overflows.

      It might be more accurate to say that Java forbids buffer overflows. Attempts at C and C++ buffer overflows yield undefined behavior. For example, if p points to a 1-element array, *(p+1) is undefined. And (p+2) is undefined, even without a dereference.

      Despite the name, an implementation is allowed to define "undefined behavior" (C99 3.4.3, C++98 1.3.12), and could map it to some safe behavior, such as raise(SIGABRT). Actually doing this would be quite a bit of overhead. The resulting environment might be even slower than JRE, if that is possible. :-)

      I have seen it alleged that there are instances for which C or C++ *require* unsafe behavior, but I haven't seen one described specifically. If anyone knows of an example, please post it.

    20. Re:Advertisement? by cookd · · Score: 1

      Actually, it is more than that. .NET can run WITH or WITHOUT the sandbox. If you're running web applets, you'll be running WITH the sandbox, and all is good. In that case, the C or C++ or IL Assembly simply won't run if it isn't verifiably safe.

      --
      Time flies like an arrow. Fruit flies like a banana.
    21. Re:Advertisement? by cookd · · Score: 1

      And just to clarify, his argument is false.

      You can choose what privileges are granted to a .NET app. If the .NET app uses unverifiable code, then it requires the "run unverifiable code" privilege. You'd be insane to grant that privilege to .NET applets from unknown web sites, just like you'd be insane to grant JNI access to Java applets from unknown web sites.

      --
      Time flies like an arrow. Fruit flies like a banana.
    22. Re:Advertisement? by cookd · · Score: 2, Informative

      Ummm ... are you saying if a developer chooses to write unsafe code on .NET it is the fault of the developer that he can do so? By it's very name it implies that remote computers are going to connect to it, so one would hope it's not built to be too riddled with security holes or potential to be 'dangerous'.

      The developer can choose to do whatever he/she wants. The nice thing about .NET is that the end user can then choose whether or not to allow that developer's code to run on his/her machine, and can obtain additional information that aids him/her in making that decision.

      The .NET VM will verify the bytecode to determine whether the developer has done anything "unsafe" (such as perform pointer arithmetic or call native Windows code). If so, the VM will check the user's security settings to determine whether unsafe code is allowed to run in this context.

      --
      Time flies like an arrow. Fruit flies like a banana.
    23. Re:Advertisement? by cookd · · Score: 2, Informative

      His point is essentially that .NET does not protect the user against untrusted code, while Java does. If you run .NET code, you have to trust the developer, because the system won't protect you against a malicious or careless developer. If you run Java code in a sandbox, you're safe, because the system will watch what's going on and can be sure of the safety of its information.

      If that is the point, he's dead wrong.

      Just like you can run Java code in or out of the sandbox, you can run .NET code in or out of the sandbox. If the developer does pointer arithmetic or anything else that cannot be verified as "safe", the code will require additional permissions to run. Just like calling the file system APIs requires additional permissions in Java. It just means that if you want to write in C and target .NET, you can, but your users will have to grant your code additional permissions before it will run.

      --
      Time flies like an arrow. Fruit flies like a banana.
    24. Re:Advertisement? by spongman · · Score: 1
      If you run Java code in a sandbox then you're safe.

      If you run .NET code in a sandbox then you're also safe.

      What Gosling forgot to mention that while Java has a sandbox model, .NET also has a so-call 'Code Access Security' infrastructure that goes far beyond Java's simplistic 'app/applet' security.

    25. Re:Advertisement? by owlstead · · Score: 2, Interesting

      I agree with almost everything of your post. However, I must say that not every features .NET has over Java is an improvement. And not everything has such a long track record either. It took MS almost no time at all to implement almost every single feature of Java 1.5 into C#. Then again, Java added auto-boxing, which seems to stem from C#. None of the features of both languages is really original of course.

      Note that the Java VM of Microsoft was not that safe. I am very curious if .NET will have a better track record. Safe code is very interesting thing to have - if it runs on a safe virtual machine.

    26. Re:Advertisement? by cecom · · Score: 1

      Yeah, let's see you port that C++.NET application to anything :-)

    27. Re:Advertisement? by LordHunter317 · · Score: 1

      It might be more accurate to say that Java forbids buffer overflows. Attempts at C and C++ buffer overflows yield undefined behavior. For example, if p points to a 1-element array, *(p+1) is undefined. And (p+2) is undefined, even without a dereference.

      Despite the name, an implementation is allowed to define "undefined behavior" (C99 3.4.3, C++98 1.3.12), and could map it to some safe behavior, such as raise(SIGABRT). Actually doing this would be quite a bit of overhead. The resulting environment might be even slower than JRE, if that is possible. :-)

      All operating systems handle this particular "undefine behavior" in a safe and efficent manner. On Linux, it's called SIGSEGV. If you access memory outside your process space, you're killed.

    28. Re:Advertisement? by Saeed+al-Sahaf · · Score: 1
      A hunting rifle can be used to kill people. Does that mean the trigger should only work after inserting a valid and current hunting license?

      Actually, yes. I think so.

      --
      "Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
    29. Re:Advertisement? by j1bb3rj4bb3r · · Score: 1

      A hunting rifle can be used to kill people. Does that mean the trigger should only work after inserting a valid and current hunting license?

      that's actually not a half bad idea...

      --
      *yawn*
    30. Re:Advertisement? by Anonymous+Brave+Guy · · Score: 1
      Most people who are going to use the new .NET support are people who have legacy C programs and want to gradually transition them to the .NET base in stages. [...] The other constituency is folk who are writing stuff that is almost but not quite at driver level.

      There are also a lot of developers who write libraries rather than finished executables. If your library is written in C++ for portability reasons, then Managed C++ as-was or C++/CLI as-will-be is probably the easiest way to provide a wrapper for anyone writing under .NET to use your products.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    31. Re:Advertisement? by andalay · · Score: 1

      Ok so maybe you had to do some extrapolation to understand the story. Pretend he was coming at her with the hunting rifle, she somehow managed to get it. Does it work for you now?

      The point was that such things can be used for self-defense.

      I know, its hard to try to understand what other people are thinking! Just don't be a requirements engineer :P (please don't take this too seriously)

    32. Re:Advertisement? by sleepingsquirrel · · Score: 1
      Of course, he's theoretically wrong; the C standard actually does not exclude the possibility of preventing programs from doing bad things
      Luckily, the tools to do this already exist... As well as more run-of-the-mill alternatives like Valgrind and other memory bounds checkers.
    33. Re:Advertisement? by ndykman · · Score: 4, Insightful

      Not so. Well, unless you hacked the .Net type verification and loading code, managed to install it over the .Net Framework (not easy, really).

      All use of unsafe features in .Net are marked as such and can't be hidden. So, pointers, unsafe casts, etc. all stick out to the type loader. In fact, if an .Net assembly tries to mark itself as safe and it has unsafe features, the loader won't load it.

      As far as I know, there is no example of unmanaged code that can violate the managed code type system, and .Net was explicitly built to keep this from happening.

      Also, this ignores that C/C++ support is much more complicated in .Net. Yes, there is the IJW (It Just Works) stuff that allows unmodified code to compile to unsafe .Net assemblies, but there is also the C++/CLI stuff, which creates a CLS version of C++.

      Frankly, this seems like a bit of sour grapes to me. .Net does really improve on Java in lots of ways. Yes, James, Java isn't the last word on programming languages. .Net isn't either.

    34. Re:Advertisement? by wolfgang_spangler · · Score: 1

      A hunting rifle can be used to kill people. Does that mean the trigger should only work after inserting a valid and current hunting license?

      Actually, yes. I think so.


      Oh that is a GREAT idea. Practice before hunting season would be a terrible idea. Since you don't like guns nobody else should enjoy shooting them. We should also ban archery as well. I mean, that is just for killing people. Slingshots...gotta get rid of those. Darts, toss those in the trash. Knives, worthless pieces of human killing steel! People could get along just fine without knives.

      What a jackass, you think that since you dont like something it has no purpose or use? What a freaking waste of oxygen.

    35. Re:Advertisement? by gburgyan · · Score: 4, Interesting
      I have to agree -- and I'll try to extend your arguments even further.

      In my current job, which involves quite a bit of C#, I had the opportunity to port large chunks of our legacy application from C++ to Managed C++. We didn't gain security benefits, nor did we gain speed; we didn't loose any either. However we gained a lot of maintainability since we now have a single stack-trace to deal with that bridges all of the languages that we have (now reduced to C# and C++ -- down significantly from when we relied heavily on COM)

      The fact that MS gave us that choice is wonderful. If we wanted to be using JNI (which I had the unlucky opportunity to use), we'd not have made much progress at all.

    36. Re:Advertisement? by miu · · Score: 1
      Again, I'm not really sure exactly what Gosling said, so I don't want to put words in his mouth, but in interviews of his I've seen in the past it seems that he claims that JNI is safer than 'unsafe' because in JNI there is a firewall - data is passed off to unsafe code that can't access anything other than the data it is given, in the CLR model code within the program itself is marked as unsafe which allows it to do things which are very difficult to verify do not act outside the memory it is supposed to be operating on and additionally that this makes verification, even when code is not marked as unsafe, very difficult to do correctly.

      I certainly can't claim to know whether or not Gosling's belief is true or not, but I think this goes beyond being a security manager issue of allowing or not allowing JNI/unsafe operations by an applet or program and states that allowing C types to operate at all within the program makes bulletproof verification impossible.

      One counter argument to Gosling's position of course is that in JNI itself the firewall of external code operating only on the data you give it is an illusion, that by allowing an unsafe SO to be loaded into your memory space and request operations of the JVM you have the exact same problems that embedding the unsafe code within the program create in the first place. That by pretending that JNI constrains unsafe operations you are simply being dishonest.

      --

      [Set Cain on fire and steal his lute.]
    37. Re:Advertisement? by clem.dickey · · Score: 1

      All operating systems handle this particular "undefine behavior"

      ... if they see it. The hard part is to catching the cases which the O/S doesn't see because the memory past the end of the buffer is mapped.

    38. Re:Advertisement? by T-Ranger · · Score: 1

      If you were going to kill someone with a rifle, why would you ever get within hand to hand range? For fuck sake, not every firing a gun before, from 10m you would be able to hit a person firing from the hip.

      And if they did get within hand to hand range, then they could get closer to them then the length of the barrel, making it very very difficult for you to use it effectivly as a firearm. Ignoring the insane American obesssion with firearms, a rifle is not a good choice for personal defense.

    39. Re:Advertisement? by Saeed+al-Sahaf · · Score: 1
      What a jackass, you think that since you dont like something it has no purpose or use? What a freaking waste of oxygen.

      What's with kids like you today. A disagreement, a misunderstanding, and you are already out with the insults. Jackass? What happened to meaningful discussion. Ah, to be 14 again, like Wolfgang.

      --
      "Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
    40. Re:Advertisement? by andalay · · Score: 1

      Alright, I give up.

    41. Re:Advertisement? by devinoni · · Score: 2, Informative

      Other than generics, and static imports, all the new language features of Java 1.5 aka 5.0 were available in C# 1.0. There was even a slashdot story about it. http://it.slashdot.org/article.pl?sid=04/10/11/145 4220&tid=108&tid=8/

    42. Re:Advertisement? by BlizzyMadden · · Score: 1

      I agree. C/C++ are the dominant languages--sorry, Sun marketing dept.--and aren't getting any less popular. Given that the Moore's law will start to expand in the realm of multithreaded/multiprocessor rather than raw clock cycles, the high performance of C++ will be more critical than ever.

    43. Re:Advertisement? by AaronLawrence · · Score: 1

      You mean like the "NX" protection?
      Data memory protection per area is probably one of the biggest parts OF a managed language.

      --
      For every expert, there is an equal and opposite expert. - Arthur C. Clarke
    44. Re:Advertisement? by curri · · Score: 1

      Actually, even now C# does not support inner classes (just to cite a java feature that I like; there *may* be many others :)

    45. Re:Advertisement? by AaronLawrence · · Score: 1

      Not usually. OS memory is allocated in big blocks by the language runtime, so you can usually write far past the end of any particular variable's "correct" space without the OS detecting it.

      Although the OS protects other PROCESSES against yours, it doesn't protect you against yourself. And that is the problem: someone can force your (insufficiently robust) code to overrun its buffers and then cause your code to do something else that wasn't intended.

      --
      For every expert, there is an equal and opposite expert. - Arthur C. Clarke
    46. Re:Advertisement? by curri · · Score: 1

      > Allowing executing code from a purely 'data memory' space. That should never, ever be possible under any circumstances. I'll fight for that cause if I have to.

      Actually, although that is a great idea for most programs, JIT compilers need that capability (and there are a few other applications, in the compiler/vm domain that may need it too)

    47. Re:Advertisement? by Bodrius · · Score: 3, Informative

      What are you talking about? Inner classes are fully supported in C#...

      Unless you're talking about anonymous inner classes (a different animal, typically with a different purpose altogether when it comes to design motivation).

      This seems to have been a matter of designer taste on the part of Hejlsberg. 2.0 should bring anonymous methods, which aims to solve the same type of problems anonymous classes did, in a neater way.

      --
      Freedom is the freedom to say 2+2=4, everything else follows...
    48. Re:Advertisement? by malfunct · · Score: 3, Informative

      Nope, at least not if it can't verify its safety and request permissions correctly. There is a chain of trust that needs to be developed before the .NET framework will allow the assembly to load. One thing that you should do if you don't want unsafe code to execute is remove that permission from your program (can be done with an attribute in your source code) and then these unsafe modules just won't load.

      Not saying this can't be defeated but there are tools in the languages to protect yourself.

      --

      "You can now flame me, I am full of love,"

    49. Re:Advertisement? by GroovBird · · Score: 1

      Mod parent up please. It's time people that know shit get heard.

    50. Re:Advertisement? by Mortlath · · Score: 1
      The C/C++ compiler (version 7) for Visual Studio .NET has a compiler switch that will turn on buffer overflow detection.

      It's great for debugging your code, and I haven't seen a noticable slowdown using it.

    51. Re:Advertisement? by rackhamh · · Score: 1

      There could be a mechanism to unlock the rifles on a firing range.

      So no, I have absolutely no problem rendering a dangerous tool inoperable in settings where it should never be used.

      Giving people freedoms doesn't necessarily have to be a free-for-all.

    52. Re:Advertisement? by damiangerous · · Score: 1
      There could be a mechanism to unlock the rifles on a firing range.

      And this mechanism would work in the 12 acres of private property my friend has behind his house (which is large enough to hunt legally)? It would work every single time we felt like going out back and putting a few round into paper? How would that work, exactly?

      So no, I have absolutely no problem rendering a dangerous tool inoperable in settings where it should never be used.

      There is virtually no such setting, and even if there were you would have to assign the task of deciding that to someone.

      Giving people freedoms doesn't necessarily have to be a free-for-all.

      Indeed. That's what licenses/permits are for. Considering the rate at which legal firearm holders commit crimes (much lower than the population as a whole) I think it's a pretty damn good system.

    53. Re:Advertisement? by StarsAreAlsoFire · · Score: 1

      You may not be able to "overflow" some data buffer in Java, but you can always write garbage to it.

      Erm, the point of overflowing a buffer is to dump executable data into the stack, hopefully somewhere that will get executed. Or to change a value *which is not associated with said buffer*. Obviously if you working with some particular buffer you can overwrite data in it. That hardly matters and cannot be considered a bug.

      FWIW I don't agree with Gosling. I don't use .NET and do use Java, but it really is mostly a comfort issue. I don't feel comfortable with MS taking over the world by yet another increment ;~)

      Since the point of the ability to execute insecure code is to allow for importing of archaic code, I agree with it as a concept. Anyone intentionally coding out of the sandbox with .NET on new code should simply be shot. There are other languages for that kind of thing. If you need low-level access, learn to write real low-level code; use C (or whatever). If you *think* you need low level access, and you don't know C, you don't f*ing need low-level access.

      As always, a hasty generalization created for /. on a whim :~)

      Cheers

    54. Re:Advertisement? by Anonymous Coward · · Score: 1, Informative

      And type safe delegates, type safe reference value parameters, custom defined metadata, user defined enumerations, explicit interface implementation to avoid syntactic and semantic method clashes, various language abstractions (properties, operator overloading).

      Just talking about V1.0 of C# here - I'm aware that Sun has copied many of those features in Java 1.5. For V2.0 there's a real implementation of generics rather than a kludge on type of the JVM... blah blah blah...

    55. Re:Advertisement? by IWannaBeAnAC · · Score: 1
      Sorry, that simply isn't true.

      Such code would cause undefined behaviour, and it is purely up to the implementation what happens in that case. It would be quite possible to have a C compiler that includes rigorous bounds checking and called abort() in such a case.

      For example,

      int main()
      {
      char myarray[5];
      char *p = myarray; // ptr to start of array

      char *q = p+5; // one-beyond-the-end is allowed, not dereferencable
      *q = 'x'; // UNDEFINED - could be a memory exception or reformat your harddrive, or abort()

      char *r = q+1; // UNDEFINED - even *forming* this pointer is illegal
      }

      Now, The ISO C standard says that such programs are ill-formed. In most cases, such behaviour is detectable at runtime by having the compiler insert bounds checking. Unfortunately, most compiler vendors (including Sun and Microsoft) allow this code as non-portable extensions, and specify that the behaviour overwrites memory. But make no mistake, it is a deliberate choice by the compiler to allow this, rigirous bounds checking most definitely allowed for standard C.

    56. Re:Advertisement? by CaptnMArk · · Score: 1

      There is however a difference.

      Java and D# is (in theory, excluding VM bugs) "secure".

      C++/C is not. Bugs can have disastrous effect.

      With Java, one cannot automatically download the "potentialy insecure" code at all.

      With .NET digital signatures will not help at all if some downloaded C/C++ component has an exploitable bug.

    57. Re:Advertisement? by synx · · Score: 1

      This sounds similar to the ActiveX permissons system which did not work so well. Users click on 'ok' over and over until the program runs to their satisfaction.

      To call it the user's fault is an unsophisticated view. The better view is to recognise user's motivations and psychological underpinnings and work with it. If this means designing a system with less flexibility then so be it.

      The problem with computer companies such as Microsoft and others, is they are so heavily concentrated on technology and only technology - they forget their users. The classic example is to provide flexibility at the expense of usability. Some people might argue the entire office suite embodies this concept.

    58. Re:Advertisement? by malfunct · · Score: 2, Informative

      What I am saying, if you read it, is that you can tell the .Net framework that your application does not accept unsafe modules. If that is the case the C/C++ module that does unsafe actions (which are obvious to the frameworks security checks which are extensive and expensive) it will not be loaded. There is no danger of accidentially running unsafe code in an application that doesn't accept unsafe code. If you are worried about security it would be in your interest to not give your application this permission, especially if you are dynamically loading libraries through relfection.

      It would pay for you to read:

      http://msdn.microsoft.com/library/default.asp?url= /library/en-us/dnnetsec/html/seccodeguide.asp

      --

      "You can now flame me, I am full of love,"

    59. Re:Advertisement? by Ayende+Rahien · · Score: 1

      Now try to implement this in this case:

      int *arr = malloc(sizeof(int)*5);

      How do you do bounds checking without some putting omse sort of VM in there for any memeory access?

      --

      --
      Two witches watched two watches.
      Which witch watched which watch?
    60. Re:Advertisement? by junglee_iitk · · Score: 1
      ....Too much flexibility for the wrong purpose leads to problems though, just as too much rigidity leads to problems when things need to be flexible.

      In a nutshell, C is Elastic Girl, while other are Mr. Incredible.

    61. Re:Advertisement? by IWannaBeAnAC · · Score: 1
      You certainly don't need a VM.

      You need to be able to associate the pointer with a particular array returned from malloc. In this particular case, this is trivial because the compiler knows about it. What is much harder is something like

      void foo(int* p)
      {
      p[5] = 0;
      }

      I can think of three solutions (there are probably other solutions too):
      1. provide a way to find out which array a pointer points to. For example, malloc() needs to store the array size somwhere, so the compiler can (in principle) find this out - similarly for stack allocated arrays. If course, depending on how malloc etc work, this could be expensive, but it isn't necessarily slow.
      2. Standard C allows the posibility that pointers are 'fat', so a pointer could actually contain two addresses, the actual address of the pointee, as well as the base address of whatever array it points to (from which there would be a way to find out the array size). Unfortunately, this probably violates POSIX semantics, but you can't have everything.
      3. An associative array that keeps track of which array each pointer points to. This is really a version of (1) that doesn't require integrating with malloc().

    62. Re:Advertisement? by Jordy · · Score: 2, Informative

      C++/C is not. Bugs can have disastrous effect.

      Sigh. There are plenty of garbage collectors and boundscheckers for C/C++. Heck, there are several bounds checker extensions/patches for GCC that introduce bounds checking to both stack and heap. Boehm is a fine garbage collector if you like that sort of thing. They go back at least 10 years.

      Combined with a non-executable stack and heap, randomized address space layout and signed return addresses (StackGuard XORs with a random value and verifies before returning), it becomes extremely difficult to exploit.

      And of course with C++, you don't actually have to use pointers or arrays. There are enough nice safe standard containers.. well I won't go into that.

      That said, not all security exploits are buffer overflow related. There were plenty of security exploits before buffer overflows became popular and there are still plenty today. They can exist in Java just as easily as anywhere else. You pass an unescaped buffer from a user to a db call, no amount of VM is going to help you avoid someone taking advantage of it.

      --
      The world is neither black nor white nor good nor evil, only many shades of CowboyNeal.
    63. Re:Advertisement? by kohsuke · · Score: 1

      > What are you talking about? Inner classes are fully supported in C#...

      That's a news to me. Are you sure?

      I suspect you mean "nested types", which are different from Java's "inner classes" in that they do not have implicit enclosing parent instance.

    64. Re:Advertisement? by Jugalator · · Score: 1

      C and C++ allow for buffer overflows.

      One of the new features of the C++ .NET compiler is that it now has a switch to enable runtime checks for buffer overflows.

      --
      Beware: In C++, your friends can see your privates!
    65. Re:Advertisement? by DrXym · · Score: 2, Informative
      The "integrating more cleanly" bit is worth more exploration. Java does allow native calls via JNI but it's always been bloody fiddly to get it to work. It does work, but it's fiddly requiring you define an interface, run a tool to generate stubs and implement those stubs handling exceptions & objects via a large set of JNI helper methods. Thus the average Java programmer doesn't even *think* about writing native code unless they absolutely, positively have to. So virtually every third party lib is pure Java, and has no dependencies on native executables or platform specific features. There are exceptions of course (e.g. SWT) which hit the underlying OS but in general this is true.

      Now onto .NET. C++ is fairly easy to pull into a project - write some garbage collection safe wrappers around your "legacy" code and now it runs in .NET. And via PInvoke you can call native methods easily too. And then there's COM interop which pulls in ActiveX controls. That's all good and well, but it also means that lots of projects are not "pure" - they're polluted with Win32 crap and generally not portable.

      That's probably what gets to Gosling - that .NET is touted as a portable development platform but it isn't. Projects are infested with unpure, unsafe and platform-specific code. Microsoft can preach portability but they know that very few people will be disciplined enough to bother with it. Thus people are tied to Win32 even when they're using a allegedly portable runtime. Even the likes of Mono only gets around this by pulling in winelib.

    66. Re:Advertisement? by matfud · · Score: 1

      Javac is written in java. The java runtime is not normally written injava but thats due to a fundamental bootstrap problem on most hardware/OS.

      However some hardware can run java byte code directly and in those cases the VM (or at least the management parts such as memory managmenet) can be written in java.

    67. Re:Advertisement? by snorklewacker · · Score: 1

      Heck, that's probably more accurate than you know. Gosling created Oak. It was the Sun marketing machine (there's something I never thought I'd say) that turned it into the great edifice of hype that is Java.

      Aside from some slick verification techniques, there wasn't a damn thing innovative in Oak. Afterward, it picked up Hotspot from Self, but otherwise continued to be saddled with a VM that was, overall, pretty darn dumb. The folks at Bell Labs have a much better design with Limbo, but they were just too late to market.

      --
      I am no longer wasting my time with slashdot
    68. Re:Advertisement? by J.+T.+MacLeod · · Score: 1

      I realize this offends some people's sense of rights, but I'm not particularly inclined to defend somebody's "right" to use a firearm outside its intended purpose.

      I assume your judgement of those purposes exclude self-defense, then?

    69. Re:Advertisement? by Bodrius · · Score: 2, Insightful

      You are correct, I should say that C# fully support static inner classes.

      "Nested type" and "inner class" are, as far as I know, equivalent terms and the latter has been a common term used in both languages. However, this is the first time I know of someone who differentiates the two terms in practical use.

      What makes the implicit "this.Outer" the essential feature of an "inner class" in your terminology? I'm also curious as to why you consider it such an important feature.

      Once more this seems to be a matter of designer taste, but unlike anonymous inner classes, I do not see how this is particularly useful.

      I have seen 2 broad categories where the reference to the outer class is useful:
      - Inner classes for logic encapsulation in a complex class: passing the reference explicitly is no pain here, though.
      - Anonymous inner classes: most useful because the class declaration itself is overkill, doing the constructor plumbing even more so.

      I always saw the non-static inner class as a nice element of syntactic sugar that quickly gets out of control because it solves a non-problem if you ignore anonymous inner classes. In the process they complicate the language with special semantics and syntax for little need. Of course, once you bring this in to support anonymous inner classes it pays for itself. But the problem is that anonymous inner classes have almost always been a crufty solution themselves... 99% of the times I used them effectively they were functors and what I wanted was a method, not a full class.

      Ignoring anonymous inner classes for a sec:

      In Java, I do not have to pass an instance of my object to the inner class, so I get 'for free' the ability to write this (horrible) syntax:

      int x= this.ExtremelyLongNameBecauseWeKnowClassesGetLongN amesTheseDays.privateMember.foo();

      If the class has a non-trivial size (which for non-anonymous classes can easily happen) or the reader of the code is not familiar with the special semantics of Java's non-static inner classes, it's not immediately obvious where this reference came from.

      As a programmer I have to make an explicit decision to NOT keep an extra reference in my object. if I forget to put the static modifier, I get this dancing implicit this.Outer 'for free' too, when normally I just don't need and pollutes the contents of the object.

      In C#, you have to explicitly decide you'll need a reference to your outer type, and then use it:

      public MyFooInnerClass(MyBarOuterClass bar)
      { myBar = bar; } ...

      int x = this.myBar.privateMember.foo();

      The latter code seems to me more straightforward and readable, not depending on special semantics to know where myBar came from.

      Sure, I have to pass the 'outer' object to the constructor myself instead of letting the compiler do it, but in exchange I don't have to worry about a different instantiation or reference syntax. Anyone who has never seen this done before will not be too surprised this works, and will have little trouble understanding what is going on.

      In order to keep things clean in Java in my code I always made inner classes static until I actually NEEDED the outer reference. That is not different than explicitly passing the reference to the outer object in the constructor when you find you need to, only the latter is always an explicit decision on the programmer.

      That seems to me a good thing, but once more it's a matter of taste.

      --
      Freedom is the freedom to say 2+2=4, everything else follows...
    70. Re:Advertisement? by DavidHopwood · · Score: 1

      You're mistaken. It is possible to mark unmanaged code as "safe", and call it via PInvoke from managed code. Such code can easily violate the managed type system. There is no possibility of checking whether it actually is safe, other than manual code review. This means that any security bug in unmanaged code on a system can potentially compromise the managed code (just as JNI native methods can in the case of Java).

    71. Re:Advertisement? by m50d · · Score: 1

      Having code and data stored the same way was the great advance that made modern computers possible. It has to be doable so you can have self modifying code. This isn't needed most of the time, but there are times when it is, and it is worth it for those cases.

      --
      I am trolling
    72. Re:Advertisement? by MerlinTheWizard · · Score: 1

      SO when was the last time you needed it?

      And in the very rare cases where it's needed, there can be various gateways to transfer code in executable area. But under precise control. I hear people claiming what you claim all of the time, but I fail to see one valid reason. There is not any.

      I think you're kinda mistaken: this is probably what made modern consumer computing possible. Not "modern computing" in itself. By the way, have you ever heard of the Harvard architecture? Did you know it's not dead? And well, we can expand on it to have yet another new architecture.

      All in all, I'll correct your claim: mixing data and code is what made modern unstability and unsecurity possible.

    73. Re:Advertisement? by Jagasian · · Score: 1

      Fundamental hardware/OS bootstrap problem? Why can C compilers be written in C? Or Lisp compilers in Lisp, etc? They don't need special C-CPUs or Lisp-CPUs to accomplish that. All that is required is for somebody to write a real Java compiler that compiles to native code. The problem is that there has yet to be written a viable Java compiler.

    74. Re:Advertisement? by m50d · · Score: 1

      When coding in befunge it's pretty essential, so a few minutes ago, though that is only a bit of fun. I don't have any concrete examples, but I don't do any low level programming. But just look at how programming took off as soon as it was realised you could store code in the same way you store data. Yes I have heard of the Harvard architecture, and it reminds me of hurd - lots of papers and theoretical arguments saying why it should be a superior design, no working machines that show big improvements, and a lack of software.

      --
      I am trolling
    75. Re:Advertisement? by ndykman · · Score: 1

      My understanding is that for certain types, P/Invoke can be done safely, if the marshaller for P/Invoke can provide marshalling by value, thereby giving the unmanaged code access to a local copy of the native value type, which can be checked in the unmarshaller.

      For example, BSTRs contain the length of the string, and the marshaller can enforce that, and the strings are copied, so the native memory is never exposed.

      Since .Net has application domains, the unmanaged DLL is prevented from crossing into the managed memory space. There may be a hole here, but I haven't heard of it yet.

      For more complex P/Inovke operations, where you must pass a part of pinned memory to the unmanaged DLL, this is allowed, but it is marked as unsafe. Any time a DLL is given a pinned reference (a managed pointer), the code is unsafe, because you are giving access to the managed heap.

    76. Re:Advertisement? by aztracker1 · · Score: 1

      okay, you give me a gui kit that *DOESN'T* use an unmanaged native gui library.. beyond this, the newer versions of mono are targetting the use of gtk+ on linux.

      --
      Michael J. Ryan - tracker1.info
    77. Re:Advertisement? by matfud · · Score: 1

      C compilers can be written in C because C compiles to machine code which a computer can run. Java is compiled to bytecode which most hardware cannot run (apart from the processors I mentioned which can run bytecode directly). Therefore you have a bootstrap problem. How can you write a VM in java when the hardware cannot run bytecode.

      Statically compiling bytecode to machine code is, in general, a waste of time and effort. You loose many of the advantages of java such as its code verification mechanisms and, unless you are very clever, its dynamic loading/linking. You also loose its security model. After you have worked around all those problems you end up with the same optimisation issues languages like C suffer from. Static optimisation of code can only take you so far. Without profiling the code when it is running you cannot reliably tell which optimisations are necessary (you could perform this profiling by hand and modify your code but then you either loose portability or have to support lots of platform specific optimisad code. VM's have an advantage here in that they can (and do) analyse the code while it is running and do compile heavily used sections into machine code.

  3. Woah by pHatidic · · Score: 5, Funny

    CowboyNeal is defending Microsoft. Someone take a screengrab, Slashdot's been hacked!

  4. So you mean to tell me by Anonymous Coward · · Score: 5, Insightful

    So you mean to tell me that the father of Java won't be slightly bias?

    C'mon now. There is no vulnerability. Don't post this sort of crap. Its strictly knee-jerk material meant to bend a few people out of shape and start flames. .NET is great (for its target area)
    J2EE is great (for its target area)

    Both are secure, stable and reasonably fast if you are a GOOD programmer. ANYONE who does ANY C or C++ code that will be used in industry needs to ENSURE that they just take a few extra precautions and are aware of secure coding techniques in both languages. Its rather quite simple.

    To sum it up: nothing to see here folks.

    1. Re:So you mean to tell me by bitflip · · Score: 3, Interesting

      Actually, this is the kind of thing I like to see. It is definitely technology related; it's omission would be an error, IMO. If I'd seen this someplace else, and didn't see a discussion of it on /., I'd be concerned.

      The fact that the editors actually chose to point out the flaw in the argument (in MS' favor!!!), rather than adding to the sensationalism is a welcome and refreshing change.

    2. Re:So you mean to tell me by scovetta · · Score: 1

      I agree, the article was crap. Java can do essentially the same things by using JNI (Java Native Interface-- you call DLLs from Java). I like to bash Microsoft just as much as the next /.er, but the inclusion of the ability to execute unsafe code on .NET isn't a vulnerability, nor is it a mistake. It's a choice. If you write crappy code, don't blame the language.

      --
      Wer mit Ungeheuern kämpft, mag zusehn, dass er nicht dabei zum Ungeheuer wird. --Nietzsche
    3. Re:So you mean to tell me by Decaff · · Score: 1

      Wrong. Java is slow no matter who codes it.

      Nonsense. Java is translated to native code that is profiled and optimised at run-time.

    4. Re:So you mean to tell me by tsm_sf · · Score: 1

      That said optimization does not in fact speed things up is entirely outside the scope of this argument.

      --
      Literalism isn't a form of humor, it's you being irritating.
    5. Re:So you mean to tell me by Lord+Ender · · Score: 1

      Face the facts. The software you use and depend on will be written by BAD programmers who don't take "a few extra precautions." Wouldn't you prefer these bad programmers use languages which prevent them from making serious security mistakes in the products you use?

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    6. Re:So you mean to tell me by Brandybuck · · Score: 1

      Some languages prevent some classes of serious security mistakes. Other languages prevent other classes of serious security mistakes. But no language prevents all classes of serious security mistakes.

      --
      Don't blame me, I didn't vote for either of them!
    7. Re:So you mean to tell me by Tough+Love · · Score: 1

      That said optimization does not in fact speed things up is entirely outside the scope of this argument.

      You're full of bull. Have you benchmarked it? I have. I'm no Java lover but the speed of JIT compiled Java is phenomenal these days.

      --
      When all you have is a hammer, every problem starts to look like a thumb.
    8. Re:So you mean to tell me by TapeCutter · · Score: 1

      "profiled and optimised at run-time" - Think about what you just said. On a fast machine for a general app there may not be that much difference but it is doomed to be slower than the same app written in C. Java is much more sophisticated than the "P-Code" that was used in the 70's but the basic principle is the same. C is sometimes refered to as a geration 2.5 language. The vast majority of code that goes into Win/nix O/S's is C because in most cases it is a fast and flexible as assembly. As TFA points out there are a lot of points to attack C because security is not "built in". The O/S can do stuff like page wipes to overcome some of the worst "holes" but in practice you need to build the security in if you want to have any hope of portable security.

      Java is excellent for writing secure distributed apps fast, it trades speed to do this! Lets see a Java VM written in Java and see how fast it runs Java apps?

      Performance, Price, Quality - Pick any two, Java can fill the Price/Quality combination, C can fill the Performance/Quality combination. Get the two mixed up and it could turn ugly.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    9. Re:So you mean to tell me by Decaff · · Score: 1

      Java is much more sophisticated than the "P-Code" that was used in the 70's but the basic principle is the same.

      No it isn't. The P-Code for Java is the way that Java apps are distributed, but on almost all VMs it is translated to pure and optimised native code. This is nothing like the 70s situation at all.

      The vast majority of code that goes into Win/nix O/S's is C because in most cases it is a fast and flexible as assembly.

      That is not the reason at all! The vast majority of this code is in C for historical reasons. Truly high performance Java has only been around for a few years, so it would be a bit late to write Windows and Linux in it!

      Java is excellent for writing secure distributed apps fast, it trades speed to do this! Lets see a Java VM written in Java and see how fast it runs Java apps?

      There is no connection between security and speed. Matters of security (range checking and byte code validation) can usually be done once for most code then optimised away at run time.

      As for the Java VM in Java - IBM has already done this, and it works fine!

    10. Re:So you mean to tell me by Decaff · · Score: 1

      Yeah, whatever dude. Say what you like, but the bottom line is that all the Java apps I use are slow. This was true five years ago when people were prattling on about how Java wasn't slow, and it's still true today.

      Substitute 'C++' for 'Java' and this is exactly what I was hearing 20 years ago, when all 'true coders' used assembler.

    11. Re:So you mean to tell me by curious.corn · · Score: 1

      agreed, Eclispe is a humongous beast but does loads of neat stuff. It does eat gobs of ram but I'm also fiddling on 3.1m3 (ie not stable). Done properly Java is good (wanna see a really cool java app? lookup Acquisition, a P2P for Panther)

      --
      Mi domando chi à il mandante di tutte le cazzate che faccio - Altan
    12. Re:So you mean to tell me by Decaff · · Score: 1

      Didn't know that it could do that instantaneously.

      It doesn't, but why does this matter?

    13. Re:So you mean to tell me by Decaff · · Score: 1

      And it was just as true then. The truth is that it is much easier to write fast applications in C or assembly than in these "advanced" new languages that try to make programming into fingerpainting.

      I think that time is long past. To write fast code in assembler you would need to have detailed knowledge of the register set and pipelining of the specific processor you are using. The same goes for C - you have to tell the compiler all kinds of information about the processor - the type, word length etc., and even then the compiler can only make a good guess at how to optimise the code. The advantage of the Java Hotspot (as used in Sun's VMs) approach is that the compiler can produce native code for the specific processor you are using at the time you run the application, and then the machine code can be optimised by profiling as the application runs. In some cases, this can provide performance faster than C. As this kind of run-time optimisation gets better that boost in performance over the traditional approach should become routine.

    14. Re:So you mean to tell me by 0111+1110 · · Score: 1

      To write fast code in assembler you would need to have detailed knowledge of the register set and pipelining of the specific processor you are using.

      So since such detailed knowledge is virtually impossible when your end users are all running different CPUs, are you actually saying that assembly langauge is slow? Ahem. Do you mean to imply that Java is faster than assembler? That a good Java program can execute the same task faster than an assembly program? And I am not comparing code written by a good Java programmer and a bad assembly programmer. I guess that is what you are saying. I find that difficult to believe.

      I am not very familiar with Java. I have avoided it due to its reputation for inefficiency. But I have studied .NET a bit and found (IIRC) that it does not actually produce native code per se. That it is still essentially an interpreted language. I assume that converting from langauge terms to actual machine instructions still takes time in the meatspace world that we live in.

      If Java is fully compiled (to machine code) at runtime, then the only performance penalty (in theory) would be waiting for it to compile before you can run it which for large programs could be significant of course. If this is how it works it is kind of an interesting compromise. While the user may have to wait 10 minutes for the program to compile before he uses it, in some cases the increased machine code optimisations could be worth it if the program is run for long periods.

      My main complaint, which applies to any high level language without real inline assembly support is that I cannot roll my own functions efficiently. With c/c++ and inline assembly I can write functions that are more efficient for my particular task. I don't want to have to execute all kinds of instructions that I don't personally need but which seemed like a great idea for completeness and safety to the language writer. Particularly in a critical (according to the profiler) inner loop.

      --
      Quite an experience to live in fear, isn't it? That's what it is to be a slave.
    15. Re:So you mean to tell me by Decaff · · Score: 1

      So since such detailed knowledge is virtually impossible when your end users are all running different CPUs, are you actually saying that assembly langauge is slow?

      Of course it can be. It is very easy to code ineffeciently in assembler! On some processors, with multiple pipelines and complex register sets it can be very hard to write efficient assembler.

      Ahem. Do you mean to imply that Java is faster than assembler? That a good Java program can execute the same task faster than an assembly program? And I am not comparing code written by a good Java programmer and a bad assembly programmer. I guess that is what you are saying. I find that difficult to believe.

      Why? It can be very hard to produce effective fast assembler on today's complex processors. The Sun Java Hotspot system includes features such as automatic instruction scheduling, re-organising machine code instructions for improved performance on specific processors. This requires no effort from the programmer.

      I am not very familiar with Java. I have avoided it due to its reputation for inefficiency. But I have studied .NET a bit and found (IIRC) that it does not actually produce native code per se. That it is still essentially an interpreted language.

      No. .Net produces native code at runtime via a JIT (Just In Time) compiler. It is not interpreted.

      If Java is fully compiled (to machine code) at runtime, then the only performance penalty (in theory) would be waiting for it to compile before you can run it which for large programs could be significant of course. If this is how it works it is kind of an interesting compromise. While the user may have to wait 10 minutes for the program to compile before he uses it, in some cases the increased machine code optimisations could be worth it if the program is run for long periods.

      What happens with Hotspot is roughly like this (the exact process depends on switches than can be supplied to the VM): The program starts interpreted, then as it runs background processes determine the speed-critical sections and translate them to highly optimised machine code, including things such as loop unrolling and method inlining where appropriate. This way there is no wait for compilation when the application is started. This profiling and compiling is an on-going process, continously fine-tuning the performance of the application.

    16. Re:So you mean to tell me by Decaff · · Score: 1

      Try running WindowsXP on a 286. Then you shall see the light.

      How does this impossibility relate to the speed of Java?

    17. Re:So you mean to tell me by Lord+Ender · · Score: 1

      And security is not a "yes/no" question. Something that prevents programmers from making some classes of security flaws should be used even if it doesn't prevent all classes.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
  5. Don't disagree with Microsoft... by BlueCup · · Score: 4, Insightful

    I don't disagree with Microsofts position. Yes errors are possible, but it's a programming language, and not Microsofts responsibility. With a case like programming it is the programmers responsibility to release code without exploits... c and c++ are fast, they have many advantages other languages don't have (such as Java) if a programmer decides to take advantage of that, with a slight bump in risk, then I say more power to them.

    --
    WANNAWIKI Wannawiki WannaWiki WANNAWIKI!
    1. Re:Don't disagree with Microsoft... by Jagasian · · Score: 1

      Thank god you do not design programming languages. The truth is that runtime array bounds checking introduces very little performance penalties, yet has huge benefits in terms of safety, security, and reliability of software systems. Most security holes are due to buffer overflow attacks, something prevented by array bounds checking.

      There are many other things that Java or .NET do that introduce HUGE performance penalties, but array bounds checking is not one of them. Automatic garbage collection is probably the biggest performance penalty. Trying to claim that lacking certain runtime safety checks only causes a "slight bump in risk" is just plain incorrect. It is more like a huge increase in risk! Go read any security news site and pay attention to the cause of the security holes.

      Just assume for a second that every piece of Microsoft's code was written in a language with mandatory runtime array bounds checking. Nobody with modern computer hardware would notice any performance difference. However, all of those buffer overflow exploits could no longer be used to root a system, run arbitrary code, etc. Sure they could still be used for denial of service attacks because the runtime would raise an exception once it noticed an array was indexing outside of its boundaries... but then DoS vunerabilities are not nearly as bad as a remote hole.

      That is one reason why Microsoft is moving towards runtime safe languages. They want a more reliable software system. C and C++ are kept for backwards compatibility and popularity.

    2. Re:Don't disagree with Microsoft... by St.+Arbirix · · Score: 1

      Yes errors are possible, but it's a programming language, and not Microsofts responsibility. With a case like programming it is the programmers responsibility to release code without exploits...

      If Microsoft wrote a language that prevented errors and exploits...

      That's bordering on paradox.
      My head hurts.

      --
      Direct away from face when opening.
    3. Re:Don't disagree with Microsoft... by jbplou · · Score: 1

      Plus the fact that .Net C++ is barely used. I would wager that VB.Net and C# make up over 95% of development using the .Net platform.

    4. Re:Don't disagree with Microsoft... by matfud · · Score: 1

      Just a minor point:

      Automatic garbage collection, in normal situations where many small short lived objects are created on the heap, is often faster then OS level memory allocation. However the cost tends to come in lumps rather then be amortized over the entire runtime of the application.

    5. Re:Don't disagree with Microsoft... by Jagasian · · Score: 1

      Which is exactly the problem. Java, C, C++ and the like are typically used for interactive applications such as desktop applications, web servers, etc. It is not acceptable for a program to pause for an extended period of time so that it can mark and sweep garbage.

      Java and its die-hard fanboys are incapable of admitting the faults or drawbacks of the language and platform that is Java. They tend to cherry pick benchmarks showing Java outperform C or C++ applications. But these are definitely NOT real world benchmarks. They are contrived!

      In languages like C and C++ the programmer has more control over memory allocation and can therefore prevent objects from being allocated on the heap. In addition, the fact that these languages are typically statically compiled makes it possible for them to be optimized to move heap allocated objects to the stack. Java simply doesn't allow for this because it is typically compiled to bytecode for JVMs, which at best do some minimal optimizations during runtime.

      I remember seeing a 3D first person shooter video game written in Java. Funny that it needed so much RAM and such a fast CPU to put out graphics that an 8MB DOS PC with a 100mhz pentium could do with a comparable game written in C.

      Fact and fiction. Real applications and contrived benchmarks.

  6. What a surprise! by Anonymous Coward · · Score: 5, Insightful

    This could have just as easily read "Java Creator Disses Rival Product, Ignores Flaws in His Own."

    In Java, everything is an object! Oh...except for the basic types, you need to use object wrappers for those.

    1. Re:What a surprise! by Eric604 · · Score: 1
      In Java, everything is an object! Oh...except for the basic types, you need to use object wrappers for those

      If Java had operator overloading then object wrappers would actualy be nice to use and not a PITA.

    2. Re:What a surprise! by fimbulvetr · · Score: 1

      Oh great! Another java kludge!

    3. Re:What a surprise! by The+Snowman · · Score: 1

      Java 5 does, it's still doing the conversion in the generated bytecode though.

      Not quite. Java does not overload operators, it simply unboxes and reboxes your wrapper objects for you. It works similar to operator overloading to the user of the class, except it is about ten times less efficient.

      --
      24 beers in a case, 24 hours in a day. Coincidence? I think not!
    4. Re:What a surprise! by Atzanteol · · Score: 1

      That is the one thing that pisses me off the most about Java...

      No operator overloading! Oh, except for String. I guess we can make *an exception for one class*.

      --
      "Ignorance more frequently begets confidence than does knowledge"

      - Charles Darwin
    5. Re:What a surprise! by sonamchauhan · · Score: 1

      > No operator overloading!
      Hyuk! That's one of Gosling's regrets too.

      I was at Gosling's Q&A session where he made the many-big-trucks security-flaw remark. He may have made it when answering a couple of questions I asked him (but I don't recall that for sure.) I was disappointed at his answers - I wished the JVM had better multi-language support and think Parrot (the VM for the Perl6 effort) might just hold the future here.

      I was surprised at his remarks Gosling mentioned managed C++ (not legacy C++) as insecure. I think until there is a specific vulnerability reported he is just sniping at a rival. Though, I've heard that MS has removed (or made optional) pointer support from the latest managed C++ .NET version

      Anyway, about operator overloading: Someone else asked Gosling if he had any regrets about not including something in Java from the beginning.
      Gosling replied he wished he had put in operator overloading, which he said was a big deal for some folks - for instance, the scientific programming community.

    6. Re:What a surprise! by toriver · · Score: 1

      Oh great! Another java kludge!

      Er, C# (or rather the CLI) does the same autoboxing and -unboxing. So if it's a kludge, it's a common one not just in Java. This makes Smalltalk and Python the only pure OO languages, I guess.

  7. JNI by codepunk · · Score: 2, Informative

    I guess he forgot all about JNI. Now don't get me wrong I like java and would not even think about messing with .NOT but quit telling lies, java has the same exact hole.

    --


    Got Code?
    1. Re:JNI by patniemeyer · · Score: 4, Informative

      But JNI is not Java... It's an API. For that matter you might consider sockets and network connections to make Java unsafe because they could invoke unsafe applications.

      It is completely fair to point out that .NET allows you to choose safe vs. unsafe code... but it is a little different from the Java scenario in that this is unsafe code that is run through the VM. It's just an odd choice to make.

      Pat Niemeyer
      Author of Learning Java, O'Reilly & Associates

    2. Re:JNI by SnowZero · · Score: 1

      Any JNI application is essentially running in "unsafe mode" within the VM. The VM has no mechanism to protect itself from a JNI application it is running. I don't find that to be much different from running "unsafe" applications.

      With JNI, due to the complexity of the glue pushed on the native application, it's quite easy to mess up the VM. Java is not a bad language, but I find JNI to be one of the most unweildy native interfaces I've seen, even compared with those for functional languages.

    3. Re:JNI by spideyct · · Score: 2, Insightful

      It may be fair to point out, but it is kinda silly without any context.

      Java lets you write to the user's filesystem. Does that make it insecure? You could run a program to wipe out your hard drive!

      But Java allows for a "sandbox". So does .NET. And if your code runs in that .NET "sandbox" (for example, if it is running from a network resource), it won't let you run unsafe code.

    4. Re:JNI by YetAnotherAnonymousC · · Score: 1

      Huh? What exactly is the difference?

      JNI - native code run in the process that is the VM, full ability to muck with the memory space. ability, through overriding to call object VM methods with unexpected values .NET unmanaged code - native code run in the process that is the VM, full ability to muck with the memory space. ability, through overriding to call object VM methods with unexpected values

    5. Re:JNI by patniemeyer · · Score: 1

      I agree about JNI. But just to point out the difference again - JNI is an API, it's there for integration. It's not something that a normal programmer will ever use. It doesn't bring unsafe code into the VM, it provides a way to invoke it from the VM.

      What you're saying is true, but JNI is not really analogous to unsafe code in the VM. User code in the Java VM must first pass the verifier and any security policy. To me this puts the security decisions up a level... The code can't intentionally or unintentionally wreak havoc on the VM... it can only call an API or not call an API.

      Pat Niemeyer

    6. Re:JNI by insert_username_here · · Score: 1

      The VM has no mechanism to protect itself from a JNI application it is running.

      I'm not sure if this counts, but only trusted software is allowed to call VM code. In particular, no applet will ever be allowed to even load a DLL, let alone call its native methods.

      If software in a Java Web Start application tries to use JNI (e.g. OpenGL programs using JOGL), the platform will ask the user whether or not to allow it.

      From the Java API:
      http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ Runtime.html#loadLibrary(java.lang.String)

      First, if there is a security manager, its checkLink method is called with the libname as its argument. This may result in a security exception.

      I'm pretty sure .NET has the same thing. In either case, it ultimately comes down to trust.

      --
      -- Dramatisation - May Not Have Happened
    7. Re:JNI by cookd · · Score: 1

      To me this puts the security decisions up a level.

      No, it doesn't. User code in the .NET VM has to have permission from the VM to operate "unsafely". If the VM can't verify the code and the code doesn't have permission to operate unsafely, the VM will refuse to run it. The security decision stays in the same place.

      --
      Time flies like an arrow. Fruit flies like a banana.
  8. A truck, eh? by Faust7 · · Score: 5, Funny

    the company 'has left open a security hole large enough to drive many, many large trucks through.'"

    Like, say, a truck about the size of Sun's Java runtime environment.

  9. Java is a type-safe language at the VM level... by patniemeyer · · Score: 5, Insightful

    This is what really distinguishes Java from other languages. The Java verifier is a sort of theorum prover that examines the byte-code and can guarantee that it does not violate certain rules such as forging the type of a reference or under/over-flowing the stack. Because this is done at the verify stage it is still possible to compile the bytecode down to machine level instructions after that and run at full speed. This is why Java is both safe and fast.

    To support C/C++ semantics (ad-hoc pointers) you'd have to throw all that out the window and I assume that's what he's talking about.

    Pat Niemeyer,
    Author of Learning Java, O'Reilly & Associates and the BeanShell Java Scripting language.

    1. Re:Java is a type-safe language at the VM level... by YU+Nicks+NE+Way · · Score: 1

      You're wrong.

      The Microsoft CLR is also type-safe at the VM level. If you choose to use pointers in Managed C++, though, you lose any ability to assert heap access safety, and therefore must mark your code as unsafe, because you can perform pointer arithmetic.

    2. Re:Java is a type-safe language at the VM level... by d1v1d3byz3r0 · · Score: 1

      I was reading this comment thinking "hey, this sounds a lot like the way Java verifier was described in 'Learning Java'"... then I read your sig. Gotta love slashdot.

    3. Re:Java is a type-safe language at the VM level... by augustz · · Score: 1

      He is.

      In .NET you have a choice, managed or unmanager code.

      Of course, in Java you can also throw it out the window if you want to. Somehow that was missed in his writeup.

    4. Re:Java is a type-safe language at the VM level... by afidel · · Score: 1

      Sure it does, comiled Java code can be just as fast as C++ code and nearly as fast as C code. It all depends on how good the libraries are and how smart the compilers are. There is numeric code available for Java today that is just as fast as equivilant libraries for C++. Hell real numeric code is STILL written against FORTRAN libraries because the code is that good, that well optimized, and that well tested. Java GUI's suck, but numeric code and server code has long since been more than fast enough.

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    5. Re:Java is a type-safe language at the VM level... by I+judge+you · · Score: 2, Insightful
      It would be really nice if you KNEW WHAT THE FUCK YOU WERE TALKING ABOUT.

      Of course the article contains a few brief quotes from Gosling and fails to clarify whether he knew (and spoke of) the differences between safe managed code, unsafe managed code, and native code...

      However, it is clear that *you* do not know.

    6. Re:Java is a type-safe language at the VM level... by mattdm · · Score: 1

      How recently have you compared, and what were you testing? For many computational tasks, the differnce is negligible.

    7. Re:Java is a type-safe language at the VM level... by patniemeyer · · Score: 4, Informative

      Yes, actually, it does. Have you checked it recently? The only overhead that natively compiled Java code would have over comparable C++ is that it always does array bounds checking. Other than that you just have to ask yourself, what kind of optimization can a static compiler (C/C++) do that a dynamic, profiling runtime compiler (Java) can't do?

      Garbage collection in Java has been faster than free/malloc in C for years. This is in large part due to the fact that the runtime can recognize very short lived objects and put them on a special part of the heap.

      It's not necessary to use unsafe languages to get performance any more.

      Pat Niemeyer

    8. Re:Java is a type-safe language at the VM level... by Anonymous Coward · · Score: 1, Informative

      .NET has the same kind of mechanism. All IL is checked and verified. An assembly that contains embedded native x86 code cannot be verified and will only execute in an environment with full trust permitted. It is exactly the same as JNI.

    9. Re:Java is a type-safe language at the VM level... by mattdm · · Score: 1

      And I should add, I hate java and I wish it would die, so my opinion on its performance vs. C/C++ is unbiased. :)

    10. Re:Java is a type-safe language at the VM level... by patniemeyer · · Score: 1

      Would you like to be a little more specific in your criticism?

      Have you had to generate byte code or deal with the Java verifier? I have.

      Pat Niemeyer

    11. Re:Java is a type-safe language at the VM level... by patniemeyer · · Score: 1

      I wasn't trying to say anything in particular about .NET... I know that it has a similar VM. I was just trying to explain what the type safety issue means and what Gosling is talking about WRT Java. I probably could have phrased it differently.

      Pat Niemeyer

    12. Re:Java is a type-safe language at the VM level... by Anonymous+Brave+Guy · · Score: 3, Interesting
      Sure it does, comiled Java code can be just as fast as C++ code and nearly as fast as C code.

      You imply that compiled C code is faster than compiled C++ code, which IME is rarely the case these days. In particular, optimisations performed by C++ compilers have almost caught up with their C brethren. With almost perfect zero-overhead implementations of all the major C++-only language features now in common use and the added performance boost from things like inlined code in templates, the balance often tips significantly in C++'s favour now.

      There is numeric code available for Java today that is just as fast as equivilant libraries for C++.

      Can you give some examples of high quality numerical libraries written in pure Java (i.e., without JNI)?

      Disclaimer: I'm a professional C++ developer, and I write high performance maths libraries for a living.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    13. Re:Java is a type-safe language at the VM level... by patniemeyer · · Score: 1

      I understand what you're saying WRT managed vs. unsafe code. But I don't think it's really analogous to JNI. JNI is an API. You might, for that matter, consider sockets and network connections to make Java unsafe because they could invoke unsafe code.

      Everything that runs in the Java VM must pass the verifier and any security policy first. The checks are then at a much higher level: can I use this API? Can I call this method?

      No one uses JNI for normal programming... it's an integration thing.

      Pat Niemeyer

    14. Re:Java is a type-safe language at the VM level... by Rakshasa+Taisab · · Score: 1

      No, GC has never been, and never will be faster than free/malloc. It does gain some advantages since it can move around objects in memory as it does its collection, thus improving cache hits to some extent. Free/malloc on the other hand are some very simple algorithms, cheap and with good general efficiency.

      You can argue that Java's GC does give advantages in avoiding cache hits, but saying that it is faster than free/malloc is just plain wrong. It isn't and never will be.

      --
      - These characters were randomly selected.
    15. Re:Java is a type-safe language at the VM level... by vidarh · · Score: 1
      I keep hearing claims that Java is now so damn fast, however the only thing that matters to me is that on all machines where I executve Java applet or Java applications they slow my machines to a crawl and have response times that would make a 286 blush.

      I have no particular reason for mistrusting all the people that claim their Java code runs fast, but my experience is the opposite: I've never experienced running a Java application without being horrified at the low performance, particularly in terms of UI responsiveness, to the point where I now actively avoid applications written in Java.

      Maybe it's just the quality of Java developers :-)

    16. Re:Java is a type-safe language at the VM level... by d1v1d3byz3r0 · · Score: 1

      Actually, I wasn't criticizing. I read and enjoyed your book. I was merely commenting on the coincidence that your explanation reminded me of your book before I even knew who you were. I'm still on the fence about Java. I feel it's gotten over-complicated with all the vendors adding new bells-and-whistles all the time. I shouldn't complain, I work for IBM; but I find myself more comfortable in Lisp and C when I'm coding my own stuff.

    17. Re:Java is a type-safe language at the VM level... by hobuddy · · Score: 4, Informative

      You're quite right that Java's speed is excellent these days (for non-GUI code, at least). I've spent a lot of time recently working with a large system that was first implemented in Java (by highly skilled developers) and then ported to C++ (by greenhorns). The C++ port is only 50-100% faster, which isn't worth the price in developer time that's been wasted on memory leaks and other forms of memory corruption that were never a factor in Java. Besides that, supporting multiple platforms with the C++ version is the #definition of pain.

      However, the C++ version uses only about 1/4 or 1/5 as much memory as the Java version, and starts up far more quickly. If a *desktop* application needs to be deployed on older machines, or if the application is so memory-intensive it taxes the limits of today's server hardware, Java still falls flat.

      --
      Erlang.org: wow
    18. Re:Java is a type-safe language at the VM level... by afidel · · Score: 2, Interesting

      You should be able to find plenty of starting points here.

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    19. Re:Java is a type-safe language at the VM level... by patniemeyer · · Score: 1

      Thanks and as someone else pointed out I was replying to the troll... I should know better. Don't know why I did that.

      Pat Niemeyer

    20. Re:Java is a type-safe language at the VM level... by YU+Nicks+NE+Way · · Score: 1

      The point is that you're wrong about type safety. Type inference is a purely syntactic operation, which is why languages like ML don't need explicit typing. The problem with unsafe IL code isn't type inference, but bounds checking.

    21. Re:Java is a type-safe language at the VM level... by Xyrus · · Score: 1

      "It's not necessary to use unsafe languages to get performance any more."

      And that's why all games are written in java right? And all those big number-crunching science apps are in java as well?

      Don't get me wrong, I like Java. It does have it's place. But when I'm looking for critcal performance, Java is the last place I look.

      This goes double if I need to access hardware.

      Java is getting better, but it's still not there yet.

      ~X~

      --
      ~X~
    22. Re:Java is a type-safe language at the VM level... by jeif1k · · Score: 1

      You may generate Java byte code all you want; that doesn't qualify you to comment on other languages, including what aspects of Java are unusual or unique. And, in fact, you got it wrong.

      Lots of languages guarantee runtime safety using all sorts of mechanisms.

    23. Re:Java is a type-safe language at the VM level... by rjh · · Score: 1
      What kind of optimization can a static compiler do that a dynamic, profiling runtime compiler can't do?
      I'll grant you C, but C++ I can't. C++'s type mechanism stomps all over Java, to the point where I can exploit the type mechanism to do things like programmatically unroll loops, shift computation from run-time to compile-time, etc.

      Admittedly, most of these techniques involve template metaprogramming, which is one of the more black-art parts of C++. However, Java simply can't compete with C++ in this realm; Java doesn't have the tools.

      At the present time, Java's "generics" are weak tea compared to the strong generics of C++ (and the even stronger ones of Ada95). As soon as I can use Java's generics mechanism to do compile-time assertions, then I'll think Java can compete with C++ in this realm.

      (Note: for all I know, the next release of Java will be able to do this. I don't keep abreast of cutting-edge Java developments, only what's in the most recent releases.)
    24. Re:Java is a type-safe language at the VM level... by cookd · · Score: 4, Interesting

      Free and malloc are NOT very simple algorithms. They have arbitrary complexity. malloc ranges from the normal case of about 100 instructions (when a block of memory of the correct size is available) to unbounded (when data must be paged out to make enough room for the new allocation and the data for tracking it). Free can also be arbitrarily slow, as releasing one block may trigger a coalesce operation.

      So you have to measure time per malloc and time per free, then total them up and compare it to GC's time per allocation and time spent in GC. In some cases, one will be significantly larger than the other, but in most nontrivial programs, using modern malloc/free and modern GC, it comes out pretty close to even.

      Some argue that the "pause" from GC is a problem. Maybe. Except that as mentioned before, malloc can also "pause" for arbitrarily long times. And a lot of work has been done on "concurrent" GC that doesn't pause. If you can afford paging in from disk (swap file), you can also afford GC's "pause".

      Finally, when you write a big program, you spend incredible effort in your program tracking memory. That takes cycles. "If x then save a copy cause we'll have to free it later, etc."

      The bottom line is that there are some cases where GC still won't work, but those cases are getting smaller and smaller. For most cases, the argument that GC is slow or inefficient just isn't true. Go do some real benchmarks, or go study up on the already published benchmarks. GC is pretty efficient, and malloc/free has no significant speed advantage anymore.

      --
      Time flies like an arrow. Fruit flies like a banana.
    25. Re:Java is a type-safe language at the VM level... by cecom · · Score: 2, Insightful

      Yes, actually, it does. Have you checked it recently? The only overhead that natively compiled Java code would have over comparable C++ is that it always does array bounds checking. Other than that you just have to ask yourself, what kind of optimization can a static compiler (C/C++) do that a dynamic, profiling runtime compiler (Java) can't do?

      Java suffers a penalty of about 500% on the average because of pointer chasing. There is no compiler or optimization that exist today that can optimize that, but Java as a language requires it, while C/C++ does not. (Think about how an array of complex numbers can be implemented in either languages, for example)

      Static versus dynamic compilation has little to do with this, since both Java and C/C++ can be compiled statically or dynamically (although Java tends to benefit more from dynamic compilation).

    26. Re:Java is a type-safe language at the VM level... by patniemeyer · · Score: 1

      Gosling's point (which he made specifically referring to an "image" type for example) is about type safety at the bytecode level. All of Java's security starts with the proposition that you can't forge types. Bounds checking and not wiping out the stack are just as important. But the type safe VM is what allows Java to impose security policies on code and even run untrusted code in a sandbox safely.

      I assume the same applies to managed code in .NET.

      Pat Niemeyer

    27. Re:Java is a type-safe language at the VM level... by YetAnotherAnonymousC · · Score: 2, Insightful

      That's not all. Even natively compiled Java code has additional overhead in casting operations and in object instantiation.

    28. Re:Java is a type-safe language at the VM level... by swdunlop · · Score: 1

      Not so much missed, as deliberately omitted. Gosling has made this sort of statement in the past without discussing the distinctions between managed code, unmanaged code, and contrasting it with Java's sandbox and type verification features. The article author has made a very obvious omission in not mentioning the finer points of the issue, and simply stating Gosling's assertation.

      It's a marketing fluff piece, in favor of Sun. It's on ZDNet, which is about as well known for hard hitting journalism as.. What? Good Morning America?

    29. Re:Java is a type-safe language at the VM level... by cecom · · Score: 1

      Some argue that the "pause" from GC is a problem. Maybe. Except that as mentioned before, malloc can also "pause" for arbitrarily long times. And a lot of work has been done on "concurrent" GC that doesn't pause. If you can afford paging in from disk (swap file), you can also afford GC's "pause".

      I basically agree with you, but I must point out that a GC cycle potentially touches the entire heap and can cause massive paging. A good malloc() and free() implementation never does that. Additionally, GC operates well only when no more than 50% of the available heap is used. So I guess it is safe to say that when physical memory is tight, malloc() and free() have the advantage.

    30. Re:Java is a type-safe language at the VM level... by 16K+Ram+Pack · · Score: 1
      In addition, code performance matters less and less as machines get faster, memory goes up etc.

      If you are involved in the 90% of the software industry that moves data around, the code bit of processing is taking a smaller and smaller slice of time compared to disk or network IO.

      Concentrating on using safer, more productive languages and making code easier to understand is the direction we should all be aiming for.

    31. Re:Java is a type-safe language at the VM level... by cookd · · Score: 1

      Safer to say "some kinds of GC operate well only when no more than 50%..." There are lots of different Garbage Collectors, with lots of different characteristics. Some have that problem, others don't.

      --
      Time flies like an arrow. Fruit flies like a banana.
    32. Re:Java is a type-safe language at the VM level... by 16K+Ram+Pack · · Score: 2, Insightful
      Horses for courses.

      I run projects developing business database-based software. Stuff like java and .net suits me fine. Do I need to access hardware beyond what those languages give me? Nope. Ever likely to? Probably not, but there are ways to interface.

      How critical is performance? It's as important as it needs to be. If a daily process has a 12 hour window to run in and takes 1 hour instead of 30 minutes, do I care? It's fast enough.

    33. Re:Java is a type-safe language at the VM level... by clem.dickey · · Score: 2, Insightful

      It's been about eight years now that Java has been touted (not necessarily by present company) as faster than C. Do I really need to check again? I did check yesterday, and Java took about one minute to bring up an application login menu. That is slower than any C program, with the possible exception of Lotus Notes. So there's speed and then there's speed. Initialization is time is still not too good in Java. Maybe Sun (and IBM, from whence my Java comes) could take a few pointers from Microsoft (Word) and Apple (OS/X boot). Keep "hot Java environments" ready for use, starting at boot time. Figure out how to run in less than ~0.5Gb of RAM. Mac OS X has seen memory requirements steadily *shrink* since initial release. That is unusual, if perhaps unprecedented. Amit Singh describes some of Apple's tricks at kernelthread.org. I'd like to see Java do that.

      Still, some of us C/C++ coders get pretty tired of the assumption that all technology benefits accrue to Java (or will Real Soon Now - the 4GHz and 5GHz Pentiums should really help) while none accrue to C/C++.

      Oh, and can I mention that heap? Java's insistence on the garbage collection model prevents the determinstic destruction of objects, upon which some programming idioms rely ("resource allocaation is initialization" is one). I don't mind that a heap exists for programmers who wish to use it, but It Would Be Nice If Java also permitted automatic allocation (and, more importantly, deallocation) in the C++ model. The RTE would have to deal with stale references to automatic objects, but Java could take care of that by raising an exception when auto destruction would create a stale reference.

    34. Re:Java is a type-safe language at the VM level... by bnenning · · Score: 1

      on all machines where I executve Java applet or Java applications they slow my machines to a crawl

      That's just because Sun has yet to produce a UI library that doesn't suck. For non-UI tasks Java's performance has been more than acceptable for quite a while. And there are Mac OS X apps that use Java as an interface to the Cocoa API that are indistinguishable from non-Java apps in appearance and performance.

      --
      How to solve most of our problems: 1.Lots of nuclear plants. 2.Cure aging.
    35. Re:Java is a type-safe language at the VM level... by pyrrho · · Score: 1

      I tend to think that Java is too much in the OO religion... it's my bias, I know, and I'm not maligning Java wontonly.

      But I agree with you that metaprogramming is something that is proving to be an amazing new addition to programming idioms.

      In the end the advantage of C++ is that it has evolved to allow new idioms without ever forcing them and closing off access to the machine.

      No doubt, closing off that access may be a good idea in some cases, but that "some" can never be all. So I'll wait until Netcraft tells me C++ is dead and then I still won't believe it.

      --

      -pyrrho

    36. Re:Java is a type-safe language at the VM level... by GreyWizard · · Score: 1

      Concentrating on using safer, more productive languages and making code easier to understand is the direction we should all be aiming for.

      Safer and more productive? You must be advocating C++ over Java. Well written C++ code uses the standard template library. Pointers and manual memory allocation are used rarely if at all, so there is no practical risk of memory leaks or buffer overflow. Constructors and destructors can be used for resource allocation so even things like file handles and database transactions are managed automatically. That's safety Java can't match.

      Meanwhile what Java means by safety is a startling lack of powerful features. Tasks that are easy to handle with a few lines of C++ require mind numbing verbosity in Java. This makes Java more "productive" only if one measures raw lines of code rather than accomplished objectives.

      --
      Not all those who wander are lost.
    37. Re:Java is a type-safe language at the VM level... by Anonymous+Brave+Guy · · Score: 1

      OK, there are lots of links there, and assuming they are what they say they are, they demonstrate that Java has some fairly routine numerical libraries available for it. That doesn't much help with your claims about performance, though. Do any of those libraries you mentioned provide some sort of timing information that can be compared to C++ code performing equivalent operations?

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    38. Re:Java is a type-safe language at the VM level... by lsdino · · Score: 1

      Along with many GCs there are also many unmanaged memory allocators. I think it's pretty likely that in the choice between malloc/free & GC that GC wins lots of times. Allocation is nearly free in many GCs which goes a long way towards beating malloc.

      But if you're coding in C/C++ instead of using malloc/free you can roll your own memory allocators that are highly specialized to the task at hand (and C++ even provides operator new to overload for this task). You get memory from the OS (or large chunks from malloc/free) and then hand it out as appropriate. You can then optimize for address space (keeping little unused address space in the process because you need >2-3gigs on a 32-bit machine), you can optimize for free (condensing multiple allocations into a single free), you can optimize for large number of fixed size large objects (allocating from a large slab of memory, freeing onto a linked list), optimize for locality (if you have a tree or some other data structure) or any other number of reasons.

      Like all engineering decisions you need to evaluate the requirements of what you're building and determine which one's better for you. Personally I think GC kicks ass for almost everything. It's really such a productivity boost to not have to worry about freeing memory. And if you're not rolling your own allocators then there's a good chance that it will beat malloc/free.

    39. Re:Java is a type-safe language at the VM level... by 16K+Ram+Pack · · Score: 1

      The STL still allows memory leaks to occur, does it not?

    40. Re:Java is a type-safe language at the VM level... by YetAnotherAnonymousC · · Score: 1

      No one uses JNI for normal programming... it's an integration thing.
      Bullshit. There are plenty of "normal" programs out there that may be written primarily in Java for many of its strengths but don't care about cross-platform coding. These programs may need to do OS-specific stuff - say make Win32 APIs, send IOCTLs, etc. Purely new native code, and executed using JNI.

    41. Re:Java is a type-safe language at the VM level... by WolfWithoutAClause · · Score: 1
      No, GC has never been, and never will be faster than free/malloc.

      That's not true. It certainly can be faster. In fact in a lot of cases the GC never runs, because the program ends before that point; and then using GC can indeed offer better performance- the shortest C equivalent usually involves hand releasing memory, and that can mean it ends up freeing memory that strictly doesn't need to be. It does depend on the programmer though.

      In addition, memory allocation in some languages, like Java, is extraordinarily cheap, just bumping a pointer on by a length, and free can almost literally take no time at all (the VM can pick out the objects it wants to keep which may be very few, and the rest just get written over by the malloc.)

      GCing in, say, Java has had the bejeezus optimised out of it, they are stunningly quick operations, and built into the language because they are so often called; more so than malloc and free, which is only a library.

      If you think about it, that may well mean that the current Java implementation is faster than a C implementation you may happen to be using.

      There can also be issues with C- it is possible for the heap to fragment, Java can defragment, C can't. I have worked on systems where fragmentation actually occured; and it crashes the system. In a fairly real sense Java is very much faster.

      The percentage difference between malloc/free and GC is now small enough that the differences between individual programmer skills are bigger than the performance hit of GC- in other words, a lot of programmers out there are worse at doing memory handling than a well written GC.

      --

      -WolfWithoutAClause

      "Gravity is only a theory, not a fact!"
    42. Re:Java is a type-safe language at the VM level... by Anonymous+Brave+Guy · · Score: 1
      Inlined code is not always a win. There is a point where decreased branch misprediction penalties are overwhelmed by shitty cache utilization.

      Sure, it depends on context. I was thinking of simple things like a sort function. In C++, using std::sort, any ordering function you pass through can potentially be considered by the compiler, inlined directly into the sorting loop, and then fully optimised as if it had been written there all the time. You just can't do that with the extra level of indirection required by function pointers, or whatever the equivalent is in your language of choice. Typically an ordering function will be quite short, and as such an inlining operation like this will save space as well as reducing branching, making it a win-win option on any architecture you like.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    43. Re:Java is a type-safe language at the VM level... by cookd · · Score: 1

      Yay!! I've found intelligent life on Slashdot!

      --
      Time flies like an arrow. Fruit flies like a banana.
    44. Re:Java is a type-safe language at the VM level... by Woodblock · · Score: 1

      You don't get it. It isn't worth saving money on the systems if it takes a team of developers a year to make something twice as fast or use a fifth of the memory. For many applications, getting twice as many transactions would cost much less than what you would have to pay a single developer for a year. And, the computer comes with a support contract.

    45. Re:Java is a type-safe language at the VM level... by bluGill · · Score: 1

      That would all be true, except you lose RAII in order to gain GC. RAII manages more than just memory as if it was memory. With RAII there is no need to remember to close files, end transactions, and a lot of other overheard because it is done automatically when you get rid of the memory. GC doesn't work well in that model because there is no deterministic way to be sure that something is done before you go to the next step that requires the previous one to finish. (in fact every GC I've heard of doesn't allow this at all, but in theory you could call destructors in the GC so I won't call it an absolute limitation, but it still is a loss)

    46. Re:Java is a type-safe language at the VM level... by swillden · · Score: 1

      That would all be true, except you lose RAII in order to gain GC. RAII manages more than just memory as if it was memory.

      Mod parent up, this is a very good point.

      I'm a big fan of GC, but I'm also a big fan of RAII. For anyone who's wondering what that is, it's "Resource Acquisition Is Initialization", and it's an approach to managing resources in an object-oriented, block-scoped language. The basic idea is that all resource allocation is done, effectively, in object constructors, and every resource (memory, file handles, graphics contexts, whatever) is owned by the object that allocated it, and is therefore freed when that object goes away.

      If you use it religously, RAII makes management of all sorts of resources, including memory, a nearly zero-effort activity, just as GC does for memory.

      I've thought that it should be possible to produce an extensible GC which allows you to register additional resource pools, associate resources with objects and then allow the GC to manage the non-memory resources as part of its memory management. I haven't seen anyone take a serious stab at building something like that, though, and I don't have the time.

      every GC I've heard of doesn't allow this at all, but in theory you could call destructors in the GC so I won't call it an absolute limitation, but it still is a loss

      Actually, Java has this destructor-like concept, it's called a "finalizer". Unfortunately, there's no way to know when, or if, a finalizer will get called so you can't really do anything useful with them.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    47. Re:Java is a type-safe language at the VM level... by xtremee · · Score: 1

      This is why Java is both safe and fast.

      Safe... maybe, but since when Java is FAST?

    48. Re:Java is a type-safe language at the VM level... by StarsAreAlsoFire · · Score: 2, Interesting

      I call bullshit.

      If 'greenhorn' C++ developers can make an app that is even ONE PERCENT faster, then the Java Developers WERE NOT 'highly skilled'. Period. But TWICE as fast? As in, C++ takes 1/2 the time to execute 'x' as the Java version? No way. Not even if we are talking linear algebra code*.

      An experienced Java programmer knows you have to memory manage large apps. Yes, Java will *always* use more memory than an equally well written C++ app; however, unless you are working *exclusively* with *huge* arrays, java will be damn near as fast, and often faster than equivilent C++ code. Hell, if those arrays have to be collected in C++, Java will be faster. *UNLESS* you optimize the living crap out of your C++ code and ignore optimizations on your Java code.

      I have *plenty* of issues with Java (for instance, who the f*ck decided on a 64MB default max memory space for the JVM?). Speed has always been one of my Java PLUS points.

      * A quote for the lazy:
      "For example, IBM Watson's Ninja project showed that Java can indeed perform BLAS matrix computations up to 90% as fast as optimized Fortran."

    49. Re:Java is a type-safe language at the VM level... by synx · · Score: 1

      Aspects seem like a clean way to handle this.

      I'm not an expert in AspectJ (yet...) so I can't say for certainty, but it seems like this might work out very nicely.

    50. Re:Java is a type-safe language at the VM level... by synx · · Score: 1

      I'm in a similar boat as you, and one major productivity loss is crashes due to lame things like segvs. When you are trying to support a production environment where developer time and long term batch-speed is the bigger problem, a system like Java works out great.

      At work we are just about to make the switch from C++ to Java. It helps tons that our C++ platform is really crufty and sucky - Oracle accessors which use %-style specification strings and a lame-ass C++ MFC-looking object library. The switch is a no-brainer, plus the refactoring support that Eclipse and Intellij sports really make the whole deal even better.

      Modern business software development is about agility (or at least it should be) and minimising development time. A $7000 Mac workstatin with 8 gb ram is cheap compared to the average software developer salary.

    51. Re:Java is a type-safe language at the VM level... by brunos · · Score: 1

      It's true that there is no decent java numerical library. However if you implement your own ruotines java isn't that bad: it is maybe 50% slower than carefully optimized Intel Compiler code with SSE3 etc. But you have the great advantage that you do not have to play around with optimizer flags. This is especially good if you develop on one architecture and run on another (quite common in physics). Another problem with C/C++/FORTRAN (that often get mixed together in projects) is that you end up with a program that for unknown reasons will compile only on one machine (we have a program that compiles only on our SGI onyx2 server only from a particular o2 terminal ...). I see that a lot of future work, especially "grid" software is trying to take advantage of the ease of use and reusability of java code. I have not played around with generics yet, but templates are really handy in C++ numerical libraries ... Hope someone comes up with a nice java numerics library.

    52. Re:Java is a type-safe language at the VM level... by Jussi+K.+Kojootti · · Score: 1
      No one uses JNI for normal programming...

      How is that any better than saying 'No one uses unsafe code in .NET'?

    53. Re:Java is a type-safe language at the VM level... by toriver · · Score: 1
      While Java will dynamically grow its heap size, it will never, ever shrink it.
      1. Yes, it will. What you wrote was true once upon a time, but hasn't been true for years: The heap can shrink down to start heap size.
      2. Your so-called demo example makes the erroneous assumption that System.gc() actually forces garbage collection. Anyone who actually reads the API docs knows that it doesn't unless you turn off async GC totally.
    54. Re:Java is a type-safe language at the VM level... by vidarh · · Score: 1

      Apparently it's not just Sun, seeing as the apps I've tried include things like Eclipse etc. that doesn't use Sun's UI libraries.

    55. Re:Java is a type-safe language at the VM level... by GreyWizard · · Score: 1

      In principle, yes. In practice, no. As an example, consider the task of concatenating two strings. In C this would require malloc() most of the time, so a call to free() would be needed somewhere and could be forgotten. In C++ this requires new and delete which are equivalent, but the STL string class handles that automatically, so there's nothing to forget.

      --
      Not all those who wander are lost.
    56. Re:Java is a type-safe language at the VM level... by toriver · · Score: 1

      The total heap size will count up, but it will never, ever count down. Try it. Load up that program and leave it running overnight and throw open your process manager to see if the heap size has shrunk.

      It won't.


      My bad, I now see you need to add the command-line flag -maxf to the java executable to enable it - by default, it will not shrink it.

      E.g. with -maxf0.6 it will release heap memory back to the OS if 60% or more of the heap is free, but will not go below starting heap value (-Xms parameter value)

      Interesting googled link that shows the parameters have been in the VM from JRE 1.2 (but IIRC the Windows VM got them in 1.3.x).

    57. Re:Java is a type-safe language at the VM level... by StarsAreAlsoFire · · Score: 1

      It isn't strange at all. Just good code practice.

      I did not say bypass garbage collection. So far as I know, that would be completely impossible. Could be wrong I suppose.

      In large, memory intensive apps you need to HELP the GC -- :: Don't create objects until you need them. This is a 'duh' a surprising number of people miss. :: Pause long enough for the GC to do its stuff. You won't run into this problem until you are doing some seriously heavy memory use. It is possible that your app can run in the default memory space, but the JVM isn't collecting disposed objects fast enough. If you are pegging the CPU and creating and discarding millions of objects, this may become a thorn in your side. :: Ensure that you don't maintain *ANY* references to objects you don't need any more, so that the GC doesn't have to 'think' to hard about 'is this okay to toss?' (think unlinked structures, simple case 3 or four objects that aren't visible to any other part of the code, but reference each other extensively).

      There are other ways, tips and tricks etc. Using stringbuffers instead of strings for *any* string that might be used more than once, for example. 'Don't create it if you don't need it' can be harder than it sounds; you need to know what is happening in the background.

    58. Re:Java is a type-safe language at the VM level... by 0111+1110 · · Score: 1

      In addition, code performance matters less and less as machines get faster, memory goes up etc.

      But what about all these posts that say Java is as fast as C/C++ in all problem domains? If true, then fine (although I find it difficult to believe). If not then Java will soon be a dead language.

      Also, maybe you haven't been keeping up with the news (working can do that to you), but the free ride is over. Software is now going to be more responsible for performance increases than hardware. That is the future. Efficient programing and real concurrency are the future. "cycles are cheap" and "just wait a year and it will be fast" will be laughed at in a decade. It is incredibly naive. Sure not all programs need to be fast, but some do. It is about time that programmers began to take some responsibility for the speed of their code again. I for one am hedging my bets by getting more into assembly again. Some kind of concurrent (built in from the ground up) low level (like highly macroed assembly) version of C or ADA is what I see as the future. If it is to be a managed language, fine, but that had better not impact on performance or you will simply lose out to your competitors even if it takes them longer to get their product out the door. I say again, the free ride is over. There is only so much you can get done in x seconds.

      --
      Quite an experience to live in fear, isn't it? That's what it is to be a slave.
    59. Re:Java is a type-safe language at the VM level... by cookd · · Score: 1

      Yeah, it is a loss. RAII still works since all major implementations allow for a finalizer to run at GC time, but since GC isn't deterministic, the finalizer might not be run when you expect.

      But this is kind-of looking a gift horse in the mouth. GC eliminated the need to explicitly dispose, so now you're complaining that you don't get the benefits of explicitly disposing. At least for heap-based allocations.

      For stack-based variables, this is still a loss, but at least it is easy to fix. C# has a "using" construct that calls the Dispose() method when you exit the using block. If that doesn't work, a try-finally block will. But yeah, it would be nice if there were a way to declare automatic (in the C sense) objects in GC languages.

      --
      Time flies like an arrow. Fruit flies like a banana.
    60. Re:Java is a type-safe language at the VM level... by Random+Hacker · · Score: 1

      I would especially be interested in seeing a high quality, fast numerical library for complex arithmetic written entirely in Java. Both C++ and Java let you define a Complex type (C++ lets you get nicer syntactic sugar, but that's beside the point). The real difference is that C++ lets objects live on the stack, or as elements inside an array, whereas in Java *all* objects live on the heap. If in C++ I say

      std::vector< Complex<double> > foo(10000);

      I get a block of storage with 160,0000 bytes containing a consecutive sequence of 10,000 pairs of doubles representing complex numbers (just as I would get in Fortran). If in Java I say:

      Complex[] foo = new Complex[10000];

      I get an array of 10,000 references (i.e., pointers) to Complex objects, each of which must be individually allocated on the heap:

      for (int i = 0; i < 10000; ++i)
      {
      foo[i] = new Complex(0d, 0d);
      }

      Now which language do you think is going to do a faster complex Fourier transform?

    61. Re:Java is a type-safe language at the VM level... by hackrobat · · Score: 1

      The only overhead that natively compiled Java code would have over comparable C++ is that it always does array bounds checking.

      Have you seen the enhancements to Java 5? There is no bounds checking if you use the new for-each loop (of course).

    62. Re:Java is a type-safe language at the VM level... by cnettel · · Score: 1

      Is the compiler/VM smart enough to unwind it properly for an array, compared to other collections? foreach in .NET doesn't bound-check in the same way as other accesses, but it still manages to be slightly slower than a common for loop for an ArrayList or similar. I haven't benchmarked the Java 5 implementation. Have you?

    63. Re:Java is a type-safe language at the VM level... by Mr2001 · · Score: 1

      But yeah, it would be nice if there were a way to declare automatic (in the C sense) objects in GC languages.

      The next version of C++/CLI--the replacement for ugly old Managed C++ in .NET--is supposed to do this (actually, this version was supposed to, but I guess the feature slipped). It'll still be based on finalizers and IDisposable, but the syntax should be the same as automatic destruction.

      --
      Visual IRC: Fast. Powerful. Free.
    64. Re:Java is a type-safe language at the VM level... by kraut · · Score: 1

      >Garbage collection in Java has been faster than free/malloc in C for years. This is in large part due to the fact that the runtime can recognize very short lived objects and put them on a special part of the heap.

      Of course, in C and C++, programmers put short-lived objects on the stack. No matter how special the heap in Java, it's not going to be faster than incrementing / decrementing the stack pointer ;)

      --
      no taxation without representation!
  10. Unsafe code is called -- duh, Unsafe by Saint+Stephen · · Score: 2, Interesting

    I hate to defend MS on this, but you have to have a certain type of permission to call unsafe code. As soon as you call anything such as that, the whole program becomes immediately unverifiable.

  11. What about before? by RizwanK · · Score: 1

    What were in the command language routines BEFORE C/C++?

  12. Why is this here? by zoloto · · Score: 1

    I did Read the Fine Article and didn't find anything in it worth mentioning. Nothing specific, or even elluded to. What a waste.

    1. Re:Why is this here? by value_added · · Score: 1
      Nothing specific, or even elluded to.

      Err, it seems the correct spelling of "alluded" eluded you entirely and left us readers with the illusion of a coherent thought.

  13. What a well researched article! by apoplectic · · Score: 4, Insightful

    New languages such as C# and Visual Basic.NET only produce managed code.

    Hey, what about the keyword unsafe in C#? Sheesh.

    1. Re:What a well researched article! by CableModemSniper · · Score: 1

      Well going by MS's definition, unsafe is managed, just still unsafe. Its not the same as unmanaged code (Again using MS's definitons of unsafe (as in the keyword, and managed and unmanaged). At least AFAIK.

      --
      Why not fork?
    2. Re:What a well researched article! by dedazo · · Score: 1

      Unsafe refers to pointer operations, not security. The code is still managed and under the effective permissions "bucket" under which the assembly is being executed. "unsafe" doesn't mean "unsecure".

      --
      Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
    3. Re:What a well researched article! by DavidHopwood · · Score: 1

      Incorrect. See .

  14. It's called unsafe code for a reason by jerometremblay · · Score: 4, Informative

    Unsafe code is not subject to security checks of the .NET virtual machine. To execute unsafe code, you have to specifically grant those rights to the executing program. It is not something automatic.

    Applications that require safety (for example running plugins downloaded from the net) simply don't allow those assemblies to be loaded.

    Where is the problem again?

    1. Re:It's called unsafe code for a reason by spongman · · Score: 1

      get a clue, your processor can ONLY execute "unsafe" code.

  15. Someone should tell by ahdeoz · · Score: 2, Insightful

    Gosling that Java is inherently insecure, as it is written in C.

    1. Re:Someone should tell by BlueCup · · Score: 1

      Here Here! But, wait... if someone did that, wouldn't that make the Microsoft bashers feel like morons?

      --
      WANNAWIKI Wannawiki WannaWiki WANNAWIKI!
    2. Re:Someone should tell by BitchKapoor · · Score: 1
      " Gosling that Java is inherently insecure, as it is written in C."

      Not necessarily true -- IBM's Jikes/Jalapeno Java VMs are written in Java. The way you build them is (1) run them under another VM until they sufficiently JIT compile themselves to be self-hosting, (2) dump the JIT-compiled memory image, and (3) load the image whenever you need to run the VM.

  16. Too funny. by augustz · · Score: 1

    A:
    In .NET you can write code that harms a computer and deletes files.
    B:
    In Java you can write code that harms a computer and deletes files.

    A:
    You can write code in C#, in which case it is managed and helps prevent you from making stupid mistakes.
    B:
    You can write code in Java in which case it is somewhat managed and helps prevent you from stupid mistakes.

    A:
    Under .NET you can write code in C++ (which very few folks developing for .net do) and you take the risk of stupid mistakes.
    B:
    Under Java you read Sun's document on "Integrating Native Methods into Java Programs" and write you code in C++ in which case you run risks of stupid mistakes

    I fail to see the point of this article. Developers can write imperfect code if they want to. This is true in Java and .NET, though .NET makes it a bit easier with plenty of warnings.

    1. Re:Too funny. by spiffy_dude · · Score: 1

      I don't know as much about .NET, but most client Java runs through Java Web Start, which offers signing and a sandbox so that the user can't let and end user application delete files unless they've previously said "I know this code is unsigned, but please harm my computer anyway". The whole point of JNI as I see it is to integrate functionality that you can't do with Java itself. It is a last resort; it breaks platform independence, isn't that speedy, and requires that you maintain two code bases in different languages. It is almost always a bad practice to be writing code using JNI. Don't do it.

  17. Rediculous by SnprBoB86 · · Score: 2, Interesting

    Assemblies (.NET DLLs and EXEs) require special permission to run unsafe code. In the eyes of .NET, all unmanaged code or any use of pointers is considered unsafe. This includes every C/C++ application ever. .NET's philosophy on security is clear:
    A .NET assembly is secure except by special request to use unsafe code. Over time, all assemblies should be completely void of unsafe code except for assemblies from trusted sources.

    For example: The end user can grant unsafe permissions to the Microsoft Managed DirectX assemblies. Anyone could then use these assemblies without needing unsafe permissions. If you trust MS MDX to use unsafe code, and you trust the app you downloaded to use MS MDX, you don't need to give the app permission to use unsafe code.

    --
    http://brandonbloom.name
    1. Re:Rediculous by janoc · · Score: 4, Insightful
      Yeah, right - the same problem as with signed ActiveX - once a buffer overflow in the trusted code is found, your security is a fair game - the attacker has to only persuade e.g. your browser to load the buggy but trusted code. The managed languages like C# and Java were invented exactly with the purpose to prevent this kind of holes.

      To me this looks like a similar problem as allowing running native code via ActiveX. Yeah, we have permissions, signing and what ever - how much does it take for a trusted but buggy ActiveX applet to be exploited?

      Huge mistake, IMHO. And do not compare this to JNI - I am no Java expert, but AFAIK you simply cannot call JNI functions from something like web applet by design, whereas here it is on the discretion of the app developer.

    2. Re:Rediculous by spideyct · · Score: 1

      It is NOT at the discretion of the app developer. By default, you cannot execute .NET assemblies containing unsafe code if they are running from the network (as in the ActiveX example). That means it is the USER's discretion to allow that code to run (since they need to enable it through a policy configuration - it is NOT just a simple "this code may be unsafe, would you like to run?"

    3. Re:Rediculous by cookd · · Score: 1

      Well, you have a point. Certain assemblies will be marked as trusted and will be marked as "callable from untrusted code" (i.e. there's no way you can hurt the system through the interfaces provided).

      That's the same as Java's model, though. Certain classes are available from within the sandbox, and if those classes have security holes, they can be exploited. .NET works the same way.

      The question is where you draw the line between "providing APIs to untrusted code so the applets can do interesting stuff" and "protecting the user from applets that find holes in the APIs." ActiveX is probably too far to the left. Java is probably too far to the right. Where's .NET? Only time will tell...

      --
      Time flies like an arrow. Fruit flies like a banana.
    4. Re:Rediculous by janoc · · Score: 1
      Well, the problem is that it CAN be enabled - either by a stupid user or buggy application. We saw quite a few such hacks with security zones in MSIE, didn't we? Such as viruses or spyware lowering the security settings for MSIE as one of their first actions. Running ActiveX applets is also at user's discretion, albeit a bit easier and is it a good thing? I do not think so.

      Essentially you are giving an unsuspecting user a rope to hang himself again and again with something like this - for the convenience of a developer :( Why to have all that elaborate scheme with managed code when you are blowing holes into it right away to accomodate insecure code.

    5. Re:Rediculous by dedazo · · Score: 2
      Let me see if I get this right. There's this "thing" (which I won't call a feature) that can be enabled, at the machine, process or domain level, by an administrator. It is secured by default. Your position is essentially that it's wrong merely because it exists. Correct?

      Do you even know what you're talking about? Do you know how the .NET security model works? Let me guess - the answer is "no".

      If the same thing was a "feature" of some open source framework and I were making the same argument as you I'm sure someone (like you) would come along and use exactly the same point I'm making to prove how wonderful open source is, but always remember that you have to be responsible with how you configure security and so on.

      If .NET didn't allow these things someone else would be holding that up as proof that "it sucks".

      With Microsoft, it's always dammed if they do, and dammed if they don't, so why try to sound like you're rationalizing something you a) dislike on principal; and b) don't understand.

      --
      Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
    6. Re:Rediculous by Westley · · Score: 1

      Yes, it *can* be enabled - just as you *can* enable Java to run JNI code from applets. There's nothing to stop viruses or spyware changing the Java plug-in security settings either, is there?

      Now, why weren't we meant to compare this "hole" with JNI, precisely?

      Both systems allow the execution of unmanaged code if you give them the right permission. Neither system allows execution of unmanaged code when running in a "this is something on the web" context.

    7. Re:Rediculous by JesseT · · Score: 1


      Yeah, right - the same problem as with signed ActiveX - once a buffer overflow in the trusted code is found, your security is a fair game - the attacker has to only persuade e.g. your browser to load the buggy but trusted code. The managed languages like C# and Java were invented exactly with the purpose to prevent this kind of holes.


      Well, you should know that in the .NET security model, the only trusted code is safe and verifiable code... code that can be verified by the .NET CLR to be safe. That is, no buffer overflows, full type-safety, etc.

      You also have fine grain control over what security access rights you can give an application, particularily one you've downloaded off the net. You can restrict access to the file system (in a fine-grain manner, like which directories or files it has access to), sockets, access to other processes and global resources, unmanaged code-execution, unsafe code-execution, the list just goes on.

      Microsoft has actually created new language extensions for C++, and collectively it is called the C++/CLI language, which is a superset of ISO Standard C++ 14882-98. The MSVC++ 2005 (8.0) compiler, which is an implementation of C++/CLI, allows several programming models. You can develop pure managed applications and assemblies in C++/CLI--these are applications that are completely type-safe and have no buffer overflows as they are verifiable. Developing pure managed applications means that you can't use unmanaged code, however, like traditional STL or the standard C++ libraries--instead, you use the .NET base class library. There is also a version of STL that is completely managed using a combination of C++ templates and .NET generics. Next, you can develop mixed managed and unmanaged applications, allowing you to yes, have unsafe code. But you need to have given the application proper security rights to jump into unmanaged code sections before you can execute it. The safety is transfered to the user. And then, finally, theres the traditional unmanaged model that most of use are familiar with, where you write standard C/C++ applications--no use of .NET.

      Anyway, the point is is this is much better than ActiveX. Microsoft has really focused a lot on security; although unfortunately, most of it is not going to come to light until people start releasing more managed applications.

  18. Why oh why by Anonymous Coward · · Score: 4, Insightful
    When elevators were first invented, people didn't want to use them because people thought they were not safe. They were right. Elevators were not safe. When Mr. Otis invented the safety elevator, which had a catch so that it would not fall even if the cable were cut, people started using elevators. It would be foolish to trust your life to an elevator without such a safety system. You could use it to lift bales of hay or cement powder or something but you wouldn't put a human being in it.

    It's the same with C. We should know by now "you cannot use C to handle untrusted data (ie, data from untrusted machines on the net)". All such data need to be handled in a sandboxed system, a system with safe memory access. This means something like Java or similar things.

    A lot of people will make posts that say things like "C doesn't cause the problems, it's incompetent or lazy programmers who cause the problems." Whatever. No excuse. That's like saying "we shouldn't need seat belts or airbags; all we need is to make sure that drivers don't make mistakes." Drivers and programmers do make mistakes and that's why we need safety mechanisms in both cases. C provides none. Programming in C is like driving around in a car from the fifties, with no seat belts, no airbags, no head rests, no ABS.

    So any decision to extend the use of C is just foolish. What is the purpose of doing this? If people must use horrible legacy code then just use it, but why drag that into new frameworks like .NET?

    It does not compute, for me at least.

    1. Re:Why oh why by omicronish · · Score: 2, Informative

      So any decision to extend the use of C is just foolish. What is the purpose of doing this? If people must use horrible legacy code then just use it, but why drag that into new frameworks like .NET?

      Managed C++ is basically a compatibility language. It exists to provide developers an easy way to interface legacy C/C++ code with .NET code. By providing MC++ Microsoft is actually providing a way for developers to slowly migrate to more modern languages (sorta like JNI with Java; imagine if you couldn't make system calls at all). Without it considerably more effort would be needed to port and allow existing code to interface with new systems.

    2. Re:Why oh why by Gaewyn+L+Knight · · Score: 1

      Programming in C is like driving around in a car from the fifties, with no seat belts, no airbags, no head rests, no ABS.


      So... it's roomier... it will last longer... accelerate faster... brake faster... and be MUCH tougher thus negating many of the reasons airbags and seatbelts save lives?

      And BTW... many cars did have seatbelts in the 50s.

      Every code has a purpose... NO programming language or programming ideal is ever perfect or the end of the evolution.

      If programmers in all languages would do appropriate input checking and cowardly refuse to use any function that would allow an input buffer overflow the world would be a better place for EVERY language.
      --
      Telcos have alot of dark fibre in the States. Most people assume that's optical fibre...but it's actually moral fibre.
    3. Re:Why oh why by trg83 · · Score: 1
      So... it's roomier... it will last longer... accelerate faster... brake faster... and be MUCH tougher thus negating many of the reasons airbags and seatbelts save lives?

      Yeah, we all know they didn't have inertia way back then!! Seatbelts save lives because they keep people from flying out windshields. Airbags save lives because they keep people from hitting their head on the dash or steering wheel. Your logic is atrocious.

    4. Re:Why oh why by 16K+Ram+Pack · · Score: 1
      If you need the performance/flexibility of a language like C, it may be worth it, but often, such performance and flexibility are not required.

      If you are running projects, what matters is cost - cost now and cost in the future. Memory leaks cost money in development, testing and client dissatisfaction. If a language does it for you, that's something else that you don't have to worry about and can make your system run better.

      One rule of optimisation and efficiency is not to make it more efficient than it needs to be. If something needs to respond in 4 seconds and you are doing it in 3, stop working on it. If you are over 4 seconds, get optimising. In my experience of systems, a few key features of a system (the 10% that deal with the 90% of requests) are worth optimising. Stuff like table management is rarely worth optimising because it rarely gets done.

      Another thing that is worth remembering is how cheap PCs are and how expensive programming time is. If a function is too slow and only used by 2 people, it may be cheaper to swap out their PCs than to change the software.

    5. Re:Why oh why by 0111+1110 · · Score: 1

      it may be cheaper to swap out their PCs than to change the software.

      What if they already have the fastest PC: dual core or SMP, water or phase changed cooled and overclocked CPU, 4+ Gigs of low latency, high speed RAM etc? People who need the speed very often stay upgraded to the bleeding edge already. And that has just become a lot easier and cheaper due to the recent stagnation of CPU technologies.

      --
      Quite an experience to live in fear, isn't it? That's what it is to be a slave.
    6. Re:Why oh why by Gaewyn+L+Knight · · Score: 1

      f=ma and with those cars you were a lot smaller part of the 'm' in the equation than in modern cars. Plus wonderful things like THICK all steel body panels meant that a lot more of the intertia was spent in the deformation of the materials of the vehicle than in attempting to toss you out.

      Airbags and seatbelts are a good idea... they would have been great back then. However they are WAY more necessary on todays vehicles that weigh 1/3 - 1/2 what those did.

      My logic is not atrocious... it is succint and overstated just like the original post.
      <hint>Maybe even a bit facetious</hint>

      --
      Telcos have alot of dark fibre in the States. Most people assume that's optical fibre...but it's actually moral fibre.
    7. Re:Why oh why by Yunzil · · Score: 1

      Drivers and programmers do make mistakes and that's why we need safety mechanisms in both cases. C provides none.

      Au contraire. Speaking as a C programmer, C can provide all the safety mechanisms you could ever need. You just have to code them yourself. :)

    8. Re:Why oh why by hesaigo999ca · · Score: 1

      It is very simple, anyone knowing the microsoft business model knows they are just bringing what is left of the "old" developers over to the new frame work...this way it ensures that c & c++ will be legacy by way of comparison....get a programmer developing his c, then use some prefab code from the libraries, and see how much easier it is to use the vb.net or c# or j#....hey guess what...he is learning again, teaching an old dog new tricks. He becomes valuable again to the "now"
      community, and hangs up his c g-string for a c# g-string.....it is a very smart move by microsoft....do you think they will actually allow "real" c & c++ programming....no...they will allow the syntax of it, they will still implement the clr.....so the clr, will in fact proof read the code, and maybe throw some errors if it can to avoid bad style or "old" habits.

      All I can say is being a developer of the "new" world...I can see this as the beginning of the end for the old hats...after this, you will be very hard pressed to find any developers in c & c++...why should we, when evryone is happy working with the faster c#....

      I dont like microsoft that much, I have done a fair bit of linux programming & kernel stuff....
      c & c++ will still be needed, but with the new .net framework being ported over to unix/linux...you think it won't get engulfed there too, you may be surprised...we are talking about the efficientcy factor!

  19. 1 out of 1000? by icypyr0 · · Score: 1

    From the article:

    "Of the approximately one thousand developers that Sterling knows, he could only recall one directly developing under the C++ code. Whether this indicates an unwillingness on the part of developers to utilise code that is unsafe is notclear."

    Uh, so Sterling only knows 1 regular C++ developer out of 1000? I find that extremely hard to believe, although it is in line with the sensationalist tone of the article...

    1. Re:1 out of 1000? by st3v · · Score: 1

      "Uh, so Sterling only knows 1 regular C++ developer out of 1000? I find that extremely hard to believe, although it is in line with the sensationalist tone of the article..."

      No, he knows 1 Managed C++ developer out of 1000. Managed C++ is basically programming in C++ under the .NET Framework.

  20. JNI by steelem · · Score: 1

    Doesn't JNI suffer the same problem (but force the developer to shoot themselves in the process from insanity)?

  21. Re:James Gosling is an expert in this area by Anonymous Coward · · Score: 1, Insightful

    What about all the open-source applications built with C and C++? I.e. virtually all OSS apps?

  22. Re:James Gosling is an expert in this area by reflective+recursion · · Score: 1

    Gosling is hardly an expert at anything. He has serious NIH syndrome and raises awareness about issues that died decades ago. Only a lay person with no knowledge of programming history would consider anything he says insightful.

    Of course, what he says about .NET is probably true (I don't know however, I don't use that garbage). The issue is so beaten and rehashed that most programmers get nauseous thinking that the last half century of advancements have all been in vain.

    --
    Dijkstra Considered Dead
  23. ...all C programmers deal with. by Anonymous Coward · · Score: 1
    Don't code much, do you? Yes, C programmers deal with these traps all the time - that's why there are so many buggy, exploitable programs, you half-witted, slack-jawed luser.

    --
    ...and of course you must be careful not to overwrite the bounds of memory blocks, free a memory block twice, forget to free a memory block, use a memory block after it's been freed, use memory that you haven't explicitly allocated, etc. We C++ programmers have developed tricks to help us deal with this sort of thing, in much the same way that people who suffer severe childhood trauma develop psychological mechanisms to insulate themselves from those experiences.

  24. All C programmers? by Space+Coyote · · Score: 1, Interesting

    which last time I checked, all C programmers deal with.

    "Trust the programmer" is the most asinine statement ever put to paper, with the possible exception of "security through obscurity."

    We have an operating system so that programmers don't have to do boilerplate file and memory operations themselves, we have good type-safe languages so they don't have to spend time profiling all of their code to make sure it doesn't have any buffer overrun risks.

    --
    ___
    Cogito cogito, ergo cogito sum.
    1. Re:All C programmers? by ArbitraryConstant · · Score: 1

      ""Trust the programmer" is the most asinine statement ever put to paper,"

      bwhahahahahaha

      It's funny because it's true.

      "with the possible exception of "security through obscurity.""

      No, it's worse than that. :)

      --
      I rarely criticize things I don't care about.
    2. Re:All C programmers? by 16K+Ram+Pack · · Score: 1

      When I code, I want languages that do as much of the crappy stuff as possible. I want languages that get me to define business logic. I don't want to have to delete objects before they go out of scope. I don't want to have to pass a pointer to something, I just want to tell you to do it and you sort it out.

  25. Homeowners!! Beware! by Stevyn · · Score: 4, Funny

    No longer should homes be built using nails. All new homes should be built with really strong glue. Even though nails are faster and easier to work with, a carpenter might accidentally smash his thumb with a hammer. Plus, nails contain metal which may warp your home in the event a huge magnet is placed near the house.

    --The Elmer's Glue Foundation for Strength and Security

    1. Re:Homeowners!! Beware! by BillsPetMonkey · · Score: 1

      Good analogy. Mod up.

      --
      "It's not your information. It's information about you" - John Ford, Vice President, Equifax
    2. Re:Homeowners!! Beware! by Tired+and+Emotional · · Score: 1

      Yeah - but the difference is when you smash your thumb with a hammer, you generally find out about during QA.

      --
      Squirrel!
    3. Re:Homeowners!! Beware! by mikael · · Score: 1

      Even worse, he might use an nail gun, and put a nail into his brain! Ouch!

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    4. Re:Homeowners!! Beware! by quarkscat · · Score: 1

      Or better still, really strong glue AND
      SS screws (not unlike belt & suspenders)
      and steel joining plates on post-and-
      beam construction. And that merely for
      framework &and forms for the rebar-
      reinforced concrete walls.

      Face it. Programming languages are like
      any other tool made by man. In the hands
      of a skilled craftsman, any software can
      be rendered safe. A Michealangelo can
      create a beautiful statue, but I wouldn't
      trust a mallet and chisel in the hands of
      a 6 year old.

      The underlying question should be:
      "Does .NET offer better software security
      than other programming languages, when used
      by 6 year olds?"

      IMHO, the answer is: "No difference!"

    5. Re:Homeowners!! Beware! by phoenix.bam! · · Score: 1

      I kinda find your example here funny. My father builds houses for a living and has actually started using construction glue for many things instead of nails. (he still uses finishing nails to tack the stuff he is gluing so it stays in place, but the glue is actually what is holding it together aftwards.) I know that has nothing to do with your point, but the glue does work better for holding together decks and outside stairs that have the problem of warping and forcing the nails loose.

  26. from the throwing-stones dept. by game+kid · · Score: 1

    from the throwing-stones dept. indeed. If .NET is so terrible, why does the creator of Java have to complain in the first place? I think the Java guys should spend some time bettering the look of Java UI's and the loading time of the VM; that way they shouldn't have to be so vocal to succeed. I'm not exactly sure why Sun sued MS to stop it from using the language, but since then IE users went from a non-standard Microsoft VM to Sun's standard but (in my case) slow-loading VM that takes loads of memory, with UI's that often look plain. I'd much rather have the Jellybean Start button on every Web form.

    That said, it does seem redundant to have teh C in .NET, now that Managed DirectX (and most likely third-party OpenGL tools), is available. No USB support I know of though. .NET "assemblies" can be restricted to only do certain things (not read your Registry, spawn popup windows and the like) through a permissions applet in the Windows control panel; I don't know how it affects unsafe code though.

    --
    You can hold down the "B" button for continuous firing.
  27. Apparently not! by Anonymous+Brave+Guy · · Score: 1
    I highly doubt that we will see a virus or serious security issue in applications built with Java anytime soon.

    Maybe that's because you can't write much of the software that could be vulnerable to that sort of thing in Java at all. When was the last time you saw an operating system written in Java?

    Java is an excellent example of a useful tool to help protect Joe Average programmers from certain types of programmer error. However, if you think removing pointers from a language guarantees security, then please consider that many of the most common security flaws are due to things like SQL injection, which Java does nothing to prevent.

    Java is also a child's toy that regresses the state of the art by nearly 20 years in the hands of a good programmer, and those are usually the guys who write operating systems, networking utilities, etc. Any competent C++ programmer will be using pointers very little and in tightly controlled areas of the code anyway. C++ is not C, and has much stronger tools for abstraction.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Apparently not! by Phil246 · · Score: 1

      i thought one of the most common security flaws was attributed to buffer overruns?

    2. Re:Apparently not! by bani · · Score: 1

      no longer, it's now logical exploits like cross site scripting and sql/arbitrary command injection -- and java won't save you here.

    3. Re:Apparently not! by Theatetus · · Score: 1

      Not really. Those are getting rarer and rarer as older libraries get phased out (remember, joe average programmer is never in a position to write an exploitable buffer; the buffer was written by some grad student at Berkely 10 years ago as part of a library).

      Check vulndev. Check bugtraq. The bugs coming out now are not for the most part "crafted user input overflows the heap" but rather "crafted user input is passed to a SQL interpreter" or "crafted user input is used as a format string". There are, incidentally, fairly good static tests for these things, but A) Java (and C and C++) doesn't use them and B) they unacceptably limit the range of possible applications.

      --
      All's true that is mistrusted
    4. Re:Apparently not! by jbplou · · Score: 1

      It is against the structure of Java and .Net to be used to write an Operating System. Java was made to be portable between operating systems not programming OS's. .Net code for the most part removes the .dll hell of programming Windows and allows programs to be installed on the various versions of Windows without modification so I can install the same program on Win 98 and Win Server 2003 without issue. MS must of realized that 64 bit processing was around the corner because you can move .Net apps between 32-bit and 64-bit with ease.

    5. Re:Apparently not! by 16K+Ram+Pack · · Score: 1
      Yeah, all those major financial organisations use "toy" languages.

      Who cares if you can or can't write an OS in Java. How many organisations want to write their own OS? You know any retailers who want to do that? Operating system development are a tiny part of the overall computer industry.

      Java programmers are professionals, just like C++ programmers. They are often working in a different space - that of in-house application development. I don't know many companies using much C++ for in-house application development any more - it introduces risks and costs that aren't there with Java or .net.

      Java and .net are the next step to the future. A future that will eventually be that businesses just graphically design their business models and rules, that are executed. There will always be a need for low-level programming for purposes like building operating systems and tools, but the desire of businesses is to have a shorter gap between requirements and delivery. That does not mean C++.

    6. Re:Apparently not! by Anonymous+Brave+Guy · · Score: 1

      Sorry, but I think you missed my point. The posts further up were attacking C and C++ code for its frequent vulnerability to certain kinds of attack. My point was simply that in Java you can't even write code to perform equivalent tasks in the first place, so it's hardly a fair comparison.

      From your comments, I'm guessing your experience is almost entirely in database-driven projects. Here the attacks are more likely things like SQL injection anyway, and Java is no more inherently protected there than C or C++.

      Java and .net are the next step to the future. A future that will eventually be that businesses just graphically design their business models and rules, that are executed. There will always be a need for low-level programming for purposes like building operating systems and tools, but the desire of businesses is to have a shorter gap between requirements and delivery. That does not mean C++.

      J2EE and .Net obviously have potential for distributed database applications with client-side UIs, which certainly covers a large class of business applications. It's hardly the entire software development market, though.

      All those bells and whistles are mostly useless for scientific and engineering applications, and I'd bet there's at least as much work in the instrument control/embedded market as there is in business database apps. These areas tend to use C, C++, or perhaps FORTRAN at present, for their performance, portability, and/or low level control.

      I'm quite sure that the future in these areas is not with C++. Indeed, it would be sad if we couldn't learn from several decades of programming experience and come up with a cleaner, safer, more powerful language than that sooner or later. However, neither Java nor .Net-in-whatever-syntax is going to be that evolution. Their advantages simply aren't very relevant to people working in these other fields, and in some cases they're clear steps backwards. In that sense, they very much are toy languages. The fact that they happen to be convenient for writing glorified database apps doesn't change that.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  28. Gosling vs. Kernighan Cage Match!! by Anonymous Coward · · Score: 1, Funny

    Sunday! Sunday! Sunday!

  29. Beware the agenda by BillsPetMonkey · · Score: 3, Interesting

    C++ allowed you to do arbitrary casting, arbitrary adding of images and pointers, and converting them back and forth between pointers in a very, very unstructured way.

    Unstructured? Yes. A huge security hole? No more than any other language using COM objects. You can write crappy spaghetti code in any language. The type interface for .NET and the unsafe keyword for managed code are there to restrict how you use native objects.

    What Gosling is really criticising is the way .NET handles managed code, which java can't do so easily (remember jini? Me neither) - so what .NET should really do according to Gosling is have a sandbox runtime with no severely restricted access to the native interfaces - to hell with performance compared no native methods? Oh, that'll be just like ummm .. java then.

    --
    "It's not your information. It's information about you" - John Ford, Vice President, Equifax
  30. Did you really say: by tod_miller · · Score: 1

    which last time I checked, all C programmers deal with.

    Yes, they all do, and thank fuck for that, else we would have net worms and trojans and shit spreading through unchecked buffers left right and center.

    Don't just tack some bullshit to the end of the story.

    The fact is, we do not have to sanity check every 3 lines of code. New languages are called new languages for a reason.

    Also, I think Gosling (who has produced a language that 10 if not 100's of millions use) knows a *little* tiny bit more than you about languages, and your highschool hacker C coding isn't something to brag about.

    Sorry, but fuck me for stupid one liners on /.

    --
    #hostfile 0.0.0.0 primidi.com 0.0.0.0 www.primidi.com 0.0.0.0 radio.weblogs.com
    1. Re:Did you really say: by Artraze · · Score: 1

      Also, I think Gosling (who has produced a language that 10 if not 100's of millions use) knows a *little* tiny bit more than you about languages, and your highschool hacker C coding isn't something to brag about.

      And I bet you believe Microsoft every time they come out and say stuff like "Linux is less secure than Windows"? After all, Microsoft has a product that 100s if not 1000s of millions use, so I think they'd know a little tiny bit more than some kernel hackers.

      Face it, the guy is attacking a competing product. He will never applaud it and say ".NET is better than Java". At best he won't say anything. It this particular case, he decided to bash .NET.

      And regardless of you cynicism, this _is_ something C/C++ programmers deal with all the time. Whether or not they do so effectively is arguable, but the one-liner is true.

    2. Re:Did you really say: by KarmaMB84 · · Score: 1

      Yeah, we all deal with the system of typing.

    3. Re:Did you really say: by tod_miller · · Score: 1

      I disagree, I honestly believe that if .Net was better than Java he would say so, but then also say, you can take that proprietary nice .Net solution, and then work with it, or use Java with an established JCP, and huge industry support blah blah.

      Even if .Net was anything Java is (language + libraries + portability) it wouldn't affect the viability of Java.

      You sound like you just spend some $$$ of some online .Net certification. Good luck to you.

      --
      #hostfile 0.0.0.0 primidi.com 0.0.0.0 www.primidi.com 0.0.0.0 radio.weblogs.com
  31. Since when is this a flaw? by IonPanel · · Score: 1

    Oh, no! Microsoft supported arguablly most popular and well-used languages on the planet in it's product line! C and C++ give the developer total control and thus you can produce really efficient code. The byproduct is, if you are a human being, you will make mistakes, and since you have maximum control and flexibility with C and C++, these mistakes could be quite big mistakes since there is no lovely Common Language Runtime or Java Virtual Machine there to stop you. That's not a flaw in .NET, thats just a fact. Microsoft supports multiple languages, but never forced anybody to use C or C++. In fact, they are more likely to want you to use C#

    --
    Dave Bell
  32. Gosling jealous... by borgheron · · Score: 1

    Despite it's origins, C# is a much better language that Java.

    In C#, everything is an object, there are no funky "beans" and everything is introspectable. With Java, this just ain't so.

    GJC

    --
    Gregory Casamento
    ## Chief Maintainer for GNUstep
    1. Re:Gosling jealous... by ziggy_travesty · · Score: 1

      Not to be pedantic, but the primitive types in C# are not actually objects, they just behave like objects via boxing. This is done so that native 32-bit ints don't carry object overhead, but still maintain object-like usage. Best of both worlds...

  33. No framework can protect against malicious code by ThinkTiM · · Score: 1

    There wasn't enough in the article to be exactly sure what Mr Gosling was talking about. But I know that it's quite possible to deploy malicious code into a J2EE server - and I'm not sure what kind of company would not keep check of what is being deployed (read "SDLC").

    Type safety doesn't seem to me to be related to security unless you just let anyone install stuff into your production environment. And if you did then people wouldn't need to resort to exploiting that particular weakness.

  34. Unmanaged code where? by mugnyte · · Score: 1

    Oh - you must mean when you call anything in the OS, or reference any one of their former-perfect-solution COM objects?

    Actually, use of a language isn't the trouble, just writing *well* in that language. Even checking the source isn't problem....they do employ an army of programmers, and send them to dozens of "better C" classes, written by gurus they themselves employ.

    In the end, it might be the sad support for legacy interfaces that they're stuck with, or the fact that they can't seem to upgrade all of their code fast enough. Whatever it is, MS can't seem to improve their programs without forcing a sandbox to do it, eh? Sad.

    Everyone knows that in a C/C++ world, you end up adopting or building a safer framework to avoid letting newb's use the standard C lib like the wild cowboy it was born as. In fact, it's what makes "better" programmers once they learn all these crazy nuiances, down to hand-asm optimizatios. But if you're stuck with tons of code that needs to be refactored (or just completely reengineered) because of past mistakes, there is a breaking point. Applications that *rely* on cowboy tactics are there to hold you up.

    SO they release a "whole new OS" every few years or so, and force everyone to jump. They make the kernel bullet proof, and thunk old code. But somehow, something like IE lives on to trick users over those damned ActiveX objects, or marketing gets their fingers into Outlook and makes it auto-run everything. Sad, but MS is a product of many teams pushing different directions - which is to say it's no different than many companies.

    Perhas they will learn a lesson from Open Source after all -> many eyes makes for better checking.

    As an experiment, I think MS should just re-release IE as a complete .NET app from the ground up. It may enlighten MS about the limitations of .NET, the pervasiveness of a good security model, and how to useful componentize an application (and NOT build it as "an integral part of the OS").

  35. Hmmm by Sophrosyne · · Score: 1

    Well, I have a truck... and .Net.... now how can I reproduce this bug!?

  36. He just doesn't get it, or he's spreading FUD by TheKingAdrock · · Score: 2, Insightful
    It's not the language, but the VM that matters. With the new C++/CLI (http://msdn.microsoft.com/visualc/homepageheadlin es/ecma/default.aspx) you'll be able to write code that is verifiable, just like C#, or have the option to call into "unsafe" native code. Imagine that, a migration path for users!

    .NET supports many languages, and they can all "play nice", and interoperate (compare this to Java).

    1. Re:He just doesn't get it, or he's spreading FUD by psykocrime · · Score: 1

      .NET supports many languages, and they can all "play nice", and interoperate (compare this to Java).

      Java has the same ability. You can compile (in theory) any language into java bytecode and run it on a JVM, and integrate pretty much seamlessly with "regular" java code. Many other languages already have ports to the JVM, or were written specifically for the JVM. For examples of what I'm referring to, see: Groovy , Jacl, Jython, Nice, JRuby, and Rhino among others.

      And since there is JNI, you can also combine Java with native C/C++ code as well.

      --
      // TODO: Insert Cool Sig
    2. Re:He just doesn't get it, or he's spreading FUD by gl4ss · · Score: 1

      well.. it still leads to potential problems - unintended functionality that is still 'right' as far as any machine could interpret.

      of course it's 'safe' if you don't make mistakes.

      --
      world was created 5 seconds before this post as it is.
    3. Re:He just doesn't get it, or he's spreading FUD by harlows_monkeys · · Score: 1
      You can compile (in theory) any language into java bytecode and run it on a JVM, and integrate pretty much seamlessly with "regular" java code

      In general, you can compile pretty much any language into pretty much any other language. I've heard rumors of a Fortran to troff compiler, for God's sake.

      However, in practical terms, it works better with the .NET stuff than with the JVM, because the .NET VM was designed for this, and so the features of more languages map well onto the .NET VM than map well onto the JVM. Basically, running other languages on the JVM is generally a novelty, perhaps useful in special circumstances, whereas on .NET most of those languages are on an equal footing.

  37. Re:James Gosling is an expert in this area by KiloByte · · Score: 1

    Well, show me a single usable Java VM. By usable I mean "not crashing all the time, able to run the same code the same way every time and still containing a decent set of features". I haven't seen one.
    This is not a flaw of the language itself -- but the fact that after all those years we still don't have a single stable Java environment says a lot.

    Java is touted as a tool for writing safe code. Now, how many life-critical applications are written in Java? And how many in C? Hmm...
    And for things that don't need an extreme degree of efficiency and/or stability, there always are scripting languages like Perl or Python... (no, .NET is not an answer -- it has an abysmal record in both of these departments).

    The amount of Java propaganda I perceive declined a lot in the last ten years. For me, Java is a failed experiment. Let's not try to dig up its corpse. Let it rot.

    --
    The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
  38. Re:What's the flaw again? by Anonymous+Brave+Guy · · Score: 1
    What's wrong with that?

    Assuming this is a genuine question and not a troll: it removes the consistency from the type system that was supposed to be one of Java's original selling points, and consequently necessitates hacks involving wrapper types and/or artificial concepts like boxing to write code in Java that could be written quite straightforwardly in other languages.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  39. Re:What's the flaw again? by borgheron · · Score: 2, Informative

    Just curious... What's wrong with that?

    It speaks to the purity of the language. Being able to deal with *everything* as an object is a distinct advantage since it allows you to, potentially, extend basic types into more complex ones and it also prevents you from having to "box" primitives in objects and "unbox" them on the way out.

    BTW, JDK1.5 (aka Java 5) has a new feature called "autoboxing" which does the above boxing for you. This doesn't really count as those types being objects, it's more of a kludge than anything else.

    This difference means that C#, from an OO standpoint, is a more pure language as opposed to Java which is a "hybrid" OO language.

    GJC

    --
    Gregory Casamento
    ## Chief Maintainer for GNUstep
  40. Re:What's the flaw again? by bnenning · · Score: 2, Informative

    Just curious... What's wrong with that?

    It's ugly and non-orthoganal. Look at the Arrays class for example; there are dozens of duplicated methods that are identical except that they take bytes, chars, shorts, ints, etc. as arguments. I'd much rather have everything be a true object; any performance issues can be handled by the compiler, runtime, or Moore's law. Autoboxing helps, but better to fix it for real than with syntactic sugar.

    --
    How to solve most of our problems: 1.Lots of nuclear plants. 2.Cure aging.
  41. Re:What's the flaw again? by Shazow · · Score: 1

    Sorry if people thought I was trolling, it was a genuine question. I've been using Java for several years now and it clearly has its uses. I never heard of this "type system that was supposed to be one of Java's original selling points", but that could be my own shortcoming.

    My impression was that Java is supposed to be a fully object-oriented programming language. If that's not what the project calls for, you should be using a different language instead of "necessitating hacks involving wrapper types and/or artificial concepts like boxing".

    I could be wrong, but I find that people descriminate against Java because they misuse it, not because there's some fundamental flaw with it.

    - shazow

  42. I believe Gosling is wrong by frovingslosh · · Score: 5, Funny
    James Gosling this week called Microsoft's decision to support C and C++ in the common language runtime in .NET one of the 'biggest and most offensive mistakes that they could have made.'

    Gosling is dead wrong. I believe that Microsoft will soon prove they are capable of even bigger and more offensive security mistakes.

    Also, the choice to actually use .NET is at least as big of a security error.

    --
    I'm an American. I love this country and the freedoms that we used to have.
  43. Re:What's the flaw again? by Shazow · · Score: 1

    I think I see what you mean. Thanks for clarifying. Guess I never encountered this.

    - shazow

  44. In other news... by joto · · Score: 1
    The same hole exists in java. It's called JNI (or even RMI, Corba, SOAP, etc...).

    If you want a language that has no "security holes", you'd better build a computer without them too. Some way or another you have to hit the bare metal in the end...

  45. Microsoft has no choice ... by duslow · · Score: 1

    Because of the huge library of commercial software that is written in C++, they have no choice in supporting it if they want to continue their dominance in the desktop arena. Companies are not going to port their software to managed languages anytime soon because they don't HAVE to in order continue to selling their products. Microsoft also sent the message to them that they don't have to, so why would they? Even if they all started the conversion now, it would take many years to get everything converted. Even still there will be applications out there written in non-managed style. The bottom line is that it will be a very long time before everything on a Windows box (minus the OS of course) runs in a 100% managed environment.

  46. Re:Advertisement? - You don't understand C by ppenrod · · Score: 2, Informative

    "C and C++ allow for buffer overflows. They allow for improper or intentional coding to cause software to try to violate memory space of other functions or programs. They allow for memory allocation without necessarily providing any cleanup later. In the hands of bad, sloppy, lazy, or malicious programmers these traits have always proven to be a problem time and again on many different platforms."

    C is not for everyone.
    For starters, it's a small language by design.
    It was used to write OS code from the beginning.
    It assumes you know what you are doing and allows you to break the rules to get it done.

    If you want safety go back to Pascal...

  47. Re:James Gosling is an expert in this area by bani · · Score: 1

    try writing povray in java. and once you're done, see how well it performs.

  48. Defending home turf by Commykilla · · Score: 1

    What a big shocker... the "father" of Java says that the .NET runtime and the C# language are terrible and you should use Java instead..

    What did you expect him to say "Great job guys, everyone better use that instead of Java! I suck!"

    --
    Communism was just a red herring.
  49. Safe? Unsafe? What were we sold??? by basking2 · · Score: 1

    Note that this isn't a particular vulnerability, just a system of typing that makes it easy to introduce vulnerabilities, which last time I checked, all C programmers deal with. .NET was sold as a "safe" coding solution because C# was strongly typed and did bounds checking. Also, .NET puts your code in a sandbox. By using a C or C++ library with any "safe" code you make that code now unsafe because there is nothing preventing the virtual machine code of the C or C++ code form doing bad things to the (for example) C# generated code. This is a fault in the language of C and C++. It is true that all C and C++ programmers deal with it and as such I'm surprised more don't seem to understand what these dangers involve or how they can impact code written in a "safe" language (like SML) running in the same space as "unsafe" code like C.

    --
    Sam
  50. But what's worse? by Spy+der+Mann · · Score: 1

    Allowing C++ programing in .NET, or calling .NET programs from C++?

    Frankly I have no F'ing idea of what's this "biggest mistake" to begin with (IMHO, the biggest mistake was bundling IE with Windows).

  51. Whatever by Pedrito · · Score: 1

    Man, all sensationalism and no meat. And you know, if MS had decided not to support C++ in .NET, he would have come out saying something like, ".NET must have problems if they can't even support C++ in it." Get real. And like anyone uses C++ in .NET anyway. I mean, if you really like doing things the slow and hard way, I suppose you could, but there aren't that many people that do.

    Any C++ programmer worth his salt can pick up C# in no time and will realize it's going to save them a ton of time. I still go back to C++ when I need to do unamanged code, and hey, sometimes I have to, but it's pretty infrequent. And it's not like it just transparently blends in with .NET. I mean, it's not difficult to use my managed code, but I'm definitely making a conscious decision to use it. Oh well, pointless article.

  52. lost my faith by phek · · Score: 2, Funny

    After reading the comments to this post, I have finally lost my faith in the industry... C was around before your 'secure' languages, and C will be around long after your 'secure' languages become outdated/obsolete.

  53. My opinion on this... by agraupe · · Score: 1

    I'm an amateur programmer... I do stuff for fun, and sometimes for a school project, that sort of thing. I started programming with C/C++ when I was about 8. Since then, it's been hard for me to switch to any other language. Sure, I probably could, if I tried. I have, in the past, produced working Perl and PHP code, and if I put my mind to it, I could probably learn those languages to the same degree that I know C. Now, the relevant part: C/C++ is still the dominant language! Although other languages may be technically better, they cannot compete for portability, libraries, and number of programmers and so on. The only thing that will fix the flaws of C and C++ is a redesign of the two languages with the explicit goal of creating as much commonality as possible between the the C or C++ standard and the "safe" implementation. Certainly, the only other mainstream languages are more suited to web applications, or scripting. C and/or C++ may have flaws, but it's more work to iron them out than it is to live with them.

    1. Re:My opinion on this... by synx · · Score: 1

      Depends on where you look, C/C++ is _not_ the dominant languages. In middleware/business logic situations (which is a extremely high amount of code being written today), Java is extremely popular. There is an extremely large and well supported library set for doing j2ee/java development. Same with the size of the community (look at the Jakarta project).

      The disadvantages of C++/C has been expounded by many, so I won't repeat most of them, but one problem with C++ is what I call the 'hungus links' - for large software projects which have grown organically, links tend to get really large as people followed the 'reuse code' doctrine (not a good idea in an enterprise setting - your code reuse policy has to be unusually strict). Eg: my app takes 970 MB RSS (physical ram) and 1.7 GB VSS (total virtual address) to compile. That takes about 15 minutes to complete.

      Fixing it is fairly difficult considering that you could break quite a bit of things and certain types of code-reuse is very difficult to break. The only solution in some cases is to duplicate code to remove functional dependencies between inappropriate component sets.

      For the purported design goals of C and C++, they are not inherently flawed - but for a modern business logic development environment they are not the best choice either. Being able to develop faster and safer is usually the goal.

  54. Yeah, dangerous tools... by Eternally+optimistic · · Score: 1

    Like shoes, the let people walk in front of buses and get run over. Can't have that flexibility for all those irresponsible people, no Sir.

    You won't get around having to pay attention if you want to accomplish anything worthwhile.

    --
    What keeps me going is my inertia.
    1. Re:Yeah, dangerous tools... by TWX · · Score: 1

      Well, part of the reason why I run Linux is that since peer review is possible, there is a greater chance that someone will catch an error and provide a repair method. Proprietary systems don't have this extra level, so a problem in the Microsoft world requires Microsoft people to acknowledge and repair the error. I don't rule out them doing this, but I don't expect it to happen with the speed that it seems to happen in the OSS world when an error in programming is discovered.

      One of these days I'll email some of the people responsible for fixing bugs in the Linux Kernel and other major daemons that run on Linux systems to find out how long the bug fix process generally takes. I'm sure that they have to go through and figure out what exactly the code does, what it's supposed to do, what *else* it does, and if there's any quick way to deal with the issue. I am genuinely interested in the process, as I'd like to compare it to how long it takes proprietary vendors (of any OS, not just Windows) to get a security fix ready.

      --
      Do not look into laser with remaining eye.
  55. Sun FUD by jeif1k · · Score: 1

    .NET has two kinds of code: safe and unsafe. Safe code makes the same guarantees as "pure" Java. Unsafe code makes the same guarantees as C, i.e., none. Of course, Java has the same constructs: it also has safe code and unsafe code. Java's unsafe code happens to be written in C/C++, however, which has lots of disadvantages compared to C#'s unsafe construct or C/C++ compiled to a CLR backend.

    Gosling isn't the smartest guy around when it comes to programming languages, but even he understands this much. So, we have to conclude that his misrepresentation of the situation is deliberate FUD.

  56. OT: pedantic sig nitpick by ca1v1n · · Score: 1

    In an efficient market, price equals marginal cost. Marginal cost of software: zero.

    I think you mean "efficient and infinitely large", as the efficient behavior only pushes the price down to the marginal cost asymptotically.

    Not that I object to the notion in the slightest.

    1. Re:OT: pedantic sig nitpick by malfunct · · Score: 1

      Futhermore in markets where the "average" price doesn't reach the marginal price even in an infinite market (these are usually markets with a 0 marginal price) you end up with what are called natural monopolies and they are actually the most efficent that market can get if you want anyone to participate in it. This is because people will pull out of a market if they can't get the price up to the average cost. So there are some markets where price won't reach marginal cost and software may be one of those markets.

      --

      "You can now flame me, I am full of love,"

  57. Re:What's the flaw again? by andreyw · · Score: 1

    And now that JDK1.5 came up with a sort-of solution to a problem that didn't have to exist, it might be actually worth playing with. Or not...

    Seriously, if I ever want to deal with boxing and unboxing objects again, I'll go back to casting black magic with templates and RTTI under C++.

  58. you got it backwards by jeif1k · · Score: 3, Insightful

    This is what really distinguishes Java from other languages. The Java verifier is a sort of theorum prover that examines the byte-code and can guarantee that it does not violate certain rules such as forging the type of a reference or under/over-flowing the stack

    You arae kidding, right? Do you seriously believe Java is the first or only language to guarantee runtime safety? Safe languages are the rule, not the exception.

    To support C/C++ semantics (ad-hoc pointers) you'd have to throw all that out the window and I assume that's what he's talking about.

    C# distinguishes safe and unsafe code. C#'s safe code is as safe as "pure" Java code. You can think of C#'s unsafe code (or its equivalent in C/C++) as code linked in through the JNI interface, except that C#'s unsafe code has far better error checking and integration with the C# language than anything invoked through JNI.

    Altogether, C#'s "unsafe" construct results in safer and more portable code than the Java equivalent, native code linked in through JNI.

    Pat Niemeyer, Author of Learning Java, O'Reilly & Associates and the BeanShell Java Scripting language.

    Well, then I suggest you learn some languages other than Java before making such ridiculous statements.

  59. Not only that by ad0gg · · Score: 1

    Majority posts are defending microsoft.

    --

    Have you ever been to a turkish prison?

    1. Re:Not only that by stevesliva · · Score: 1

      Sun, Microsoft, same difference. Not team players.

      --
      Who do you get to be an expert to tell you something's not obvious? The least insightful person you can find? -J Roberts
  60. Summary of the article by bonch · · Score: 1

    Summary of the article:

    Java creator: ".NET is insecure because of C and C++. Java is better."

    Microsoft developer: "Only if you use unmanaged code. Out of thousands, I only know of one developer using C++ .NET."

    Why would Slashdot even bother with this meatless story? Oh, yeah--page hits for OSTG ad clients. :P

  61. Re:.NET time is over by bonch · · Score: 1

    Not much of a loss here but rather an opportunity for serious developers to concentrate on the UNIX world.


    You're right! *goes back to hacking on Mono*

  62. But what if... by fireman+sam · · Score: 1

    managed programs have been mentioned in previous posts (ie .NET, python...) and how in the future all "desktop" (ie non system) applications are written in one of these "managed" languages.

    My problem with that is what are the virtual machines written in? C, C++, Pascal? Probably a non-managed language.

    Q: What happens if there is a vulnerability in a "non-managed" application?
    A: The "non-managed" application is vulnerable.

    Q: What happens if a vulnerability occurs in one of these virtual machines?
    A: All of my applications are vulnerable.

    I know which one I would prefer.

    --
    it is only after a long journey that you know the strength of the horse.
  63. I hate Java. by Anonymous Coward · · Score: 1, Interesting

    A little off-topic, but I just have to say it now that someone mentioned Gosling...

    The "enterprise" label is given to any application that meets the following requirements:

    o Must be Java-based.
    o Must be a bloated/slow POS that crashes every day making oncall a total nightmare.
    o Must have little to no documentation(requires an expensive consultant to install)
    o Must cost a lot of money cause if it was cheap it must mean it sucks. Right? uhhh

    At least this is true with the company I work for.
    I long for the days most webapps were written in scripting languages...

    So I'd like to say thank you Gosling for making working as an IT sysadmin suck.

  64. Drop that crack pipe! by dusanv · · Score: 1

    Seriously, how do you imagine that the garbage collection will ever be faster than the native??? I compiled Java to native with gcj and it was actually slightly slower than running inside the VM (IBM's which was quickest at the time). Either was an order of magnitude slower than C++ at the same task. I'm sick of hearing about how unsafe C/C++ is. If Java was so good, we'd be seeing all sorts of stuff popping up written in Java and I'm not talking about dinky servlets and server/browser side stuff only. Everything larger written in Java has failed miserably so far (HotJava, Corel WordPerfect, ...). Java is slower, memory intensive and not very flexible. Get over yourself and learn C++...

    1. Re:Drop that crack pipe! by espressojim · · Score: 1

      How 'bout if most of the bioinformatics tools written over at MIT's Broad Institute were all written in java. I've got a lot of 'number crunching apps' running right now.

      Some of them are even running on our compute cluster...yummy.

  65. Re:What's the flaw again? by cecom · · Score: 1

    I'd much rather have everything be a true object; any performance issues can be handled by the compiler, runtime, or Moore's law.

    That would be nice if it were possible. Unfortunately, it isn't (at least on a practical scale, esp. considering that we seem to be at the end of Moore's law). Turning everything into an object in a procedural language like Java would have a tremendous negative impact on performance, since currently there aren't practical optimizations to take care of that. Such a hypothetical language would be an immediate failure, even though it might look ellegant.

  66. In related news... by slavemowgli · · Score: 1

    In related news, it was also announced that being alife exposes you to the very serious threat of dying. Gosling was quoted as saying that the lack of a proper cure for dying meant that science had failed, and also accused god of an inherently buggy design, demanding that life be stopped immediately so everyone could go back to a safe state of un-existance.

    --
    quidquid latine dictum sit altum videtur.
  67. C++ isn't so unsafe by Anonymous Coward · · Score: 1, Informative

    For those of you who haven't looked at C++ in 10 years or so (apparently all of you), things have changed. Modern C++ is completely different from C, and for that matter completely different from C a few years ago. Not much unchecked pointer code to deal with. In fact, NONE, except when you have to interface with a C library, and then that stuff is confined to a single well-tested abstraction layer over the C library.

    Why is it that open source type people stay away from C++? The few open source C++ projects I have looked at look like they were written about 10 years ago.

    If you're one of those who think C++ is just a big complicated mess, do yourself a favor and take a look at it now. I thought that not too long ago too but then I actually took the time to learn it well and it has completely changed the way I code (even in other languages!). Yes, it is big, and it is complicated, and it is most DEFINITELY not perfect. But it directly has facilities to support some very modern and powerful programming paradigms.

    1. Re:C++ isn't so unsafe by Skapare · · Score: 1

      C does all I need at this level. I've been programming with pointers (and addresses) since 1972. I do know how to handle them safely. I don't need the bloat of a big STL coming along for the ride. If I have an app that needs OOP and the bloat won't matter, I do it in Pike.

      --
      now we need to go OSS in diesel cars
    2. Re:C++ isn't so unsafe by conantroutman · · Score: 1

      Amen to that, anybody heard of std::string?, it's been around for awhile now.....

    3. Re:C++ isn't so unsafe by conantroutman · · Score: 1

      Do you ride a horse to work?

    4. Re:C++ isn't so unsafe by Skapare · · Score: 1

      Excuse me? C is more like driving a Ferrari. At least with a Ferrari you can smash yourself to bits by making a mistake. And it goes fast. The best you can do with a horse is hope it stomps on you in a fit of rage. It also goes slow and has a mind of its own.

      --
      now we need to go OSS in diesel cars
    5. Re:C++ isn't so unsafe by conantroutman · · Score: 1

      Touche! I'll give you C is fast, but unless your writing software for wrist watches the C++ bloat argument just does not make sense anymore.

    6. Re:C++ isn't so unsafe by Skapare · · Score: 1

      If it makes a difference whether I can run 200 instances of a program on a given hosted system because it is written in C, versus 40 instances in C++, then I will choose C for that reason. But in reality, the big reason I do choose C is because I am able to do things in C just as well. I have plenty of tools of my own that make C very viable. And since these tools are specific to what I need, and not generalized to the least common denominator, they work fine for me, and they don't add anywhere near as much RAM footprint as C++ does.

      As far as moving up to an OO language (which C is not, although it does not preclude an OO design which I have sometimes done with C), I am already doing that ... I just skipped over C++ in so doing (and skipped Java, too, I might add). Now I use Pike. Is Pike bloated? Sure it is; anything at this level certainly is. But for applications where the bloat doesn't matter, I sure don't need to go back down to a C/C++ type programming model. So in the end I have a full spectrum of capability in my language choices. I can write very sophisticated applications, or I can write screaming daemons that run circles around other stuff. And I mix the two where needed, too.

      --
      now we need to go OSS in diesel cars
  68. Re:Java numeric libraries by Anonymous Coward · · Score: 3, Interesting

    Sorry. This doesn't really cut it. Note the dates on the website. Its been moribund for about 2-3 years (the unfortunate side effects of downsizing useful government initiatives to fund the military/security complex and tax cuts, but that is another sad story).

    Of the two "numeric" libraries mentioned on the website only one handles complex numbers and the implementation in java leaves much to be desired (relative to assembly or C). To my knowledge, the Lau Numerical libraries based on algol routines are good and probably the most extensive available in java, but there are numerous performance issues relative to FORTRAN and only some are even marginally optimized to run in parallel.

    With the advent of dual core opterons in the near future and the commercialization of grid computing, as a SUNW investor, I'm still hopeful that James Gosling and Sun will step up to the plate here. So far, I haven't seen my fervent hopes come true, but perhaps you know something I don't. If so, I'd love to hear about it.

    Investing aside, this is really unfortunate as 1) I love to program in java, 2) my area of interest is in the application of numeric algorithms for bioimaging and 3) I would like to make better use of such in threaded, object oriented/actionlistener/GUI contexts for which java excels. When one attempts to call numeric libraries to produce actionlisteners attached to dynamic graphics calls, even minor performance penalties can notably degrade graphics performance particularly when matrix sizes that result from even NTSC video resolutions.

    I'm not too thrilled about invoking JNI as there can be a substantial overhead on calling native code such as BLAS from within java (not to mention that it is complicated, even for relatively simple function calls and of course non portable). This also ignores the problems raised about java's floating point representation and its inability to code for addition and multiplication within a single clock cycle as can be done in FORTRAN. Such problems are especially acute when dealing with eigenvalue problems in which the results contain roots with multiplicity and where ill-conditioning can be an issue for iterative solutions. Obviously, 64 bits will help in such circumstances, but its not really a general panacea.

    This is all somewhat off topic, but I am always on the lookout for someone who knows better than I, as I am keen to prove myself wrong (and hence be in the position to write more effective java code).

    It is ironic that Sun has move aggressively to grid computing, but has still not fully address limitations within java's numeric routines. James Gosling made some noises about attending to these defects on the forum you mentioned quite a few years ago, but to my knowledge no real response to the criticisms raised in references to be found via the website you cite. At least none that I am aware of.

  69. Re:What's the flaw again? by nosferatu-man · · Score: 1

    Turning everything into an object in a procedural language like Java would have a tremendous negative impact on performance, since currently there aren't practical optimizations to take care of that. Such a hypothetical language would be an immediate failure, even though it might look ellegant.

    Funny, I seem to have heard of some real, practical languages where every variable is an object.

    --
    To spur "enterprise Linux," Big Bang, the distributed two-phase commit.
  70. Re:James Gosling is an expert in this area by sapgau · · Score: 3, Interesting

    Man, why don't you tell us why you really hate Java.

    No, Java is not suitable (or useful) for what an engineer would call a "critical" application. Those applications are coded in C or C++ (or Assembler).

    I'm using java because that was the business decision made by my boss (or my boss' boss). So I'm just told what I have to do (what interface the user expects, what system I have to connect to, etc.) But for the company I work for, Java might be a critical part of their business plan.

    For example, you won't find java in a heart monitor in the hospital but probably find the server that keeps your health records is done in Java. Whoever is developing the Health record system can (more or less) pass the code to a new developer to continue working on it without expecting the new guy to be an expert on that particular system.

    Anyway, this could all be bullshit if sound coding practices are not follow on ANY language.

  71. Re:What's the flaw again? by takev · · Score: 1

    That is the point of the discussion, if Java is supposed to be fully object-oriented, why are the basic types not objects.

    This is about trying to add and int to a List, why do I need to convert (box) the int to an Integer to add it to the List.

    There are many object oriented languages like Python, where the basic integer is an object.

    I guess Java has int and Integers, because, they copied it from C++ and at the same time disallowing operator overloading.
    They broke the no-operater-overloading-law with Strings, where you can add two Strings (which should be a normal object) together using the + operator. Why haven't they added all the operators for the Integer as well.

    Just some inconsistencies in Java I have always wondered about when I was programming in it. You should try a language like Python, to see how fun a real object-oriented language should feel.

  72. Re:What's the flaw again? by cecom · · Score: 1

    Oh, yeah, that's why they are taking over the world. How many commercial projects (or free for that matter) are written in Ruby, Smalltalk and Eiffel compared to C/C++, Java and now C# ?

    Note: I am not saying they are bad languages. Lisp could be added to the list too (no pun intended). However in order to be really successful, a programming language must combine power with reasonable efficiency (at least for now).

  73. Good programmers vs. bad programmers by Skapare · · Score: 1

    Good programmers can produce good code in any language that doesn't have security holes. Of course they have to be allowed to do so, and not distracted by silly management directives like meeting deadlines. While bad programmers can create massive security holes no matter what language is involed ... and sometimes even deliver these security holes on time. Management just eats it right up.

    --
    now we need to go OSS in diesel cars
  74. I'll take microsofts side for once by David's+Boy+Toy · · Score: 2, Interesting

    Java is way way over hyped, not to mention proprietary.

    You can program C++ using classes such as std::string in a manner similar to the java string class. This eliminates most of the buffer overrun issues that plague many C programs. But unlike java you can bit twiddle when you need to, ideally encapsulating your twiddling in a class.

    Java is simply a straight jacket for programmers, but straight jackets can't prevent logic errors. Your data is still at risk through stupid programming mistakes.

  75. Re:What's the flaw again? by cecom · · Score: 1

    Ahem, in C# everything is an object ??? Excuse me, but that is blatantly false.

  76. Meta Programming by pyrrho · · Score: 1

    I now think that Java represents a belief that object oriented programming is the end point.

    C++ is demonstrating there is a point beyond it in which, as might have been expected if you are Stroustrup, where OOP is just one idiom.

    the point beyond is metaprogramming.

    Java, like Pascal, is based on people taking themselves literally when they say they "have found the proper way to program".

    Not that Java is Bad, mind you, but I'm sick of the Java programmers whining about how bad C++ is, when in fact it's still the leader in supporting whatever the machine can do in the most efficient way reasonably possible.

    --

    -pyrrho

    1. Re:Meta Programming by synx · · Score: 1

      re: meta programming.... aka template metaprogramming...

      my co-worker thinks, and i tend to agree, that template meta-programming is a step in the wrong direction for programming. Using advanced compile time templates to achieve certain things do not improve code readability. And if you say that is not important, then please let me know who you are so I can make sure you never get hired at my work. I also don't like Perl for large projects for this reason as well.

      The things that are possible in a language such as Objective C with Cocoa (The nextstep AppKit/FoundationKit on OS X) are really impressive - it makes you wonder if we really need more compile-time staticism. Being able to dynamically handle the world is a major plus, and template meta programs aren't really giving us the explicit ability to handle run-time dynamicism. You can build a while layer of run-time dynamism, but that doesn't necessarily write my core-project faster.

    2. Re:Meta Programming by pyrrho · · Score: 1

      good point about the readability... I think that people can internalize and thing in a way where types are a kind of variable... but then, the really confusing part is the kinds of errors misusing even simple templates currently yeild in most compilers... but I think the compilers can catch up to that as well and give more sensible warnings. Still, fair point.

      As far as the amazing stuff happening at compile time... well if we could have as efficient a solution to the similar problems at runtime...great,

      But even so that will likely never be as efficient as what you can do at compile time in which much of the indirection or composing simply compiles away.

      Mind you, I'm admitting that this is somewhat obscure at the moment, and that I'm so impressed with some of the tricks I've seen now (calling them "tricks" is admitting something too), such as in the Blitz ++ library, that I am enamored of the potential. I'm not saying it's all ready for prime time or this is the final form... quite the opposite, I think it's just begun... perhaps the promise will play out with dynamic systems.

      I have not programmed in Objective C, or on the Mac for years and years, so I'm not sure what you mean there.

      --

      -pyrrho

  77. no no, not that big by pyrrho · · Score: 1

    a pickup.

    --

    -pyrrho

  78. Give a crook a hammer, and he'll break *Windows* by Anonymous Coward · · Score: 1, Funny

    Duh, I missed the obvious pun.

  79. Come on... by RedHatRebel0 · · Score: 2, Interesting

    I don't like Microsoft just as much as the next Linux user, but come on... Good programmers know how to deal with the problems inherent in C/C++. Not to mention that those problems extending beyond .NET to all C/C++ environments. Besides, why should anyone listen to the anti-C++ rantings of one of the top dogs in Java world. Just remember that today's security is tomorrow vulnerability.

  80. Re:What's the flaw again? by Shazow · · Score: 1

    I have. I've programmed in C, Java and Python, that is why I was wondering what the big deal was. They're all very different languages, I never bothered to compare them.

    I can see the inconsistancies that you're referring to but I guess I just don't question the tool... I use it. :-)

    It does take a few extra lines to convert things occasionally, but I never saw it as such a huge deal, I figured they had a good reason for making things the way they did.

    Thanks for the simplified explination, though.

    - shazow

  81. However.... by TheLink · · Score: 1


    1) The virtual machines are not written by the same people writing the apps. While you might be a better programmer than those writing virtual machines, as Bugtraq shows, the vast bulk of programmers aren't very good at writing C or C++ programs.

    2) Even if there is a vulnerability in the virtual machine, the attacker does not usually have direct access to the virtual machine - the attacker can only go through the app, and the vulnerability might not be able to be exploited.

    3) Often a bug in the VM would be found fairly quickly once it gets used by everyone because it's at a low level - it's like having your CPU not do something correctly. Only the really obscure functionality would be untouched - but if they're mostly untouched they're less likely to be problems in practice.

    4) If there's a security bug in the VM, you only have to fix one thing- the VM and your apps should still work. In contrast fixing C buffer overflows etc for dozens of different programs is not that easy. Multiply that by tons of different apps by thousands of programmers and you should see the magnitude of the problem.

    5) It's an example of specialisation and delegation. Go look up how many vulnerabilities there are in the Perl/Java/Python VMs. There haven't been many announced over the years. The few people who are good at writing VMs write VMs. Those that are crap at programming like me, write in Perl etc and so don't have to deal with keeping track of pointers, allocating enough memory etc, regularly screwing things up so that "an attacker can execute arbitrary code of the attacker's choice".

    --
  82. Managed OS by owlstead · · Score: 1

    Unfortunately Java still has to run on an unmanaged OS. Even though the Java language provides a very nice API to a lot of things, it is not as rich as the Windows API. Microsofts API will become more and more managed when MS releases Longhorn. After that it will become increasingly secure.

    I cannot see ANY similar advancement for Linux or Solaris. The problem with Java is that there is no Java OS. Even worse, there is no default way to handle Java installations or manage libraries (version management). Don't even mention Java web start please.

    A Java programmer who finds it difficult to deploy his standalone applications.

  83. Oh yeah? by letdinosaursdie · · Score: 1

    I claim a huge elegance hole in Java.

  84. Re:If Java is the answer what is the question? by Skapare · · Score: 1

    I do find a few web sites online that have really crappy programming. Various errors occur, ranging from empty content, to corrupted output, to big error messages. The most common programming languages involved (based on the extensions of the filenames) are: ASP and Java. Often these errors happen due to unexpected conditions that just don't get handled properly.

    Java may be able to cover up things like bad programmers leaving buffer overflows in socket I/O. But languages like Java and Perl also make it easier for morons to think they can be programmers. Then we end up with web sites and other applications that just don't do the right things at all. But at least they don't have buffer overflows and they might even have been delivered on time.

    C/C++ certainly has some flaws. But we've known about them for a couple decades; good programmers know what and how to avoid them.

    The real solution is to clean up the ranks of programmers. About 75% of them out there need to find another line of work. I hear Walmart has some openings.

    --
    now we need to go OSS in diesel cars
  85. That hole large enough by Laser+Lou · · Score: 1

    to drive trucks through is called a "bay door." I bet even Sun has bay doors at their offices.

    --
    No data, no cry
  86. Great timing, C has been around a long time by dre+lander · · Score: 1

    The arival of .NET is a funny occasion to suddenly realize that C is a fundamental security risk.

  87. why the big hole? by toocoolforschool · · Score: 1

    because .NET is such a slut.

  88. pots and kettles, you know... by 1nv4d3r · · Score: 3, Funny

    I guess that's why there's no java native interf...

    oh. nevermind.

  89. Yay, more rhetoric from Sun by rabtech · · Score: 3, Informative

    Like we really need more Rhetoric from Sun... but I'll deal with his concerns anyway.

    In order to use "unsafe" code from managed C++ (or unsafe blocks in C#) you must have "FullTrust" security rights, otherwise the code fails to run.

    You could shoot yourself in the foot but the runtime is perfectly capable of detecting and coping with corruption of the managed heap (generally by closing down the offending AppDomain.) Of course you can write a COM component in C++ and call it from dotnet, which is (in effect) the same exact thing! (I dare you to try and stop me from trashing Java or dotnet once I'm loaded in process via JNI or COM...)

    CAS (Code Access Security) means that no other code can call your "unsafe" methods without FullTrust either, so there is no danger from code running off the web of doing this.

    JNI is the same thing, Sun just gets to hide behind the lie since the risks aren't known by or integrated with the platform. At least with unsafe code the runtime is fully aware of that pointer voodoo magic you are trying to pull and can deal with it appropriately.

    In other words Game Developer X can hand-tune the rendering algorithm inside the "unsafe" code areas, but develop the rest of the platform in fully managed code, making the development process much easier to write, test, and debug.

    (As an aside, thanks to the antitrust ruling Microsoft is not allowed to comment on a great many things, including competitors. I don't know if this falls under that heading, but in many cases Microsoft's employees can't just come out and call bullshit when they see it for legal reasons.)

    In conclusion: Sun should shut the hell up.

    --
    Natural != (nontoxic || beneficial)
  90. Re:What's the flaw again? by skraps · · Score: 2, Interesting
    That is just because of the auto-boxing. The CLI specifies primitive types like
    bool, int, uint, int16, uint16, int32, uint32, int64, uint64, char, and byte.
    These are quite distinct from their corresponding boxed types in the System namespace,
    Boolean, IntPtr, UIntPtr, Int16, Uint16, Int32, Uint32, Int64, Uint64, Char, and Byte.
    The "box" and "unbox" CLI instructions allow for the translation between the two sets above. There is nothing automatic about this at the CLI level.

    The reason you've probably never seen it, and the reason your code snippet works, is because C# is smart enough to automatically insert box and unbox instructions where appropriate.

    If you want to prove this to yourself, try reading the ECMA Standard 335, which covers the topic.

    --
    Karma: -2147483648 (Mostly affected by integer overflow)
  91. C programmer deals with it by Earlybird · · Score: 4, Insightful
    • Note that this isn't a particular vulnerability, just a system of typing that makes it easy to introduce vulnerabilities, which last time I checked, all C programmers deal with.

    Yes, CowboyNeal, but do they want to deal with it, and should they deal with it?

    For every programmer who reads security bulletins and keeps tabs on the latest string-copying buffer overflow issues and fundamental security principles, there are a hundred who don't know or care.

    C is a high-level language that:

    • Has direct access to every part of the operating system and executes instructions directly from memory. This means that malicious code can slip into its memory space through buffer overflow exploitations and the like.
    • Is, in almost all cases/operating systems, running with the same capabilities as the logged-in user, which means it has virtually endless power that ranges from formatting your hard drive to infecting other nodes with worms or looking through your email app's address book. It's not limited to the desktop computer of the hapless Windows user, either: Unix daemons running on servers as non-root users can cause serious havoc.

    Programmers want to be productive -- most want to make things make colourful stuff happen on the screen, not fiddle around with buffer guard code. So the more security can be built into the language and its running environment, the better.

    Many languages, such as Python or Ruby, provide security against what I mention in my first bullet, through a virtual machine. They're not impenetrable, and are of course, as dynamic languages, subject to a different class of security holes (eg., string evaluation of code), but they're a step up from the C level.

    Other languages, like Java, provide capability-based security models, allowing for sandbox environments with fine-grained control over what a program may or may not do. Java's security system is ambitious, but since most Java apps run on the server these days, it's not frequently used, and except for browser applets, Java code tend to run unchecked.

    In a way, Java tries to do what the OS should be doing. Programs run on behalf of its human user, and their destructive power is scary. Why should any given program running on my PC have full access to my documents or personal data? As we're entering an age where we have more and smaller programs, and the difference between "my PC" and "the net" is increasingly blurred. Operating systems need to evolve into being able to distinguish between different capabilities it can grant to programs, or processes -- we need to think about our programs as servants that are doing work for us by proxy.

    The same way you wouldn't let a personal servant manage your credit cards, you don't want to let your program do it -- unless, of course, it was a servant (or, following this metaphor, program) hired to deal with credit cards, which introduces the idea of trust. The personal accountant trusts the bank clerk, who trusts the people handling the vault, who trust the people who built the vault, and so on.

    In short, any modern computer system needs to support the notions of delegated powers, and trust.

    Programmers will certainly never stop having to consider vulnerabilities in code. But painstakingly working around pitfalls inherent in one's language, be it C or indeed .NET -- we need to evolve past that. The users, upon whom we exert so much power, certainly deserve it.

  92. Pascal isn't safe either by Unordained · · Score: 3, Interesting

    Why do people think of Pascal as inherently safe? If you want to mess with pointers, it's really rather easy. Stick 'em in a variant (union) record, do your arithmetic against another named integer, and there you go. I mean really ...

    "Object-oriented programming" is ill-defined. It encompasses a lot of languages that go about it in entirely different ways. To me, the most it can mean is "calling functions with an assumed this pointer." What does OO mean to you? Virtuals? What makes it "real"?

    There are benefits to C beyond speed and direct access to memory, hardware, etc. People seem to forget that for us to make software "work together", calling conventions across libraries need to be compatible. Which is why we picked C calling conventions. It's not necessarily the most expressive if you're into fancy things, but it is flexible enough for most everything. My main problem with Java isn't the language -- it's the libraries. Lots of them, packaged in their own special way, not really designed for use by any language.

    Languages, most of the time, aren't the issue. We haven't gained all that many 'new' features with new languages, at least not anything we can't easily live without. Access to symbols is an issue, however, and a really important one from the point of view of integration, code re-use, and even making sure you're using trusted/proven code.

    Regardless of buffer overflows, you can still write infinite loops, incorrect logic, etc. in just about any language. These language wars are about markets -- they're about money.

    1. Re:Pascal isn't safe either by McLoud · · Score: 1
      If you want to mess with pointers, it's really rather easy. Stick 'em in a variant (union) record, do your arithmetic against another named integer, and there you go.
      I can agree that pascal has it's flaws, but this? You will not get any kind of memory problems by using records and variants, unless you are using variant with OLE in some weird combination. Now, if you use the pascal pointes much like you do in C, or you work with arrays with range check turned off, then there you go.
      --
      sign(c14n(envelop(this)), x509)
    2. Re:Pascal isn't safe either by mark_lybarger · · Score: 1

      My main problem with Java isn't the language -- it's the libraries. Lots of them, packaged in their own special way, not really designed for use by any language.

      i don't really follow the point here. yes there's lots of java libraries available today. the java community (or those who prefer to develop robust applications over buggy, unmaintainable code) likes to think of these as tested bits of code. and tested code is golden when it comes to the number of lines of code you need to write. less lines for you means less bugs.

      yes, there's a TON of java libraries, and to learn the API's take time, but that's no different than any other language. my linux system has a TON of libraries. lots of them. packaged in their own special way. not designed for use by any other languages. it's the other languages that have had to find a way to utilize these legacy libraries.

      and to answer your question, to me, object oriented means that the language provides inheritance, encapsulation, and polymorphism.

    3. Re:Pascal isn't safe either by Unordained · · Score: 1

      The fact that you can do this means you can have dangling pointers, access violations, etc. like any other language that supports pointers at all. I'm just pointing out that there are ways of abusing the language. If you use pointers in C correctly, you won't have any problems either. If you use any language correctly, you'll not have any problems. If you use any language even remotely unsafe incorrectly, you can have problems. Most languages are at least slightly unsafe in one way or another; some allow you to turn off error checking, range checking, type checking, etc., sometimes even dynamically, around a single chunk of code, etc.

    4. Re:Pascal isn't safe either by Unordained · · Score: 1

      There was an accepted standard of interoperating across the C calling convention. As long as various languages supported the standard calling convention (there's nothing special about the C one, almost any would do), libraries and code could be re-used (and use each other) without worrying about using whatever language someone else decided on. The bottom line is this: if I want to code in C and you want to code in Java and someone else wanted to use PHP and yet another person wanted to use Fortran or *shudder* Cobol, we shouldn't have to re-implement the libraries every time, we shouldn't have terribly convoluted mapping functionality to gain access to libraries (the JNI isn't exactly pretty) and we really shouldn't have to worry about it much at all.

      The way we do things, our language wars are much more than just language wars: when someone argues for Java, they're also arguing (sometimes without realizing it) for all the already implemented Java libraries vs. libraries available by default in other languages. When you advocate Perl, you're also advocating CPAN. With PHP, you're advocating PEAR. Some of them internally re-use other libraries (particularly ones written in C) but that doesn't guarantee anything. Because of library incompatibilities, when you select a language, you have to do so based on the available code, not just on the language itself.

      When you switch languages because something's easier or quicker or more obvious or readable or whatever in a language X, you shouldn't have to hunt down a whole new set of libraries that may or may not interface with equivalent libraries in the language you were just using, in turn meaning your apps can't (at least not easily) interoperate. So while I try to tell people there's nothing special about coding in C++, that it's not "better" than other languages, just easier for me to use and therefore my preferred tool, the truth is that if I switch languages for a particular chunk of a project, it's an enormous hassle to make things work together, and I'm not willing to deal with that.

      It's vendor lock-in, and we happily go along with it. Sometimes it's just because language designers don't think of this as something they need to support, but in the case of companies like Sun or Microsoft, I think there's more to it.

      It's entirely possible to write maintainable code in a language other than Java, programmers have been doing it for years. From my experience, it depends more on the programmer than the language -- whether or not you're able to think ahead, care about doing so, and do so usefully. And then document what you do, what you didn't do, and why. That's not much to ask, is it? Bugs happen in any language. Why not claim that laws make crimes (or even accidents) not happen?

      For the OO definition: inheritance is vague. It means you keep at least the interface from one other class; it doesn't say whether or not you can get multiple interfaces from other classes, and it doesn't say whether or not you can get implementations of those interfaces from other classes (and if so, how many -- just 1, or several, or always all?).

    5. Re:Pascal isn't safe either by mark_lybarger · · Score: 1

      yes you have to learn new libraries and api's when you switch languages. it's all part of the job.

      i recall many moons ago, working with c programs on a VMS system that called into fortran functions. and fortran into c functions. there were hoops and restrictions both ways. do i pass by reference or pass by value?

      i define inheritance to be where one object inherits properties and functionality from it's parent object . i get my blue eyes and analitical nature from my mom. i could over ride those if i want and perhaps change to hazel eyes if i want. there's other things i inherited from my father, so i would think that inheritance from potentially more than one parent class. for people, we learn the implementations over time, but i would say that implementation is also inherited (but able to be overridden).

  93. Gosling Emacs security holes + spyware + malware! by SimHacker · · Score: 3, Funny

    Gosling Emacs (written by none other than James Gosling) has many HUGE security holes that you can pilot an aircraft carrier through.

    Emacs has a notorious "shell" facility that can actually run a shell and send it arbitrary commands!!!

    In fact, there's even a built-in scripting langauge called "Mocklisp" that enables hackers and viruses to totally reprogram the behavior of the editor (and it looks like Lisp, but without any of those confusing lexical closures and list processing functions).

    Gosling Emacs is actually spyware, because it has a hidden "keyboard macro" facility that can spy on every character you type! Emacs is also malware, because at any point it can instantly undo any editing changes you've made!

    One of the biggest most offensive mistakes is that James Gosling has not fixed these huge security holes in Emacs, after all these years. In fact, many of the security holes have been reimplemented in another notorious piece of communist spyware called Gnu Emacs!

    All Emacs should be banned!!!

    -Don

    --
    Take a look and feel free: http://www.PieMenu.com
  94. Different != Better by EventHorizon · · Score: 3, Insightful

    Incompetence leads to trouble in any language. For instance, a recursive function which does not enforce a recursion limit may:

    - segfault in C
    - throw an unhandled exception in python
    - churn up 2GB swap in java (or something similar)

    In any case, think DoS. The solution is to program competently, regardless of language.

    1. Re:Different != Better by pjt33 · · Score: 1

      It would throw an unhandled exception (StackOverflowException) in Java too, unless you've allocated a stunning amount of stack.

    2. Re:Different != Better by DerWulf · · Score: 1

      - churn up 2GB swap in java (or something similar)
      java.lang.StackOverflowError

      --

      ___
      No power in the 'verse can stop me
    3. Re:Different != Better by slashusrslashbin · · Score: 1

      Point is well made, but just to clarify:

      In Java, at least most common JVMs in use today, the stack will blow first ( just like in C), at the -Xss limit throwing a java.lang.StackOverflowError; if not, the only memory used will be up to the -Xmx limit, by default 64M, although normally more in any significant application, throwing a OutOfMemoryError.

      Because of these Sandbox limits, it is unlikely that a single Java JVM would churn up 2GB of swap, unless you configure it with 2GB more stack than you physically have!

      At University, my favorite way of DoSing my own box, if Mr.Grim Reboot from E.Eng decided to run circuit simulations on it, was to do:

      void main(char** argv, int arg) {
      while(1) {
      int pid = fork();
      malloc(10000000);
      }
      }

      When Mr.G.R. gave up, a little Ctrl-C would bring the box back up.

      Simple. Effective.

    4. Re:Different != Better by Decaff · · Score: 1

      Incompetence leads to trouble in any language. ....
      - churn up 2GB swap in java (or something similar)


      Yes but some languages limit the trouble. Your example of churning up swap in Java is wrong because you can set a limit for memory use with the VM.

    5. Re:Different != Better by jschottm · · Score: 1

      The solution is to program competently, regardless of language.

      Similarly, rather than putting seat belts and airbags in cars we should all just drive competently? I'm an excellent driver, but there's been times I've made mistakes that could have been bad. Everyone has. The same thing can be said for programmers.

    6. Re:Different != Better by aminorex · · Score: 1

      > - churn up 2GB swap in java (or something similar)

      Only if you regard 64MB as being similar to 2GB.
      The stack is limited in Java, by default.

      --
      -I like my women like I like my tea: green-
  95. Re:James Gosling is an expert in this area by Steamboater · · Score: 1

    If you want to eliminate java, please fly out to mars and destroy the rovers... they're running code written in java.

    and kill your 3G cell phone.
    - Bart

  96. "theorem provers" by SimHacker · · Score: 1
    He's just parroting what Gosling has always said about Java, since the time it was named Live Oak. Gosling just likes to write and think of programs as "theorem provers".

    Years before Java, James Gosling wrote a "combination macro-preprocessor and theorem prover" named Ace, which was used to compile the rasterop code in X11/NeWS.

    NeWS supported all 2^4 rasterop codes, but some were MUCH more commonly used than others. So Craig Taylor and James Gosling came up with a way to write huge pyramids of parameterized CPP macros, that could generate small slow code for uncommon rasterops, and big unwrapped fast code for common rasterops and their permutations (like scrolling up and down).

    Eventlly it got out of hand, so for X11/NeWS, Gosling wrote a new C parse tree based macro processor called "ACE", that was more of a "theorem prover" (isn't everything?) than just dumb string replacement like CPP. It could estimate the number of instructions and the speed of the code, and you could advise it how to make the trade-offs in deciding between "fast" and "small" branches of macro expansions. You could write a 2-d raster loop macro several different ways, with alternative ways to expand it, and ACE would decide based on how fast you wanted each raterop variation to run.

    Unfortunately, Java never had a macro facility, let alone a "theorem prover" like ACE. Of couse Lisp macros are more powerful, general purpose, cleaner and better intergrated than ACE. Unfortunately, Java's C-like syntax makes it impossible to design a decent macro facility. So instead of having indecent CPP macros like C, Java has no macros at all.

    The lack of a built-in macro processing facility is one of Java's major weaknesses, which is one reason that Java simply can't hold a candle to Lisp.

    -Don

    --
    Take a look and feel free: http://www.PieMenu.com
  97. Re:The frog choking the bird that is swallowing hi by Bill+Dog · · Score: 1

    Or rather, just STFU and simply wait 10 years, learn from whatever mistakes in .Net's design surface, and then introduce Java#!

    --
    Attention zealots and haters: 00100 00100
  98. it'd dead, Jim by jeif1k · · Score: 1

    The site is indicative of what's happening with Java numerics as a whole: it's dead. It's not that Java isn't fast enough--it is--it's that the language sucks for actually writing numerical code. Writing numerical code in Java is like doing trigonometric calculations in Roman numerals.

  99. Gosling is actually wrong... by Anonymous Coward · · Score: 1, Informative

    You can choose not to allow the unsafe code blocks with security settings. He just hasn't done enough homework to know what he's talking about.

    On top of this, allowing unsafe blocks of C/C++ is a good thing when people are porting to a managed language and need integration. It's pretty amazing that you can set a flag and run your old code in the new environment and call it from C#!

    My impression of him has dropped significantly. Apparently experienced .Net programmers know a heck of a lot more than he does.

  100. Re:What's the flaw again? by guet · · Score: 1

    Ruby on Rails? Datavision? Basecamp? Instiki?

    Take a look at this ad hoc list of Ruby applied. It's a relatively young language, so there aren't as many libraries/apps as something like C or Java, but it's growing.

  101. malloc+free: fast, simple, and can be even faster by nothings · · Score: 4, Informative
    Malloc and free are simple algorithms, and whoever told you otherwise was wrong.

    I don't know where you got your understanding of malloc, and especially free, but it's severely out of date. Knuth published about "Boundary Tags" no later than 1973 (citeseer is down, so no link). Saying that a coalesce operation "can be arbirarily slow" is just FUD. A boundary tag makes free() a fast O(1) operation: check the previous block in memory to see if it's free and if so join, a fast O(1) operation; check the next block in memory to see if it's free and if so coalesce; add free block to free-list, done. Yes, it's not zero work like a GC implementation sort-of is, but "arbitrarily slow"? It's basically at least as fast as malloc().

    Allocation requests can hit disk, sure, but so can GC allocations even if they're just bumping a pointer: it all depends on the working set size. GC compaction can reduce fragmentation to reduce working set size, but that is only a big win if there's a lot of fragmentation, and most apps using a good malloc() don't exhibit that much. (It is also possible for a GC to rearrange memory so more in-working-set data is on pages together, reducing the working set page count without changing the total memory used. I don't know of any in-use implementations of this, since you need hardware support to know what objects are more-in-use; generally this is only available at the page level, where it's no help. I think maybe an early microde-based Smalltalk implementation might have done this.)

    If your malloc has to walk giant free lists to find an open block, then sure, that can be slow. That's why people use trees of free lists based on size and such to make it more O(log N), and O(1) for small allocations. (On large allocations, actually using the memory amortizes the cost.) Read about dlmalloc, for example.

    Furthermore, let's not misrepresent GC. Stop-and-collect GCs have obvious extra costs beyond the free-of-charge free (or lack of need for one). Incremental GCs that don't pause are usually slower overall and only preferred for interactive programs. For example, incremental GCs usually require "write barriers" or "read barriers" which require several extra instruction on every fetch from memory or every write of a pointer variable in memory. This can add up across the entire program. Incremental GCs also tend to be conservative, and only end up collecting things that, say, were garbage at the start of the most recent collection round, and generational collectors allow garbage to collect in later generations for some time, so they don't actually necessarily have a smaller working set than a non-leaky malloc()/free() program.

    Another big win in non-GC systems is that you can use pointers that don't come off the heap. That way you can avoid allocation and deallocation and GC entirely. (You can actually do some of this in a GC system too if it's a 'conservative' GC that copes with pointers into the middle of blocks. Those pretty much only get used for adding GC to C and C++, though.) Here are some common ways this happens:

    • statically allocated arrays
    • small arrays and strcts on the stack
    • structs that are components of other structs, or arrays at the end of structs
    • use of special allocators:
      • slab allocators (it's even possible to embed this entirely inside the default allocator for all small allocations)
      • pool allocators (allocate a large block of memory, suballocate from it, deallocate all at once)
      • "stack" allocators (allocate a large block of memory, suballocate from one end, only allow freeing from the same end, so allocation is a adding to a pointer and deallocation is reseting that pointer)

    Of course, doing all these things requires that you balance your different types of malloc()s with the correct, matching type of free(). In practice, GC proponents overestimate the diffi

  102. Re:James Gosling is an expert in this area by reflective+recursion · · Score: 2, Insightful

    i was thinking more along the lines of Lisp or Scheme. please do your own research, I really don't have time to school a newbie. Java is nothing new. Hell, even pascal had P-code. Welcome to the 1980s and prior. GC is some new technology according to Java people.. what a fucking joke.

    --
    Dijkstra Considered Dead
  103. Rule for selecting programming language: by notany · · Score: 3, Insightful
    Good architect will know how to choose tools to match the problem. (If you can't, either you are not educated or you are code slave)

    Rule:

    If you don't need to spend 5-10% of your development time to speed/size optimizing your program to make it useable, you are not using language/abstractions that is high level enough to your task.

    Explanation:

    If I use high level languge (say Haskell/OCaml/Clean/Common Lisp) and use all it's abstarction powers, program code will usually be 10-50% of the size compared to same program written in C/C++ (and Even Java). Now that X% (50-90%) of slack will take X% of development time and contain X% of the bugs. It will make the program much harder to change too. You can see that the 5-10% spent into optimization (you can even write the fast parts in C if you like) will pay.

    If you don't belive, compare code of gnu-arch arch to darcs. Both are similar version control systems.

    --
    Dyslexics have more fnu.
  104. The sad thing is by Sycraft-fu · · Score: 1

    This actually as happened kind of close to what you are thinking. Nails, apparantly, have been decided to be not safe enough for many tasks in home construction. They've been replaced with screws. Now if you've done any kind of construction, you know that a screw does indeed hold much better than a nail. Great, but it's damn overkill. Nails work FINE and have been working fine for centuries.

    Building codes actually have been heading towards this redicilous safety level where everything has to be overspec'd. My parents built a new house receantly and it was just amazing the stupid features that had to be added to meet code. Things that make no difference, things that do not exist on almost all houses in the US (being that most houses are used not new), nevermind the world.

    It wouldn't supprise me if they started requiring padded walls and floors so peopel can't accidentally bump themselves and get hurt :P.

  105. Screwed. by TapeCutter · · Score: 1

    Did you ever contemplate that it could be because of the predominance of softwood framing or in some cases stronger joints mean less framing. Walls used to be 3' thick and solid because they didn't know how else to hold up a roof. Also roof trusses are now made to order in factories so need to hold up to transport.

    Why use softwood? - The good stuff has been mowed down and what is left is snapped up for exposed or decorative uses.

    --
    And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
  106. Gosling... by im_thatoneguy · · Score: 1

    Gosling went on to say that programming on computers was far too large of a security hole and that the human brain would be the future realm of Java's "multi-platform" strategy.

  107. No C code is insecure by RedLaggedTeut · · Score: 1
    Its not C/C++ code that is insecure.

    Its the resulting assembly.

    No, it is the C code itself. It would also be insecure if you ran it on a C interpreter, although exploits might work differently.

    I wouldn't say C++ is insecure by design, since C++ at least allows you to "easily" add high-level data management constructs to the language, so that means at least in C++ you can write safer code, if you want.

    C is not safe because it does not allow safe string and vector types, and you cannot even add these without either sacrificing speed or writing weird code.

    I don't even want to go into how you can cast any pointer into anything you want.

    btw. How secure is Goslings emacs operating system shell ? ;-)

    --
    I'm still trying to figure out what people mean by 'social skills' here.
  108. Re:Java numeric libraries by bblfish · · Score: 1

    I am not a numerics person but I found this book:

    A Numerical Library in Java for Scientists and Engineers
    by Hang T. Lau
    Champal & Hall/CRC
    ISBN-1-58488-430-4

    It looks pretty interesting.

  109. Re:What's the flaw again? by toriver · · Score: 1

    That would be nice if it were possible. Unfortunately, it isn't (at least on a practical scale, esp. considering that we seem to be at the end of Moore's law).

    Actually, it would, but the implementation would be responsible for deducing that they were arrays and what type, instead of overloading with the types as they do now.

    Witness System.arrayCopy() which does take Object arguments instead of using overloading.

  110. he would say that, wouldn't he? by kraut · · Score: 1

    If we all believed James Gosling, we would all be writing everything only in Java, We would have rewritten everything in Java. There would be no more software flaws. No more security problems, No more world hunger. Pigs would fly past our windows.

    --
    no taxation without representation!
  111. As usual, missing the real point by 192939495969798999 · · Score: 1

    The real point here is not that C is bad or C++ is bad, but that since Microsoft is using the same device to compile C/C++/Java/VB in .Net, then the .Net engine itself could have flaws no matter what "language" you're using, JUST BECAUSE it has to support C/C++.

    --
    stuff |
  112. Re:malloc+free: fast, simple, and can be even fast by hanwen · · Score: 1
    For example, incremental GCs usually require "write barriers" or "read barriers" which require several extra instruction on every fetch from memory or every write of a pointer variable in memory.

    I'm not a GC expert, but I think this is not universally true, in the sense that you can use the MMU hardware to trap writes.

    --

    Han-Wen Nienhuys -- LilyPond

  113. Re:malloc+free: fast, simple, and can be even fast by JoeNotCharles · · Score: 1

    I'm not a GC expert, but I think this is not universally true, in the sense that you can use the MMU hardware to trap writes.

    Triggering a page fault that has to be passed to a user handler (which is what my textbook recommends - I haven't looked at this outside of that one course) is still slow. Slower than the alternative, which is to do nothing, at least.

  114. Tying security model to prog. languages is wrong by master_p · · Score: 1

    There are many reasons for this:

    1) if the security model changes, the language (run-time environment, compilers) and programs need to be updated.

    2) if there is a security flaw, it affects every program written with the language; remember the Java class loader problem?

    It is quite feasible to write straight C/assembly and be totally secure, as the Unix example shows us. Security has nothing to do with programming languages.

    The direction taken with .NET is totally mistaken, because .NET is effectively an operating system inside an operating system. .NET is a sandbox for .NET programs, while Windows is a sandbox for Windows programs. It's a wasted effort. Of course, C# might be a better C++, but that does not make the excuse of a sandbox inside a sandbox. C# could happily be a simple and plain programming language. Source-level compatibility is enough, as the Unix model proves (and Java programs are not totally portable, especially if path references are hardcoded).

  115. Earth to CowboyNeal by p3d0 · · Score: 1
    The blurb says: Java creator James Gosling this week called Microsoft's decision to support C and C++ in the common language runtime in .NET one of the 'biggest and most offensive mistakes that they could have made.'

    CowboyNeal says: Note that this isn't a particular vulnerability, just a system of typing that makes it easy to introduce vulnerabilities, which last time I checked, all C programmers deal with.

    That's the point, genius. By making the .NET platform support C, they get the problems that all C programmers deal with. Java doesn't have those problems.

    --
    Patrick Doyle
    I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
  116. Re:What's the flaw again? by Thomas+Miconi · · Score: 1

    It's ugly and non-orthoganal. Look at the Arrays class for example; there are dozens of duplicated methods that are identical except that they take bytes, chars, shorts, ints, etc. as arguments. I'd much rather have everything be a true object

    Than you'd be using the ArrayList class, which can store any object (including Integer, Float, etc), and has the same capacities.

    ArrayList is the standard, basic Java collection class. The Arrays class is a utility class, as can be seen from the fact that all methods are static. It can be seen as a set of utilities for independent arrays of primitive types, but there's no need to use any such array. It's just there to help if you absolutely want to.

    Thomas-

  117. Java has many potential drawbacks for numerics by Anonymous+Brave+Guy · · Score: 2, Interesting

    Java has several pretty fundamental disadvantages when it comes to serious numerical work, compared to a language like C or C++.

    The most obvious is the "everything is an object" principle. If you can't create value types for things like vectors or complex numbers, you're imposing performance overheads for dereferencing before you even start doing any maths.

    Moreover, serious maths work often involves large data sets. We work with graphs with many thousands of nodes pretty routinely, which can make fine control of how much memory each node occupies very important even on powerful workstations with lots of RAM. When you're constrained to do everything using indirection and using a limited set of primitive types, this is difficult to impossible.

    Then of course there's Java's floating point requirements, which were technically impossible to meet for a long time IIRC. I'm not sure whether they've been fixed even today, but certainly if you require a VM to do a manual series expansion to calculate trigonometric functions according to your strict requirements, while everyone else is using a single FPU instruction and getting an answer that is either identical or off by one in the last binary place, you are not going to be winning in the performance stakes.

    The bottom line is that the same things that are strengths for safety/security in general applications -- lack of low-level control and banning dangerous primitive constructs -- can be huge weaknesses when those are necessary to achieve an acceptable result in the real world.

    Despite Sun's propaganda, I suspect C and C++ are still considerably more portable than Java. I don't know how you managed to get code only compiling on one machine on one platform. We routinely build our code on something like 15 different compiler/platform combinations, with many more having come and gone in the past, and anything not building on any platform is usually an old compiler failing to support a standard feature properly so we rewrite that code to work around the problem. Java's "perfectly portable" floating point requirements might be an advantage in this area -- we do occasionally see very minor discrepancies in the outputs on different platforms -- but I don't see Java as an advantage for actually compiling your code across different platforms.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Java has many potential drawbacks for numerics by matfud · · Score: 1

      Java is not the be-all end-all of protable programng languages but in general is does allow you to write code that is more portable.

      You ahve already touched on one of the differences. Java does guarentee you the same numerical answer on all platforms (if you use strictfp). This can really become a problem if doing simulation where errors have a nasty tendancy to accumulate). Trig functions vary greatly in the accuray of the results they return. In C/C++ this can often be worked around unsing compiler flags but they introduce the same overhead that javas trig functions do (although java does now have two sets of trig functions. One set is guranteed to produce the same results and one set is used for performance).

      Another difference is realted to the memeory/threading model that the Java memeory model defines. This is of vital importance if you are writing multi-threaded programs. It provides a baseline of requirements that must be supplied by the VM. In C/C++ this does not exist. Niether spec defines the way that multi-threaded code interacts. It's all left to third party theading libs/OS primatives. Even if you choose the same library its behaviour can often differ on different hardware.

      Just a few of the things I noticed when coding C and Java.

      matfud

    2. Re:Java has many potential drawbacks for numerics by brunos · · Score: 1

      True, Java does have all these disadvantages, whereas C++ has many many advantages. And yes, C++ is very portable across platforms, however heavily optimized code that uses fancy C++ / Compiler features does take some effort to port; particularly when you "inherit" code. A lot of code I have to deal with relies on many libraries, it in not always obvious to track all the dependencies, header files, maybe some inline assembly, threading, graphic libraries, etc. It does take some effort. Even getting a basic application that I built a few years ago on Linux, OpenGL, QT, Blitz; took a bit of playing about, installing the old libraries, recompiling them etc. The exact same application in Java + Java3D is twice as slow, but ran right away. But without a decent numeric library I think it might be quite an effort to make a real numeric application in java even if in some cases extreme performance is not an issue.

    3. Re:Java has many potential drawbacks for numerics by Jagasian · · Score: 1

      It is simply not true that Java's memory and thread handling is the same on all platforms. Some platforms implement different scheduling algorithms and last time I checked, some don't even implement true preemptive scheduling. Hence if a thread doesn't explicitly sleep or yield, then all other threads get starved! How is that for portability? On one platform your program would work, on another it won't even redraw the GUI.

      Then there are the garbage handling platform differences. Let me ask you this, if the programmer cannot depend on an object's finalizer being called, then why include a finalizer at all? In addition, extremely important things must often be accomplished in a finalizer. So again, another significant example of platform differences. Even better, an object can save itself from being collected in its finalizer, and if it does so, then the Java standard guarantees that the finalizer will never be called again. Yup, a finalizer will never be called more than once, but it might not be called at all. Great standard behavior. Not standard where it counts and standard where it hurts.

    4. Re:Java has many potential drawbacks for numerics by matfud · · Score: 1

      If you read the specification for java's memory model then you would find that it explicitly does not specify scheduling algorithms and it is correct not to do so as it could heavliy impact performance on some hardware/OS combinations. It provides a minimum set of requirements that must be met. If you code to the specification you will not have any problems related to scheduling. But then again if you don't read the spec and just assume that the threading model is preemptive you have no one to blame but yourself.

      Garbage collection is transparent. Its implementation does not affect your code in any way. (apart from the length of time it takes to perform the GC)

      As for finalizers the less said about them the better. They are basically a very bad implementation of an occasionally necessary function. And they arn't quite as bad as you make out. They are not gaurenteed to run only because the VM cannot ensure they are run in the presence of a vm error/forced shutdown. My advise is "don't use them" they are nasty.

      matfud

  118. Does anyone actually use .NET? by nogginthenog · · Score: 1

    No really. I have only 1 program that uses .NET. I have to say I'm not that impressed with it (though I accept this could be a problem with the program rather than .NET itself). This program I use at work only - the .NET framework is not installed at home as I have no need for it.

  119. Re:What's the flaw again? by cecom · · Score: 1

    Thanks for this reply.

    I've been wondering myself what essential properties distinguish an object from a primitive value. If it looks and smells like an object syntactically, then surely it must be an object (doens't matter how it is implemented)?

    C#'s primitives clearly aren't objects (they don't live in the heap, etc), however if you can refer to them as one, then they as well might be from the language standpoint. The question is with the automatic boxing do they mimic real objects in all aspects ?

    I think the answer is no. They fail in one very important aspect. You can box a primitive variable , creating an object copy of it, however if the variable is modified the copy will not change.

  120. Re:What's the flaw again? by cecom · · Score: 1

    Can you clarify ?

  121. Re:What's the flaw again? by skraps · · Score: 1
    Good observation, but that is also true of anything that derives from ValueType. DateTime, for example, also has that characteristic.

    You could use that fact to argue that primitives do not, in fact, destroy C#'s pureness, since they are semantically indistinguishable from ValueType's (I think).

    OR, you could argue that the existence of ValueType by itself destroys the 'pureness' of C#. ValueType does require special support from the runtime to achieve its tricks. It's impossible to write your own class, in any dotnet language, that does what ValueType does.

    --
    Karma: -2147483648 (Mostly affected by integer overflow)
  122. Spin by Random+Hacker · · Score: 1
    Gosling:
    C++ allowed you to do arbitrary casting, arbitrary adding of images and pointers, and converting them back and forth between pointers in a very, very unstructured way.

    Note the use of the past tense, "allowed", rather than the present tense, "allow". The clear implication being that C++ and C are obselete languates that no one writes in anymore.

  123. Re:Java numeric libraries by matfud · · Score: 1

    Java does have some performance problems related to numerical computing. Primarily this is due to its cross platfrom nature. In java you are guarenteed to get the same answer on every platform, irrespective of the hardware FP unit. C, C++, Fortran do dot make that gauratee. FP units do produce different results for the same operation (especially trig functions) (The major one is how much accuracy is used for intermediate results in the hardware) and because of this java often has to emulate math functions to get the result you expect.

    If you are not interested in cross platform usage and you know exactly what your processor does for all fp operations then you can do without java. (Note many hardware platforms are now complying to international standards for fp (properly rather then the half arsed attempts made in the past))

    In general JVM's are not optimized to compile byte code to processor extensions such as MMX/SIMD/Altevec. They could, to a limited degree, be implemented to do this. They currently are not.

    Most languages cannot compete (performance wise) with fortran for numerical routines. Much of this is due to the structure of the language which allows compilers to optimise well and produce very performant machine code. Also this is partly due to the sheer amount of time the routines ahve been around and the amount of manual optimization put into them. This is good if you want the ultimate in performance.

    Right thats some of the arguments. Figure out what your need and make your choice. (preferably after researching even more before making your decision)

    matfud

  124. Re:malloc+free: fast, simple, and can be even fast by nothings · · Score: 1
    The survey (or two?) I've read on the subject said this did not perform competitively with other techniques. The granularity of information is kind of poor.

    It also doesn't help with the problem of detecting stores of new pointers into old objects for generational collection.

  125. Re:James Gosling is an expert in this area by matfud · · Score: 1

    Yes GC is an old concept but that does not mean it is static. There is a lot of research in GC techniques and optimisations. Its a changing field and producing improvements all the time.

  126. Why C++ on .NET is right for security by Herb+Sutter · · Score: 1
    I think he's highlighting that security is a genuine concern (which is good), but he seems to be misinformed about how C++ is actually supported on .NET. If the situation were what the article seems to indicate, I'd be concerned too.

    Fortunately, it's not. Maybe I can provide some more context about my design so that he can see how this is a choice that makes the world more, not less, secure.

    You can and should write perfectly verifiable code in C++ targeting .NET, perfectly safe code where you're not allowed to use those dangerous casts, etc. It's called

    /clr:safe
    and it's encouraged. And writing verifiable C++ code means a lot more than just writing C# code in C++ syntax (though you can do just that if you like) -- you also get to use templates and automatic destructors and other major C++ power features safely and verifiably.

    For example, consider one of those other C++ power features: STL. Of course, the plain native STL isn't bounds-checked or verifiable. But we also provide a complete STL/CLR library (previously also called STL.NET) which is fully verifiable. STL/CLR is a library that brings all of C++'s familiar containers, iterators, and algorithms straight to the managed world with full interoperability with the CLI container interfaces. This is what you can do (only) in a language that supports both templates and generics: Have a template, like stdcli::vector, that implements a generic interface, like IList. You can use it as a vector (it is one); code that uses a std::vector today can work seamlessly with a stdcli::vector. You can use it as an IList (it is that, too); C# and VB (and C++) code can happily foreach on it.

    And I think I already mentioned this is all completely safe and verifiable.

    STL/CLR is an example of how C++ on .NET really brings together the best of both worlds, with no compromises: C++ code gets its usual full STL style of programming and full template specialization and everything else that makes the Standard C++ language and library so powerful. And you can still take one of those container objects and pass it directly to a C# or VB app that can use it naturally. It's safe.

    Sure, you can also explicitly disable safe mode and write/call unsafe code too if you want -- in any language. That's not specific to C++; you can do that with C# unsafe and Java JNI. If it's immoral to call into unsafe code when you need to, why does C# have unsafe, and why does Java have JNI?

    One thing this discussion does underscore, though, is the design choice difference between the JVM's "one language" and the CLR's "many languages." There's a lot of C++ code out there. Which is better for security -- to ignore that code and tell people to throw it all away because tossing it is good for them, or to give C++ developers an easier migration to take their existing valuable code and make it also be safe and verifiable?

    For those interested in some more details, I've written about a number of these issues on my blog.

    Cheers,

    Herb

  127. Isn't Java or parts of it written in C/C++? by bXTr · · Score: 2, Insightful

    Talk about not eating your own dogfood?

    --
    It's a very dark ride.
  128. Re:What's the flaw again? by toriver · · Score: 1

    Basically, System.arraycopy() takes Object arguments. Every array in Java is an Object, that's why this works. System.arraycopy() is normally implemented in native code to just binary copy that part of the heap, so it doesn't bother with "types" and stuff like that.

    Arrays.sort() and friends, however, are implemented in Java, and need to know the array element types. Whether you should have one method which takes the array as an Object and deduces internally, or you use overloading per array type is an implementation issue. Using overloading means you don't need a cast inside the method, which is nice to avoid.

    But the essence is: An array is an Object.

  129. Still don't get it huh. by TapeCutter · · Score: 1


    "No it isn't. The P-Code for Java is the way that Java apps are distributed, but on almost all VMs it is translated to pure and optimised native code. This is nothing like the 70s situation at all.

    All that has been done here has been enabled by faster machines, the basic concept is still the same. Java still has to spend time translating and optimising the P-Code during run-time. Java is much quicker than a P-CODE interpreter but it still takes time to do stuff at run-time, native apps do this at compile time. Any "security" checking, no matter what the language, will eat up instructions.

    "That is not the reason at all! The vast majority of this code is in C for historical reasons."

    HoHoHeHeHaHa, you seriously think we should write operating systems and device drivers in Java? Wrong tool for the job, the reason they were, and still are, written in C is because assembly language takes way too much time. The reason people write apps in Java is because it takes way too much time in C for the same portability and security.

    --
    And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    1. Re:Still don't get it huh. by Decaff · · Score: 1

      Java is much quicker than a P-CODE interpreter but it still takes time to do stuff at run-time, native apps do this at compile time. Any "security" checking, no matter what the language, will eat up instructions.

      Yes, but the way most modern Java systems work is to run the compilation as a background thread. This allows the program to get started immediately and then this thread performs tasks such as code analysis to allow security checking to be optimised out in many cases, then it profiles the application to produce very highly optimised machine code (even to the extent of re-ordering instructions to suit the pipeline structure of specific processors). The whole system has been very highly tuned to avoid noticeable delay for the user.

      why not take a look at Sun's Java site and check out the white papers on Hotspot technology? You'll see its a pretty awesome process.

      HoHoHeHeHaHa, you seriously think we should write operating systems and device drivers in Java?

      It has already been done: JJos.

      Java is just a language. There is no reason why it shouldn't be used almost everywhere that C is. It doesn't even have to be interpreted - there are plenty of compilers around if that is what you prefer.

    2. Re:Still don't get it huh. by TapeCutter · · Score: 1

      I kinda think we are on the same side. However my original point was Java takes extra time (even though small, like an extra thread). I agree that "Java is just a language." and readily admit I am not totally up to date with all the latest implementations.

      I think the 2 strengths of Java are security and portability. Portability is pretty good in vanilla "C" provided the programmer is aware of O/S differences but security is left as an excercise for the programmer. That leaves me thinking that security is the most important plus that Java has over "C". In either language security costs cycles. In "C" you have the option to skip on checks not implemented by the O/S (or sometimes even edit the kernel).

      If you don't give a shit about security (closed system) and want to sqeeze every cycle from the cpu C (with a bit of inline ASM if need be) is stronger than Java. Another plus for C is the defacto-standard thing, for whatever reason windows & *nix are written in C.

      Having said all that I think a Java based O/S for general purpose and commercial use is a good idea and would automatically solve some big headaches with "open system" C based O/S's. In practice it would mean vendors would have to re-write thier apps rather than simply port them to the "next level" and legacy apps go in the bin. When you consider the investment in existing C code I think a "Java only" O/S is going to be a very hard sell.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    3. Re:Still don't get it huh. by Decaff · · Score: 1

      If you don't give a shit about security (closed system) and want to sqeeze every cycle from the cpu C (with a bit of inline ASM if need be) is stronger than Java.

      A few years ago I would definitely have agreed, but now I have changed my mind. It seems that the Sun Java Hotspot system is basically an expert system for generating machine code for whatever processor you are on. It does a phenomenal amount of work profiling and fine-tuning the generated machine code. I honestly think that in a few years it will be able to do far better than any pre-compiled C with hand-coded assembler added.

      Another plus for C is the defacto-standard thing, for whatever reason windows & *nix are written in C.

      Heh, things are definitely better these days, but when I was coding C even 10 years ago, the amount of conditional code I had to include to deal with processors and compilers was considerable. (I even had problems with different versions of gcc).

      The Java OS was a proof of concept, and probably not practical, but I really think the way forward is virtual machines almost everywhere.. eventually!

  130. Gosling, FUD. by tjstork · · Score: 1

    The use of unmanaged code in .NET is unsafe, but, .NET itself has a security policy system which checks to see if unsafe code is actually used. So, Gosling

    Using the import attribute to talk to a Windows DLL, that code is automatically unsafe. Link with a C++ library and wrap it using the "IJW" managed / unmanaged bridging in C++ for .NET, is also unsafe. Using the "unsafe" keyword and pointers within C# is also unsafe. Also, since .NET 1.0 SP3, using the compiler services to generate code is also unsafe.

    All unsafe code is trapped by the .NET runtime system, which checks security permissions for that application. You cannot ship an unsafe application without the explicitly allowing unsafe content to execute. Unsafe applications cannot be run off of a network drive, nor can they be run off of a web page.

    Gosling is a super programmer, and, as the inventor of Java, made popular the idea of virtual machines.

    --
    This is my sig.
  131. Re:James Gosling is an expert in this area by reflective+recursion · · Score: 1

    you assume i don't know this. or think it is relevant to what i am saying about Gosling's NIH. neither is the case.

    --
    Dijkstra Considered Dead
  132. MS makes things more OPEN and still complaints? by milette · · Score: 1

    I would have thought that the 'NIX crowd would be jumping up and down for joy with this revelation.

    For years, you've all been whining and crying about how MS is 'proprietary this and 'closed that -- nad now when they DO decide to open up the CLR with ADDITIONAL language support - now you're whining about security? Gimme a break!

    Until now, the CLR in .NET has supported just C#, VB.NET as the main development languages. However, the way the CLR was MEANT to evolve and be open OPEN to the addition of new native language support.

    Yes folks -- PERL.NET, PHP.NET -- and even, (god forbid) Fortran.NET, or COBOL.NET could be seen someday soon.

    The support of C and C++ does nothing but open the door for people who otherwise would not have access to the .NET platform. Is the word OPEN suddenly causing you fear because it happens to be related to something MS did (this time)? :)

    Java dudes -- stick to the sandbox where you won't get hurt -- bury your heads in the sand if you want -- but don't block the road for people who WANT the power and speed of C, C++ and C#. (I run with knives too -- AND LIKE IT! :)

  133. Gosling is right, but Java has the same problem by DavidHopwood · · Score: 3, Interesting

    .NET and Java are both insecure, because they both rely on too much code written in unsafe languages.

    If you want to implement a system based on language-level security using a mixture of code in safe and unsafe languages, as little as possible of the system must be written in the unsafe language(s), and that part must be treated as being in the system TCB.

    Some unsafe code is unavoidable if you want the system to be able to use OS facilities on Windows and Unix. However, it must be written by people who know how to write secure code, and gone over with a fine-tooth comb for possible weaknesses.

    It is completely disingenuous for either Microsoft or Sun to claim that these platforms are secure, given that their implementations depend on millions of lines of unsafe-language code that no-one is ever going to review properly. Even more so since both .NET and Java allow any arbitrary application to load unsafe code.

    So basically, Gosling's argument is correct: .NET will never be secure with its current architecture. Neither will Java. I am personally convinced that language-based security can be made to work (using a capability security model), but not the way Microsoft or Sun are doing it.

  134. Probably - but ... by krischik · · Score: 1

    True, Java is unlikely to be self hosted. But you should remember that compiler desiners are top programmers while majority of programmers are only average (its after all the definition of "average").

    And here lies the fundametal problem of modern software development - C/C++ are to difficult for the average programmerer - still there are the most used languages.

    You don't agree? I give you an example. A programming language for average programmers should not compile the following code:

    int X [10];
    X [10] = 1;

    Or if it does compile a runtime exeption should be raised. You think everybody would spot that? Well how about:

    int X [10];
    int Y; // // 100 Lines code with lot's of if () and for () and an enourmous switch () //
    Y = 10; // // 100 Lines futher code with more if () and for () // and an another enourmous switch () //
    X [Y] = 1;

    The is a statistic that the average Ada programmer spends only 1/10th of its time with a debugger when compared to the average C programmer.

    Martin

  135. Basic security should be provided. by krischik · · Score: 1

    It is quite feasible to write straight C/assembly and be totally secure,
    as the Unix example shows us. Security has nothing to do with
    programming languages.

    But they are not. At least twice a week I get a security update from SuSE. Usualy a buffer overrun and sometimes an integer overrun.

    Now if you think that Algol 60 (yep 1960!) has build in buffer overrun protection it make you wonder. All those update would not be needed when a language was used which provided basic security features.

    And indeed the Boing 7E7 Dreamliner Software in witten in Ada - which has both build in buffer overrun and build in integer overrun protection. And guess what: The Airbus uses Ada as well.

    Martin

    1. Re:Basic security should be provided. by master_p · · Score: 1

      Would you have a buffer overrun problem if the stack wasn't executable? you wouldn't.

      And writing software in ADA does not help if you need to access O/S functions written in C/assembly.

    2. Re:Basic security should be provided. by krischik · · Score: 1

      Well, I guess you nevel looked over you C fence - otherwise you would know better. Maybe you want to read a little about Ada (http://en.wikibooks.org/wiki/Programming:Ada:Tuto rials) before making false claims.

      At least you should know it that the language is spelled Ada - after Augusta Ada King, Countess of Lovelace (http://en.wikipedia.org/wiki/Ada_Lovelace).

      You see, Ada programers are different. When other programmers choose a cammel or a snake as there symbol we have choosen a woman :-) .

      Anyway, to answer/correct your statemens:

      To 1)

      Not all buffers are on the stack - there is heap memory and static memory as well. Besides "Denail of Service" attacks don't need executable memory - they just need to overwrite memory to make the programm crash.

      And the new JPEC viruses use interger range overruns.

      Not to forget: "Denail of Service" on a Airbus 380 means 500 coffins. Don't you think that Airbus checks twice before choose a programming language. Did they choose C? - No, they did not!

      To 2)

      You might want to read about Ada's Interfaces.C and System.Mashine_Code packages. Ada was designed to get rockets into space and keep planes in the air. Of corse it can do all the low level system progamming stuff. Actualy much better then C. I have done many years of C programming - I know.

      Martin

  136. sure glad no Sun software is written in C++ by peter303 · · Score: 1

    Or else it might have that security hole too.

  137. Re:Java numeric libraries by Jagasian · · Score: 1

    Java guarentees that your program calculates the same result on every platform? Then why is thread scheduling platform and even JVM dependent? Why is garbage collection platform and even JVM dependent? If you are supposed to write code that doesn't depend on thread or garbage handling differences, then the same can be said for languages like C or Fortran, where you are not supposed to write code that depends on endian or floating point differences and hence C and Fortran are also cross platform.

    The truth is that Java simply doesn't take advantage of platform specific optimizations, while other languages do. This is a drawback to Java in its current state. Nothing is stopping somebody from writing a better Java compiler... but then I could have said that back in 1995 too.

  138. Re:James Gosling is an expert in this area by Jagasian · · Score: 1

    The problem is that the garbage collection methods used by Java are over 25 years old!

  139. He's just a lousy promoter. by Doc+Ruby · · Score: 1

    He's right, but this kerfuffle is blown out of proportion. He's only banging the original "safety" features of Java really hard. C/C++ is less safe than Java, which is a feature to many programmers who want more freedom in what they execute - risk takers. But since most people never change their defaults, even security constraints in .NET that could stop unsafe C/C++ code are rarely applied. That contributes to the lower safety. This is the basic impetus for Java itself, universally accepted. The only controversy here results from Sun's loss of Kim Polese, who masterminded the Java launch marketing, successfully communicating the advantages of code safety, even before it was a daily headline issue. Gosling is very well informed, and quite smart - as is obvious. When you start thinking that a bunch of .NET programmers are a lot smarter than him, you should examine your premises.

    --

    --
    make install -not war

  140. Give a man a gun,... by hummassa · · Score: 1

    and give him a pencil and he'll kill much more people. Reference: George W. Bush. All depends on which pencil.

    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
  141. Re:Java numeric libraries by matfud · · Score: 1

    As I said in another reply to you thread scheduling and garbage collection do not alter the results produced by your code.

    The threading model provided by java works as advertised. If you did not take the time to RTFM then its your own fault you got bit.

    And as I have said before java can and does take advantage of platform specific optimisations. VM's are capable of compiling bytecode to machine code (after security checks have been performed)

    But all of that is pretty much beside the point. Java is popular is areas where you need a language that tries fairly hard to protect developers from themselves. Its not as powerful as C/C++ but with power comes responsibilty and the increased chance of doing something really nasty. It does not matter if you think that java is faster/slower then language x, it has its place.

    The code I write is complex (there is lots of it) and using a language that can stop anyone on the development team from making stupid mistakes is a win for us. It is also a win for our customers as they end up with products that are more reliable. Yes they still have bugs but those bugs do not crash the servers (web servers/app servers that is). This means more reliability for them.