Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Programming IT Technology

How C# Was Made 391

prostoalex writes "Bruce Eckel (from the Thinking in C++/Java/Patterns/Enterprise Java fame) and Bill Venners have interviewed programming legend Anders Hejlsberg. After 13 years in Borland and joining Microsoft in 1996, Hejlsberg now leads the development of C# language and talks about the development process, reasons some things exist in C# and some not, as well as future directions."
This discussion has been archived. No new comments can be posted.

How C# Was Made

Comments Filter:
  • "Co-opt Java" (Score:2, Informative)

    by tealover ( 187148 ) on Saturday February 07, 2004 @04:32PM (#8213654)
    I believe that was the mandate given Hejlsberg by Gates.

  • by Anonymous Coward on Saturday February 07, 2004 @04:36PM (#8213676)
    There a great interview [sys-con.com] with The father of C# here too,
  • by enkafan ( 604078 ) on Saturday February 07, 2004 @04:37PM (#8213688)
    There is a pretty good interview [microsoft.com] on the .NET show on MSDN with Anders too. It runs about one hour, so get a comfy chair.
  • by atlasheavy ( 169115 ) on Saturday February 07, 2004 @04:39PM (#8213697) Homepage
    Joel Spolsky published a great article [joelonsoftware.com] a while back on .Net, his company's strategy for the platform, and why Anders so damn cool. Also, just in case you're curious as to how his last name is pronounced, it's pronounced hells-burg.
  • ...right here [artima.com] to save you a click thru the MSDN page.
  • by The_DOD_player ( 640135 ) on Saturday February 07, 2004 @04:57PM (#8213820)
    Also, just in case you're curious as to how his last name is pronounced, it's pronounced hells-burg.

    No, it most certainly is not!
    First its Hejlsberg, not Hejlsburg. "Hejl" is pronounced just like "Heil", as a german would in a WW2 movie :). "berg", the "g" is more or less mute, so it pronounced more like "bear".
    So its "Heils-bear"
  • It was a piano joke. (Score:1, Informative)

    by Anonymous Coward on Saturday February 07, 2004 @05:11PM (#8213904)
    NT
  • Re:"Co-opt Java" (Score:2, Informative)

    by tealover ( 187148 ) on Saturday February 07, 2004 @05:14PM (#8213929)
    I use them on my cell-phone daily. It appears you're still thinking in terms of desktop applications. You better start thinking in the now before you become obsolete.
  • Checked Exceptions (Score:5, Informative)

    by po8 ( 187055 ) on Saturday February 07, 2004 @05:16PM (#8213951)

    Actually, Java supports both checked and unchecked throwables: the latter with the class Error. My programming style is to make throws that I don't expect to be "routinely" caught throw Errors rather than Exceptions. An Error can still be caught, but since you don't expect it, you needn't declare it.

    The checked exceptions are still useful for the case where it would probably be a bug not to handle the exception, e.g. "search found no element" or "file not found". The reason for the two kinds of throwables is exactly this: you don't want to declare that every method doing division throws DivideByZero. Unfortunately, the Java library designers don't seem to have gotten it, and so there's a bunch of things like IOException that IMHO should have been Errors.

  • by JohnnyCannuk ( 19863 ) on Saturday February 07, 2004 @05:19PM (#8213966)
    ...uhmm

    Go here [sun.com] and when you done, go here [sun.com] and get it.

    When you are done playing, come back and see if your post makes sense.
  • by Scott Wood ( 1415 ) <scott@buserror . n et> on Saturday February 07, 2004 @05:52PM (#8214170)

    You can get garbage collection and array bounds checking in fully compiled languages (such as D [digitalmars.com]), too.

    And you'd better still worry about such things to a certain extent, or else you'll be throwing exceptions on legitimate usage cases when your fixed-size buffer turned out to be too small, running out of memory because you didn't bother nuking references to old objects, etc.

  • by Anonymous Coward on Saturday February 07, 2004 @05:56PM (#8214194)
    Java supports both checked and unchecked throwables: the latter with the class Error.

    Unchecked exceptions should be derived from the RuntimeException class. Generally subclasses of Error are not meant to be caught ("An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch" - from the Javadoc for Error).

    you don't want to declare that every method doing division throws DivideByZero

    That doesn't throw an exception/error at all, it returns NaN [sun.com].

    there's a bunch of things like IOException that IMHO should have been Errors

    IOException is something that needs to be checked. It can occur because of low disk space, broken network connections (including NFS mounts), bad character coding, etc. Even FileNotFoundException is a subclass of it.
  • by ajagci ( 737734 ) on Saturday February 07, 2004 @06:10PM (#8214281)
    I think on many issues, Hejlsberg is missing the point and the reasons he gives aren't necessarily the actual reasons why particular design tradeoffs are good ones.

    But it really doesn't matter. The changes that C# made relative to Java are obvious and proven (e.g., value classes, removal of statically checked exception declarations, declared unsafe code sections). Many of them had made Sun's bug parade. All of them had been in other languages before either Java or C#. In fact, C# is, in many ways, close to Modula-3.

    There seems to be another reason for some of the design decisions: patents. Sun has patents on several aspects of the JVM and Java, and if Microsoft wanted to be free of potential future claims by Sun, they had to avoid those in their own competing virtual machine.

    Keep in mind that Hejlsberg is also a salesperson for the language anyway. That means that he may not be telling you the real reasons behind design decisions, but the reasons that sell the language well.

    In any case, however it came into existence, C# is a somewhat better language than Java, and we should be happy about that: whether you are planning on using C# or not, it raises the bar for what is considered standard in industry. Without C#, Sun probably wouldn't even have made the largely cosmetic changes they made to Java in 1.5, and maybe the continued existence of C# will force them to fix other misfeatures of Java and the JVM in future versions. And C# (but not .NET) may turn out to be the free and open language that Java should have been; time will tell.
  • by bolind ( 33496 ) on Saturday February 07, 2004 @06:22PM (#8214341) Homepage
    It's Hejlsberg, and it's pronounced more like "heil-s-bear", heil as in "sieg heil" or "tile".

    I should know, as we come from the same country.

  • by Panix ( 2408 ) on Saturday February 07, 2004 @06:57PM (#8214583) Homepage
    Unfortunately, Java gets most of these features at a superficial level, since it has to support older VMs. Sun sees that C# has these things and that developers want them, so they give them as much of the syntactic advantage as they can without "breaking" their older VMs... its really a shame.

    The Microsoft CLR has support for many of these features (and others) built into the underlying framework. As a result, things like Generics in C# are about a hundred times as functional and advantageous than they are in Java. Read the article that was linked to in this story, and it will readily become clear that Java is playing catch up at this point. The C# creators really thought of these things *up front* and designed the framework for them, and it really shows.

    One of the best examples of this in the interview is that of generics. In C#, if you declare a List of Customers (List), you can see that all the way down to the Reflection/introspection level. It really, genuinely is a List of Customers. However, in Java, because they have to live with their inferior framework, a List of Customers at the Reflection level is a List of Objects... hence, its just an illusion. You get the type checking at compile time, but lose performance advantage and true Generics support.

    Thank God for the folks at Ximian though! I really like much of the .NET development framework, and now I can use it on UNIX based systems. I am still waiting for a nice release that will fully run on Mac OS X though.
  • by Kupek ( 75469 ) on Saturday February 07, 2004 @07:03PM (#8214626)
    C++ is the opposite. In C++, you can do anything you damn well please on a variable of a type parameter type. But then once you instantiate it, it may not work, and you'll get some cryptic error messages. For example, if you have a type parameter T, and variables x and y of type T, and you say x + y, well you had better have an operator+ defined for + of two Ts, or you'll get some cryptic error message. So in a sense, C++ templates are actually untyped, or loosely typed. Whereas C# generics are strongly typed.

    I disagree with that assessment. Both C# and C++ generics/templates are strongly typed. It's just that the enforcement happens in different places.

    In C++, if you try to stick a class into a templated class when that class doesn't have a particular member function defined, the compiler will yell at you, just like Hejlsberg said. But for some reason, this doesn't count as type checking? Yes, template error messages can be strange (and very long) if you're not familiar with them. But that's just a lesson in "know your tools."

    To me, "strongly typed" is strict type enforcement at compile time. C++ templates certainly do this.

    Constraints, however, are something that I think are a generally good idea. Stroustrup's reasoning for not including them in C++ was that "Requiring the user to provide such information decreases the flexibility of the parameterization facility without easing the implementation or increasing the safety of the facility." (The Design and Evolution of C++, Stroustrup, 343).

    He does, however, show an interesting way to get around this using inheritance:

    template <class T>
    class Comparable {
    T& operator=(const T&);
    int operator==(const T&, const T&);
    int operator<=(const T&, constT&);
    int operator<(const T&, const T&);
    };

    template <class T : Comparable>
    class vector { // . . .
    };

    (The D&E of C++, Stroustrup, 344)

    This technique is similar to how C# does constraints, class List where T: IComparable. One is supported and enforced by the language, the other is a natural consequence of the languages facilities. In general, I think that constraints are probably a good thing. Having an error message like "Can not instantiate class Y<T> because T does not implement z()" is probably best, and when looking at a class' declaration, it would be nice to see up front what assumptions the templated class makes.
  • Re:Its not redundant (Score:4, Informative)

    by hobuddy ( 253368 ) on Saturday February 07, 2004 @08:28PM (#8215151)

    In your example, I know with complete certainty that I am creating a new "Type" and assigning it to the variable "varName". This is not the case if it used the syntax of Python. How do you know I am not calling a method called "Type"?

    You don't know, and you shouldn't.

    Suppose at first you do, in fact, instantiate a new object via the 'Type()' call. Later, during the optimization phase, you discover that in most cases you can return a reference to a pre-existing, pooled object. In Python, you can make that change without breaking client code; not so when object creation is explicitly annotated.

    As to whether Type is a method, function, or class constructor, it doesn't matter as long as the returned objects implement the required interface.

  • Re:worst C# drawback (Score:4, Informative)

    by enkafan ( 604078 ) on Saturday February 07, 2004 @10:39PM (#8215831)
    Here's your macro: http://weblogs.asp.net/jan/archive/2003/04/29/6168 .aspx [asp.net]
    There are plenty of people working on tons of free libraries out there. The gotdotnet workspaces are pretty good place to search for things, but your best best is to follow the weblogs on asp.net.
  • Re:worst C# drawback (Score:4, Informative)

    by Bazouel ( 105242 ) on Saturday February 07, 2004 @11:55PM (#8216172)
    Ever bothered to look at http://www.codeproject.com ??

    How about you write your own getter/setter macro and publish it there ? That is how a community is built, slowly but surely.
  • by globalar ( 669767 ) on Sunday February 08, 2004 @01:10AM (#8216514) Homepage
    "There are so many parts of the whole software development process that needs to be improved."

    Completely true.

    In a time when tools are myriad, code can be found for free, and the Internet archives and Google searches lessons and tutorials for us, software developement is crazy. And its funny and ironic that the most essential part to software developement, the developement (it's process: the drafting, coherent, problem-solving design, habitual testing and review, documentation, etc.) is seen as expendable!

    Someone somewhere once had the great idea to cut back in software developement - make an unrealistic timeline, change the project's goals and pretend the code will reflect those changes, switch people in and out during developement like nodes in cluster, outsource, skip some testing or only test what you know works, etc.

    You are right. Programmers, engineers, etc. can make wonders with far fewer resources, capable tools, and little financial incentive. But without some sense in the process, without a plan to succeed and solve problem(s) with this software (especially adherence to the plan), whatever wonders may have been created are lost in bad habit. So what happens in a lot projects (probably the majority)? Let's buy more resources, more capable tools, and dump other things into the developement.

    Fifth grade, I had a teacher who made us repeat a short sentence to her everytime we "forgot" to do our homework:

    "Mrs. H, I failed to plan to succeed."

    And everytime we said it, it was true.
  • Re:worst C# drawback (Score:2, Informative)

    by aderen ( 323539 ) on Sunday February 08, 2004 @02:10AM (#8216722) Homepage
    You can download vs.net property generator for free from my site http://www.adersoftware.com/index.cfm?page=vsPrope rtyGenerator
    no source code included, but if you need it, I can email that to you.
  • by aziraphale ( 96251 ) on Sunday February 08, 2004 @06:37AM (#8217416)
    Actually, it's worse than you think...

    int i = new int(1);

    No heap allocation has occurred, we've just allocated an int32 on the stack and dumped the output of the int32 constructor into it. That new keyword is really just an indicator that tells us we're calling a constructor.

    And how about this:

    int[] ints = {1, 2, 3, 4, 5};

    That just allocated a new heap object, and there's no new keyword in sight...

    (Before anyone argues that that's just like string s = "hello", it isn't... string literals are constants, they're pulled out of the interned string pool when they're referenced. Array literals like the one above are created in bytecode on the fly.)
  • Brief Historic Note (Score:2, Informative)

    by j.leidner ( 642936 ) <leidnerNO@SPAMacm.org> on Sunday February 08, 2004 @09:25AM (#8217768) Homepage Journal
    "After 13 years with Borland, Hejlsberg joined Microsoft in 1996 [...]"

    If you remember what happened a while ago, the story goes: Microsoft was facing competition from Borland, so they hired away all their lead developers to break the company's neck.

    It almost worked.

    PS: Don't use anything that has a '#' in it and isn't music!

  • Re:"Co-opt Java" (Score:2, Informative)

    by Anonymous Coward on Sunday February 08, 2004 @11:02AM (#8218048)
    Your arguments on Java are baseless. Java was originally designed to be as an appliance/emmbedded application development system. The problem was they couldn't get anyone interested at the time they originally developed it so they decided that "Hey, this internet thing is getting some publicity, let's use it there." Ten years later, it's finally starting to get used for what it was originally intended: cell phones, ATM's, etc.

"May your future be limited only by your dreams." -- Christa McAuliffe

Working...