4 ms·
Java wasn't good enough...but that was not the reason MS created C#. They were very scared of Java at the time, and their attempt to "embrace and extend" failed
by olavk 9y ago
Java wasn't good enough...but that was not the reason MS created C#. They were very scared of Java at the time, and their attempt to "embrace and extend" failed. So they created their own language.
Out and ref was not a clean way to return multiple values - they are actually a pretty ugly way to return multiple values. (Tuple unpacking is the clean way, but that has only recently been added.) Out and ref was added because C++ API's had call by reference, and MS wanted to make integrating with windows API's easier. I suspect value types (structs) were added for the same reason.
That said, C# did end up a much better language than Java, especially with later improvements like generics and Linq.
- curtis 9y ago> (Tuple unpacking is the clean way, but that has only recently been added.) Oh, I agree with you there, but that doesn't change the fact that ref/out parameters were a much, much better than the way Java forced you to do it. I don't mean to imply that C# 1.0 was a good language even for the 90s, but it was a big practical improvement over Java. I think C# 2.0 is the first point where someone could make the claim that it was actually a good language, at least for that era.
- Arwill 9y agoThe logic behind Java is that the language should not concern itself with technicalities, the JVM will take care of it. This principle goes both ways, the JVM can't optimize your code if you have already decided how it should behave. As i understood, that is why they never added the more technical features as MS did in C#. In principle if you want to return multiple values from a method, you can return them in an array, and in principle the JVM optimizer will take care of the array. That is in principle, i don't know how good the optimizer got in this regard. But i still prefer Java for simplicity and readability.
- dtech 9y ago> In principle if you want to return multiple values from a method, you can return them in an array This is not viable. If I want to return e.g. an (error) code and string, the only Array you can put that in is an array of the root type (Object), losing all type-safety. In C# and Scala multiple return values use a Tuple class, with some syntactic sugar to easy create and read them. It will eventually be in Java [1], it just takes decades. It also has very little to do with the optimizer, there's not reason why the JVM couldn't support & optimize it. [1] http://openjdk.java.net/jeps/305 http://openjdk.java.net/jeps/305
- olavk 9y agoOptimization is not the issue. It is not possible in a strongly typed language to return multiple heterogeneous values in an array. That is why we have tuples.
- badsectoracula 9y ago> They were very scared of Java at the time This is an understatement, reading some of the antitrust documents you can clearly see that Microsoft was afraid that Java's ability to create rich programs that run regardless of OS would end up making Windows unnecessary since it wouldn't matter what OS you had. They saw Netscape as a distribution vector for Java and the JVM and was an important reason for why they made IE (one could say "and ActiveX" but that was already a thing they had anyway). And FWIW i think they were partially successful in that their own MS Java did kill Java on the desktop and browser (the startup performance of Sun's runtime was also a factor, but the main thing i always remember developers being concerned around the turn of the millennium was compatibility with the VM that everyone had - the MS Java - both in terms of supported APIs and in terms of runtime performance - MS Java was way slower and contributed extensively to the idea of Java being slow). Of course they failed to avoid making Windows unnecessary for a large number of applications, but instead of Java it was HTML, CSS and JavaScript. If that is a better alternative... well, i'm sure there are people who prefer it this way.
- olavk 9y agoI'm one of those who prefer HTML/CSS/JavaScript to Java applets! It is interesting that MS for a while heavily pushed JavaScript and dynamic HTML in order to undercut Java...until they belatedly realized they had creating something which was just as bad to the Windows lock-in.
- pjmlp 9y agoThe irony is that Applets are back, now they are called WebAssembly.
- da02 9y agoI agree. Those emails/PDFs released in the DOJ case very enlightening and proved a lot of what Charles Ferguson was talking about in his books, "Computer Wars", "High Stakes, No Prisoners". MSFT was even afraid of AOL, Oracle, and others teaming up to offer a home appliance (eg. a net PC) at low prices and undercutting the PC industry. Of course, those partnerships and alliances never did work out. Sun and Netscape hated each other, for example. Microsoft was even worried Sony would "take over" the home since game consoles were becoming as powerful as PCs. Flash forward a few years: when I used my brother's PS3 in 2010, I couldn't believe how awful the browser was on such a powerful machine. Hollywood and media companies were also afraid of Microsoft in the 90s. MSFT was making deals with Dreamworks, NBC (ie MSNBC), and others. It really did seem like MSFT had the cash to takeover the world and charge fees everytime a movie needed to be distributed. At one point, early on, Bill Gates suggested people would pay a nickel or dime to view a website. Then, in the low 2000s, when .Net came out, there was a slide that compared the PC desktop to the WWW. MSFT wanted to offer APIs/languages/abstraction layers for the WWW that were analogous to the MSFT desktop. The same paranoia people had of MSFT/AOL/Oracle, continues, but the names have change to different companies.
- Someone1234 9y ago> (Tuple unpacking is the clean way, but that has only recently been added.) That's both accurate and a little misleading. Tuples are ten years old, they were added in 2009/10. However, improvements in syntax and cleaner unpacking have been recent additions. In general though ref and out have taken a back seat to Tuples for years now in C#.
- DonHopkins 9y ago>MS wanted to make integrating with windows API's easier Agreed: integrating with other languages was very important to Microsoft, but not to Sun with its "100% Pure Java" campaign. See my other comment about that: https://news.ycombinator.com/item?id=16354176 https://news.ycombinator.com/item?id=16354176
- pjmlp 9y agoOut and ref were already a thing in many Algol/Pascal derived/inspired languages. Given C# designers, the goal was always to have a safe language, with enough features to go the extra mile in performance without necessarily being forced to use something else. Something that Java designers are now catching up with, but we still need to wait a couple of years before Valhalla, Pananama and Metropolis are finally here.