C# and Java
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
The languages are very similar in syntax, some of the differences are discussed here: Guru99-Java vs C# – Difference Between Them[^]
-
Close enough.
Java
is 'easy' anyway. My two cents."In testa che avete, Signor di Ceprano?" -- Rigoletto
Agreed. I found Java easy to master. But I would add a suggestion: If want to master Java, focus on JavaFX. JavaFX makes setting up a good user interface easy. Oh, by the way: the Kotlin language is very close to Java. Kotlin is gaining popularity. Many large organizations are moving from Java to Kotlin, as it is more modern and very powerful. It is especially popular for developers who write apps for Android devices (such as cell phones) But: I found Kotlin quite difficult to master. It has a much steeper learning curve than Java. To do Java (including Java for Windows), I would recommend the IntelliJ IDEA IDE. For Kotlin (especially when writing Android apps) I would recommend the Android Studio IDE. The two IDEs are closely related. Good Luck!
Get me coffee and no one gets hurt!
-
The languages are very similar in syntax, some of the differences are discussed here: Guru99-Java vs C# – Difference Between Them[^]
C# is more powerful and is developing faster - my two cents
Nick Polyak
-
Agreed. I found Java easy to master. But I would add a suggestion: If want to master Java, focus on JavaFX. JavaFX makes setting up a good user interface easy. Oh, by the way: the Kotlin language is very close to Java. Kotlin is gaining popularity. Many large organizations are moving from Java to Kotlin, as it is more modern and very powerful. It is especially popular for developers who write apps for Android devices (such as cell phones) But: I found Kotlin quite difficult to master. It has a much steeper learning curve than Java. To do Java (including Java for Windows), I would recommend the IntelliJ IDEA IDE. For Kotlin (especially when writing Android apps) I would recommend the Android Studio IDE. The two IDEs are closely related. Good Luck!
Get me coffee and no one gets hurt!
Very nice thorough and helpful answer! (my 2 cents) Best wishes--
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
It's been some years, but when I got a (corporate) Java project, I had to go shopping: Eclipse (IDE), Spring (UI), Struts, Apache (Web server), NetBeans, JBoss (app server), etc. before I could write any code. c# (Windows; .NET framework) was "no" shopping.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
A Brief, Incomplete, and Mostly Wrong History of Programming Languages[^]:
1996 - James Gosling invents Java. Java is a relatively verbose, garbage collected, class based, statically typed, single dispatch, object oriented language with single implementation inheritance and multiple interface inheritance. Sun loudly heralds Java's novelty. 2001 - Anders Hejlsberg invents C#. C# is a relatively verbose, garbage collected, class based, statically typed, single dispatch, object oriented language with single implementation inheritance and multiple interface inheritance. Microsoft loudly heralds C#'s novelty.
I boldest the key differences to be aware of. :laugh:
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius
-
A Brief, Incomplete, and Mostly Wrong History of Programming Languages[^]:
1996 - James Gosling invents Java. Java is a relatively verbose, garbage collected, class based, statically typed, single dispatch, object oriented language with single implementation inheritance and multiple interface inheritance. Sun loudly heralds Java's novelty. 2001 - Anders Hejlsberg invents C#. C# is a relatively verbose, garbage collected, class based, statically typed, single dispatch, object oriented language with single implementation inheritance and multiple interface inheritance. Microsoft loudly heralds C#'s novelty.
I boldest the key differences to be aware of. :laugh:
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius
-
Concurrency control in the net framework is far easier to understand and correctly implement. Java implements this via Dykstra's base implementation. The net framework hides this complexity.
===== The Joke ====> You
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
Yes, relatively easy. Here are some differences to watch out for: - Generics are different, weaker. The syntax sometimes feels oddly backwards too, eg `public boolean containsAll(Collection c);`. - `foreach` loops don't use the `foreach` keyword, but that takes about 10 seconds to get used to. - Since there are no real delegates, Java tends to use interfaces with a `run` method (or equivalent). That also affects how events work. You can use anonymous classes that implement the relevant interface though, you don't have to create a thousand full classes. - Inner classes by default have a reference to a specific instance of their outer class. To get a "plain old inner class", it needs to be a static inner class, which is not a static class. That sounds more confusing than it is. - Operator overloading doesn't exist. Not even for `String`. Avoid `==` between objects (including `String`, but also `Integer`), unless you really meant to compare for reference-equality. And yes, BigInteger arithmetic is pretty painful in Java .. but also pretty efficient actually. BigIntegers in C# only recently approached how efficient they are in Java. - In terms of the framework, `List` -> `ArrayList`, and `Dictionary` -> `HashMap` (some tutorials may mention `Hashtable`, disregard them). - There are no unsigned integers (except `char` but we don't talk about that), which for the most part doesn't matter (many operations are independent of signedness, and there are special methods such as `Integer.compareUnsigned` to implement the operations that *are* dependent on signedness) except that Java's `byte` is signed and you will probably occasionally forget that and get some bugs due to unintended sign-extension.
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
it is very close. in the beginning, there is a saying that C# steals Java...
diligent hands rule....
-
it is very close. in the beginning, there is a saying that C# steals Java...
diligent hands rule....
Isn't it commonly known that MS and Sun were arguing about MS' right to develop their Java compiler and market it as Java? MS ended up turning their back to Sun/Java, declaring: OK, we'll forget Java and make something better, then! According to my taste, MS succeeded; C# is and improvement over Java in several respects. But I have been working for a number of years in environments where any such opinion was highly non-PC.
-
Isn't it commonly known that MS and Sun were arguing about MS' right to develop their Java compiler and market it as Java? MS ended up turning their back to Sun/Java, declaring: OK, we'll forget Java and make something better, then! According to my taste, MS succeeded; C# is and improvement over Java in several respects. But I have been working for a number of years in environments where any such opinion was highly non-PC.
my experience: Java components are good at cross platform because JVM. they can run on Linux and UNIX without recompile. I have a Java component to generate Excel file on UNIX, after I copied it to Linux, it is still working well. amazing to me...
diligent hands rule....
-
my experience: Java components are good at cross platform because JVM. they can run on Linux and UNIX without recompile. I have a Java component to generate Excel file on UNIX, after I copied it to Linux, it is still working well. amazing to me...
diligent hands rule....
I know what you mean. Now with Net5 & Net6 it just amazed me how easy it was to execute the app on linux now that most of the frameworks catched up to net5.
sudo apt-get install -y dotnet-runtime-6.0 && \
dotnet MYAPP.dllOnly thing to get used to that you "run" dlls^^
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
At the basic level, they're close. Very close. When it comes to finer nuances, C# got ways to write concise code that Java doesn't (top-level statements, switch expressions to name two examples). There's also some nice syntax sugar in C# that Java doesn't have when it comes to OOP. But overall, they're REALLY similar. After all, they all inherit the basic C syntax. I switch between C# (my main development language) and C++ (a project of mine is a user-mode driver the binary requirements for which .NET won't fulfil without bending backwards) and the transition isn't too bad. Syntax-wise, Java fits nicely into the same family.
-
Yes, relatively easy. Here are some differences to watch out for: - Generics are different, weaker. The syntax sometimes feels oddly backwards too, eg `public boolean containsAll(Collection c);`. - `foreach` loops don't use the `foreach` keyword, but that takes about 10 seconds to get used to. - Since there are no real delegates, Java tends to use interfaces with a `run` method (or equivalent). That also affects how events work. You can use anonymous classes that implement the relevant interface though, you don't have to create a thousand full classes. - Inner classes by default have a reference to a specific instance of their outer class. To get a "plain old inner class", it needs to be a static inner class, which is not a static class. That sounds more confusing than it is. - Operator overloading doesn't exist. Not even for `String`. Avoid `==` between objects (including `String`, but also `Integer`), unless you really meant to compare for reference-equality. And yes, BigInteger arithmetic is pretty painful in Java .. but also pretty efficient actually. BigIntegers in C# only recently approached how efficient they are in Java. - In terms of the framework, `List` -> `ArrayList`, and `Dictionary` -> `HashMap` (some tutorials may mention `Hashtable`, disregard them). - There are no unsigned integers (except `char` but we don't talk about that), which for the most part doesn't matter (many operations are independent of signedness, and there are special methods such as `Integer.compareUnsigned` to implement the operations that *are* dependent on signedness) except that Java's `byte` is signed and you will probably occasionally forget that and get some bugs due to unintended sign-extension.
Based on the above, can I simply sum this up as: - TLDR: "Java sucks" - Long story: "Java sucks big time"
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
What is the question-behind-the-question, you autocondimentor you?
Paul Sanders. If I had more time, I would have written a shorter letter - Blaise Pascal. Some of my best work is in the undo buffer.
-
I was wondering, how close are C# and Java, syntax? Would be Java be "easy" to learn if I know C#?
Archchancellor Ridcully
been some time since did Java, 2012. Learned Java at school/uni, first programming job java. then C# 2013, easy enough curve. Now C#/.net 2012 vs Java 2012, a lot of programming similarities. But 2022 c#11/.net core and visual studio 2022, lots of little things, Linq. Java probably got something similar, not sure. Main thing what in Java are you planning on doing, maths, backend, services likly similar cross over. front end/ui stuff, that more JavaFX vs xaml maybe?# Languages similar, frameworks stepper curve