|
Why not just go back to flippin switches?
|
|
|
|
|
mmm, dipswitches, drool
|
|
|
|
|
You guys are too high level. Get out the soldering gun...
|
|
|
|
|
No, I have jumper cables ready
|
|
|
|
|
Enough laugh. The point of learning machine code (or, at least, assembly language) first is that
1. You learn that, what runs software, is hardware. And hardware has physical limitations. You want an efficient program? Do your best to write an efficient implementation!
2. When you start using languages that make your life simpler (or, at least, less complicated, like C), you don't that simplicity for granted, but actually appreciate it.
To some degree, programmers who don't understand the value of low level languages remind me of users who don't understand the value of the software they use. They take it for granted and they want it to do things right (sometimes, despite the fact they have given the wrong input!!!).
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
I think this way of thinking makes a lot of sense. I totally agree.. BUT
Is assembly really the best choice for a NEW programmer? I think they will give up before they get anything done.
Ask not whether it is useful. Ask what it is useful for.
|
|
|
|
|
C# and Java in the same option!
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Yes, because they are essentially the same thing. :P
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
Bleh, from a syntax point of view maybe.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Not only the syntax. With Java/C# you also have...
0. Garbage collection, a.k.a. the programmer doesn't want to bother taking care of his pointers and he wouldn't mind sacrificing runtime efficiency for coding easiness.
1. Complex class libraries that you have to learn before you can write a decent, non-trivial application
2. OOP is mandatory, which isn't bad in itself, but...
a) Everything.IsDerivedFromABaseObjectClass() == true // yuck!
b) No multiple inheritance... WHY??? Ok, 99% of the programmers out there don't want to bother undestanding virtual inheritance. So there you have interfaces, which, IMHO, are just as (or even more) messy.
I'd love to continue with this rant, but I have to go to sleep. Sorry!
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
I completely agree with you. I think Microsoft was so much inspired by the Java while developing C#, there are some differences but on the core they are both same…
cout << "\0";
// its backSlashZero
|
|
|
|
|
C# isn't perfect, but at least it's not Java.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
2a) is a good thing--it allows you to bypass the type system for some nifty tricks (generics can't do everything).
2b) I agree with, I wish C# had M.I.
I'd forgotten Java has G.C., it's been so long since I've used it. But personally I hate GC--that's the single biggest mistake the C# designers made. IMO
Logan
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
2a) isn't a good thing. Generics are bad. Templates are a lot better.
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
I don't recall much difference between generics and templates. Am I totally missing something?
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
There is a BIG difference between templates and generics.
Templates works like this:
0. Programmer writes generic function/class/whatever. Example:
// this is C++
// compiler won't generate any code from this
template <class T>
class CLinkedList
{
private:
T m_tValue;
CLinkedList<T> *m_plltNext;
public:
//...
};
1. At compile time, whenever the compiler finds an instance of the template, the program replaces all instances of the template parameters with its actual values. Example:
int main()
{
// compiler will create a class called CLinkedList<int>
CLinkedList<int> lliExample;
// compiler will create ANOTHER class called CLinkedList<double>
CLinkedList<double> lldAnotehrExample;
return 0;
}
2. At run time, the program doesn't know ANYTHING about the templates. It only knows about its specific instances (the actual functions/classes/whatever).
Generics work like this:
0. Programmer writes generic function
' this is VB.NET
' in .NET, generic classes have metadata that tell the runtime that they have parameters.
Public Class LinkedList(Of T)
Private Value As T
Private NextNode As LinkedList(Of T) ' the implicit pointer... yuck!
' ...
End Class
1. At compile time, the compiler doesn't create new classes from the generic definition.
Module Test
' I don't remember very well, but I think the VB.NET equivalent of static is Shared
Public Shared Sub Main()
' compiler will generate code that tells the runtime to replace
' the generic metadata with the actual generic parameters
Dim LLOfInt As LinkedList(Of Integer), LLOfDouble As LinkedList(Of Double)
End Sub
End Module
2. At run time, the JIT/interpreter only knows about the generic class until it finds a request to create/use an instance of a specialization of the generic.
---
Are generics more powerful than templates? No. You can do this in C++:
template <class T>
class CBox
{
public:
T content;
};
int main()
{
CBox<int> a;
CBox<double> b;
a.content = 10;
b.content = 15;
b.content += a.content; // C# equivalent can't do this
}
Are generics safer? If you can't program, yes. But we're supposed to know how to program.
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
leonej_dt wrote: CBox<int> a;
CBox<double> b;
a.content = 10;
b.content = 15;
b.content += a.content; // C# equivalent can't do this
I don't know why you say this. I just wrote the following version in C# with generics and it works perfectly:
class Box<T> {
public T content;
}
Box<int> x = new Box<int>();
Box<double> y = new Box<double>();
x.content = 10;
y.content = 15;
y.content += (double)x.content;
Yes, C# makes you cast the int to a double, but that's hardly a limitation.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
modified on Monday, April 7, 2008 12:50 PM
|
|
|
|
|
And what about this?
namespace test
{
class Base { }
class Test1 : Base { void Test() { Console.WriteLine("Test performed by Test1"); } }
class Test2 : Base { void Test() { Console.WriteLine("Test performed by Test2"); } }
class Test3 : Base { }
class Box<T>
{
public T content;
}
class Program
{
static void Main(string[] args)
{
Box<Base> bb = new Box<Base>;
Random r = new Random();
int i = r.Next() % 3;
switch (i)
{
case 0:
bb.content = new Test1();
break;
case 1:
bb.content = new Test2();
break;
case 2: bb.content = new Test3();
break;
}
if (i < 2)
bb.content.Test(); // error
else
Console.WriteLine("Can't perform test.");
}
}
}
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
I'll just take your word on that one. :P
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
I'm sorry, I got it TOTALLY wrong with my examples. But here's a better comparison between templates and generics:
http://blogs.msdn.com/branbray/archive/2003/11/19/51023.aspx[^]
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|
|
Cool! I'll check it out later, now that u've piqued my curiosity.
Thanks
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Ahhh, so the big difference (in my mind at least) is that templates are compile-time "specialized", while generics are run-time specialized. This means that with templates and C++ you can basically treat the type parameter as whatever you want, and the compiler will tell you if you can't do it.
With generics and C#, there is no such freedom because you must specify all of your constraints up-front (since generics are specializable at runtime and therefore must be able to accept any compatible type, not just the ones you happen to use).
Now that I remember a little, I did like that about C++, and it is one thing I find particularly annoying about C#, so thanks for clarifying that for me.
Logan
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Also...
leonej_dt wrote: Private NextNode As LinkedList(Of T) ' the implicit pointer... yuck!
How is this any different from:
leonej_dt wrote: CLinkedList<t> *m_plltNext;
I don't understand your "yuck!" could you please explain that to me? Are you referring to the fact the .NET keeps a reference as opposed to a pointer, and thus keeps the object alive?
[Update: Oh I see, the C++ version isn't type-specific, so you can link together instances of different-templated LinkedLists. Hmm that's interesting, but you could still do this in C# without generics, by using a common base type or interface (or even just object).]
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
One problem I do have with generics is that there is no "is a" relationship between GenericClass<SubType> and GenericClass<BaseType>.
For example, List<Button> "IS A" List<Control>, but C# doesn't accept this, to my knowledge.
|
|
|
|
|
No! A List IS NOT a List<control> because a List can't contain Controls. The fact both lists could contain Buttons is just a mere coincidence.
To those who understand, I extend my hand.
To the doubtful I demand: Take me as I am.
Not under your command, I know where I stand.
I won't change to fit yout plan. Take me as I am.
|
|
|
|