473,842 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Another C# critique

I have posted a C# critique at
http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up
the following issues :

- unsafe code
- attributes
- garbage collection
- non-deterministic destructors
- Objects can't exist on the stack
- Type / Reference Types
- Boxing / Unboxing
- Mutability
- Classes as Modules and Programs
- Polymorphism through Class Inheritance
- Interface Delegation
- Interface Extensions
- C# Missing Template Template Parameters
- Late Added Generics
- Source File Layout
- Public Fields
- Special Primitives
- Is it a Property or is it a field?
- Microsoft

I am perhaps guilty somewhat of being a flame baiting troll, but at the same
time I honestly want to improve on the critique.

Thanks in advance for your responses.

--
Christopher Diggins
yet another language designer
http://www.heron-language.com
Nov 15 '05
188 7277
Yes, MI makes it easy to implement abstract visitors in C++.

However, we're talking about C#, and C# has delegates which replace many
uses of the Visitor pattern.

As for indirect visitor, which, if I understand correctly is just a specific
application of double-dispatch, I would guess that a collection of Delegates
pointing to virtual classes (simulating a double V-Table) would work.

I'd have to see a real example to come up with a solution though. I came
across a few other examples of uses, but I'm still looking for one that's
really elegant. A parser-generator might use one, but then again I think
delegates could be used. I haven't really been forced to thought about it.

Perhaps you could provide a link to a good, elegant use of Indirect
Visitors. I've already found
http://www.bleading-edge.com/Publica...5/Column11.htm, but
is there a better example?

Because I'd love to try to figure out an alternative in C# that doesn't rely
on Multiple Inheritance. If nothing else I'd like to try for the challenge.

--Matthew W. Jackson

"Andreas Huber" <ah****@gmx.net > wrote in message
news:40******** **@news.bluewin .ch...
codymanix wrote:
*** NO MULTIPLE INHERITANCE ***!!!

Biggest fault of C# in my opinion.


If you can state only one example where multiple nheritance is
required I'll believe you,
otherwise not. Multiple Inheritance is just bad style used by poor
programmers.
All Multiple Inheritance scenarios are best solved using composition
instead.


Please then tell me how to implement an indirect visitor in C++ without MI
(I'm sure google'll give you all you need to know).

Regards,

Andreas

Nov 15 '05 #101
Yes, MI makes it easy to implement abstract visitors in C++.

However, we're talking about C#, and C# has delegates which replace many
uses of the Visitor pattern.

As for indirect visitor, which, if I understand correctly is just a specific
application of double-dispatch, I would guess that a collection of Delegates
pointing to virtual classes (simulating a double V-Table) would work.

I'd have to see a real example to come up with a solution though. I came
across a few other examples of uses, but I'm still looking for one that's
really elegant. A parser-generator might use one, but then again I think
delegates could be used. I haven't really been forced to thought about it.

Perhaps you could provide a link to a good, elegant use of Indirect
Visitors. I've already found
http://www.bleading-edge.com/Publica...5/Column11.htm, but
is there a better example?

Because I'd love to try to figure out an alternative in C# that doesn't rely
on Multiple Inheritance. If nothing else I'd like to try for the challenge.

--Matthew W. Jackson

"Andreas Huber" <ah****@gmx.net > wrote in message
news:40******** **@news.bluewin .ch...
codymanix wrote:
*** NO MULTIPLE INHERITANCE ***!!!

Biggest fault of C# in my opinion.


If you can state only one example where multiple nheritance is
required I'll believe you,
otherwise not. Multiple Inheritance is just bad style used by poor
programmers.
All Multiple Inheritance scenarios are best solved using composition
instead.


Please then tell me how to implement an indirect visitor in C++ without MI
(I'm sure google'll give you all you need to know).

Regards,

Andreas

Nov 15 '05 #102
OK kids, with so many other things to argue about, let's not keep going with
the C++ vs. C# battle. They are two languages perfectly suited to different
types of programming. Neither is obsolete. C++ caters to the crowd and the
projects requiring maximum flexibility and power, at the cost of being
burdened with a large number of arcane syntactical and structural nuances
that the programmer must be aware of at all times. The language also favors
that power and flexibility at the cost of automatic
language/compiler-induced robustness and security. Looking at it from this
perspective, C# is the exact oposite. C# goes a long way to protecting
programmers from themselves, and boosts productivity at the cost of being
less flexible. However, clearly both are needed, and neither language is
going to die anytime soon. Hell, if COBOL is still around, just imagine how
long C++ will be ;-)

And while I think there are stricter controls over the evolution of C#, and
it didn't start from ground zero (like C++ coming from the C world, which
most claim to be the roots of some of C++'s worst nuances in an effort to
retain backwards compatibility), I do believe C# will develop it's own
quirks as time progresses. However, I would take a language that evolves to
meet new challenges and paradigms any day, even if that means living with a
few quirks, over one that is super clean yet completely stagnant - that is a
recipe for extinction and irrelevance.

-Rob Teixeira [MVP]

"Max Guernsey" <ma**********@h arbingersoftwar e.com> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl...
<di********@dis cussion.microso ft.com> wrote in message
news:u9******** ******@TK2MSFTN GP09.phx.gbl...
C++ over time has become a language of kludges and fixes that the developer
has to code because the compiler is badly designed in the first place.


Wow! I have never heard it stated quite so eloquently. I've been looking
for someone like you. I only have one question:

Where do I ship the time machine you're going to use to go back and make
sure that C++ was designed properly? Please make sure that it didn't have
templates so that we dinosaurs are lucky enough to have to sprinkle our

code with typecasts like you advanced C# programmers. Also, if you have time,
can you see to it that multiple-inheritance was replaced by interfaces so
that I can spend my life retyping the same method over and over?

Thanks in advance.

Nov 15 '05 #103
OK kids, with so many other things to argue about, let's not keep going with
the C++ vs. C# battle. They are two languages perfectly suited to different
types of programming. Neither is obsolete. C++ caters to the crowd and the
projects requiring maximum flexibility and power, at the cost of being
burdened with a large number of arcane syntactical and structural nuances
that the programmer must be aware of at all times. The language also favors
that power and flexibility at the cost of automatic
language/compiler-induced robustness and security. Looking at it from this
perspective, C# is the exact oposite. C# goes a long way to protecting
programmers from themselves, and boosts productivity at the cost of being
less flexible. However, clearly both are needed, and neither language is
going to die anytime soon. Hell, if COBOL is still around, just imagine how
long C++ will be ;-)

And while I think there are stricter controls over the evolution of C#, and
it didn't start from ground zero (like C++ coming from the C world, which
most claim to be the roots of some of C++'s worst nuances in an effort to
retain backwards compatibility), I do believe C# will develop it's own
quirks as time progresses. However, I would take a language that evolves to
meet new challenges and paradigms any day, even if that means living with a
few quirks, over one that is super clean yet completely stagnant - that is a
recipe for extinction and irrelevance.

-Rob Teixeira [MVP]

"Max Guernsey" <ma**********@h arbingersoftwar e.com> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl...
<di********@dis cussion.microso ft.com> wrote in message
news:u9******** ******@TK2MSFTN GP09.phx.gbl...
C++ over time has become a language of kludges and fixes that the developer
has to code because the compiler is badly designed in the first place.


Wow! I have never heard it stated quite so eloquently. I've been looking
for someone like you. I only have one question:

Where do I ship the time machine you're going to use to go back and make
sure that C++ was designed properly? Please make sure that it didn't have
templates so that we dinosaurs are lucky enough to have to sprinkle our

code with typecasts like you advanced C# programmers. Also, if you have time,
can you see to it that multiple-inheritance was replaced by interfaces so
that I can spend my life retyping the same method over and over?

Thanks in advance.

Nov 15 '05 #104
cody <do************ *********@gmx.d e> wrote:
the problem with const correctness is if you change your mind and want that
a method is able to change the parameter, you have to change all const
specifiers in the whole library and all dependent apps!


No, that's the *good* thing about const correctness. Otherwise, all
that changes is the documentation (you do document whether or not
methods will change data within parameters, don't you?) and people may
well not notice. They may well be making an assumption that you're
*not* going to change things. At that stage, the code is broken, but
you don't know it. With const correctness, the compiler *tells* you
that the code is broken, and you can examine every invocation of the
method and see whether it's still okay or whether you need to create a
copy.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #105
Matthew W. Jackson wrote:
Yes, MI makes it easy to implement abstract visitors in C++.

However, we're talking about C#, and C# has delegates which replace
many uses of the Visitor pattern.

As for indirect visitor, which, if I understand correctly is just a
specific application of double-dispatch, I would guess that a
collection of Delegates pointing to virtual classes (simulating a
double V-Table) would work.


Sorry, I meant "acyclic visitor". Here's a good article:

http://www.objectmentor.com/resources/articles/acv.pdf

Regards,

Andreas
Nov 15 '05 #106
cody wrote:
If you can state only one example where multiple nheritance is
required I'll believe you,
otherwise not. Multiple Inheritance is just bad style used by poor
programmers.
All Multiple Inheritance scenarios are best solved using composition
instead.


Please then tell me how to implement an indirect visitor in C++
without MI (I'm sure google'll give you all you need to know).


Iam not sure yet was the "indirect visitor" pattern is but iam sure
it can be better
solved using composition or interfaces.

It would be great if you could explain me a little about "indirect
visitor".


Sorry, I meant "acyclic visitor". Here's a good article:

http://www.objectmentor.com/resources/articles/acv.pdf

Regards,

Andreas
Nov 15 '05 #107
[snip]
Why would they benefit from const? Are you talking about immutable
classes or immutable objects now?


In C#, reference types with value semantics (string, delegates, etc.) are
all immutable, i.e. when you call a function that "looks like a modifier" on
an object of these classes you will never modify the object itself. Instead
the original object is copied, the copy modfied and then returned. This is
because it would be very surprising if functions could modify such an object
that was passed as in parameter. This can lead to excessive copying and
that's also why there is the StringBuilder class. Another way of enforcing
constness is through read-only wrappers around collections. Note that this
means having another indirection between you and the data.
In C++ the very signature of a function will tell you whether it will be
modifying the passed arguments or not. Hence, immutable objects and
excessive copying are much less widespread and there is no need for runtime
read-only wrappers. Everything regarding constness is enforced at
compile-time.

Regards,

Andreas

Nov 15 '05 #108
di********@disc ussion.microsof t.com wrote:
C++ over time has become a language of kludges and fixes that the
developer has to code because the compiler is badly designed in the
first place.


Would you please do all of us a favor and do some research before you make
such blanket statements? It is always easy to say something is badly
designed without saying why exactly you think so. The C++ committee is
certainly a bunch of smart, hard-working people. There *is* a reason behind
all the things you critisize as badly designed.

Nov 15 '05 #109
Comparing C++ (unmanged) to C# is like apples to oranges, both are fruits
but very very different.

However if you comprae C++/CLI to C# then I will listen. Both are in the
same world, managed.

"Andreas Huber" <ah****@gmx.net > wrote in message
news:40******** **@news.bluewin .ch...
[snip]
Why would they benefit from const? Are you talking about immutable
classes or immutable objects now?
In C#, reference types with value semantics (string, delegates, etc.) are
all immutable, i.e. when you call a function that "looks like a modifier"

on an object of these classes you will never modify the object itself. Instead the original object is copied, the copy modfied and then returned. This is
because it would be very surprising if functions could modify such an object that was passed as in parameter. This can lead to excessive copying and
that's also why there is the StringBuilder class. Another way of enforcing
constness is through read-only wrappers around collections. Note that this
means having another indirection between you and the data.
In C++ the very signature of a function will tell you whether it will be
modifying the passed arguments or not. Hence, immutable objects and
excessive copying are much less widespread and there is no need for runtime read-only wrappers. Everything regarding constness is enforced at
compile-time.

Regards,

Andreas

Nov 15 '05 #110

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
3749
by: Long | last post by:
How to include an HTML doc in another HTML doc Problem: to insert the body section of an HTML doc in another HTML document at a specific location. One possible way is to add a WebCharm tag like this: <%@charm:html 20 0 my_services.htm %> When the HTML template is processed by a WebCharm-aware web server, the
19
2561
by: TC | last post by:
Are there any good sites or forums for a web critique? I went to alt.html.critique and it's pretty dead.
9
2290
by: bowsayge | last post by:
Inspired by fb, Bowsayge decided to write a decimal integer to binary string converter. Perhaps some of the experienced C programmers here can critique it. It allocates probably way too much memory, but it should certainly handle 64-bit cpus :) #include <stdio.h> #include <stdlib.h> char * to_binary (unsigned long value) {
39
1947
by: Eric | last post by:
There is a VB.NET critique on the following page: http://www.vb7-critique.741.com/ for those who are interested. Feel free to take a look and share your thoughts. Cheers, Eric. Ps: for those on comp.programming, this may be off topic, but I've posted there because the critique was part of a discussion in that group.
0
9870
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10610
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10670
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10308
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4499
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3141
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.