Re: What I don't like about C# so far, compared to C++ (managed or

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Aug 6, 2:16 pm, Jon Skeet [C# MVP] <sk...@xxxxxxxxx> wrote:
Then tell us what you don't like about C# Jon.

I've done so several times in the past, but briefly:

1) The "lock" statement should have been "using" with an appropriate
locking type. Seehttp://pobox.com/~skeet/csharp/miscutil/usage/locking.html

That's some advanced MoJo there, Jon. Multithreading. I'm a little
less advanced--for example today I found out that C# has a neat and
compact "forward reference" that means you don't have to declare the
forward referenced class as a composite member in your class--but can
actually simply define/use it for the first time in a method parameter
list (assuming it's part of the same namespace). A little different
from traditional C++.


2) Switch needs to be brought into the 21st century - even if the
current behaviour is appropriate, the syntax and scoping could be
significantly improved

Yes, I agree--I've never actually used Switch in any of my programs--
seems so limited, using integers/char for control statements. I use If/
then (nested) instead, same thing. I'm still trying to figure out
(and will experiment today) with identifying objects in C# dynamically
at run-time (do you use "if(object_passed_to_your_function is
MyClass)"?? Seems that way. I thought it might be MyClass.GetType(),
but that just gives you the general (too general) Type of the object
it seems, thought that might be the same thing (another demo project
for today). At some point I'll give in and actually buy a book on C#
(I have on preordered, a nutshell guide due to be published this fall,
by O'Reilly). In the meantime I'll ask this group, which is faster
and easier than looking it up. Forget about "Help" function in Visual
Studio 2005--too much information, usually too generic also.


3) I'd like object-oriented enums, similar to Java's:http://msmvps.com/blogs/jon.skeet/archive/2006/01/05/classenum.aspx

Same thing I suppose.

4) I'd like "private-to-property-code" variables which can't be
accessed by the rest of the class, like those introduced with automatic
properties in C# 3, but available for non-trivial properties too


Yes, somewhere I saw that "properties" are the new "global variables".


5) I'd like non-nullable reference types which can be used as
parameters etc, eg: "void Foo (string! x)". Ideally the compiler should
deal with this at compile time, but at the very least it could generate
code to throw ArgumentNullException where appropriate

Why? I have no idea why non-nullable is important. Must be a multi-
thread thing.


6) I'd like named indexers

Instead of the named IEnumerator class (which you can rename) I take
it? A small point for code clarity I presume.


7) I'd like extension properties like C# 3's extension methods - handy
for writing fluent interfaces

No idea what you're saying here. A quick look at Wiki "http://
en.wikipedia.org/wiki/Fluent_interface" shows a rather confusing
example, that's not at all easy to read, especially since no main()
program "using" the interface is show (hate it when that happens).
Looks too obscure to me--I vote with the people that say "fluent
interfaces" are too hard to read. As for IConfiguration, I'll
probably never use it ("The IConfiguration interface defines
properties and methods used to access configuration information for
Collaboration Data Objects (CDO) objects.) http://en.wikipedia.org/wiki/Collaboration_Data_Objects
(obscure Server stuff--too specialised for my taste)


BTW, inline class definitions really *are* ridiculous. I'm going
through a mess of such a class definition right now,

Sounds like you're dealing with a badly written class - which can
happen in any language.

In C++ you need to keep two bits of identical information in sync -
practically the definition of redundancy. If you want that behaviour,
however, you could always create an interface for every single class
you write.

I used to write C and C++, then moved to Java and then to C#. I've
never looked back with *any* fondness at the .c/.h split, and any time
I've had to work with C or C++ since I've found that to be one of the
pain points.

You're way ahead of me of course. I code as a hobby when I have spare
time from my real job. Right now I'm awaiting some projects so I'm
building an N-ary tree to prove some geneology stuff (see here:
http://tinyurl.com/2rh987). Amazing that my home grown tree is
similar to the C# cookbook's tree, independently derived.

RL

.



Relevant Pages

  • Re: [patch 0/8] Nesting class_device patches that actually work
    ... you give one of your "subclass devices" an interface, ... Take a step back and look what a kernel interface is about. ... device tree by following the "device" symlink from sysfs to get a unified tree ... the hierarchy is not a reason not to be able to walk up the chain and change ...
    (Linux-Kernel)
  • Re: ATL-COM: return pointer to instance
    ... > tree a second time. ... You should call AddRef any time you are handing a new reference to the ... both your own code and the VB code refer to the interface, ...
    (microsoft.public.vc.language)
  • Re: developing for something that isnt there..
    ... xml was chosen becouse well. ... creating a tree model of javabeans was my insisting becouse i didnt' ... had a complelty differnt strucutre and style of interface, ... and interface to send messages about them the classes ...
    (comp.lang.java.programmer)
  • Re: [PATCH] Open Firmware device tree virtual filesystem
    ... the of_* routines continue to define the ... The main problem with the current powerpc interface to the device-tree ... tree is in kernel memory, and the lifetime of the properties is tied to ... In general, we don't fabricate the @unit-address part, we use OF's own ...
    (Linux-Kernel)