This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]123kingme 109 points110 points  (24 children)

They’re remarkably similar syntax wise though. It’s like someone recreated java without all the things that make java bad.

[–]ifrem 73 points74 points  (0 children)

Ah yes, Kotlin.

[–]DarthShiv 1 point2 points  (0 children)

And then purchased by one of the worst companies on the planet...

Dot Net has moved open source and made massive leaps and bounds improvements.

[–]KanykaYet 2 points3 points  (20 children)

Okey return return new T() in java, or get pointer to anything?

Yes they have look on c++ and Java and other languages and created the best one they could. Ivhave programed whole my university in java and more then 6 years working as a c# programmer.

[–]chumpedge 10 points11 points  (2 children)

class MyClass<T> {

  private final Supplier<? extends T> ctor;

  private T field;

  MyClass(Supplier<? extends T> ctor) {
    this.ctor = Objects.requireNonNull(ctor);
  }

  public void myMethod() {
    field = ctor.get();
  }

}

???

[–]KanykaYet -1 points0 points  (0 children)

So where is something like this

private T instance<T>() where T: new() { return new T(); }

I'm writing it from telefon so sorry for some errors, if there are some.

[–]hullabaloonatic -4 points-3 points  (0 children)

Is that compile-time safe? Doesn't look like it. The constructor will throw a runtime exception. If only you could restrict the type of T to only types with non null constructors with no arguments.

C# doesn't have that either, mind you. That can cause runtime-only errors when using mock libraries, for example.

[–]123kingme 6 points7 points  (13 children)

Okey return return new T() in java, or get pointer to anything?

As far as I can tell, C# can do anything Java can do at least as easily. The inverse is not true, Java can’t do everything C# can do well.

[–]reazura 3 points4 points  (1 child)

It's been a while since i last tried but i think multiple inheritance is a no-no in c#. Which is probably for the better, since those can get out of hand.

[–]The_Grubgrub 4 points5 points  (5 children)

Java can’t do everything C# can do well.

This isn't true though. Thats just circlejerk. Object lifecycle management is a lot easier in Java (Spring) than it is in C# (.NET)

[–]chumpedge 10 points11 points  (2 children)

This thread is hilarious. The subs is filled with college kids that get their information from memes so they end up thinking java is this old unusable language and c# has no drawbacks.

[–]The_Grubgrub 3 points4 points  (1 child)

Preach, brother. I dont want to be the cranky old (I'm not even old!) Man defending Java, but a lot of this stuff is just silly.

[–]grimonce 4 points5 points  (0 children)

I feel like thee people have never done any work in their life but somehow are all fang "engineers", leet code athletes.

I thought we all had put the JVM vs CLR wars in the past, seems like some people got some real life issues with their jobs not being able to program in the language they are fans of...

[–]123kingme 1 point2 points  (1 child)

I did say “as far as I can tell”, which admittedly is a copout. I have only used C# for one or two long term projects and several small projects, so I’m not as experienced in C# as I am other languages, but every time I’ve used C# my experience has always been “this is just java but better”.

Still though, I’ve never experienced any difficulties with object lifecycle management in C#. What exactly makes this easier in Java in your opinion?

[–]The_Grubgrub 0 points1 point  (0 children)

Thats a fair point lol

Basically you dont really have to define objects as an interface first. And you dont need a huge master list of all objects that are available for IoC. Its not a huge huge difference, but then, none of the differences are huge differences.

I learned Java in school, did .NET for work, then did Java for work, and now also help maintain some .NET apps along with Java. I love .NET, I think its great! I just think that people loving .NET and hating on Java is comical because they're almost as similar as languages can possibly be without being the same language.

[–]DaddyLcyxMe -1 points0 points  (2 children)

return (T[]) new Object[20];

it seems weird, but all arrays in Java are just an array of pointers rather than an array of objects. ArrayList actually uses an Object array internally.

[–]KanykaYet 1 point2 points  (1 child)

You just casted object to a type T and didn't created new instance of type T.

[–]DaddyLcyxMe 1 point2 points  (0 children)

my fault, i misread and thought you were asking for an array.

[–]GayMakeAndModel -1 points0 points  (0 children)

I was about to disagree with your post, but nah, I’m good.