473,889 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I've Had Enough

I've had enough of C#. I've had enough of using parentheses for every
'if' statement. I've had enough of having to mix assignment of return
value of methods with flow control, making writing code that's both
readable and consistent, impossible.

C# is hindered by its predecessors and the Microsoft marketing
department. If Anders had his way, this language would be a one where
readable code isn't a near impossibility for non-trivial code; but no,
Microsoft marketing and C++/Java got in his way. The evidence is
blatently apparent in the language.

Microsoft, the company where money comes before technology, has struck
again. The repercussions affect us all.
Nov 16 '05
123 4042
C# Learner wrote:
For clarification, the difference with Delphi's returning mechanism is
that there's no need to declare the result variable, and no need to use
'return result;'.


So how then do you exit "early" from a function, if you have checked
input arguments and decided you already know the result without further
processing? Is your only choice to wrap the entire rest of the function
body inside an else block? If so, the code gets very unreadable very
quickly, especially if there multiple possible early exit points from
the function.
Nov 16 '05 #51
Kevin P. Fleming wrote:
C# Learner wrote:
For clarification, the difference with Delphi's returning mechanism is
that there's no need to declare the result variable, and no need to
use 'return result;'.


So how then do you exit "early" from a function, if you have checked
input arguments and decided you already know the result without further
processing? Is your only choice to wrap the entire rest of the function
body inside an else block? If so, the code gets very unreadable very
quickly, especially if there multiple possible early exit points from
the function.


One can exit early if one so chooses, using 'Exit'.

i.e.:

function Foo: Boolean;
begin
Result := True;
if FooBar then
Exit;
//...
end;

Personally, I don't like exiting before the end ever. If the routine is
so complicated that you need to return before the end to avoid a code
mess, I think it needs refactoring. Perhaps my opinion on this is
somewhat biased, though, due to this being a style I've practised for a
long time.
Nov 16 '05 #52
Reginald Blue wrote:
[...]
Just promise us that you won't start coding in Cobol.NET.


Well, I've never touched Cobol, so I can't appreciate how horrible it
might be, but I can tell you for certain that I'd never remotely
consider using Fortran! :-)
Nov 16 '05 #53

"Julie" <ju***@nospam.c om> wrote in message
news:40******** *******@nospam. com...
C# Learner wrote:

Julie wrote:
> I'll take the language any day. It is their sucky, buggy, deficient
> IDE that
> gets my goat, day after day.
>
> So far, their IDE can handle "hello world" class projects, but not much
> more...
The IDE seems pretty solid to me; but I guess it could be a case of
different machines, different setups, etc.

How about a deal: you take the language and I take the IDE ;-P


Consider yourself lucky. Any commercial-scope project is way outside the
bounds of the IDE.

I'm currently working on one solution composed of maybe 30-40 projects of
C#,
managed C++, and native C++, with multiple forms, controls, etc.

It is a battle to get through a day w/o numerous restarts due to the piece
getting hung up on itself. As we speak, the compiler can't build a
project
because somewhere else the IDE has a file open (in this case, a debugging
pdb
file). Closing all files, and even the project/solution doesn't solve the
problem, the only solution is to restart and rebuild.

Try closing the IDE and deleting the .suo file. This sounds like a known bug
that has been cropping up for quite some time(I seem to recall filing a bug
report myself), there is hope it will be fixed in whidbey, but I don't know
if there was any official word on that and considering how hard it is to
reproduce I couldn't test. Though I havn't run into it in about a year it
does happen and it will drive you nuts. It seems to crop up most commonly
with large C# or C++ projects and *may* be related to the size of an output
assembly. I imagine someone else here knows waht I'm talking about and
remembers more details that I do.
A *major* piece of crap, but what should I expect, MS is run by a bunch of
snot-nosed adolescents that think they know everything.

Not to sound harsh, but you pretty much sound like a know-it-all in all of
your posts. Considering the content of said posts I'd say you have a long
way to go before that attitude is anywhere near correct.
Nov 16 '05 #54
C# Learner wrote:
Personally, I don't like exiting before the end ever. If the routine is
so complicated that you need to return before the end to avoid a code
mess, I think it needs refactoring. Perhaps my opinion on this is
somewhat biased, though, due to this being a style I've practised for a
long time.


Everyone has their own opinions, but think of a simple situation: you're
writing some sort of text parser, and you need a function to take a
token parsed from the file and turn it into an integer value for use
elsewhere in the program. There are many different tokens, of varying
lengths, but they are all known at compile time.

int ParseToken(stri ng token)
{
if (token.Length == 0)
return 0;

switch (token)
{
case "A":
return 1;
case "B":
return 2;
default:
break;
}

if (token.Length < 2)
return 0;

switch (token)
{
case "M1":
return 23;
case "M2":
return 25;
default:
break;
}

etc.
}

Without early returns, this code becomes extremely difficult to read due
to many levels of indentation and extra blocks. Breaking it up into
multiple functions to avoid that would be silly, as it's so simple.
Avoiding the early returns as a matter of "style" causes the code to be
less efficient, as it will continue trying to compare the token against
strings it could never match (granted the compiler may be smart enough
to help out here, or it may not).
Nov 16 '05 #55
Kevin P. Fleming wrote:
[...]

Without early returns, this code becomes extremely difficult to read due
to many levels of indentation and extra blocks. Breaking it up into
multiple functions to avoid that would be silly, as it's so simple.


To be honest, I find the following slight modification which doesn't
return early, much easier to read:

int ParseToken(stri ng token)
{
int result = 0;

if (token.Length > 0)
{
if (token.Length == 1)
{
switch (token)
{
case "A":
result = 1;
case "B":
result = 2;
default:
break;
}
}
else
{
switch (token)
{
case "M1":
result = 23;
case "M2":
result = 25;
default:
break;
}
}
}

etc.

return result;
}

Again, this may just be due to what *I* am used to doing.

<snip>

Regards
Nov 16 '05 #56
C# Learner wrote:

Julie wrote:
I'll take the language any day. It is their sucky, buggy, deficient IDE that
gets my goat, day after day.

So far, their IDE can handle "hello world" class projects, but not much more...


The IDE seems pretty solid to me; but I guess it could be a case of
different machines, different setups, etc.

How about a deal: you take the language and I take the IDE ;-P


Consider yourself lucky. Any commercial-scope project is way outside the
bounds of the IDE.

I'm currently working on one solution composed of maybe 30-40 projects of C#,
managed C++, and native C++, with multiple forms, controls, etc.

It is a battle to get through a day w/o numerous restarts due to the piece
getting hung up on itself. As we speak, the compiler can't build a project
because somewhere else the IDE has a file open (in this case, a debugging pdb
file). Closing all files, and even the project/solution doesn't solve the
problem, the only solution is to restart and rebuild.

A *major* piece of crap, but what should I expect, MS is run by a bunch of
snot-nosed adolescents that think they know everything.
Nov 16 '05 #57
C# Learner <cs****@learner .here> wrote:

<snip>
So one can choose either readability or consistency, but not both.
I don't believe that's true.
Here's the above slightly changed to show a more Delphi-like returning
construct:

FontTagElement GetFontTagEleme nt()
{
//...

if (length == SingleElementPa rtCount) {
if (arr[FirstIndex] == FontNameSpecifi er) {
string name = arr[FirstIndex];
result = new FontTagElement( name);
} else {
int size = TryStringToInt( arr[FirstIndex]);
result = new FontTagElement( size);
}
} else if (length == DualElementPart Count) {
string name = arr[FirstIndex];
int size = TryStringToInt( arr[SecondIndex]);

result = new FontTagElement( name, size);
} else {
result = null;
}
}

Voilà -- no loss of readability and no inconsistency!


Actually, I find that less readable than the straight returns, myself.
With returns in the middle of the method, I know that that's the end of
the useful path of that method. However, you can easily make C# behave
like Delphi in that respect, to a large extent. Just declare:

FontTagElement result;
at the top of the method

and

return result;

at the end.

Personally the first thing I'd ditch from the above is the K&R
bracing...

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #58

"Daniel Pratt" <ko************ ******@hotmail. com> wrote in message
news:u6******** ******@TK2MSFTN GP09.phx.gbl...
Hi C# Learner,

"C# Learner" <cs****@learner .here> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I've had enough of C#. I've had enough of using parentheses for every
'if' statement. I've had enough of having to mix assignment of return
value of methods with flow control, making writing code that's both
readable and consistent, impossible.

C# is hindered by its predecessors and the Microsoft marketing
department. If Anders had his way, this language would be a one where
readable code isn't a near impossibility for non-trivial code; but no,
Microsoft marketing and C++/Java got in his way. The evidence is
blatently apparent in the language.

Microsoft, the company where money comes before technology, has struck
again. The repercussions affect us all.
No language that I've encountered would I consider perfect. Not even
close. Any language that I've seen is either filled with compromises or is
practically useless (or both). Have you found a language you like better,

or are you considering another vocation?

Regards,
Daniel

Hi and sorry but I have to add here some hints to my favorite language:
Smalltalk.
Smalltalk is pure OO and source-code readability is superior. It is
dynamically typed so type declarations are not necessary - it uses keyword
messages
aMessageBox titled: 'I have had enough' confirm: 'Do you like
Smalltalk?' onYes: [ Transcript show: 'read further'; cr ]
instead of
aMessageBox.Sho w( "'Do you like Smalltalk?", "'I have had enough'
confirm" ... );
Unfortunaltley major Smalltalk didn't integrate well in the past into the
Windows OS - VisualWorks / IBM VA have their own philospohy about using the
native OS
IBM VAST uses a Motif layer and VisualWorks emulated widgets.

Dolphin ( www.object-arts.com ) is a nice Windows-Smalltalk with a nice
Windows integration.
Smallscript is an ongoing work to integrate Smalltalk with .NET

We have created our own - still proprietary Smalltalk which has also a deep
OS Integration.
It is not easy to integrate Smalltalk with .NET - Traditionally Smalltalk
dialects have their own Virtual-Machine incl. JIT. CLR is too limited in
many ways to run Smalltalk
effectifley on it. David Simmons ( www.smallscript.org ) who was in the
design team of .NET is creating with S# for .NET.

Be carefull - if you enter the world of Smalltalk programming you will
probably never like to go back - which means today swiming against the
mainstream.

Regards, Frank Lesser, www.lesser-software.com

Nov 16 '05 #59
Jon Skeet [C# MVP] wrote:
[...]
Personally the first thing I'd ditch from the above is the K&R
bracing...


Well, I have tried the other style (can't remember how it's termed...)
and it is my opinion that the K&R style makes code more readable, as it
places less emphasis on the individual blocks of code.

I'm not expecting everyone to share this viewpoint; I'm merely
expressing it.

I think the K&R bracing style is like Marmite -- you either love it or
you hate it :-)
Nov 16 '05 #60

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

Similar topics

23
264
by: C# Learner | last post by:
I've had enough of C#. I've had enough of using parentheses for every 'if' statement. I've had enough of having to mix assignment of return value of methods with flow control, making writing code that's both readable and consistent, impossible. C# is hindered by its predecessors and the Microsoft marketing department. If Anders had his way, this language would be a one where readable code isn't a near impossibility for non-trivial...
101
4034
by: C# Learner | last post by:
I've had enough of C#. I've had enough of using parentheses for every 'if' statement. I've had enough of having to mix assignment of return value of methods with flow control, making writing code that's both readable and consistent, impossible. C# is hindered by its predecessors and the Microsoft marketing department. If Anders had his way, this language would be a one where readable code isn't a near impossibility for non-trivial...
26
1128
by: C# Learner | last post by:
I've had enough of C#. I've had enough of using parentheses for every 'if' statement. I've had enough of having to mix assignment of return value of methods with flow control, making writing code that's both readable and consistent, impossible. C# is hindered by its predecessors and the Microsoft marketing department. If Anders had his way, this language would be a one where readable code isn't a near impossibility for non-trivial...
98
2444
by: C# Learner | last post by:
I've had enough of C#. I've had enough of using parentheses for every 'if' statement. I've had enough of having to mix assignment of return value of methods with flow control, making writing code that's both readable and consistent, impossible. C# is hindered by its predecessors and the Microsoft marketing department. If Anders had his way, this language would be a one where readable code isn't a near impossibility for non-trivial...
0
9969
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
11203
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
10794
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
10896
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
9612
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...
1
7999
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3257
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.