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
But what exactly did you hear?
Also note that assemblies cannot hold other assemblies, and assembly is the
unit of deployment that consists of one or more modules (NOT assemblies).
Why would you need to embed an assembly into another?
The only possibility to build multiple module assemblies now, is by using
the command-line build tools, the upcomming version of VS will add this
function to the IDE.
But again this has nothing in common with static linking.
Willy.
<di********@dis cussion.microso ft.com> wrote in message
news:u5******** ********@TK2MSF TNGP10.phx.gbl. ..
Why not? I heard that this was coming sometime, 2.1 then? We need the
ability to embed an assembly into anotiher assembly (.exe).

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:Oe******** ******@TK2MSFTN GP09.phx.gbl...
As I told you before C# 2.0 doesn't have .lib and static linking. Static
linking involves a native code compiler and a linker, these are the
domain
of C++.

Willy.

<di********@dis cussion.microso ft.com> wrote in message
news:O7******** ********@TK2MSF TNGP10.phx.gbl. ..
> As for preprocessors, theyre evil, hard to debug and just not good in any > way to have mixed compiled code.
>
> I prefer to use a const value rather than conditional compile, at least C# > has reduced this need by having defines limited to true or false
> values,
> still I would prefer it not there at all.
>
> The lack of .lib static linking was a bad thing to not have, thankfully
> its
> back in 2.0.
>



Nov 15 '05 #91
> > > What is it about my brain? I am having trouble expressing the whole
non-constness thing. What I mean to say is that I can't have a const
instance of a type. Even though the reference itself can be const.
The whole const-stuff in C++ is stupid. Classes should be self-contained, and therefore everybody should be able to modify them safely. This is
real-world, or do you know objects in the real world that are constant?

:)
This really doesn't hold up at all.

For instance, it's handy to be able to return an array from a method,
some times - the array could fundamentally be part of the instance's
state. However, I want the contents of that array to be effectively
read-only, so that the caller can't tamper with the state of the class
just by using:

byte[] data = instance.StateD ata;
data[0] = 15;

Const-correctness would prevent that (and many similar problems, mostly
to do with collections).

As I said, const correctness is only useful with not fully selfcontained
like pointers, arrays and so on.
in C# you would write an accessor method which supports only get to retrieve
the array's values:

int this[int index]
{
get {return a[index];}
}

Iam still waiting for the time where C# will support named indexers like in
VB.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu
[noncommercial and no fucking ads]
Nov 15 '05 #92
> > 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".

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #93
> > 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".

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #94
> > The whole const-stuff in C++ is stupid. Classes should be
self-contained, and therefore everybody should be able to modify them
safely. This is real-world,
or do you know objects in the real world that are constant? :)

Maybe in C++ it was neccesary due to the whole pointer-stuff and so
on but in other
languages it is not.
Oh, yet another ingenious insight!

http://www.research.att.com/~bs/blast.html

I'm afraid the "pointer-stuff" has not much to do with whether const makes
sense or not. It is also worth noting that there is an experimental C#
compiler supporting const (Rotor I think) and that most experts would

rather see const back in Java and C#. Reference types with value-type semantics
(e.g. string) would benefit from const (performance-wise).

Why would they benefit from const? Are you talking about immutable classes
or immutable objects now?

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #95
> > The whole const-stuff in C++ is stupid. Classes should be
self-contained, and therefore everybody should be able to modify them
safely. This is real-world,
or do you know objects in the real world that are constant? :)

Maybe in C++ it was neccesary due to the whole pointer-stuff and so
on but in other
languages it is not.
Oh, yet another ingenious insight!

http://www.research.att.com/~bs/blast.html

I'm afraid the "pointer-stuff" has not much to do with whether const makes
sense or not. It is also worth noting that there is an experimental C#
compiler supporting const (Rotor I think) and that most experts would

rather see const back in Java and C#. Reference types with value-type semantics
(e.g. string) would benefit from const (performance-wise).

Why would they benefit from const? Are you talking about immutable classes
or immutable objects now?

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #96
> One of the really useful reasons to be able to specify that a function
does
not change one of its operands is for self-documentation.
Normally you don't have to care wheather an object is changed or not since
all objects
should be self-contained.
As another example, suppose you were looking at some code that used a Matrix class. You come across this function:

Matrix m1 = new Matrix( 4, 12 );
...
Matrix m2 = invert_matrix( m1 );

You consult the documentation and find that it says: "invert_mat rix returns the inverse of the specified matrix". And that's about it (about from some
info about possible exceptions and un-invertable matrices). Now, of course, you have to go and inspect a load of complicated matrix-inversion code just to see if the operand is changed.

Such things like arrays, matrices, lists and so on are generic containers
which are not
really selfcontained since they represent no real-world object. You can
always use a wrapper or only provide an indexer/enumerator that doesn't
allow changes.

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!

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #97
> One of the really useful reasons to be able to specify that a function
does
not change one of its operands is for self-documentation.
Normally you don't have to care wheather an object is changed or not since
all objects
should be self-contained.
As another example, suppose you were looking at some code that used a Matrix class. You come across this function:

Matrix m1 = new Matrix( 4, 12 );
...
Matrix m2 = invert_matrix( m1 );

You consult the documentation and find that it says: "invert_mat rix returns the inverse of the specified matrix". And that's about it (about from some
info about possible exceptions and un-invertable matrices). Now, of course, you have to go and inspect a load of complicated matrix-inversion code just to see if the operand is changed.

Such things like arrays, matrices, lists and so on are generic containers
which are not
really selfcontained since they represent no real-world object. You can
always use a wrapper or only provide an indexer/enumerator that doesn't
allow changes.

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!

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 15 '05 #98
Cody -- wow, you must be incredible if you can make a statement such as:
Multiple Inheritance is just bad style used by poor programmers.
MI *IS NOT* bad style, it is a language construct. Style, for the rest of the
world, is *independent of constructs*. If it weren't, we wouldn't have:

recursion
switch statements
global scope/variables
break/continue
return (except at the end of a function/method)
etc.
etc.
etc.

Statements like yours are the *VERY REASON* that MI and other constructs are
frowned upon. Rather than denigrating language features, you should redirect
your energy to elucidating on style for the benefit of all programmers, poor or
otherwise.

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.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk


--
Bret Pehrson
mailto:br**@inf owest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl >>
Nov 15 '05 #99
Cody -- wow, you must be incredible if you can make a statement such as:
Multiple Inheritance is just bad style used by poor programmers.
MI *IS NOT* bad style, it is a language construct. Style, for the rest of the
world, is *independent of constructs*. If it weren't, we wouldn't have:

recursion
switch statements
global scope/variables
break/continue
return (except at the end of a function/method)
etc.
etc.
etc.

Statements like yours are the *VERY REASON* that MI and other constructs are
frowned upon. Rather than denigrating language features, you should redirect
your energy to elucidating on style for the benefit of all programmers, poor or
otherwise.

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.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk


--
Bret Pehrson
mailto:br**@inf owest.com
NOSPAM - Include this key in all e-mail correspondence <<38952rglkwdsl >>
Nov 15 '05 #100

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
9715
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10940
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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();...
0
5695
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.