-
learning c# very confusing.
Hello there.
I know java and c++, but trying c# I find it very confusing.
Is so close to java and c++, that sometimes you dont know what is what.
Do you have the same problem?.
-
Re: learning c# very confusing.
Mike,
Well not previously having known either Java or C++, I don't have that
problem. <g>
~~Bonnie
"Mike Tsakiris" <miir@iprimus.com.au> wrote in message
news:3d8c07cc@10.1.10.29...
> Hello there.
> I know java and c++, but trying c# I find it very confusing.
> Is so close to java and c++, that sometimes you dont know what is what.
> Do you have the same problem?.
>
-
Re: learning c# very confusing.
Mike Tsakiris wrote:
> Hello there.
> I know java and c++, but trying c# I find it very confusing.
> Is so close to java and c++, that sometimes you dont know what is
> what. Do you have the same problem?.
No.
What specific problems have you had?
Kunle
-
Re: learning c# very confusing.
Kunle Odutola
> Mike Tsakiris wrote:
>
>>Hello there.
>>I know java and c++, but trying c# I find it very confusing.
>>Is so close to java and c++, that sometimes you dont know what is
>>what. Do you have the same problem?.
>
>
> No.
>
> What specific problems have you had?
>
> Kunle
>
>
Ok. What I mean is, I find it difficult to remember functions, methods,
classes, etc, where they are used, in which language. Maybe it's me.
Between Java and C++ you had a sizible difference, but with C# and Java,
well...Some things have to be close but not closer.
What we have next, C## C### 
-
Re: learning c# very confusing.
>Ok. What I mean is, I find it difficult to remember functions, methods,
>classes, etc, where they are used, in which language. Maybe it's me.
>Between Java and C++ you had a sizible difference, but with C# and Java,
>well...Some things have to be close but not closer.
There is a book (whose title escapes me right now) which was published by
Wrox. I know it was not Beginning ... or Professional C#. So it is the
third book. ;-) This one presents C# from the aspect of knowing C++ and
Java. It presents what you do in C#, how it compares to the languages, and
where you will see differences with Java and C++.
This type of book may be of help to you since it points out for the major
functions that you use how it compares backwardly to your known languages.
As to closeness between languages....we have, in the past, taken Java programs,
copied an pasted the source into a C# class, and gotten a clean compile.
So the languages are not too far apart, which makes me think it should be
very easy for a java developer to learn.
-
Re: learning c# very confusing.
Get some background on object-oriented concepts. See books like Taylor's
Object Technology or Grady Booch's Object-oriented Analysis & Design. After
that, the languages will make more sense.
SBC
"Mike Tsakiris" <miir@iprimus.com.au> wrote in message
news:3d8c07cc@10.1.10.29...
> Hello there.
> I know java and c++, but trying c# I find it very confusing.
> Is so close to java and c++, that sometimes you dont know what is what.
> Do you have the same problem?.
>
-
Re: learning c# very confusing.
<vb.@127.0.0.1> wrote in message news:3d91fae9$1@10.1.10.29...
>
><Snip>
> As to closeness between languages....we have, in the past, taken Java
programs,
> copied an pasted the source into a C# class, and gotten a clean compile.
> So the languages are not too far apart, which makes me think it should be
> very easy for a java developer to learn.
What are the advantages then of using C# over J#? If someone knows Java
wouldn't a move to J# make more sense?
-
Re: learning c# very confusing.
Kevin Young wrote:
> <vb.@127.0.0.1> wrote in message news:3d91fae9$1@10.1.10.29...
>>
>> <Snip>
>> As to closeness between languages....we have, in the past, taken
>> Java programs, copied an pasted the source into a C# class, and
>> gotten a clean compile. So the languages are not too far apart,
>> which makes me think it should be very easy for a java developer to
>> learn.
>
> What are the advantages then of using C# over J#? If someone knows
> Java wouldn't a move to J# make more sense?
Quite simply, C# is a more expressive language than J# (and Java). If you
already know Java, picking up C# is a cinch. The only scenarios in which I
would recommend J# are:
1. migrating existing J++ code
2. maintaining a single code base to run on Java (remembering that J++ ~
JDK1.1.4) and .NET
Kunle
-
Re: learning c# very confusing.
>Quite simply, C# is a more expressive language than J# (and Java).
How so?
-
Re: learning c# very confusing.
"Brian S" <brians@nospam.net> wrote:
>
>>Quite simply, C# is a more expressive language than J# (and Java).
>
>How so?
Quite simply! As my college professors used to say, during the hardest part
of the proof, "It is obviously intuitive that..."
:-)
C# supports properties.
C# supports indexers.
C# supports automatic boxing of non-object types.
C# uses delegates for events instead of polymorphic overrides of anonymous
classes.
Actually, delegates are a cool thing in themselves, for other things!
C# supports XML documentation rather than the "tacked-on" JavaDoc (which
I like, by the way).
C# supports REGION pragma, so you can hide or show code in editor.
C# supports operator overloading.
C# OO syntax requires you to be explicit ("virtual" and "overrides").
C# constructor syntax is more explicit than Java's (which just throws compiler
exceptions when your code isn't right). Java's constructor syntax is meant
to "look" more intuitive, but comes with some very strict rules that are
not immediately apparent.
C# has a couple of additional scoping operators.
C# supports method "attributes," most commonly used to make it look like
support for COM is built right into the language (it's not - it's a generic
feature).
C# allows, in certain cases, "unsafe" code which allows you to use stack-based
memory and pointers. Makes certain operations as fast as C++.
C# appears to be the language Java would have been if they could have redesigned
it from scratch several years later. It is a lot like Java, but it has some
significant improvements. Not saying that Java is a bad language - it is
very simple and clean - mostly. But C# is an improvement over Java, IMHO.
-
Re: learning c# very confusing.
>Quite simply! As my college professors used to say, during the hardest part
>of the proof, "It is obviously intuitive that..."
Now that I have been out of school for years, I don't take anything the academic
community told me very seriously.
>C# supports properties.
Can be done in Java w/ methods.
>C# supports indexers.
Can be done in Java w/ methods.
>C# supports automatic boxing of non-object types.
Why would java even need this? Does nothing to make C# more expressive than
Java because it is something that Java would never incorporate.
>C# uses delegates for events instead of polymorphic overrides of anonymous
>classes.
Not sure how this makes C# more expressive.
>C# supports XML documentation rather than the "tacked-on" JavaDoc (which
>I like, by the way).
JavaDoc is much better. This doesn't make the language itself more expressive.
>C# supports REGION pragma, so you can hide or show code in editor.
See above.
>C# supports operator overloading.
Not completely.
>C# OO syntax requires you to be explicit ("virtual" and "overrides").
OK.
>C# constructor syntax is more explicit than Java's (which just throws compiler
>exceptions when your code isn't right). Java's constructor syntax is meant
>to "look" more intuitive, but comes with some very strict rules that are
>not immediately apparent.
Not sure about that one.
>C# has a couple of additional scoping operators.
???
>C# supports method "attributes," most commonly used to make it look like
>support for COM is built right into the language (it's not - it's a generic
>feature).
How so? What do attributes have to do with COM in C#? It is more of a platform
feature anyway that does nothing to show how expressive C# is.
>C# allows, in certain cases, "unsafe" code which allows you to use stack-based
>memory and pointers. Makes certain operations as fast as C++.
Also does nothing to make the language more expressive. I have benchmarked
unsafe code and it helps but not what you get if using unmanaged C++ directly.
Also, it has caused junior devs to shoot themselves in the foot many times(so
far).
>C# appears to be the language Java would have been if they could have redesigned
>it from scratch several years later. It is a lot like Java, but it has
some
>significant improvements. Not saying that Java is a bad language - it is
>very simple and clean - mostly. But C# is an improvement over Java, IMHO.
And C++ was the language that C would have been if they redesigned it. Languages
are always evolving irregardless of what they were modeled after.
-
Re: learning c# very confusing.
A list of my favorite new features having to do with expressiveness:
properties and iterators (cleaner, more concise syntax)
automatic boxing and unboxing (cleaner, more concise syntax)
foreach - language support for iterators
"Brian S" <brians@nospam.net> wrote:
>
>>Quite simply! As my college professors used to say, during the hardest
part
>>of the proof, "It is obviously intuitive that..."
>
>Now that I have been out of school for years, I don't take anything the
academic
>community told me very seriously.
Best advice I ever got from a college professor. "When an OO problem looks
too difficult, add more objects." Simplify by adding complexity. Works
almost every time.
>>C# supports properties.
>Can be done in Java w/ methods.
Not as expressively. There is a definite syntactical difference in Java
between attributes and methods. In C#, accessing a property or accessing
an attribute has the same syntax.
If you write a library that uses some attributes, and later you want to swap
out the raw attribute access for code, you can do it in C# with properties.
C#:
image.Visible = true;
bool visible = image.Visible;
Java:
image.setVisible(true);
boolean visible = image.getVisible();
The C# syntax is cleaner, more concise. That fits the definition of "expressive,"
doesn't it?
>>C# supports indexers.
>Can be done in Java w/ methods.
Again, not syntactically the same. We are talking about expressiveness here,
not the ability to accomplish a task. Otherwise we can have the "C# versus
Macro Assembler" discussion (you can, technically, do anything in MASM that
you can in C#, and it will run faster in MASM).
In my book,
string item = myObject[index];
is preferrable to:
String item = myObject.getItem(index);
It's just extra stuff to type, extra stuff to read. It makes the language
somewhat simpler at the compiler level.
Plus, the C# syntax gets the "meaning" across more clearly, which is, the
IDictionary object is really an "array" of items indexed with Strings (or
other objects).
>>C# supports automatic boxing of non-object types.
>Why would java even need this? Does nothing to make C# more expressive
than
>Java because it is something that Java would never incorporate.
C#, using IDictionary:
myColl[index] = 10;
int number = (int)myColl[index];
Java, using Map:
myColl.put(index, new Integer(10));
int number = ((Integer)myColl.get(index)).intValue();
Sorry, the C# is easier to read. In more complex examples, the Java code
really blows up quickly.
>>C# uses delegates for events instead of polymorphic overrides of anonymous
>>classes.
>Not sure how this makes C# more expressive.
It makes it easier to express events. Polymorhism has been adapted in Java
to do the same thing, but the syntax is not as clean.
Again, not the point of whether Java can do it or not, but rather the point
of how concise, succinct, and easy to read the syntax is. Not having to
write a new class every time I want to hook an event - PRICELESS. :-)
>>C# supports XML documentation rather than the "tacked-on" JavaDoc (which
>>I like, by the way).
>JavaDoc is much better. This doesn't make the language itself more expressive.
I believe that comments are part of the language. They are part of the language
specification, after all. C# defines the XML documentation as part of its
spec. JavaDoc is actually not part of the language, but just a convention
that is used by the JavaDoc tool to extract comments and format them into
HTML.
JavaDoc "looks" better in the documentation it produces right now. However,
I can reformat the XML documentation with any stylesheet or transformation
I choose, or I can write my own. You can't do that with JavaDoc.
This comes down to an argument of meaning versus formatting. HTML formats
documents nicely, but you have a lot of work to do if you want to reuse that
data. With XML, the meaning is built in, but the formatting takes some more
work.
Don't get me wrong. I use JavaDoc, and it is a very useful tool. As time
progresses, the XML docs are going to prove to be more useful, in all sorts
of ways.
>>C# supports REGION pragma, so you can hide or show code in editor.
>See above.
It's an editor specific thing, but it is part of the language spec. And
Java does not support it. So it helps you manage your code. Small thing,
but still significant.
>>C# supports operator overloading.
>Not completely.
Java does not support it at all, and even C++ does not support it completely.
It's a good first cut, useful, and it does work.
Like unsafe code, this is not something you would want to use everywhere,
but it is useful. For instance, comparing strings:
C#:
if(myString == "katmandu")
Java:
if(myString.equals("katmandu"))
It was awkward when they first introduced Java, and it is still awkward today.
>>C# OO syntax requires you to be explicit ("virtual" and "overrides").
>OK.
>>C# constructor syntax is more explicit than Java's (which just throws compiler
>>exceptions when your code isn't right). Java's constructor syntax is meant
>>to "look" more intuitive, but comes with some very strict rules that are
>>not immediately apparent.
>Not sure about that one.
Hard to explain that one. But try to put the word "super" anywhere in a
Java constuctor other than the first line of code. The limitations in C#
are built into the syntax so that they jump right out at you. In Java, they
are not apparent until you try to compile (and then go read the language
spec to find out what the compile error means).
>>C# has a couple of additional scoping operators.
>???
Private, Public, Internal ... all in the docs.
>>C# supports method "attributes," most commonly used to make it look like
>>support for COM is built right into the language (it's not - it's a generic
>>feature).
>How so? What do attributes have to do with COM in C#? It is more of a
platform
>feature anyway that does nothing to show how expressive C# is.
Attributes are not tied to the COM support. They are a generic language
feature. They could just as easily be adapted to CORBA, and they serve other
uses for the platform as well. COM was just the example I was using. The
Attributes in C# look a lot like the non-standard C++ customizations for
COM, but in this case they are not tied to COM support.
>>C# allows, in certain cases, "unsafe" code which allows you to use stack-based
>>memory and pointers. Makes certain operations as fast as C++.
>Also does nothing to make the language more expressive. I have benchmarked
>unsafe code and it helps but not what you get if using unmanaged C++ directly.
> Also, it has caused junior devs to shoot themselves in the foot many times(so
>far).
I didn't say it should be used often. Almost never. Maybe 5% of code in
an app that really relies on it. Usually none. Good for working with graphics
at a very low level, or for manipulating sound buffers in real time...
The unsafe code part allows you to express certain ideas that you could not
express in Java, not without C++ JNI.
This part of the C# language is significantly more difficult and dangerous
than the "safe" subset, which should be used maybe 99% of the time. But
it does add to the expressiveness of the language, sort of in the same way
that adding assembly directives to the language would add to expressiveness.
;-)
As for speed, the speed up is significant for the kinds of apps that can
use it, but not as fast as C++.
I say, not as fast as C++ FOR NOW. This is the one part of the language
that has the potential to get really, really fast as the CLR JIT compiler
improves.
>>C# appears to be the language Java would have been if they could have redesigned
>>it from scratch several years later. It is a lot like Java, but it has
>some
>>significant improvements. Not saying that Java is a bad language - it
is
>>very simple and clean - mostly. But C# is an improvement over Java, IMHO.
>
>And C++ was the language that C would have been if they redesigned it.
Languages
>are always evolving irregardless of what they were modeled after.
Java, the language, has not evolved significantly for some time. The framework
in Java has seen continuous, steady improvement since its inception. However,
almost anything that you can do in Java 1.4, language-wise, will also run
in Java 1.1 if you have all the classes available (and most of the source
is freely available).
Java would be much more expressive if Sun would add properties, indexers,
and automatic boxing to the language. However, they can't do anything that
would break that magnificent WORA codebase out there, so I don't know if
they will ever do it.
They were working on a spec for templates, which is something that C# still
lacks as well. The early spec (Java) would only support full Object types
though, not things like boolean and int. They wisely put that off indefinitely,
rather than adding a half-baked feature to the language (which would then
have to be supported forever after - the mistake that the VB-classic dev
team made over and over again).
I'm really looking forward to having templates in both languages. I hate
having to manually typecast every object stored in a collection. In most
cases, it would not be necessary if you had typed collections.
Anyway, good post. Lots to think about there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|