What's Wrong with C#

Started by
106 comments, last by Mayrel 19 years, 12 months ago
quote:Original post by the Speed Bump
I see D creeping along the edges of the public consciousness. A blip in CUJ, a slashdotting, an osnews article. I can''t quantify it, but it does seem to be slowly attracting eyes.


So does LISP, and Ruby, and Ada, and umm, lots of other programming languages.

And quite frankly, those languages are a LOT more interesting.

What is D? D is C++ except without the stuff that makes C++ great, it''s C but with a bunch of extra clutter, its C# without all the nice libraries.

So if you want a language that''s a mediocre imitation of a bunch of others, then D is right up your alley.

And this is coming from a guy who has recently decided to learn C#, so I''m not THAT much of a language bigot... or whatever. (although, I still refuse to use Microsoft libraries... Mono has nice stuff, fortunately)
Advertisement
quote:Original post by C-Junkie
So if you want a language that''s a mediocre imitation of a bunch of others, then D is right up your alley.

Precisely: D pulls ideas used in C++, C#, Java, Eiffel, and a host of other languages and is different from all of them in some way.

"Without deviation, progress itself is impossible." -- Frank Zappa
"There is only one everything"
quote:Original post by the Speed Bump
quote:... the same is true of ''implicit'' inheritance of normal methods -- you might forget to override a method in a subclass, and the superclass''s implementation might leave one of your invariants violated. Also, the same is true of the zero-argument constructor -- forget to supply that, and all four languages will happily use the superclass''s, even though the resulting object might be bad.

You got me there. Sounds like a reason to avoid implementation inheritance.

Ack! Without implementation inheritance, we''d all be typing a lot more. Unless what you actually mean is that it''s a reason to be able to seperate implementation inheritance from type inheritance. In which case I agree, some of the time.
quote:
I see your point (I recall writing code extremely similar to that, in fact), but I''m not so sure which the lesser of the two evils is.

Well, I think the explicit version is the evil one.
quote:
quote:Other random features I''d like to see in a modern C-style programming language: multimethods and memoization. Or, ideally, a reflective metaprogramming system powerful enough to let me implement those in the language.

Is memoization the same as serialization? (I''ve never heard the term used before)

No. memoization is caching the return value of a function for each set of parameters it is called with.

If the function always returns the same value for the same parameters, particular sets of parameters are likely to be repeated, and the function is complex, then memoization can be a Big Win.

With a hit in performance, it is possible to let the function access variables other than its parameters and locals, if you ensure that you invalidate the cache when a variable it uses is changed. But if the function references a lot of variables, and if it isn''t called many times between being invalidated, then it probably shouldn''t be memoized.

If the parameters are likely to be different each time, then there is no point to memoization (but see below for a caveat).

int bar () {  foo(rand(int::max));}// This is stupid, because x is highly unlikely to be the same// twice.int foo (memoize int x) {  // Do complex stuff to x //  return x;} 


If the function is so simple that the time spent looking up the parameters in the cache will always outweigh the time it would take to process the function normally, then there''s never any reason to memoize it.

// This would be stupid, because incrementing i is// much much easier than looking up i in a cache.int add1 (memoize int i) {  return ++i;} 


If a parameter forms a continuous range, then it may be possible to memoize only discrete values from the range and interpolate between those values using a specified function.

A simple memoizing square root function might look like:

T sqrt<Number T> (memoize<0.01, memoize::linear> T value); 


This declares a function that memoizes each value rounded to the nearest 0.01, and linearly interpolates between memoized values.
quote:
quote:Also, I greatly dislike the function/delegate distinction. If it looks like a function, smells like a function, and sounds like a function, I want to be able to put a pointer to it in a variable that points to a function.

I think everybody agrees with that. D separates functions and delegates because it has to, not because it''s the right thing. Delegates are implemented as a pair of pointers; a function pointer and context. (either an object instance or a stack frame) Function pointers are basically used for callbacks into C.

This is true. But if you read the standards for C and C++, you''ll note that the representation of function pointers is explicitly not specified. They are, amongst other things, not officially compatible with any other kind of pointer. So, from C/C++''s point of view, it would be valid for function pointers to include a pointer to some context.
quote:Original post by C-Junkie
What is D? D is C++ except without the stuff that makes C++ great,

Well, it looks like D includes almost everything that I like in C++. Certainly, apart from MI, there''s nothing missing that I can''t live without. And even MI I can grudgingly do without. Are there any specific things you think are missing?
quote:
it''s C but with a bunch of extra clutter,

I''d say it''s only clutter if you''re forced to use it, and if it doesn''t make your code clearer and more concise. The heavy-handed OOP of C#, also present in Java, which requires you to wrap even the "Hello, world" program in a class, is clutter. D, on the other hand, doesn''t do that.

In my opinion, D introduces no notable clutter, except the distinction between delegates and functions. It also removes clutter relating to memory management.
quote:
its C# without all the nice libraries.

But you can use C libraries, many of which are very nice, and many of which are in a much higher stage of development than currently available C# libraries.
quote:
So if you want a language that''s a mediocre imitation of a bunch of others, then D is right up your alley.

As is C, C++, C#...
CoV
quote:Original post by Mayrel
No. memoization is caching the return value of a function for each set of parameters it is called with.

I always thought it''d be neat if a function could be denoted as being free of side effects. Compilers would then be free to do all sorts of optimizations behind the programmer''s back. (including this, I assume)
quote:
... if you read the standards for C and C++, you''ll note that the representation of function pointers is explicitly not specified. They are, amongst other things, not officially compatible with any other kind of pointer. So, from C/C++''s point of view, it would be valid for function pointers to include a pointer to some context.

Existing compilers already implement function pointers as a single pointer, though; D needs to match this if it is going to be ABI compatible with C. (the difference between a de facto standard and a formal standard )


"Without deviation, progress itself is impossible." -- Frank Zappa
"There is only one everything"
quote:Original post by Arild Fines

So, since you''ve never actually written any C#, how would you know anything about the quality of the .NET Framework documentation?

MK 0.5 with IR eyeballs
quote:I haven''t seen *ANY* C# code that was "hammered" by this. All use I''ve seen of operator overloading in C# has been very conservative, and used only in situations where it was warranted.

It reminded me of situation like this.

Group of hardware designers.
Chief: Who added that big red button with text "Format C:" on the keyboard?
Person1: I did. It''s really cute. It has also a very nice protection on the top, so nobody would press it accidentally.
Chief: And how many would press it willingly? 10 %?
person2: 20.
person1: 21. Hey don''t try to beat me up. It was just guess, statistical data didn''t arrived yet.

So, we shall see.
quote:
quote:
And on the top you can''t use keyword "operator" as the name of your variable. Readonly is usable as name of variable as well.

OMG! And in Java I can''t use "sealed" as a keyword. You must really be desperate here if this is all you''ve got.

C# uses two keywords, where Java uses one. Also their names aren''t used uncommonly as variables. In other words namespace pollution.


quote:
Yeah, there''s a huge difference. Apples and oranges difference. Those two examples don''t do nearly the same thing.
Difference between that two examples was:
1. example 2 didn''t convert 16 bit string into 8 bit.
2. example 2 was asynchronous library with ability to join multiple request into one operation.

First example loaded a string, then flushed it to print it on the screen. Second example loaded a string, then did what was necessary to print it.
So yes apples and oranges.

quote:The Java one forces you to write a *NEW* DLL, in which functions have very specific calling conventions and uses a specific API. In contrast, P/Invoke lets you consume *ANY* existing export from a DLL. You don''t have to write any wrapper code - nothing.
System.load("somelibrary")
fail=someMethod("msvcrt");
fail2=someOtherMethod("puts",ByteBuffer,length)

Happy now? This example didn''t use a library with properly qualified package names for printing a string. Basically it allows you to use any crap from any library.
quote:Sorry, but you are coming off as a zealot on a crusade here. Your arguments are totally irrational, your writing is rambling and incoherent and I don''t really see why anyone would take you seriously.
Yes I become quite proficient with women logic. ~_^
quote:Unlike you, I actually have experience with both Java and C#, as well as quite a few other languages. You, on the other hand, seem to be wearing blinders.

The two above sentences didn''t have any sense. How can sentence 2 connect to 1?
quote:Are those corporate blinders, perhaps? Sun? Oracle? IBM?


What would you do, if I''d say MS? ^_^ Luckily for you I''m purely independent.

But if you''d like more, then. No checked exceptions issue.
http://www.artima.com/intv/handcuffs.html

I believe you as experienced C# programmer could find more and much nastier things, than person that doesn''t have programming in C# as daily requirements.

BTW how many other programming languages do you know and into what depth? Do you know what is this for? (without checking any book please) "link /section:.bss"


quote:Original post by the Speed Bump
quote:Original post by C-Junkie
So if you want a language that''s a mediocre imitation of a bunch of others, then D is right up your alley.

Precisely: D pulls ideas used in C++, C#, Java, Eiffel, and a host of other languages and is different from all of them in some way.

But it has no niche.

Systems programmers use C because What You Write Is What You Get. Total control, and they need it. But D has GC, and magic string and array type things, it''s out.

Application or web programmers I can see using Java and C# extensively, because they don''t need to worry about details, and since they use large libraries already, what''s a small extra one that JIT''s the application''s code. (and that whole C# run-in-a-jail type thing is kinda nifty...) D? Nope, _too_ low level here, and it has almost zero library support.

Games and servers are written with C or C++, because they need to worry about details. Not total control, necessarily, but the need a lot of control. D? Does magic things again, and library support is limited.

And I somehow doubt D wants into any of the scripting language niches.

Feel free to hope that D finds some market, but without a niche, as far as I''m concerned it''s useless.

anyway, that''s enough of this thread for me.
D applications are a fair bit lighter than those made using .NET or Java, as they don''t rely on a bulky runtime library. Like you said, a lot of people aren''t concerned with this dependancy, but some people want to write compact, freestanding applications without being forced to deal with the nuts and bolts.

Maybe that''s not so much a niche as a gap between niches, but D fits the bill quite nicely.

By the way, D does just fine for games, despite all the "magic". (it''s a fun game, by the way)

"Without deviation, progress itself is impossible." -- Frank Zappa
"There is only one everything"
quote:Original post by Raghar
quote:Original post by Arild Fines

So, since you''ve never actually written any C#, how would you know anything about the quality of the .NET Framework documentation?

MK 0.5 with IR eyeballs

?
quote:
quote:I haven''t seen *ANY* C# code that was "hammered" by this. All use I''ve seen of operator overloading in C# has been very conservative, and used only in situations where it was warranted.

It reminded me of situation like this.

Group of hardware designers.
Chief: Who added that big red button with text "Format C:" on the keyboard?
Person1: I did. It''s really cute. It has also a very nice protection on the top, so nobody would press it accidentally.
Chief: And how many would press it willingly? 10 %?
person2: 20.
person1: 21. Hey don''t try to beat me up. It was just guess, statistical data didn''t arrived yet.

So, we shall see.

1. Operating overloading rarely causes one to accidentally format your hard disk.
2. C++ manages to remain widely used, despite having an insanely dangerous feature.
quote:
quote:
quote:
And on the top you can''t use keyword "operator" as the name of your variable. Readonly is usable as name of variable as well.

OMG! And in Java I can''t use "sealed" as a keyword. You must really be desperate here if this is all you''ve got.

C# uses two keywords, where Java uses one. Also their names aren''t used uncommonly as variables. In other words namespace pollution.

Nobody should be calling a variable, type or function readonly. Variables and types should be nouns, functions should be verbs.

operator is a noun, of course, so one might reasonably want to use it as a variable name. But the intended audience of C#, C++ programmers, are already used to not being allowed to use operator as a variable name. Neither C# programmers can''t name a variable this, either. I wonder why you didn''t complain about that.
quote:
quote:
Yeah, there''s a huge difference. Apples and oranges difference. Those two examples don''t do nearly the same thing.
Difference between that two examples was:
1. example 2 didn''t convert 16 bit string into 8 bit.

Neither did example 1: see below.
quote:
2. example 2 was asynchronous library with ability to join multiple request into one operation.

Really? Where did this happen?
quote:
First example loaded a string, then flushed it to print it on the screen. Second example loaded a string, then did what was necessary to print it.

No, they didn''t. What both of them did was declare some functions. Neither of them actually did anything with them.
quote:
So yes apples and oranges.
quote:The Java one forces you to write a *NEW* DLL, in which functions have very specific calling conventions and uses a specific API. In contrast, P/Invoke lets you consume *ANY* existing export from a DLL. You don''t have to write any wrapper code - nothing.
System.load("somelibrary")
fail=someMethod("msvcrt");
fail2=someOtherMethod("puts",ByteBuffer,length)

Happy now? This example didn''t use a library with properly qualified package names for printing a string. Basically it allows you to use any crap from any library.

Not entirely happy, no. I''m going to follow your example, and show you how simple it is to write a C# version of Doom 3.
System.load("doom3");doDoom3(); 

Tada.
quote:
quote:Sorry, but you are coming off as a zealot on a crusade here. Your arguments are totally irrational, your writing is rambling and incoherent and I don''t really see why anyone would take you seriously.
Yes I become quite proficient with women logic. ~_^

*sniff sniff* Is that an ad hominem argument I smell?
quote:
quote:Unlike you, I actually have experience with both Java and C#, as well as quite a few other languages. You, on the other hand, seem to be wearing blinders.

The two above sentences didn''t have any sense. How can sentence 2 connect to 1?

Arild is saying that she has experience with Java and C#, whilst you have experience only with Java and are refusing to acknowledge weaknesses of Java and strengths of C#; accepting only the evidence that supports your own viewpoint.
quote:
quote:Are those corporate blinders, perhaps? Sun? Oracle? IBM?

What would you do, if I''d say MS? ^_^

Be quite surprised at your hatred of MSDN and C#? Not care?
quote:
Luckily for you I''m purely independent.

Oooh. Aren''t I lucky? Er, remind me again, why am I lucky?
quote:
But if you''d like more, then. No checked exceptions issue.
http://www.artima.com/intv/handcuffs.html

I believe you as experienced C# programmer could find more and much nastier things, than person that doesn''t have programming in C# as daily requirements.

Eh? You cite an article about the good reasons why C# doesn''t have checked exceptions as evidence for C#''s nastiness?
quote:
BTW how many other programming languages do you know and into what depth?

I realise this isn''t directed at me, but I consider myself to be sufficiently proficient in 13 programming languages; and highly proficient in 3 of them.
quote:
Do you know what is this for? (without checking any book please) "link /section:.bss"

That isn''t programming language related, you know. But...

The .bss section is a special section which is not actually included in the produced executable or library, because when loaded into memory it is all zero bytes.

The /SECTION option to Microsoft''s C++ linker overrides default attributes for the specified section.

It is generally a bad idea to override attributes for the special sections, like .bss. I think in this case it''s okay, partly because the command given doesn''t change the default attributes for the .bss section, but mainly because it doesn''t specify any object files to link, and therefore will terminate with an error.
CoV
I just thought of something about C++ (i don''t know about c# because i''ve never used it) that could be played with. If you code a program like this:

typedef char *STRING;STRING str = "asdf";str = "jkl;"; 


Both "asdf" and "jkl;" will be in memory at runtime. Pretty much everything you put in the quotes will be a constant string stored in the Data segment. You can''t modify anything in the data segment during runtime, so you would have to use an array or develop a big CString class (like in MFC) or something to solve this. I think that coding languages should have a built in string system.



-----------------------------------------------
Here comes the Thnikkaman!
------------------------------------------------------------"Many combilations elizagerth. I hope you see my particles." - Senor Cardgage
quote:Original post by Yohomyth
I just thought of something about C++ (i don''t know about c# because i''ve never used it) that could be played with. If you code a program like this:

typedef char *STRING;STRING str = "asdf";str = "jkl;";  


Both "asdf" and "jkl;" will be in memory at runtime. Pretty much everything you put in the quotes will be a constant string stored in the Data segment. You can''t modify anything in the data segment during runtime, so you would have to use an array or develop a big CString class (like in MFC) or something to solve this.

Or use std::string, which has already been made for you.
quote:
I think that coding languages should have a built in string system.

Many already do.
CoV

This topic is closed to new replies.

Advertisement