Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Bill Joy's Takes on C# 678

f00zbll writes: "Cnet is running an article by Bill Joy on security and how it relates to C# and Microsoft at large. BJ quotes verbatim: 'C# provides the ability to write unsafe code. In unsafe code it is possible to declare and operate on pointers, to perform conversions between pointers and integral types, to take the address of variables, and so forth.'"
This discussion has been archived. No new comments can be posted.

Bill Joy's Takes on C#

Comments Filter:
    • Music lesson... (Score:3, Informative)

      by jeffy124 ( 453342 )
      There is no C-Flat. Occasionally it is written on a piece of music, but it refers to a B. Lowering a C half a step gives you a B-Natural. Someone suggested C-Double-Falt. That would be a B-Flat.

      The reason for this is on the piano, the player needs to be able to look down and determine where their hands are based on the missing black keys between the notes B,C and F,E.

      Although, calling C# "B" might be interesting. But then again, there was a language B by K&R that preceded C.
      • by Ieshan ( 409693 ) <ieshan@g[ ]l.com ['mai' in gap]> on Thursday February 07, 2002 @04:50PM (#2969813) Homepage Journal
        And actually, that stands for C-Sharp, not C-Flat at all. You could call it D-Flat, but that'd be like a boob-job gone wrong instead of a programming language.
        • Re:Music lesson... (Score:2, Interesting)

          by TeknoHog ( 164938 )
          To be precise, D-flat is different from C-sharp. D-flat is a little lower in frequency than C-sharp. However, most instruments today use an 'equally tempered' scale where e.g. D-flat and C-sharp are the same note, for example the piano and anything that has a keyboard.

          The reason that classical composers wrote their works in many different keys, is that they actually sounded different. In the equally tempered scale there is no difference (except the overall pitch change).

          Disclaimer: I used to play the trumpet, which can play C-sharp and D-flat (and similar #/b pairs) differently. I believe this can also be done with string instruments.

      • Re:Music lesson... (Score:2, Informative)

        by Anonymous Coward
        > There is no C-Flat. Occasionally it is written on a piece of music, but it refers to a B. Lowering a C half a step gives you a B-Natural. Someone suggested C-Double-Falt. That would be a B-Flat.

        If you want to get technical, get your facts straight. There IS a C-Flat. And there is also a C-double flat. It just so happens that Cb is enharmonically equivalent to B, and Cbb to Bb. The reason all this seeming complexity is kept around is so that, say, you are playin in the key of Ab minor. In Ab minor, the minor third is up by 3 half-steps, or a B. But the second is a Bb, so in order to write sheet music for Ab minor, we'd have to have a whole lot of accidentals. Therefore, we call what looks like a plain ol' regular B on the piano a Cb so that we can give scale degrees 2 and 3 different positions on the staff.

        > The reason for this is on the piano, the player needs to be able to look down and determine where their hands are based on the missing black keys between the notes B,C and F,E.

        Umm. Last time I checked music theory was not designed for incompetent pen^H^Hianists like yourself.
    • IIRC, the beep made by the original IBM PC was musically somewhere between C Sharp and D.

      Guess that's why the sound was so obnoxious. C# kinda makes sense now, eh!

  • So what? (Score:5, Interesting)

    by mosch ( 204 ) on Thursday February 07, 2002 @04:35PM (#2969686) Homepage
    Since when does the ability to use pointers mean that something is wrong? C allows a lot of 'unsafe' code to be written, yet we're all using operating systems writting in C, with very little trouble caused by the OS itself.

    Sure, it'd be great (for Sun) for everybody to rewrite the world in Java, but in reality nobody can justify requiring 50% higher CPU usage in exchange for the ability to let programmers be careless.

    I'm not saying Java is a bad thing at all, merely that C# isn't any worse than C, C++, perl or python. It's a shame when a press release manages to get linked from slashdot's main page, but that's all this is. Sorry Joy, but I'm not buying it.

    • Re:So what? (Score:5, Insightful)

      by BlackSol ( 26036 ) on Thursday February 07, 2002 @04:42PM (#2969748)
      Uhmmm How many buffer overflow exploits & crashes have there been of the years?

      But I do love C though...
    • by Hiro Antagonist ( 310179 ) on Thursday February 07, 2002 @04:44PM (#2969763) Journal
      I think the difference is that .NET and C# are designed as a network-based platform; e.g., you grab code off of the 'net as you need it, rather than storing everything locally. Having "unsafe" code in such an environment is utterly suicide, as it allows pretty much anybody who can put code on the network for you to use can do what they want to your system.

      Java actually does the opposite of "letting programmers be careless"; it forces them to be pedantic. In Java, you *have* to check that data is formatted properly, or your program will throw an exception and die. You have to properly typecast objects, define variables, and return from non-void functions, or the compiler will return an error. Java forces the programmer to handle all the boring, tedious work of making sure their code handles error conditions in a proper manner; because if it doesn't, the program will crash. But it will never allow access to the system outside of the JVM -- making Java a very safe network application platform.
      • Re:So what? (Score:5, Informative)

        by Anonymous Coward on Thursday February 07, 2002 @04:45PM (#2969778)
        The willingness of people to post without knowing the fundamentals of .Net astounds me.

        You need a special security privilege to run unsafe code. Code downloaded from the net doesn't have this permission, so it can't run unsafe code.
        • Re:So what? (Score:5, Insightful)

          by good-n-nappy ( 412814 ) on Thursday February 07, 2002 @05:03PM (#2969914) Homepage
          Or wait until Microsoft adds a dialog box that says "Allow unsafe code from Microsft? 'OK' 'CANCEL' 'ALWAYS TRUST MICROSOFT'"

          Then the problem is transferred to the weakest link - the user. Just like a Word file that asks if you want to run macros. How many users always know when they should say yes?
          • Re:So what? (Score:3, Interesting)

            by km790816 ( 78280 )

            Keep in mind that it is remarkably easy for an administrator, either for the local machine or the whole network, to specify .NET security policies that cannot be overriden. This includes never allowing unsafe code that has not been previously authorized by an admin. It's simple, it's powerful, it allows great inter-op with Win32 and COM.

            .NET Framework Enterprise Security Policy Administration and Deployment [microsoft.com]

            • Re:So what? (Score:5, Insightful)

              by km790816 ( 78280 ) <wqhq3gx02@@@sneakemail...com> on Thursday February 07, 2002 @06:13PM (#2970470)
              On a side note: Does anyone really expect Joy to say anything even remotely suportive of C#. Even if C#/.NET was the greatest thing since sliced bread, (I'm not saying it is) does anyone really expect anyone from Sun, especially one of the guys that created Java, to say anything possitive, supportive?

              It's like asking BillG his opinion on Linux or LarryE his opinion on DB2.

              Let's keep things in perspective, kids.
              • Re:So what? (Score:3, Insightful)

                by jsse ( 254124 )
                On a side note: Does anyone really expect Joy to say anything even remotely suportive of C#. Even if C#/.NET was the greatest thing since sliced bread, (I'm not saying it is) does anyone really expect anyone from Sun, especially one of the guys that created Java, to say anything possitive, supportive?

                So you mean no Java developers can critize C#, especially those who work in SUN, even when the opinions might be reasonable and valid?

                Tell Microsoft stop calling GPL virus! :D

                Let's keep things in perspective, kids.

                I know you are not calling me kids, but I found this statement funny when you said it. :D
            • Re:So what? (Score:3, Interesting)

              by mcc ( 14761 )
              And lots of administrators won't bother. The network of NT machines at the high school i went to, just for an example, had a random administrator who was given the job just becuase he'd been a teacher who knew some stuff about computers, and he knew how to set up racks of ethernet switches, and he read some books. This person didn't really have much concept of security; he just disabled anything at all anyone might possibly have wanted to have done, making the computers somewhat irritating to use. And then he went to the people who'd hired him and said, look, on the NT machines you can only run netscape and wordperfect and notepad! It is secure! You will not have to worry about the students abusing the computers! And they were content.

              Despite this, there really was no security to speak of. All he'd done was limit the programs that could be executed to a small list of "approved" software. But he did it by name-- which meant that if you dropped winamp on a machine and renamed it to "notepad.exe", you could run it. The machines all had borland 5 on them, and you could execute programs you had the source to by running them in borland. And those programs could exec() others. And the write permissions were set such that one user could install Snood! [acclaim.com], and every other user who used that particular machine forevermore would have Gator Download Assistant [slashdot.org] or whatever the hell it's called popping up every time they used netscape.

              The point of my story is this: Admining is not all that simple, and many people don't try that hard at it. Windows administration gives you *lots* of options. Lots and lots of options. There's always going to be a couple configuration options that every administrator misses, somewhere, even if they're trying really hard. And lots of the administrators out there are just doing the bare minimum they have to to get their paycheck.

              So, basically, even if it *is* really easy for an organisation to set up a windows xp machine to be really secure and locked down and 'safe', and even if the vast majority of deployers do go in and work out the settings just the way they're meant to,

              If .NET blows up into something really, really big, then the networks of that minority of sysadmins who *don't* know what they're doing, like the one at my high school, are *all* that the next great internet worm needs to wreak quite a lot of havoc.

              Just a thought.
        • Re:So what? (Score:5, Insightful)

          by Hiro Antagonist ( 310179 ) on Thursday February 07, 2002 @05:03PM (#2969916) Journal
          There's also (in theory) a special security privilege to run "potentially harmful" ActiveX scripts or Outlook macros; yet they seem to slip through on a regular basis. I have little faith in Microsoft's ability to successfully implement a decent security model, based on their track history alone. The JVM doesn't provide any memory manipulation capabilities whatsoever, so even massive bugs in the JVM don't necessarily open up your entire system. I'd place a bet that there are ways around C# security.

          I will admit that I'm not fantastically well-versed in .NET (who is?), but I do understand the fundamentals.

          Furthermore, using code that handles memory directly is a lousy way to implement platform independent software; why do you think there are so many little-to-big-to-little endian conversion functions in C?
          • Re:So what? (Score:5, Insightful)

            by Lazarus Short ( 248042 ) on Thursday February 07, 2002 @05:48PM (#2970296) Homepage
            I'm not too well-versed on .NET (or compiler/interpreter issues in general), so maybe this is a stupid question, but just because C# has features to manipulate "pointers" doesn't necessarily mean that you're really playing with actual memory addresses, does it? It could just be an (internally bounds-checked) index into a big ol' byte array or something, right?

            e.g.

            print(foo);
            // interpreter looks up "foo" in the symbol
            // table, gets (e.g.) 23, and outputs memory[23]

            fooaddr = address_of(foo);
            // interpreter looks up "foo" in the symbol
            // table, again gets 23; looks up "fooaddr",
            // gets 24, and does memory[24] = 23

            fooaddr = fooaddr + 10;
            print value_at(fooadr);
            // interpreter compares fooaddr (which is 33) to
            // mem_size (which is 30), and dies (or whatever)

            As long as you test in your "value_at" function, you should be clear (from this particular problem, at least)

            Oh, and nice nick, BTW.
        • by SirSlud ( 67381 ) on Thursday February 07, 2002 @05:07PM (#2969947) Homepage
          The very existance of such an 'unsafe' flag allows for the possibility of a bug in the VM's security architecture that /could/ (I said could) allow malicious coders to flag their 3rd party code as 'safe', or otherhwise circumvent said facility.

          I think the issue at hand here is one of transparency. If this goes the way MS wants it to go, you'll likely not be aware of when you're computer is fetching code to execute from the network, so you've very little idea of the risks you expose your computer to. You're left with far more possible ways of exposing remote users to malicious code. Should you: trick them into thinking it's local code via a dialog? trick the VM into thinking its local code? exploit the requirement for the 'unsafe' flag in order to run unsafe code? There are now numerous ways of going out attempting to execute unsafe code on remote boxes.

          Now, take C, which, yes, most apps are written in, but you download them, install them, and go through a process that essentially makes you aware that your computer now has additional code residing on it, which /could/ be malicious.

          Then take Java, where you /shouldnt/ be able to write unsafe code. A much safer (better, faster, etc are not the issue here) approach when you're dealing with situations in which you might be transparently running execution code fetched from remote untrusted or unfamiliar locations. Only a bug in the VM could lead to code being allowed outside the sandbox, and even then, there is nothing in the language that could let the casual programmer attempt to munch memory, etc ... I'm apt to believe this kind of achitecture likely leads to less possible problems than the .Net approach (of allowing unsafe code at the 'discretion' of the VM). Basically, there are far fewer 'paths' to exploit in the VM in order to execute malicious unsafe code in user memory, and once an exploit is discovered, you still can't really use java to write memory sniffers or access devices, or whatnot.

          Ah well. Thats my 2 cents, from what I understand. For transparent remote-code network applications, I'll take Java's slow-but-safe approach any day of the week over MS's yet-to-be-fulfilled promises of being able to properly manage their own can of (marktable) worms.
      • In Java, you *have* to check that data is formatted properly, or your program will throw an exception and die.



        Even that isn't enough. You have to check that the data is formatted properly for the functions you call with it, or you will get an exception. (Maybe, if you're lucky.) But there's nothing in the language to force you to make sure that the data you use doesn't contain special characters with unintended effects (such as appending additional commands to delete files, etc.) For that, you would want Perl taint mode.

      • by Carnage4Life ( 106069 ) on Thursday February 07, 2002 @05:11PM (#2969973) Homepage Journal
        I think the difference is that .NET and C# are designed as a network-based platform; e.g., you grab code off of the 'net as you need it, rather than storing everything locally.

        Really??? What gives you this idea? Java + VM is relatively equivalent to C# + CLR (as mentioned in my article [gatech.edu] that appeared on Slashdot [slashdot.org] a while ago). Code can be downloaded from the Internet and run just like with Java applets or RMI applications but this is far from the primary design of the platform .

        Of all the people in the world I'd expect to criticize a technology without adequately reading up on it first, Bill Joy would have beemn one of the last I'd expect to do such a thing.

        Bill Joy (and your post) go on and on about the vulnerability of network programming then ends with the reference to unsafe code which aims at giving the impression that downloaded .NET code can be unsafe. However this is incorrect [microsoft.com], and I quote
        From a technical viewpoint, the term unsafe refers to whether the program is known to be safe. Before a program is converted from intermediate language (IL) to native code, there's a part of the runtime security system known as the verifier that looks at the IL to determine whether it's safe to execute. In this context, safe means that the verifier can prove that the IL doesn't do anything unsavory.


        IL safety is important for certain Microsoft .NET scenarios--it's nice to know that the chunk of code that you downloaded from a Web site isn't going to do anything bad to your machine. The default policy for remote code (either from a Web site or from a net share) is that the code must be verified safe to execute.

        In other situations, it's useful to write code that can't be verified to be safe. In C#, any use of pointers generates unsafe code, as does any use of interop, such as COM interop or platform invoke.

        Since you don't want to write such code inadvertently, C# requires you to use the unsafe keyword on your class or method whenever you write code that deals with pointers. When you use the unsafe keyword, the resulting IL is marked as unsafe and can only run in a fully trusted environment (usually, security policy only trusts local assemblies). In the current version of the runtime, unsafe is defined at an assembly level, so having any unsafe code in assembly makes the entire assembly unsafe.
        • by cicadia ( 231571 ) on Thursday February 07, 2002 @06:00PM (#2970389)
          First off, Joy admits that code declared as unsafe "cannot be executed in an untrusted environment," at least according to the spec. He goes on to point out that we're trusting Microsoft's implementation here, which hasn't always been the best policy, at least for security issues.

          > When you use the unsafe keyword, the resulting IL is marked as unsafe and can only run in a fully trusted environment

          This bit still scares me. Does this mean that the C# compiler marks the IL as unsafe, and that the CLR trusts this marking? If that's the case, what is there to stop someone from bypassing the compiler, and editing the IL directly? (And please don't tell me it has anything to do with signed, trusted code :)

          At least the Java model is based on fairly solid theory. The environment has a lot of nice properties which make it easy for the JVM to ensure that all code executed is safe. It begins with the position, "don't trust this code," and refuses to execute anything which it cannot prove to be safe. It doesn't rely on the programmer, or the compiler, to flag unsafe sections of code.

        • by west ( 39918 ) on Thursday February 07, 2002 @06:18PM (#2970496)
          Everyone seems to assume that most C# programs will not have unsafe constructs, making it generally practical to disallow code with unsafe constructs.

          I'm willing to bet that most C# code will contain unsafe constructs. Programmers mostly come from a C background and, like all other humans, are basically lazy. Since unsafe code is both faster and easier to write, there will be tremendous impetus to write unsafe code so as "to get it done now".

          With enough code that has unsafe constructs in it, system admins/users will end up allowing unsafe code to run by default.

          In almost all cases, users want the maximum features and least security possible. Java's "least secure" mode is a lot better than "C#"s. Therefore Java is likely to be a lot more secure than C#. Blame the users? Sure. But it's the security that is actually used that counts, not what's available.
    • Re:So what? (Score:5, Insightful)

      by jfengel ( 409917 ) on Thursday February 07, 2002 @04:47PM (#2969789) Homepage Journal

      in reality nobody can justify requiring 50% higher CPU usage in exchange for the ability to let programmers be careless.


      Actually, it can. The reasoning here is simple economics. Additional memory and CPU is very cheap, and getting cheaper. Programmers are expensive; smart programmers are even more expensive, and getting more expensive all the time.

      Your productivity is even more expensive. It doesn't take very many hours of work lost to application crashes to equal the amount of money you'd spend on a faster CPU.

      And in the end, how much memory is leaked by people who decide that the best way to combat a core dump is to delete a free() call?

      I've worked extensively in Java, C, C++, and a host of other languages. I find that in Java, I'm vastly more productive. Its ability to give me stack traces, rather than core dumps, cuts debugging cycles drastically. I'd use a debugger on my machine, but I can't use it on a customer's computer, and duplicating the circumstances of the crash can be difficult or even impossible.

      Java's ability to do garbage collection saves me vast quantities of brain cells. I don't have to remember to free memory, and I don't have to negotiate with other programmers on my team whose responsibility it is to free up every single string I allocate.

      Java has a variety of other advantages, but you can read all about them in other sources. These are the ones that demonstrate how much money is saved in exchange for the extra CPU usage. I'm no longer programming my 64K 6MHz Z-80 computer; this computer has 8000 times as much memory and 133 times as much CPU, and it's two years old. There's no reason I should be making the same tradeoffs as I did 15 years ago.
      • I find that in Java, I'm vastly more productive. Its ability to give me stack traces...

        Echo that, ghost rider. One of the things that drives me completely batty about using C++ is the lack of a stack trace when an exception is issued. That's truly antiquated.

        C//
      • Re:So what? (Score:3, Informative)

        by kaladorn ( 514293 )
        Java's ability to do garbage collection saves me vast quantities of brain cells. I don't have to remember to free memory, and I don't have to negotiate with other programmers on my team whose responsibility it is to free up every single string I allocate.

        Mind you, it eats up cycles (in speed dependent aps like the one I'm working on, we avoid garbage collection that we don't directly initiate like the plague). CPU is not _always_ cheap. For many applications, hardware (legacy PCs!) constraints do exist. Also, garbage collection is no panacea... you can still have memory leaks from the VM and from your code (somewhere you maintain a reference to something by accident and it can't be collected). Effectively, you still have to insure that references are removed in order to allow the collector to do its business.

        Don't get me wrong, I like Java. But C/C++ has some great features java is missing (structures, bitfields, unsigned values, etc). This can make interfacing with non-Java systems a severe pain in the nether-regions.
      • Re:So what? (Score:3, Insightful)

        by theoddone33 ( 184581 )
        Sure, Java is a great language, but using the speed of CPU development and the inexpensiveness of memory to mask its failures is at best a poor argument.

        I like Java as a language, but its implementation sucks. The implementation will still suck no matter how fast your CPU is, you will just notice it less.

        You've also done a great job of pointing out Java's strengths, but some people will still feel that the trade off between good language and poor implementation is not worth the trouble.
      • The reasoning here is simple economics. Additional memory and CPU is very cheap, and getting cheaper. Programmers are expensive; smart programmers are even more expensive, and getting more expensive all the time.

        Unfortunately, the "physical resources are cheap" mentality is the principal reason that I used to switch on an 8086 and be typing in Word within 20 seconds, but now I switch on a 1GHz PIII and it takes minutes before I can start writing. Code bloat is a serious problem, and people who claim that we can just buy faster kit are making it worse.

        And in the end, how much memory is leaked by people who decide that the best way to combat a core dump is to delete a free() call? [...] Java's ability to do garbage collection saves me vast quantities of brain cells. I don't have to remember to free memory, and I don't have to negotiate with other programmers on my team whose responsibility it is to free up every single string I allocate.

        Neither do I. That's what destructors are for. I work on a MLOC project in C++, and I can't remember the last time I had to write a delete statement. Why do people keep implying that because C++ isn't GC'd, it must have memory leaks? Actually, it's far easier to ensure that resources are released properly in C++ than in Java, because the former has destructors and the RAII idiom, and the latter has finally and faith in its developers.

    • Re:So what? (Score:5, Insightful)

      by EXTomar ( 78739 ) on Thursday February 07, 2002 @04:50PM (#2969820)
      One of the points Joy is making is why bother expousing the CLI/Virtual Machine memory management as "safe" if you can ignore the "safe" memory management of the VM? As stated in the article, you can write poor code that could lead to buffer overruns in Java but the JVM does the checking for you before giving the code access to the memory. In C# they claim it is a optional feature which is interesting but not sane IMHO.

      This possible problem will exist anytime you have a .Net program using another .Net component. You may have written your .Net program using safe memory management but what about their .Net component? As Joy points out, this design feature is just symptomatic of other Microsoft designs where security is an afterthought.
      • .Net framework has runtime configuration options. In order to use code which works with unsafe code, the runtime option has to be enabled for the zone of trust.

        So the security mechanisms for this exist.

        Here, read for yourself:
        http://msdn.microsoft.com/library/en-us/cpguide/ ht ml/cpconsecurity.asp

        I agree with the other poster... Bill Joy is essentially expressing FUD. I think it's pretty sad as this is the second FUD article coming from Sun on news.com in as many weeks. Sun must be terrified of Microsoft to sink to such levels.
    • Re:So what? (Score:3, Informative)

      I'm not saying Java is a bad thing at all, merely that C# isn't any worse than C, C++, perl or python.
      You can't operate on pointers in Perl. There are references, but you can't convert integers to references and you can't change the reference value in other way than by copying other existing and valid reference. Given that, you can't access memeory which you're not supposed to access.

      Perl, unlike C/C++/C#, is safe. So is Python, as far as I know.

    • Re:So what? (Score:5, Informative)

      by GreyPoopon ( 411036 ) <[gpoopon] [at] [gmail.com]> on Thursday February 07, 2002 @05:14PM (#2970005)
      Since when does the ability to use pointers mean that something is wrong? C allows a lot of 'unsafe' code to be written, yet we're all using operating systems writting in C, with very little trouble caused by the OS itself.

      I think you missed the author's point. Of course C is unsafe. It's probably one of the easiest languages with which to "shoot your in the foot". In fact, I remember back in my DOS programming days having to be very careful that my test C program didn't accidentally format my hard drive. But what the author is questioning is the wisdom of ALLOWING unsafe code in a new platform when such is clearly at odds with the company's recently stated goals. Bill Joy asserts that it is a monumental, if not impossible, task to take the security flawed C# language and make it safe. Yes, it's a step beyond C in that a programmer can't write unsafe code without doing it intentionally, but how long do you think it will be before programmers just start adding an "unsafe" modifier at the top of their code by habit? If Microsoft truly has the goal of making software secure, then they should not be supporting these kinds of features in their .NET environment. And to address your comment on the safety of Operating Systems code, you have to realize two things: 1. Operating Systems are generally written by a different "class" of programmers than many of our present day business applications, and 2. There have been some significant exploits of insecure code due to programmer error in Operating Systems, Linux included. These things are just usually fixed quickly.

      Sure, it'd be great (for Sun) for everybody to rewrite the world in Java, but in reality nobody can justify requiring 50% higher CPU usage in exchange for the ability to let programmers be careless.

      I don't know about you, but with the way processor speeds and performance have been going up lately, I don't really have a problem buying a faster CPU just to make sure that some rookie (or mischievious) programmer didn't make a mistake that really causes problems for me. As processors continue to become faster, I think people will care a whole lot less about a 50% increase in usage. Don't get me wrong, though. I don't think there's any excuse for a professional programmer to become lazy and rely on the operating environment to protect them from their own carelessness.

      I'm not saying Java is a bad thing at all, merely that C# isn't any worse than C, C++, perl or python.

      I definitely wouldn't put Perl and Python in the same security class as C and C++. There are security elements included in both of the former. For example, I don't believe that a Perl program can have a buffer overflow (although the Perl binaries did at one time, ahem). My feeling is that C# probably sits somewhere in between "the other C's" and Perl/Python in terms of its security.

      Just take another look at the article and think about it from the perspective of the non-technical user. Microsoft clearly wants the world to adopt .NET as a new standard. They want to make programming easier than ever before. This will, as a consequence, attract people with less talent to try their hand at it. If .NET is to become the talisman of development, then Microsoft has the utlimate responsibility of protecting those who have bought into that dream. If they don't start that process now, the users are doomed.

    • Re:So what? (Score:2, Interesting)

      by bentini ( 161979 )
      God, I wish people on Slashdot would understand security better. *DON'T* make a security model where you have to write good code. Make a security model where you can't write bad code. That's why Java is cool, essentially. I can run code from the internet, and not be screwed in any way. There can't be a hole in the OS, because the hardware (VM) doesn't allow it.
      This is the killer app of 10 GHz machines: Slow implementation languages. Imagine java (or smalltalk) as your one language. Sure, it's slow, but it will only matter if you're on a supercomputer, where there is only one user (the government). Especially because so much of this code can be optimized to be CPU intensive, which few things are anymore (think of memory latency).
      C is going to be around, but only because it's a platform-independent assembly. A safe language, though, is necessary to trust things.
      -Dan
    • Re:So what? (Score:3, Insightful)

      by Derkec ( 463377 )
      His point is pretty much this: Microsoft went out to copy Java and left out some of Java's best aspects - like code is safe.
  • yeah but... (Score:5, Interesting)

    by TechnoVooDooDaddy ( 470187 ) on Thursday February 07, 2002 @04:36PM (#2969694) Homepage
    I've just delivered a project in C#... let me tell you, UNSAFE is a PAIN IN THE PATOOTIE to use in C#, you have to compile the code seperately, mark it off in it's own section, etc.. I specifically coded my way around using UNSAFE even when it would've been easier to integrate legacy code using it, just due to the PIA factor involved...
    • by cheezit ( 133765 ) on Thursday February 07, 2002 @05:37PM (#2970204) Homepage
      Sorry, TechnoVooDooDaddy:
      1. You've actually used the technology in question;
      2. You have an informed opinion about the topic;
      3. And your opinion doesn't fit the anti-MS orthodoxy.

      I'm afraid we'll have to confiscate your Slashdot login now.
    • Re:yeah but... (Score:3, Interesting)

      by Alomex ( 148003 )
      let me tell you, UNSAFE is a PAIN IN THE PATOOTIE to use in C#,

      The technical term is "syntactic salt" (as opposed to "syntactic sugar").

      Syntactic sugar is a term introduced long ago by programming language researchers in academia to deride anything that makes programmers' life easier. Typical usage: "replacing
      A.java.string.concatenate(B) with A.B is just syntactic sugar".

      Syntactic salt is a relatively new addition to allow those things that ever so often you need to do, just 'cuz life's a bitch, but otherwise you should abstain from.

      Having said that please do remember: "too much syntactic sugar causes cancer of the semicolon".
  • Trustworthy Code (Score:5, Interesting)

    by SteveX ( 5640 ) on Thursday February 07, 2002 @04:39PM (#2969711) Homepage
    You can use C# to write "Unsafe" code, but it's the runtime that ultimately decides whether or not to let it run. For example, if the VM that the browser creates tries to launch a C# app downloaded from the Internet, and it's "Unsafe", the CLR will refuse to run it.

    Difference between C# and ActiveX in this case is that in ActiveX, everything is "Unsafe" and you either take it or leave it. In Java, of course, everything is "safe". C# can go either way.

    I really hope that Microsoft simply makes it impossible to run "Unsafe" CLR code in the browser. Not even an option.

    - Steve
    • Re:Trustworthy Code (Score:3, Informative)

      by xphase ( 56482 )
      The problem is that even "safe" Java has had security problems. Not relating to the language itself necessarily, but relating to browser/platform implementations.

      See the Risks Digest:

      17.39 [ncl.ac.uk]

      17.83 [ncl.ac.uk]

      18.18 [ncl.ac.uk]

      and there are many more listed in the archives.

      So until the languge/CLR mature enough, then there will be more problems with an insecure language.

      Also, note that most early Java security problems were found because sun encouraged people to find them, and then Sun would fix the problems. Microsoft doesn't want people to find and disclose bugs in it's software, so it may take longer to mature security wise.

      --xPhase
      P.S. pardon any spelling errors, i'm tired.
    • C/C++ is unsafe because it allows to have pointers.
      Java is safe because it doesn't.
      C# is either safe or unsafe, depending on how you write the code?
      So... why would we use C# in place of C++ for applications where safety isn't necessary (or more likely, practical)? and why use C# over Java when safety is desired?
  • C# FUD? (Score:4, Interesting)

    by glh ( 14273 ) on Thursday February 07, 2002 @04:40PM (#2969723) Homepage Journal
    This sounds like FUD. He didn't really post any examples about what kind of problems C# has for security, that would have been helpful.

    I think a lot of people are upset because MS has actually come out with something that can compare with Java finally.. The ability to write unsafe (unmanaged is what that really means, meaning the garbage collector and built in memory management features of the CLR won't touch it) is an added bonus to Java.

    I think the real question is- how secure is the .NET common language runtime?
    • MS Creates a language that is similar to Java, and even though it has been left unsaid by MS, they would like to lure Java programmers away fron Sun and towards .NET.

      MS Creates ads in DDJ and other tech publications with benchmarks that show C# trouncing Java J2EE.

      This is almost certianly a FUD tactic in retaliation to MS trying to lure developers away from the Java platform.
  • by mosch ( 204 )
    Wow, so Sun doesn't like MS technologies. What's next, Microsoft spreading FUD about Open Source?
  • "In unsafe code it is possible to declare and operate on pointers"

    I'm not a computer scientist, just a unix admin. My question is: Since when has operating on pointers been considered unsafe? Pardon my lack of understanding, but with that definition, wouldn't 99.9% of all code then be considered unsafe? And does't JAAVA use pointers too? Honestly I duno..

    • Pointers are pretty ubiquitous in C, and a large percentage of existing code is in C, but not 99%. Now, you can write good pointer code and bad pointer code just like anything else. To declare all code that uses pointers to be unsafe is bizarre. The danger with pointers is that you can get them pointing at weird places and get weird results. :)

      Java (unless things have changed recently) does not use pointers. That, IMHO, is one of it's benefits, not because pointers make things unsafe, but because the code is easier to follow and understand.

      Ben
    • Java doesn't have pointers... well, at least not that you (as the programmer) can see.
    • by watanabe ( 27967 ) on Thursday February 07, 2002 @05:05PM (#2969934)
      The reason that one considers working with pointers unsafe is that, for example, in C, one uses the pointer to get at an actual location in memory, and do something with what is there. Programmers frequently want to work quickly and directly with the actual bytes in RAM; for example a 10x10 integer array may be implemented in C for performance / algorithm reasons as a 1 dimensional array of 100 integers.

      The problem occurs when the programmer writes their code to work through that array using pointer / address arithmetic. Perhaps the programmer is one byte off in their math, but only on the 100th integer. That is, they read the 101st number.

      Maybe the 100th number is 99% of the time 0, and 1% of the time is 1 (I know, I'm mixing my bits and bytes, but, bear with me, please). The 101st number is just some random value in RAM. It might be 0, or it might be 1. It might be used by some other structure, it might not be used. YOU DON'T KNOW. However, the bug will only show up in the event that you use the number, and that the number is different than you expected. Those two don't happen so often. Ergo -> Jane programmer spends two weeks of her life tracking down a random crash triggered by a function that relies on that last value being 0 based on certain preconditions.

      This isn't about computers crashing, it's about memory error bugs. I once wrote a ray tracer which got the colors terribly wrong once the light sources got too bright. After some checking, it turns out my light values weren't being capped at 8 bits. They were overwriting into the adjacent byte, and screwing up color values for pixels near them. Oops. Things like that don't _ever_ happen in Java, say.

    • by Anonymous Coward on Thursday February 07, 2002 @05:10PM (#2969970)
      The key point here is memory safety, which C (and C#'s with the unsafe keyword) lack. In a language with memory safety, buffer overrun vulnerabilities and the like can't happen.

      Typically, memory safety is tied to type safety. (But, memory safety really has nothing to do with pointers. For instance, SML/NJ allows pointers, but is memory safe, since the type system won't let you treat an integer as a pointer. In SML/NJ, the type system essentially provides you with a proof that your code is memory safe). So, if your code type checks, it *is* memory safe.

      The two concepts are distinct, though. Java is memory safe, but you can break the type system with casting. So their is no *static* guarantee that your code is memory safe, but the VM includes runtime checks to make this a dynamic guarantee.
      • Since he's the only one who got the point, despite being an AC.

        The whole point of a safe language is to prevent a program from accessing memory it shouldn't. This means not only buffer overruns, but the ability to fabricate a pointer itself. Which means that trusted code won't compromise security with a buffer overrun, and untrusted code can't get a pointer to anything it might want (like, say, a capability descriptor it doesn't own).

        And the dynamic aspect is critical. Static guarantees are useless, because in the untrusted code case you weren't there to see it compile. But if you can run code from someone else, and be assured that the VM is going to prevent the program from doing anything it shouldn't, then running untrusted code becomes feasible.

        Assuming you believe the VM itself can be trusted. ;)

        This is all from memory of a lecture I had in Adv. Op Sys almost 2 years ago, so take that as you will. :)
    • by markmoss ( 301064 ) on Thursday February 07, 2002 @06:01PM (#2970393)
      First off, I'm primarily a hardware engineer, who writes small programs in C or assembly that deal directly with hardware. So I use pointers and other "unsafe" code a lot; they are both extremely useful and extremely frustrating when it comes to debug time.

      Pointers let you use just about any arbitrary number as an address and poke data in there. The virtual memory system might block this on the grounds that you don't have a page at that address -- but not all computers have the hardware to do that, you can still do horrible things by writing to the wrong place in the pages you do own, and if the protection does block the misplaced write, the resulting invalid page error is not pretty from the user's point of view.

      Pointers can be used safely -- if you program very well, like checking every address before you use it (which takes a hell of a lot of extra code), or checking the data going into the pointer calculations to ensure that no way could a wrong value come out (which assumes you didn't make any programming mistakes). And if it is a case of running downloaded code where there is a finite chance that the programmer is _maliciously_ misusing pointers, there is no way for the computer to analyze the code and detect this before you run it. Hence Microsoft's attempt to make internet and e-mail user friendly by automatically running any included executables spawned a plague of viruses, worms, and trojans...

      C++ gives you the choice of traditional pointers or references. A "reference" is a sort of super-pointer that includes data on where valid targets must be, and gets checked for validity every time you use it. I don't do Java, but I am under the impression that it uses references only. That isn't enough in itself to prevent writing Java viruses, but it gives the OS a fighting chance of confining them to the sandbox...

      OTOH, no computer is going to run entirely on "safe" code. At some level, the code has to read and write hardware registers. To do that, you take the numeric address of the register, and use that as a pointer. True, a good, secure OS would confine all such activities to drivers, which can only be installed by the administrator, who ought to know the difference between a driver and a trojan. But Microsoft doesn't write OS's like that -- NT/2000/XP is rather improved on DOS where direct writes to the video card were almost mandatory, but the security is still swiss cheese.

      Incidentally, the original reason for C allowing all sorts of unsafe activities (pointers everywhere, strcpy with no length check, etc.) was performance. Checking the length of a string every time it was used took CPU cycles and RAM to hold the extra machine code. So the creators of C left it up to the programmer to shove in an if statement to check the length when the string was input, and to do the math and pop in another if statement anywhere it was possible for the string to grow too long. This was efficient, but puts quite a load on the programmer. About that time, I was running an 8 bit computer with 16K of RAM, clock speed under 1M, and all the accounting, class schedules, grade reports, etc. for a small college went through it. Efficiency was important! Now, who's going to notice whether the program runs in 1 millisecond or 2? It's better to be reliable. And it's necessary to get the program up and running pretty fast -- that's a lot easier if you don't have to worry about pointers going wild except when you do go to the hardware.

      In C# apparently the programmer has the choice of using references and avoiding all "unsafe" code, or of declaring a module "unsafe" and programming any way that gets the job done. By making "unsafe" a PITA, they've encouraged programmers to avoid it except when absolutely necessary. I have a suspicion that once the coders get used to it, that will increase their productivity overall. In addition, it gives any tool that may run code from outside a quick way of determining whether the code was written to be safe or not. In theory...

      I have serious doubts about whether that (being able to run "safe" C-sharp programs) will actually work. First off, won't a virus-writer be able to hack the tags that say "unsafe"? Second, ways to do unsafe things in "safe" code will be discovered. Third, if your OS has security like swiss cheese, no program is going to really be safe. Do e-mail viruses actually have to do anything that isn't allowed?

      From what I've heard, Microsoft's idea of securing Outlook was to have it look at the HTML tag, and if it said executable pop up a warning which is incomprehensible to the people who are actually ignorant enough to get e-mail viruses. ('Yeah, it's from a trusted source. See the "From" line...') But if the HTML said "text", then it passed the attachment on to the Windows "open" command, which determines the type of the attachment by looking at the attachment, and if it was .exe or dozens of script-containing formats, it would let it run. Surely virus writers wouldn't be _dishonest_ and change the HTML tag so their .exe's would slip through...

      Until that sort of thinking changes, giving people a way of tagging the programs "safe" or "unsafe" is just asking for trouble.
      • "C++ gives you the choice of traditional pointers or references. A "reference" is a sort of super-pointer that includes data on where valid targets must be, and gets checked for validity every time you use it."

        This is not true. C++ references are exactly like pointers, except that you cannot rebind them. With a pointer you can point it one place, then point it another. With a reference you have to define the place it points when you create it and you cannot move it later. So:

        Foo& f = *(Foo*)0;
        cout << f.someValue;

        will still shoot you in the foot just as effectively as:

        Foo* f = 0;
        printf("%d", f.someValue);

        OTOH, in Java, they call everything a reference, but it's really more like a C pointer except that there is no pointer arithmetic. Oh, and it *is* always checked. Try to use a null reference? Exception. Try to typecast a reference in an invalid way? Exception.
  • by Astral Jung ( 450195 ) on Thursday February 07, 2002 @04:44PM (#2969766) Homepage
    I still don't understand what's so evil about C#. If you don't want to use it, you don't have to. But personally, I find that not using C# leaves a sizable gap in several different keys, meaning a lot of stuff comes out just sounding wrong.
    • C# is just Microsoft's imitation of Db. Once again, they take something that's been around since the equally tempered scale and claim it's an innovation.

  • by coonsta ( 141485 ) on Thursday February 07, 2002 @04:50PM (#2969821) Homepage
    To serious developers not familiar with C# and .NET, either don't read Joy, or be willing to look into the details yourself. You could be embarrassed if you repeat the gist of this article as lore. At the very least, you can easily convince yourself that this article is bogus in that it doesn't mention that C# has three kinds of pointers-- managed, unmanaged and transient.

    C# does allow pointers and pointer manipulation. This is mostly for programmers seeking extra performance. Like a cast in Java, declaring code as "unsafe" is equivalent to saying to the VM, "Hey, I know what I'm doing." C# pointers are definitely not as liberal as C ones (just like casts in Java are not as liberal as casts in C).

    For those sincerely seeking an intelligent discussion of pointers in the CLR, see Gough, J. "Compiling for the .NET Common Language Runtime (CLR)" Prentice Hall, NJ 2002.

    • by roca ( 43122 ) on Thursday February 07, 2002 @05:15PM (#2970014) Homepage
      > Like a cast in Java, declaring code as "unsafe" is
      > equivalent to saying to the VM, "Hey, I know what
      > I'm doing."

      This is wrong. A Java downcast is dynamically checked and cannot compromise the integrity of the virtual machine. It is not "unsafe" in any meaningful sense of the word.
  • Would know that right after he quoted from C# specification about unsafe code, he quoted again

    ""Unsafe code is in fact a 'safe' feature," the C# specification continues, "from the perspective of both developers and users. Unsafe code must be clearly marked with the modifier 'unsafe,' so developers can't possibly use unsafe features accidentally, and the execution engine works to ensure that unsafe code cannot be executed in an untrusted environment.""

    Seems like a good idea to me, whats wrong with that?
  • by CDWert ( 450988 ) on Thursday February 07, 2002 @04:54PM (#2969852) Homepage
    Uhh, and the problem with this is ???????

    All lll allow this, C3 may not be a lll but theyre trying to appeal to the uper end of that segment.

    C# allows you to write managed, OR unmanaged code as well, This is an option. As well as the coders ability to write "unsafe" code. YOU MUST INTENTIONALLY flag the code to be written as UNSAFE !

    If you dont know what you are doing and choose to do this so frigging what ???

    C# has the fundementals of a good language, forget its from MS, if it where from GNU, you;d be eating it up saying look how much better it is. I am looking forward to working with it, the .NET Visual Studio is written in C# itself , it should be pretty thouroughly debugged before its released.

    Play with it for a week , if youre a beggining C programmer youll love it, if youre experienced, youll love it for the same reasons, My bet is most of the people bitching havent read or written a single line of C#, if have and dont like it Id like to know explicity WHY ?, Ms bashing aside.......
  • Taint mode? (Score:4, Insightful)

    by chrysalis ( 50680 ) on Thursday February 07, 2002 @04:55PM (#2969858) Homepage
    A language can be both 'safe' and 'unsafe'. Take a look at Perl. You can do a lot of insecure things with it. But as soon as you launch with the -T switch, your script will run in a special mode. Values coming from an insecure source will be refused by potentially dangerous functions, unless you explicitely mangle them before the call. This is extremely powerful and prevents a lot of classical security flaws.

    I don't know much about C#. But a taint mode for it would make the language pretty safe, despite the presence of pointers.


  • by mrroot ( 543673 ) on Thursday February 07, 2002 @04:58PM (#2969875)
    There's been alot of controversy lately over security holes in programming languages. There is one language that has stood the test of time and proven to be the most secure language of all, with a record zero (0) reported security holes.

    Here [mit.edu] is the link if you want to learn more.
  • Joy FUD Club (Score:4, Insightful)

    by Master Of Ninja ( 521917 ) on Thursday February 07, 2002 @04:59PM (#2969892)
    Yep, I think the guy's getting quite jealous of MS. Love or hate these people, the .net programming specification look very powerful, and coupled with the hard-as-nails win2k/xp combination, they will be quite hard to compete against.

    What Sun should really do is get off there behinds and match C# for features. From what I understand (not much admittedly), the Java VM just has to be extended to give it the breadth of additional languages that the CLI has (in terms of being able to use unsafe methods if the programmer wishes, so allowing C to work through it). The problem with Java has MS has the dominant desktop (and a good one it is now - really this is fact if you have to use them all day long), and they have the "standard" tools for programming. This will generate massive mindshare, and might get everyone from VB to C# (at least being "safe" might be good for programs knocked up at home).

    On an unrelated topic, I think cloning the fundamentals of C# to a open-source basis is a very good idea. I might not agree how ximian are going about it, but at least the FSF has a parallel project that can bring the new language to the world - it could persuade casual safe programming, while allowing the breadth of accessing the OS directly.

    When it comes to web services, I honestly can't see the difference between Java and C# (apart from the fact everyone will use C# as the MS-sponsored dominant language). It's all down to FUD: the .net services are basically going to be the same as before - just with a .net after them, and maybe re-written in C# now.

    Java is great, but Bill Joy think he should go get it optimised - working faster, able to compete effectively with C#.
    • sorry but i can't let this go...

      coupled with the hard-as-nails win2k/xp combination
      hmmm... beginning to suspect you have no idea what you're talking about. it was hard getting past the hard-as-nails part. i have a new computer in my lab right now that won't install win2k and is locked up in the (default) install process where it thinks it's already installed but it really isn't.

      dominant desktop (and a good one it is now - really this is fact if you have to use them all day long)
      dominant in marketshare only... i find it endless frustrating and difficult to use. Macs are infinitely easier to use and as far as I'm concerned, so is KDE. I used to use Win9x/NT before I found linux.

      can't see the difference between Java and C#
      Java - multi-platform
      C# - windows only (you don't think MS is going to extend C# like they tried to extend Java for windows?)
      So, if you have a server running, it has to be windows if you develop in C#. Now, you'd have to be insane to use windows as a production-level server. Unix is the only way to go... thus, Java.

      Sure, I think Java could use some competition but seriously, a Microsoft Windows-only solution is not the answer.
  • by partingshot ( 156813 ) on Thursday February 07, 2002 @05:02PM (#2969910)

    I stopped reading after this line:
    • "So Microsoft built ActiveX, a technique within Windows for automatically downloading and executing arbitrary programs"
    Maybe Mr. Joy should read up some more:
    • Pfft... Now, why, oh why, would Mr. Joy ever say anything like that? Here's an excerpt from "The COM and COM+ Programming Primer" about ActiveX that might explain why:
      None of the other names has caused even nearly as much confusion as this one.... The reason so many people are confused by the name ActiveX is because
      the definition has changed. Originally ActiveX was a brand name for all COM-based Microsoft technologies that had utility on the World Wide Web.

      Emphasis mine.

      Hope you don't feel silly, because you've been taken in by Microsoft re-writing history.

      God bless,
      -Toby

  • Security in .NET has been built into the foundations of the CLR, not added as an afterthought as Bill Joy implies. Read more about it at the .NET Framework Security Overview [microsoft.com]. The reason Microsoft seems so cocky about their new "trustworthy computing" crusade is because they know their new framework makes it a lot easier to follow through on their promises. Although there is still room for programmer error, that room is now the size of a broom closet, not a stadium.
  • In allowing a program to be either "safe" or "unsafe", C# is little different from any other programming language - the best and highest performing code will be written in "unsafe" mode. Which leaves the users in the same position as they were before with signed/unsigned ActiveX controls; do they dare download and run an unsigned/unsafe program? Or do they give up web page features for the sake of running "safe" code?

    Java was a step in the right direction. C# may be promoted by Microsoft heavily, but the prospect of "unsafe" code is only going to send up red flags with the average users. The average desktop user doesn't want to have to worry about safe/unsafe code - they just want to be able to browse the web safely - which is what Java already provides. Sorry, Microsoft, but Java already does better what C# was intended to do.

  • What a FUD... (Score:4, Informative)

    by targo ( 409974 ) <targo_t.hotmail@com> on Thursday February 07, 2002 @05:09PM (#2969965) Homepage
    C# provides the ability to write unsafe code. In unsafe code it is possible to declare and operate on pointers, to perform conversions between pointers and integral types, to take the address of variables, and so forth

    From the tone of the poster I take that this is somehow supposed to make C# 'bad' or at least look bad. Well, how about learning some facts first that would leave an impression that you know anything at all about the topic you are posting about.

    First, yes, you can use pointers etc in C# but you don't have to. Most C# code would be written in safe mode, unsafe operations are intended for better interoperability with other code written in C, for example. There are lots of C libraries out there that want to manipulate the bits directly and this is not always possible in a typesafe language. Hence the unsafe mode, so you could pass data to these libraries exactly the way you need to. C# designers added it as a cool feature to make coding some special cases easier.

    Second, to actually use the unsafe features you need to mark a code block as 'unsafe'. The CLR will notice that and run the code in a different mode, restricting its access to the 'safe' code and data. Therefore, there is absolutely nothing unsafe about the design of the language or the CLR as such.
    Any real unsafeness (i.e. code's ability to mess with typesafe data in an unsafe way) would be because of a bug in CLR but I haven't heard of any bug of that nature yet.
  • by astrashe ( 7452 ) on Thursday February 07, 2002 @05:10PM (#2969966) Journal
    Obviously Bill Joy knows a lot more about this stuff than I do; but I think he, and many of Microsoft's critics as well as supporters, are missing a crucial piece of the puzzle.

    Many of the features that have contributed to MS's insecurity were there not because MS's engineers were too dumb to think clearly about security, but because other people decided that there was an overriding business interest that the features would serve.

    Specifically, these features usually tend to be part of the MS strategy of leveraging success in one sector into another. If you use office, it makes sense to choose VB as your scripting language. If you know VB, it makes sense to run IIS. That's why there's a VB interpreter inside every office app.

    I think that what we've seen from MS is an official change in policy -- they're saying that business considerations now suggest that security should be the #1 priority. They're admitting that the market will punish them for security holes, and that they can't sacrifice security to establish leverage from one sector to another.

    MS has always put business concerns over technical ones. For that reason, a lot of /. posters have make comments to the effect that MS isn't capable of delivering technically. It used to be the conventional wisdom here, for example, that any MS OS was destined to crash repeatedly.

    It turned out that when MS saw Unix and Linux as a threat, and when they decided that reliability was one of the biggest advantages that Unix/Linux offered, they took reliability seriously and made enormous progress in a relatively short period of time. This suggest that Windows crashed not because MS *couldn't* make it reliable, but because it wasn't a *priority* for them to do so. As soon as they saw a change in the business climate on the edge of their radar screen, they changed their behavior.

    Windows and its applications haven't been secure because MS hasn't felt it was worth making security a priority until now. There is no evidence that they couldn't cover a lot of ground very quickly in security if that's what they decided to do. And it seems as if they've decided to do just that.

    I do agree that .NET and C# are technologies that predate this new ordering of MS's priorities, and that they probably won't be very secure. Passport, the most important .NET application yet written, coded by people who ought to know the technology best, has been hacked (and patched, it's only fair to point out). If MS's people don't write secure apps with .NET, are the low end VB coders the platform is designed for going to do a better job?

    But the problem that Sun faces is that MS has proven time and time again that they're willing to spend lots of money and go through lots of iterations to take a market. They're relentless. They usually don't get it right the first time, but they usually do get it right after four attempts or so.

    I'll say something else that will probably get me modded down. After the recent flirtation between AOL and RedHat, I'm not sure that the moralistic arguments against MS hold up so well. Linux has been at the center of some pretty slimey stock swindles -- our gracious hosts, here at /., work for one of those companies.

    Meanwhile, the Bill and Melinda Gates foundation is giving extraordinary sums of money to real nuts and bolts making the world a better place kinds of causes. Gates could literally turn out to be the most significant philanthropist in the history of the world. They're giving so much money that you can almost see a chunk of what you spend on MS going to a good cause.

    All of which suggests to me that politics and the morality play that have always clouded the linux vs. windows debate should probably be put to rest.

    Windows is horribly insecure -- viruses do incredible damage in the real world, especially among the least sophisticated users. That's not political, that's a fact.

    But they're saying they're trying to clean up the mess. Sure, it's a big mess, and sure it's going to be a big job to clean it up. I give them credit for admitting it, and to taking on the task.
    • If MS's people don't write secure apps with .NET, are the low end VB coders the platform is designed for going to do a better job?

      Because there'll be a great big bloatware wizard there to clicky clicky clicky your way through alllllllllllllllll the problems. And then your boss will think you're a real "goooooroo" and you can get to the day-long meeting on time so you can compare PowerPoint slides with 'Bob' from accounting.

      (The sad part about this is that I just described about 80% of "IT departments") sigh...
  • I mean this guy is the chief scientist of Sun Microsystems and the co-author of "The Java language specification", what exactly do you expect him to say about C# ?
  • BJ quotes verbatim: 'C# provides the ability to write unsafe code. In unsafe code it is possible to declare and operate on pointers, to perform conversions between pointers and integral types, to take the address of variables, and so forth.'

    First of all (go ahead and call me a troll, like I give a fuck): it's not nice to call someone BJ, even if their initials are in fact B. J.

    "Unsafe code" has no meaning to Microsoft. I'll put it this way, code monkeys are spewing out of Devry and ITT tech (and 4 year institutions under the mask of "computer information systems" majors) daily, with no real understanding of what makes good software development, and they want a language that will be as easy as possible and will fulfill all the buzzwords like "object oriented" and "self-specification." C# will provide this, and Microsoft will support it.
  • ...even English. To try it, go into a biker bar and tell the toughest looking guy you liked his mother. If that doesn't do it, ask him if he has a sister. Make sure to call 911 before you do ;-)

    Yes, C# has an unsafe mode. So does Perl, Python, Java Script, and guess what--Java.

    The only difference is that C# lets you write unsafe code in C#. In Perl, Python, etc.. you would write a shared library (or link extensions into the language executable). And then of course you have to trust that the shared library is "safe."

    Yes, there are going to be security holes in programs written in C#. Only careful programming, and as much peer review as possible can reduce those mistakes. In the end, only time will tell if an application has holes.

    Long live the Department of FUD! Let's go scare some suits :-)

    --AM
  • Nice troll, Bill Joy (Score:2, Informative)

    by borgboy ( 218060 )
    Bill makes a lot of sniping little attacks on C# that really amount to very little. So what if C# looks a lot like Java? That's what all the C++ people said about Java back in the day.

    Then, he confuses the C language and it's inherent propensity for buffer overruns and various other pointer-math related problems with the C syntax - which is about all C# really inherits from C.

    C# executes in a runtime context, just like Java does. You have several means for controlling things like "do I let downloaded code execute file I/O?" or "do I allow unverified code to execute?"

    The crucial point here is the term unverified. The C# compiler can, and by default does, generate verifiably type-safe code. It has a compiler switch (oddly enough, "/unsafe") that enables unsafe code generation that includes unverifiable code. You have to use this switch when you use a unsafe directive in your code, and you have to use that directive to employ the pointer methods that Joy references. You might even take this a step further and think that, in an config file somewhere, there is a setting to disallow unsafe code that originated from the internet.

    Bill even hints at this, and I hate to think that he is disingenuous to the point that he's failed to actually follow up and look at the mechanisms .Net uses for code access security, but he plays it off with the FUD statement that the security was tacked on to the framework after the C# language was built. That statement utterly fragments once you have taken a close look at the security infrastructure in the .Net framework. It isn't perfect, but from what I've seen, the tools are there to allow the clueful to secure the box with a fine degree of granularity.
  • Do the following search and replace in this article:

    s/C#/Java/
    s/unsafe/native/

    And it still is true. Java has it's own "native" methods, which have all the same problems that C#'s unsafe methods have. In C#'s case it's a bit easier to work with because you don't have to change languages, (Java native methods can't be written in Java).

    Man, I hope someone calls Joy on his hypocracy.
  • by Stickerboy ( 61554 ) on Thursday February 07, 2002 @05:38PM (#2970218) Homepage
    ...before unveiling its secret weapon in the language wars:

    COBOL#!

    Yes, with the power of COBOL# Sun will be able to monopolize the huge untapped market of legacy COBOL code that could be easily modified and brought up to cross-platform, bytecode standards.

    Since there is so much more legacy COBOL code than C/C++ (75-80% of all existing code in businesses is still COBOL), Sun will one-up Microsoft, and along with Java will be able to win over developers with its advanced security features like a rigid sandbox and no direct memory manipulation.

    Next up for Sun, Java++... it's rumored that Sun's pulling out all the stops with this one, and even including a full-fledged graphical developing environment with the J++DK, complete with an intelligent "Programming Assistant" that will warn you when you're writing unsafe code! Dancing Bill Joy or paper clip graphics optional.

  • Languages that use direct memory manipulation do have drawbacks in the safe/secure area.

    I don't care how good a C/C++ programmer you are, you WILL create buffer overrun situations in your code. Period. End of story.

    All it takes is one program running as a priveleged user to have a buffer overrun and bam, compromised system.

    Thats not to say Java doesn't have the same problem. All it takes is one buffer overrun situation in the VM and boom, compromised system. It is probably safer though, you only have one large c/c++ program that many folks are looking at.

    Anyhow, my opinion.
    Barjam
  • We can do this in java too- but instead of being able to write unsafe code in java we're forced to use JNI and code in C.
  • by kindofblue ( 308225 ) on Thursday February 07, 2002 @05:49PM (#2970301)
    On a decent Unix system, it's not possible, or at least difficult, to destroy other peoples data. (Not counting, of course, buggy system call implementations.) But implemented properly, even things like "while (1) { fork(); }" will not kill the whole machine, because the OS will limit the consumption of virtual memory or CPU time, and then kill the errant process or swap it out.

    So why couldn't executable code, like ActiveX or CORBA code, be sandboxed also? This should just require that the component be put into a restricted execution context, that perhaps has lower priveleges than the user's context. The component would operate like a GUEST user, and would not have access to the invoking user's priveleges and resources, like files, etc. This guest user could have it's own scheduling priorities and quotas for a subdirectory, and so on.

    All the system calls, e.g. to DLL's or DSO's would be intercepted or remapped, or something like that, so that priveleges are checked and enforced, just like java does. Since modern CPU's can trap anything from illegal memory access to code or data, to illegal port access, it should be possible to fully isolate the code. Right?

    Of course, the performance would be inferior because of the context switching between different privelege levels. But in a "safe" mode, this would be a fantastic way to run plugins for PDFs, Flash, a whole game, or some downloadable application.

    I'm not a kernel expert, but I thought that mainframes could do this forever. What about Linux? e.g. with Wine?

    BTW, this would also make peer-to-peer style distributed computation (like the SETI project) safe and still fast.

    • by josepha48 ( 13953 ) on Thursday February 07, 2002 @06:09PM (#2970444) Journal
      On Linux while(1) fork() may take down the whole system. Also while (1) malloc(1024) may start to cause problems as well. Other UNIXes can be attacked by runaway proceses as well. Windows and UNIX have that problem. One process that goes awire can take down just about any system if it has the provelidges. Especially if it is run suid or as root.

      Building a system with the sandbox design in minds is easier than taking an existing system and putting it in a sandbox. Active X is already out there. How do you handle the existing Active X and put that in a box? You'd basically have to redesign active X. Word, Excell and Access all rely heavily on VB macros. How do you put them in a sandbox? Actually that may be easier to do but it would also be limiting. In the sandbox that Javascript runs in you are not supposed to be able to access files on the users filesystem. (note not supposed to there have been errors on that though). The idea was there though.

      Okay so you operate it in a GUEST account. If that guest is set up or can access files there goes security.

      The reality is that 28 days is not enought time to focus on security and Microsoft does not have a good track record when it comes to security. While it may be possible to start building in security into the existing system. Security is a continuous effort that must be thought of as part of the design. When a programmer creates a new language they must start to think security right off the bat. This was done with Java, but not C#.

      I say good luck Microsoft, but you have a lot of work ahead of you to prove to me that you can get security right without comprimising usability.

  • by AJWM ( 19027 ) on Thursday February 07, 2002 @06:34PM (#2970604) Homepage
    What a wonderful combination!
  • Sun's FUD (Score:5, Insightful)

    by markj02 ( 544487 ) on Thursday February 07, 2002 @07:32PM (#2970953)
    The use of "unsafe" in C# is roughly analogous to the use of JNI in Java: modules using unsafe features (or native code) are identifiable as such by the runtime, and applications with security needs can exclude them. As such, C# isn't any less safe than Java. In practice, the C# approach is likely to be safer and more secure than the Java approach, since using "unsafe" inside a C# program is much more localized and much easier to get right than writing a JNI module.

    Furthermore, C# isn't even going after the same market as Java. Java's security model primarily comes into play for applets and mobile code, but that's only a tiny fraction of all applications. C#'s purpose in life is to allow programmers to create desktop and server applications more easily. For that purpose, an easy and robust interface to native code (regular expression libraries, XML parsers, etc.) is much more important than security.

    The major problem with C# isn't technical, the major problem is that there aren't any good implementations available yet (no, Microsoft's implementation isn't all that great yet) and that C# comes from Microsoft. But once there are C# implementations that are competitive with Java implementations and once C# has a life outside Microsoft, C# will be a serious threat to Java. And we may see a truly open source, efficient implementation of C# before we see one for Java.

    For the time being, I still think Java is the more logical choice for open source applications. It may yet be a few years before competitive C# implementations and libraries come along. Sun still can keep their lead by innovating and extending the Java platform, cooperating with the open source community, and being honest about the strengths and limitations of the Java platform. But if Sun continues along their current course, they will lose sooner or later.

  • by mrm677 ( 456727 ) on Thursday February 07, 2002 @07:47PM (#2971041)
    Java is safe because it is interpreted. Sure, it is compiled, but the compiled code doesn't run on hardware.

    If .NET code is interpreted, then they can make it safe. If they have a silly marker saying "This code is safe because it doesn't operate on memory directly", then that is just silly because some hacker can easily remove this marker.

    Running code downloaded from the network, directly on your hardware, will always be somewhat dangerous. Of course that is what operating systems are for. However, there is always some way to figure out how to run malicious code in a privileged fashion.
  • by DaveWood ( 101146 ) on Friday February 08, 2002 @03:39AM (#2972915) Homepage
    It's funny that everyone here is saying Sun is spewing FUD and joking about Slashdot being rigidly anti-MS. As far as I can see, almost everyone here is rigidly pro-Microsoft and eager to heap abuse on Java and praise on Brave Microsoft for making the "Genius" C# and .NET.

    There's a tremendous amount of well-rated lies here about the article itself. It's really astounding in its volume - ranting on for pages about how Bill Joy is jealous, and C#'s pointers are totally safe, and Sun is making up lies about C#... "Insightful"! It's like some kind of geek guilt or something - we have to be hard on ourselves, and have a backlash against our backlash now?

    I prefer to actually look at the objective truth on a given day. What's the article about? Joy is saying that C# doesn't force you to be safe. It lets you choose. And the problem is that if you let people choose to be unsafe, then they sometimes will be unsafe, because it's easier, or faster, or because they don't know any better.

    Despite rampant misquoting here to the contrary, Joy wrote explicitly that he knows pointer-massaging code is marked "unsafe" in C#, and is recognized and treated differently by the CLR. It's right there in the article.

    The point is that it just brings us back to square one security-wise - to ActiveX. Break out your digital signatures. Do you trust this code? Yes or no. If you want to run it, you better. Some of it might be "unsafe." Once you start flinging pointer arithmetic around, you can stand up and piss right over the sandbox wall.

    So many choices. So much freedom. .NET is going to be asking your permission all the time. Let me tell you, I just spent the day with a secretary in a law office who was just wrapping her head around loading and saving documents. If her web browser asks her whether or not she "trusts" someone's code, she's going to just click a button at random no matter how many times I try to explain what to do.

    Joy's point is that in the context of network computing, certain kinds of flexibility are dangerous and ultimately destructive.

    I can just see all these rah-rah-C# people making the same kind of arguments I'm hearing about pointers for being able to do powerful word macros and having IE rendering emails. It's so powerful! "Just don't open any word documents from people you don't trust!" they say. Heh.

    What we've learned is that we can't dump this security dillemma on the world under the guise of "choice." We've made that mistake (MS certainly has) over and over again, and the result is the same every time. For something like .NET, without having ironclad and unequivocal guarantees - as Java can give you - you're setting yourself up to have another MS security disaster.

Our OS who art in CPU, UNIX be thy name. Thy programs run, thy syscalls done, In kernel as it is in user!

Working...