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.

107 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 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).

    2. 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.
    3. Re:Phew! by DrLZRDMN · · Score: 3, Informative

      Id like to see a kernel written in either language.

    4. 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.
    5. 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
    6. 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.

    7. 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.

    8. 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.
    9. 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.

    10. 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.

    11. 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").

    12. 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.
    13. 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.
    14. 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.

    15. 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?

    16. 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.

    17. 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.

    18. 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.

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

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

    20. Re:Phew! by andreyw · · Score: 2, Insightful

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

    21. 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,"

    22. 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!
    23. 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!
    24. 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.
    25. 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
    26. 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.
    27. 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.

  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 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.]
    4. 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.

    5. 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?

    6. 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/
    7. 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.

    8. 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.

    9. 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.

    10. 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.

    11. 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.
    12. 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.
    13. 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.

    14. 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.

    15. 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.

    16. 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/

    17. 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...
    18. 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,"

    19. 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,"

    20. 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.
    21. 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.

    22. 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...
  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.

  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!
  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.

  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 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.

  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 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.

    2. 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

    3. 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.
    4. 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
    5. 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.
    6. 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.
    7. 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).

    8. 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.

    9. 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.

    10. 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.

    11. 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."

  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 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.

  12. 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?

  13. Someone should tell by ahdeoz · · Score: 2, Insightful

    Gosling that Java is inherently insecure, as it is written in C.

  14. 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 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
  15. 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.

  16. 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

  17. 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
  18. 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).

  19. 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
  20. 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.
  21. 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.
  22. 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...

  23. 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.

  24. 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.

  25. 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.

  26. 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.

  27. 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.

  28. 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.

  29. pots and kettles, you know... by 1nv4d3r · · Score: 3, Funny

    I guess that's why there's no java native interf...

    oh. nevermind.

  30. 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)
  31. 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)
  32. 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.

  33. 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.

  34. 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
  35. 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.

  36. 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

  37. 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
  38. 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.
  39. 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.
  40. 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.
  41. 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.