Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / I just lost Respect for .Net today It's another OOP (limited) CLONE! So Sad :(

Author
Message
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Apr 2008 01:49 Edited at: 9th Apr 2008 01:56
Quote: "Inheritance and polymorphism
Only single inheritance is allowed in C#. Multiple inheritance can be achieved using interfaces."


This is SO SAD! I had no idea! Until today - when I went to do what programmers do with OOP languages - I tried to inherit a class designed for such things and WHAM... "Sorry" It's not 100% OOP

[edit]Having to write an interface for each layer - is cumbersome and is not eloquent[/edit]

[edit2] C++, Delphi, FreePascal Just rock - plain and simple - ALMOST everything else is not truly oop or is Script ... [/edit2]

[edit3]I dare say I've coined a new acronym "P"athetic "OOP" = .Net is a POOP language.[/edit3]

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Apr 2008 02:09
Quote: "This is SO SAD! I had no idea! Until today - when I went to do what programmers do with OOP languages - I tried to inherit a class designed for such things and WHAM... "Sorry" It's not 100% OOP"


Care to elucidate?

.NET isn't a language, it's a framework. C# is the language. What exactly were you trying to do and what about it failed?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 9th Apr 2008 02:18
Quote: "I dare say I've coined a new acronym "P"athetic "OOP" = .Net is a POOP language."


Lol , must remember this for the future.

Yep, multiple inheritance out of the box is what I missed when I started using C#. Although like you say there is ways around it, and chained inheritance is possible.

But, I think C#'s pro's overcome its con's, 10-1. the .NET framework is a god send when programming with one of the .NET languages, it makes life so easy.

Much good work is lost for the lack of a little more.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Apr 2008 02:20 Edited at: 9th Apr 2008 02:21
1: Almost all the .Net Languages are "OOP"
2: C# is the most "powerful" one in many ways
3: C# (And probably the entire framework) do not allow Multiple Inheritance.

Elucidate? (I love your vocabulary!)

How can a language really qualify as a true OOP language if it doesn't allow multiple inheritance? Writing an Interface to Emulate it doesn't quite jive IMHO.

This means that the .Net framework isn't ALL that much more oop than vb6.

Now I wrote (and sometimes still do) write some pretty amazing stuff in vb6, and I'm not questioning the POWER of C# in usefulness. It wouldn't be so successful... (plus the biggest marking monster on the planet helps) but to call it OOP - seems to a purist like me -

FALLING SHORT.

And Lilith - I'm one of those people like yourself that can code the same application a million different ways and it will still do the same thing (In other words - I can get around this issue easy enough)... but my thread title - for me - stands.

This Purist lost respect for C# (And the entire .Net Framework) today. It's not (IMHO) truly 100% if it doesn't support multiple inheritance - except through homebrew "interfaces".


[edit]
Quote: "But, I think C#'s pro's overcome its con's, 10-1. the .NET framework is a god send when programming with one of the .NET languages, it makes life so easy."


I agree. But I was shocked - and dismayed at this personal revelation![/edit]

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Apr 2008 03:30
Truth to tell, I never found much use for multiple inheritance and when I try to imagine the instance in which I would use it I have the feeling that it would have been a deliberate attempt to practice it rather than apply it. One of the first things I read about it was to use it sparingly. It requires an understanding of what's contributed by each class and the need to be aware of conflicts.

Interfaces, IMO, aren't inheritance. They're contracts for you to provide functionality. You gain nothing but a structure in which to work. At least it would help me with the organization of some of my programs if I designed my own interfaces. From a practical stand point it should help in keeping certain classes compatible with other .NET classes.

Having classes handed to me in .NET is wonderful. Until I really got into C# and .NET I was depending on code from The Code Project and Code Guru. But even then some of those things quit working for me for reasons I'll never understand. I had a need for a program that would monitor one of my SMTP servers and .NET provided that capability without my having to re-invent the wheel. I'm not sure that I'd like to try to inherit from it but it was nice to have the wheel handed to me rather than me having to chisel it from a boulder.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Apr 2008 04:06
Understood. It is powerful no doubt, and I agree with all your statements.

I do however love multi-inheritance.

I don't just take Microsoft "canned" classes and bury them in some esoteric nest of junk. I'm also not against such inheritance tricks for quick wrapping of a base class thats offered to tailor it for a specific purpose.. but this isn't where I use multiple inheritance.

First off, the whole thing about "don't do it to much" seems like rubbish - unless the in some languages it causes more harm than good via overhead. In FreePascal, a class base - is merely appended to. So if you have 20 variables, and 100 lines of code - then when its compiled - there is 100 lines of code (shared by each instance...very efficient) and each instance allocates the memory required for its own set of the 20 variables. Inheriting such a class effectively just appends the compiled code to the end of the code for the base class, and the new variables that may exist in the new derived class, are simply that - more variables.

When a derived class is compiled, its no different than a single class (Just has more junk in it) and the benefit of this code reuse, not tomention a side effect I personally think is wonderful in all OOP languages - and this architecture is just as beneficial in Assembly Language "oop" stuff (Yes - OOP in assembly language is possible... though been couple years since I did it - fast as hell too.)

The benefit is that when you have a base class, you allocate a new class - whether via pointer or whatever - from its base address - the variable pointers within it and the function pointers in it - have offsets where they sit stacked from the POINTER + ZERO. Now an inherited CLASS has more stuff appended (when the language implements it correctly). This means that new stuff exists at POINTER + SIZEOF(BASECLASS). If you inherit again, you now have the third level stuff appended at: POINTER + SIZEOF(BASECLASS) + SIZEOF(CHILD1)

So in code - using the POINTER of your multiple inherited class - you can do the following:

((BASECLASS*)POINTER)->BaseClassFunction();
((CHILD1*)POINTER)->ChildClassFunction();
((CHILD2*)POINTER)->ChildClass2Function();

In other words... If a BASE class is used in twenty derivitives - that ALL THOSE DERIVITIVES - no matter how complex - have the same function pointers and variables - in the same memory offset as the original BASE CLASS. Same for 2nd, and however many generations.

The impact is you can do some pretty advanced things where you can write ONE function that can process 20 different types of classes - with the SAME CODE!

Think GUI for a minute. WIDGETBASE, WIDGETCONTAINER, FORMWIDGETCONTAINER, TABWIDGETCONTAINER, TASKBARFORMCONTAINER, FORM, etc. I'm sure you can use you imagination on how one might build layered classes to describe increasingly complicated user controls. HOWEVER - because they all share the WIDGETBASE class, there are many things I do to EVERYTHING because they ALL HAVE SIMILIAR properties. I can write code to manipulate ALL those various classes - with one line of code - versus - IF classtype==blahblah then etc.

MultiInheritance is not critical for most simple tasks - but in my opinion there are many applications where multiple inheritance is the only way to properly tier complex systems - for both code resuse, resource conservation, modular design considerations, and rapid application development in general.

I would be sheepish to not add that I CAN NOT STAND trying to use Microsoft Foundation Classes. Its very powerful - and a testament to what I'm soapboxing here about - but I PERSONALLY found thier a pain to use and learn.. because I didn't write the code myself. Now in my own code - when I know every tier from the base class up - then development is milk and honey because I understand every level I put together.

Furthermore - I rarely go past 3 levels, and even more rare is 4 or five levels deep - however - knowing its there makes a difference in how my vision develops when looking at how to properly develop a specific application. Not having multiple inheritance is a LIMITATION and a hinderance.

..steps off soap box...trips... busts lip wide open... Can I inherit a bandaid?

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Apr 2008 04:38
I'll slap one on you. A bandaid that is.

I didn't so much fight MFC as much as I stared it down. I blinked first. Most everything I wrote was command line oriented. I wanted to do GUI programs but, as I said elsewhere, I had no one to go and ask questions of. At least not without major delays in the give and take. Sometimes what it takes for me is a breakthrough in understanding. Once I figured out what MFC was about it was all downhill from there. But I'm with you. I work best with things I wrote because I understand what they do, how they do it and, best of all, if they don't do what I need, I make them do it.

The problem with Windows scratch programming is that I have trouble wrapping my brain about how messages are passed back and forth. So I ended up depending on VS to provide me with the hard core functionality. Maybe someday I'll understand tabbed windows.

The major concern that was pointed out to me regarding multiple inheritance isn't so much with the added data but rather with the potential for conflicts in methods from the base classes.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Argon Knight
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Gastonia, NC, USA
Posted: 9th Apr 2008 05:52
The day I learned .Net didnt do Mutli Inheritance was after the first beta release. Wow, that came on a DVD! Had to borrow a clients computer to load it.

Microsoft laid it on thick to explain their reasons (you can googled them). I think its becuase Java doesnt do MI, or at least back in the '90s when I last coded with java.

Truth be told, I have found only a few, rare patterns that require true MI. The rest of the time , a simple public var/property intancing my custom class inside a contanier class is enough. I just think of it like namespacing for instanced objects.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Apr 2008 14:34
@Lilith - thanx for the bandaid I again can understand and agree with everything you said - (which is a pleasant surprise) - As for the conflict of method names - I can see that being an issue.

Another favorite thing for me about oop in general is you can OVERRIDE or ... often my favorite "OVERIDE + INHERIT" (C++ by default does this I'm pretty sure) I'm talking about if I have a constructor or a function that does x,y,z... then make a decenscand have a function with the same name - I can ADD to what that method does but the original will stil be called. Surprisingly - the thing I find myself not usually all that interested in is virtual functions. "Place Holders"... I see why they are cool - but usually just don't need them.

@Argon - I didn't know about the microsoft reasons at all - thanx for that - also I don't need multiple inheritance all the time - but when I do - I REALLY NEED it.

I Still like C# - and think you can do a ton with it - and development is faster - however this oop multiple inheritance thing coupled with the Just In Time Compiling, the way it more or less gives out your code unless you obfusciate - well.. All these things make me that much more a fan boy of FReePascal, Delphi, Assembly Language, and C++.

(Got to go to work - in fact - today I will be coding C# all day, using web services, flash "modules", html, javascript - so... as opinionated as I am - I'm still coding everything under the sun....<sigh> but it beats alot of things I could be doing!

kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 9th Apr 2008 14:59
Quote: "Another favorite thing for me about oop in general is you can OVERRIDE or ... often my favorite "OVERIDE + INHERIT" (C++ by default does this I'm pretty sure) I'm talking about if I have a constructor or a function that does x,y,z... then make a decenscand have a function with the same name - I can ADD to what that method does but the original will stil be called. Surprisingly - the thing I find myself not usually all that interested in is virtual functions. "Place Holders"... I see why they are cool - but usually just don't need them."


You can do that! Just use the "new" keyword, and inside the function yo might call the parent method, like in:

Quote: "public void new Position(float x, float y, float z)
{
//Do whatever you want
base.Position(x,y,z);
}"


The nicest thing about this is that you may decide if you want to do things AFTER the base method, BEFORE the base method, or some before and some after.
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 9th Apr 2008 15:18
Quote: "C# is the most "powerful" one in many ways"


Please explain why?

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Apr 2008 16:38
Quote: "[quote]Quote: "C# is the most "powerful" one in many ways""


Please explain why?[/quote]

My opinion? A matter of speed, flexibility, expandability and availability.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 9th Apr 2008 17:15
And what other .net languages do not have this? At the end of the day, they all produce roughly the same code. I think it's just a matter of what you know.

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 9th Apr 2008 18:30 Edited at: 9th Apr 2008 18:38
Managed C++ is the more powerful of the .NET languages, it allows you to mix native and managed code in the same assembly and even in the same code file, which means that inline assembler code can be used too.

Also, I believe it was the first of them to allow edit-and-continue at runtime.

Much good work is lost for the lack of a little more.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th Apr 2008 01:23
@kBessa -
Quote: "You can do that! Just use the "new" keyword, and inside the function yo might call the parent method, like in:


Quote: "public void new Position(float x, float y, float z)
{
//Do whatever you want
base.Position(x,y,z);
}"

The nicest thing about this is that you may decide if you want to do things AFTER the base method, BEFORE the base method, or some before and some after. "


I knew it did it - but I was unawares of the base.CallOriginalHere thing. THAT is cool. That's how you can do it in FreePascal (probably delphi too) Gives AWESOME fine control of the whole inherited thing Thanx for that tip!

-----------
@jasuk70 -
Quote: "Quote: "C# is the most "powerful" one in many ways"

Please explain why?

Jas
"


Sure Bro (How ya been? Love your Avatar image - its the best) Um... Basically, its a personal opinion for sure. This is based on strict data types, with the ability to override, syntatic "pleasantries" such as ++BeforeVari, AfterVari++, MyVari+=MoreStuff etc. Things like this I adore.

I'm also fond of the ability to do this (other languages might, but I've only seen it in a few so far that I know for sure):

bool Ok = MyFunction();

Above, the variable "Ok" might be assigned true or false based on "MyFunction".

I could follow it with:

if(Ok){ blah blah};

...I could...

if(Ok==true){ blah blah (notice dual equals in if statement) };

But favorite is:

bool Ok;

if(Ok = MyFunction()){ blah blah };

I just did two different things in one line! That is slick and I use this feature alot: assignments return the value assigned


(While on the matter - here something - admittedly a slight digress)
One better is FreePascal handles multi-condition statements from left to right and the first fail - STOPS the TESTING!
(single equal here same as C++ and C# dual equal == )
If((1=0) and (2=2)) then
begin
// Note.. the SECOND part of the IF will NOT be tested.
// this allows for some very clever uses for condition statements
//when combined with the "Assignments return the value assigned"
//rule.
end;


anyways, back to point - jsuk70, I haven't played with all the .Net Languages, but frankly the other languages are "twists" of something else - made to be more like C++ (C#?) anyways, and C# for the most part is syntactally similiar to C++ which its modeled after - and C++ always has had a flexible syntax in my opinion.

(I wish Circular references were a thing of the past though - they stink and the possibility for them seems to exist everywhere - and in every language.)

I'm wondering from Lilith's comment if there is even more things about C# that sorta go with my leaning towards it.

I personally have browsed the other languages and as I was reading I made the decision that C# was the one I'd learn - this is before really knowing C++ like I do now to. I was getting the info from a .Net how to book - I never finish those things - just chapter 1..maybe 2.. enough to learn the verbage - then I'm googling and compiler open and trial by fire LOL)

---------

@Monotonic - Interesting. I( never really thought (ignorance on my part most likely) that Managed C++ was really a .Net language... I knew of Managed C++ - but I thought that verbage meant "You have a .Net Application that uses some C++ Code - therefore its ".Net Managed C++" I never thought it was c++ code translated to CLR somehow. This would imply the CLR can do muliple inheritance maybe? Or does this go back to whay I posted this thread in the first place. .Net Managed C++ can not have multiple Inheritance? If I was CORRECT in my "thoughts" on what managed C++ was... then AHH... I'm confusing myself - but I know what I'm thinknig... to laborus to type it...HELP sopmeone ...finish this for me! LOL (Please Lilith, Another Band-Aid if possible! )

As for the first Edit and Continue - THAT's HOT - no matter what language! If I could take back things I have said as easily as I can take back some source code (without a full rebuild - mid debug test) I'd be much better off LOL

kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 10th Apr 2008 04:18
@jason: You're welcome. I also wasn't sure of the power of "base" about a year ago, but man... That's the best keyword in it! (even better than "this")

One thing I can mention about C#'s power is its ability to make use of pointers, because AFAIK, it's the only .NET with these powers (excluding C++, I'm talking about pure .NET languages).
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th Apr 2008 06:00
Quote: "'m wondering from Lilith's comment if there is even more things about C# that sorta go with my leaning towards it. "

You've probably hit many of the things I like about it, albeit it's what stems from the very C foundation. The one thing that I really like, and you've pointed out, is that assignment is actually an expression that has the side effect of, well, assigning. The expression

A = 4 + 2


has the value of 6. The fact that A gets assigned that value is a side effect. It's the kind of thing that lets you do something of this nature....

A = B = C = D = 0;


if you wanted to set all those variables to zero. In some of the OOP stuff that I'm doing I'll short cut things by doing

return flipped = (dbSpriteFlipped(spriteNumber) == 1);

flipped is a boolean that I use to track if the flipped nature of a sprite. It's a member of my Sprite class. When I need to check if the sprite if flipped I can call the function this represents, convert GDK's response to a boolean, assign it to my local member and return it to the code that called it.

I love the conditional operator but I don't recall if it exists in C#. It allows you to do something like

int max = a > b ? a : b ;


It's weird for me because the data type it returns is flexible. You can return ints, floats, booleans, pointers, etc.

Ever make use of the comma operator?


for (int i = 0; i++, i < 100; ) { }


The middle expression, the one that is evaluated true or false to determine if you drop out of the loop, has two expressions separated by a comma. If the second one wasn't there

for (int i = 0; i++; ) { }



the loop would quit after one test because i would be false before it was incremented. Going back to the first loop, with the two expressions, the i gets incremented but because the comma is there the expression isn't evaluated for true/false. The side effect of being incremented occurs (is forced to occur when the comma is reached because it's a critical point) but the program moves on to evaluate the next expression the nature of which determines if the loop continues. You don't even need to stop there. You can have hordes of expressions separated by commas. It's only the last one that controls whether the loop continues or not.

It's these little fun thing I like to do with the language.




Quote: "Please Lilith, Another Band-Aid if possible!"


Here's one for your head and one for your eyes. Please don't use them like tourniquets.



Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 10th Apr 2008 12:46 Edited at: 10th Apr 2008 12:47
I think that almost everything that you have mentioned above can be done in some way with VB.net too, Although syntax may be different (And to me, a lot easier to read ). Alot of people still think that VB.net is like VB6. I had someone at work who had used C# and thought that VB wasn't a capable language. I did some code to do what he thought could only be done in C# and I think I've changed his mind now. He was thinking of VB6 and didn't realise VB.net was able to do that kind of thing. What makes the VB language (I think) as good as C# (Note I'm not saying better) is its based on .net.

Recently at the UK Launch event for the 2008 series of Microsoft products (SQL a bit of strange on there not being released till the end of the year!) I went to a talk about the new LINQ technology begin demonstrated on C#, the guy giving the presentation actually admitted that the implementation of LINQ on VB is a much tider implementation and easier to read. Also the VB language construct had changed quite a bit with a lot of new functionality being added to cope with the LINQ construct.

An example of embedding LINQ into XML (BTW You get full intellisense while doing this)



For more of a description have a look here:

http://msdn2.microsoft.com/en-us/library/ms364068(VS.80).aspx

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 10th Apr 2008 14:50
Another nice thing with C languages is the:

int burgers_to_eat = ( hungryness > 10 ) ? 2 : 1;

Much good work is lost for the lack of a little more.
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 10th Apr 2008 15:02
monotonic,

Where we work, doing that is frowned upon as code readability is a high importance too, and shortcuts like that usually make things harder to read. (If you end up with someone elses code to have to work with you appreciate readability )

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 10th Apr 2008 16:19
Quote: "code readability is a high importance too"


Agreed, I used to work at a small company there was only 3 developers, me and another guy where from a C++ background and used C# to develop applications and the boss was from a VB6 background so he used VB.NET. When me and the other guy used stuff like the code above, the boss used to get the face on to say the least. He even used to complain about having to put a semi-colon at the end of a line/statememt in C#.

But, I personally think that if code is documented and commented properly then it shouldn't matter. I hate sloppy code, so much so that I have scrapped entire projects and started again if I think the code gets a bit untidy (a slight case of OCD maybe ).

I just think that:

somevar = ( expression ) ? val1 : val2;

is nicer than:

if( expression )
somevar = val1;
else
somevar = val2;


But like you say readability is of utmost importance when working in a professional environment.

Much good work is lost for the lack of a little more.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th Apr 2008 16:40
Quote: "But like you say readability is of utmost importance when working in a professional environment.
"


Readability is for other people.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 10th Apr 2008 16:44
...and that ternary (conditional) operator is standard C, not intentional obfuscation.

I do agree however that C programmers are the worst obfuscators on the planet....there's even a contest for it.

I can't imagine .NET programmers get much chance of that, since the API is pretty ugly looking to begin with at its core.

IUknown, IClassFactory, IID_Whatever....
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 10th Apr 2008 16:45
Quote: "Readability is for other people."


Of course, and when working in a professional environment you are usaully working on team projects, as opposed to hobbiest programming which usually involves one person.

Much good work is lost for the lack of a little more.
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 10th Apr 2008 16:53
Quote: "Readability is for other people"


Until you get fired

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 10th Apr 2008 16:55
Quote: "Until you get fired "



Lol, at which point you forget to check your work back into source safe, or overrite somebody elses work (by mistake of course)

Much good work is lost for the lack of a little more.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th Apr 2008 16:56
Quote: "Of course, and when working in a professional environment you are usaully working on team projects, as opposed to hobbiest programming which usually involves one person."


True. I've just never had the distinction of writing C related code for anyone other than myself. And I really don't try to obfuscate just to obfuscate. There are just some things that instinctively seem more efficient even if the optimizers are likely to take care of it anyway. Many people would assign a variable and then pass the variable to a function. If I make the assignment a parameter to the function I feel I'm bypassing the fetch operation.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th Apr 2008 16:57
Quote: "Until you get fired"


Then who'd maintain my code?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 10th Apr 2008 17:01
It also helps the author out too. The amount of times I have had to go back to a previous project after a break of a month or so and cannot read my own code.

Much good work is lost for the lack of a little more.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 10th Apr 2008 21:05
Apart from C++, C# is the most powerful .net language, because you can use unsafe code to use pointers and things, just like C++ For GUIs though, I think that VB.net is the best. In languages with a C syntax, the code generated by the form designer is virtually unreadable compared to that of VB.net With C# it is easier to see how things work 'under the covers' because it is closer to C++ than VB.net.

Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 10th Apr 2008 22:38


is a stupid way... the right way is



I have been coding in Java, Delphi, Comal80, BASIC, .NET (C# and VB), VB5+6, Assembler etc....

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa): www.tales-of-the-realms.com
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 11th Apr 2008 06:48
who cares about the stupid way lol, there really is no right way. both ways are valid. I think the stupid way is better anways. cause what if you dont want to set the variable to something. The right way will always set it. Anways you can say this is stupid or right but in the end both ways are right.
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 11th Apr 2008 12:08
Quote: "because you can use unsafe code to use pointers and things, just like C++"


So what you are saying is DarkDGK will not work in VB.net?

You can make GUI's just as well in C# as you can in VB.net.

People keep forgetting, .net is the underlying technology, The language allows you access to this technology.

Quote: "With C# it is easier to see how things work 'under the covers' because it is closer to C++ than VB.net"


Urm, all that is saying is you know C#/c++ better than you know VB.net.

Also 'C' allows you to know what is going on under the covers. OO Languages (C++ included) by their nature tend to hide things and are a lot harder to debug than pure C. But pure C means you probably have to write a lot more code to achieve the same result.

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 11th Apr 2008 14:58
somevar = val2;
if( expression )
somevar = val1;

is a stupid way... the right way is:

if( expression )
somevar = val1;
else
somevar = val2;

Much good work is lost for the lack of a little more.
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 11th Apr 2008 18:28 Edited at: 11th Apr 2008 18:31
If you're making a decision between 2 expressions to assign to a var, you should always use the Conditional Operator ?:

I don't know why people think it affects readability, because it does not! From MSDN Library:

Quote: "Calculations that might otherwise require an if-else construction can be expressed more concisely and elegantly with the conditional operator."


I do agree with this, because my code is all done in a single line of code, much more easier to understand. Of course I would write a if-else if I were to execute more statements based on the condition, like assign a variable and call a different method for each condition.


Just to compare it, I wrote a small app to dissecate. Here we create an int, and assign it a different value based on the actual Seconds. Check the image below:



As you can see, the conditional operator generated 7 less LOC in the final assembly (decompiled as IL), which means that if you do this 200 times in your code, you're executing approximately 1400 less instructions. Nice, huh?

Hope someone find this useful, or at least interesting

[edit: I had said 8 instead of 7, leading to miscalculations, sorry]
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Apr 2008 18:38
Compile it with optimization turned on then see if there's a difference.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 11th Apr 2008 18:45
That's very good to know.

I think there's an instinct that says the less code we write the shorter the code compiled. This probably isn't always the case but it probably is true enough to follow. At the very least optimization would turn out near identical code. Speed isn't always what's needed either, though I try for it.

When writing my Mouse class I had trouble getting something to work WRT reporting if a button had just been clicked. Nothing seemed to work until I started to write some of it down on paper. The problem was that I was making assumptions that some things could be ignored. I decided to expand it to every possibility. This meant nesting if/else structures within if/else structures. When all was said and done the inner else statements were empty. This only validated my original logic. I left it with the empty statements just because it worked and it wasn't worth messing with.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 11th Apr 2008 21:03
@Benjamin: Good point, didn't take care about it. With optmizations there's still 1 LOC difference.

The difference might not be big in the final compiled assembly, but I'd still like a greater performance while debbuging any game I'm making.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Apr 2008 21:42
Quote: "but I'd still like a greater performance while debbuging any game I'm making."

I can assure you the difference will be negligible. Nonetheless, I do myself use the ternary operator.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 13th Apr 2008 12:30
@jasuk70
You completely misunderstood me I said that you cannot use pointers in VB.net, but you CAN in C#. DarkGDK.net will work on either.

Of course you can make GUIs with both. I said that the designer generated code for VB.net is clearer than that for C# or C++ (because of the odd syntax when dealing with .net for those languages).

Also, I have know VB.net FAR, FAR longer than C#. C# is relatively new to me, I have only programmed about 5 different projects in it. What I am saying is that C# has more in common (obviously) with C++ than VB.net has.

Virtual X
18
Years of Service
User Offline
Joined: 27th Feb 2006
Location:
Posted: 13th Apr 2008 19:32
just use interfaces if you want to use multiple inheritance, Java does the same thing, stop whining and just accept it.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Apr 2008 21:54
Quote: "just use interfaces if you want to use multiple inheritance, Java does the same thing, stop whining and just accept it. "


Whining? Because I think its weak? Are you kidding?

Have you read the whole thread? Opinions = Whining. Got it. Thanx for that enlightning post bro!

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 13th Apr 2008 23:33
@jason p sage
There are a number of problems caused by multiple inheritance, which if you heard the list, you might reconsider One such problem is that when calling an overridden function, the actual function to call would have to be decided at runtime, which means that every time you want to call that function, it has to look through a table, find the correct function, and call it! There are loads of other similar such problems, but too many to list here.

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Apr 2008 23:50
Ok - but - I don't use that many overridden anything anyways - only when there is a specific reason to override. Normally I just inherit the original call - effectively adding to it. And I have never had a problem with C++ and multiple inheritance. Maybe because I don't use it to the Nth degree.

Frankly - I'm still disappointed at this whole C# can't do multiple inheritacen thing - just because - it strays from what an OOP language is supposed to do - traditionally anyway.

It's Ok - C# is script is what it is - not a CPU based language - and you get tradeoffs - its an interpreted JIT complier. Java also is a this sort of thing.

There's a place for scripted and "Almost CPU" languages and a place for Hardware level languages. I think C++ and FreePascal, Delphi and of course assemblers fit in this category... and all of which can do multiple inheritance.

Regardless - write an interface? Cake - more work? yeah - who cares - everthing I do in computers is more work - especially "Technology Advancements" (which usually are going backwards if you ask me - more code to do same stuff I can do in a k of ram or less - its a joke)...

But - more than one way to skin a cat. I think everything language you need to learn well so you can plan. If the C++ override jump table is a reason to not have inheritance... well - ok - that's not a problem in my eyes. Neither is wriintg and interface, or JIT compiler nor a Script -

Use whatever floats your boat and gets the job done. But, the REAL power is in coding to the architecture - FreePascal and C++ both have this and are inheritantly faster. I just wish C++ was more like FreePascal - because I can use one code base and compile on every OS just about - without any changes... (C++ you can too kinda - but - you need a ton of support software to get ambiguous API's.)

Anyway.. thanx Diggsey - No language is perfect that's for sure.

jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 14th Apr 2008 13:50
Jason,
According to Microsoft's website, C# is not an interpreted language like Java, It will finish the compilation at runtime for the processor it is running on...

Quote: "Just-In-Time Means Run-It-Fast
A key component of the runtime that results in fast execution of .NET Framework applications is the Microsoft Just-In-Time compiler (JIT). The JIT takes common MSIL (Microsoft Intermediate Language) code that is produced by Microsoft Visual Studio® .NET, the Microsoft .NET Framework SDK, or other tools that target the .NET Framework, and uses it to generate native x86 instructions. Intel processors have evolved rapidly from the early Pentium® processor design to the latest multiprocessor-based systems using the Intel Xeon™ processor. When the JIT encounters a genuine Intel processor, the code produced takes advantage of Intel NetBurst™ architecture innovations and hyper-threading technology. The JIT compiler version 1.1, due to ship later this year, will also take advantage of Streaming SIMD Extensions 2 (SSE2).
As the JIT is activated at run time, it is able to utilize information that isn't available to a regular compiler. This information can be used to provide further performance enhancements by allowing for increasingly sophisticated optimizations. The runtime effect of these additional JIT-only optimizations can be quite dramatic. The JIT can dynamically remove levels of indirection and inline frequently called methods, as it knows what code paths are actually executing. These optimizations result in a more responsive .NET application due to fewer cache misses and reduced branching. It is possible for all this to be accomplished without a perceptible delay in application execution due to the raw speed of the latest Xeon and Pentium 4 processors and the Mobile Intel Pentium 4 processor - M. (These latest processors currently run with clock rates up to 2.4 GHz, and it's reasonable to expect that they'll go even faster in the future.)"


AFAIKR The compilation process happens just once and from that point it will be converted to machine code.

http://msdn2.microsoft.com/en-us/library/ddk909ch.aspx

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 14th Apr 2008 14:09
Thanx - I know what JIT is. It means everything you distribute in .Net is SCRIPT and the best you can do is obfusciate it. All .Net gets's converted to CLR - than that gets JIT (NSE) compiled. (NSE - Not Soon Enough)

Yeah thanx man - I'm aware of what and how at the 10,000ft level - I startedt his thread thread because I was shocked I had to do Java Style junk for multiple inheritance - (Which like any thing else - is only as good as actual application of the technology)

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 14th Apr 2008 18:38
kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 14th Apr 2008 19:33
@Jason, Diggsey: Who said that? There's one perfect language! Even my cat can code on it!

LOLcode: www.lolcode.com

LOL...
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 18th Apr 2008 02:25
Let's code in Latin - Objectus Orientativiecus Programmamus Naaa.. to wordy LOL

kBessa
18
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 18th Apr 2008 06:00 Edited at: 18th Apr 2008 06:03
Quote: "HAI
CAN I HAS STDIO?
VISIBLE "Hello DGDK.NET in LOLcode"
KTHXBYE"


Lol, I can imagine LolEngine now (not LightEngine anymore):

Quote: "HAI
CAN I HAS LOLENGINE?
I HAS A CUBE
IM IN YR LOOP
R0T4T3 CUBE 1
IZ keyESC PRESSED ? KTHX
IM OUTTA YR LOOP
VISIBLE "BYE"
KTHXBYE"

Login to post a reply

Server time is: 2024-11-20 07:32:31
Your offset time is: 2024-11-20 07:32:31