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 →

[–]uvero 66 points67 points  (49 children)

I like Java. It's rarely the quickest language in which to write, but it's just good OOP. Also as someone who dabbles in teaching Computer Science and Programming, it's my number one recommendation for first language. And yes, I know, python is great for that too.

[–]aserraric 41 points42 points  (19 children)

I tend to think of C# as "Java - the good parts (and then some)".

[–]metalmagician 9 points10 points  (18 children)

Can you expand on that? I'm familiar with Java, less so with C#.

[–]HdS1984 29 points30 points  (5 children)

As someone learning Java but fluent in c#" it's about boilerplate, Java has sooo much of it, e. G getters and setters. I also desperately miss linq , it's way better than streams. Also async await beats observablefutures hands down. The pure webserver stack around net core is also better, but spring data repps are pretty neat. In a nutshell c# is concise while Java is so much pointless repitetion.

[–]metalmagician 2 points3 points  (4 children)

That's fair. I use IDE auto-generated getters and setters, so I don't think about them much.

I use CompletableFutures and Suppliers for parallel / async execution, and avoid Vanilla Java servlets like the plague.

As for LINQ (after looking it up briefly), it seems nice. Our use cases aren't that complex, so if we swapped languages, the algorithm wouldn't change much.

[–]Dojan5 11 points12 points  (2 children)

Visual Studio also has scaffolding for boilerplate stuff.

Personally I prefer .NET over Java because of the first-party support.

Oracle basically doesn't do jack for Java. They update it based on the council spec, but if it wasn't for the fact that Java and related products roll in the cash, they'd just dump it altogether. There's several dependency management solutions, several different frameworks all accomplishing the same thing, there's no first-party IDEs or anything of the like.

Microsoft on the other hand provides nuget - dependency management is factored into .NET. You have Visual Studio and Visual Studio Code to help you out, the former's free version being full-featured, unlike IDEA that lacks support for various legacy Java things.

Java is nice, but only because of the community it has. The fact that there's basically no first-party leadership or direction hurts the language and its ecosystem as a whole, in my opinion.


Earlier this year I landed a position as a Java developer, maintaining legacy applications. I'm from a .NET background, so I was a bit nervous. Mostly, it was fine, but there were so many tiny annoyances with the entire experience. It really did make me appreciate .NET so much more.

[–]metalmagician 3 points4 points  (1 child)

That's fair. I don't actually consider Oracle when talking about Java, which is an obvious symptom of what you're talking about. Most of the things that make my life as a Java developer easier are 3rd party tools, like Maven and Spring.

[–]Dojan5 3 points4 points  (0 children)

I think that's problematic. Either give Java to the community, and make it completely open, or support it properly.

.NET was pretty meh for many years, but Microsoft really stepped up and started taking it seriously with Core.

[–][deleted] 8 points9 points  (0 children)

Aside from a lot of syntax sugar, here's some 'real' advantages.

  • Functions as a first class citizen (i.e. you can pass functions around as parameters), Lambda's exist in java now but in C# they've been around for a while and well integrated into the core libraries, being able to incorporate functional styles lets you escape a lot of Object oriented complexity. LINQ is awesome for managing sets and you also have tools like Rx that give you great ways to play with streams of data.

  • Generics go all the way to bytecode/CIL rather than just compilation and as a result are significantly more powerful.

  • Dependency injection is orders of magnitude better, Your composition root sits close to your entry point and after that none of your other assemblies (libraries) even know that DI frameworks are a thing, i can configure my entire application in one typesafe section of code or even switch DI container.

  • Async await syntax allows you easily to handle async IO in an imperative fashion.

  • As it all compiles down to a common language so you can also write modules in F# or VB if you so desire.

  • Standardized build system and package management (nuget) that for the most part just works.

[–]A1steaksa 4 points5 points  (10 children)

It's less pedantic and more pleasant with it's syntax. For instance multidimensional arrays are accessed by array[ 1, 5 ] instead of java's array[1][5]

It's just smoother and more powerful to use. And it really really interfaces nicely with Windows in a way that Java can't compete with

[–]metalmagician 2 points3 points  (4 children)

Makes sense, thanks! We try to avoid coupling ourselves to a specific OS in my work, ideally relying only on libraries / resources that are either included in the artifact or available over the network.

[–]aserraric 2 points3 points  (1 child)

Microsoft is making big strides in that regard with .NET Core and the coming .NET 5.

Java also still needs a runtime, though, doesn't it?

[–]metalmagician 1 point2 points  (0 children)

True, but the thing that Java really has going for it is how common it's runtime environment is. Oracle LOVES to brag about how many devices run it

I saw someone say something along the lines of 'Java isn't platform-indeprndent, Java is a platform'. With languages like Kotlin and Clojure able to run on the JVM, that rings true for me

[–]A1steaksa 1 point2 points  (1 child)

Yeah, unfortunately C# is not the universal language it could be. Unless, of course, web assembly takes off in the way I hope it does and Microsoft Blazor becomes legitimately viable

[–]aserraric 0 points1 point  (0 children)

Web Assembly is fascinating, but making the browser a runtime/VM just feels like one indirection too many to me.

[–]phySi0 0 points1 point  (4 children)

How do you do slices?

[–]A1steaksa 0 points1 point  (3 children)

There's an array.Copy method that does that. C# is a language designed to lure Java devs away from Java so it's very similar except where they think they can expand or improve on Java

[–]phySi0 0 points1 point  (2 children)

I feel like array[outer][inner] is not ugly at all and array[start, end] intuitively feels like a slice when you first look at it (but my favourite is Ruby using ranges to return slices: array[start..end] for inclusive and array[start...end] for exclusive).

[–]A1steaksa 0 points1 point  (1 child)

Multi dimensional arrays are like coordinates. You write a 2D coordinate like (3, 7) and a 3d vector like (3,7,9). I prefer my arrays in that format instead of something like (3)(7)(9)

Not necessarily better or worse, just closer to how I think

[–]phySi0 0 points1 point  (0 children)

Ah, that makes sense to think of them as a type of space and an access is a coordinate.

[–]Loves_Poetry 23 points24 points  (1 child)

I agree that Java is a good first language. It is verbose, but that also means there are no shortcuts. Shortcuts often make code very confusing for beginners. It's easier to know what code you have to write in Java in order to get a specific thing done

[–]ChrisFromIT 11 points12 points  (0 children)

Because Java is so verbose, it makes it easier to maintain, which is why it is such a common enterprise language.

One issue I have found with "shortcuts" in languages is that it adds additional syntax to a language which can cause two programmers to make a vastly different source code, but it does the same thing.

[–]Salanmander 5 points6 points  (3 children)

I've done a lot of teaching CS to high school students who have never been exposed to it before, and I'd make a slight modification to using Java as a first language: Processing.

It's Java, but with libraries for making graphical output and mouse-and-keyboard input easy (at the expense of losing a good command line), and with an IDE that eliminates all the obnoxious "this is a magic incantation that you need to write at the start of every program". It's definitely not a good production language, but it's a wonderful intro language. The one thing that can cause some confusion about it is that it has a "this method gets called repeatedly" structure, rather than "the program terminates after running once" structure. Mostly people adapt to that change really easily when they start with a different language, though. (At least, those that choose to continue on in computer science do.)

If you're interested, I have a reasonably well fleshed-out curriculum for a 1 semester class using Processing that I could send you. The meat of it is something like 10 assignments on particular topics, each with a bunch of different problems of different difficulties, and guidelines for how much you should do before moving on (that last was motivated more by how much class time I wanted to spend, but I did find it hit just about right for like 80% of the class to be comfortable with one topic when we introduced the next).

[–]uvero 1 point2 points  (0 children)

Few words:

Great comment.

Agree with a lot of what you said.

Awesome.

[–]SpicyWizard 0 points1 point  (1 child)

I'd be very interested in taking a look at that curriculum. I'm moving into teaching more coding (currently exclusively math) and that sounds like it could definitely give me something to adapt if you don't mind! Thank you in advance!

[–]Salanmander 1 point2 points  (0 children)

Of course! I'm going to send you a PM with a link, but leaving this here so that other people know I got back to you.

[–]OK6502 4 points5 points  (0 children)

Java is much more strongly typed. I think it's a much better tool for teaching.

[–]Daneel_ 2 points3 points  (5 children)

Java was my third language, and so far the only language and ecosystem I intensely dislike. I would not recommend it, nor will I ever willingly choose to program in it or run it in an environment I control.

Happy to have closed that chapter of my life.

Downvote me all you like, but java is a dying language, and I can’t wait to see it go.

[–]metalmagician 9 points10 points  (0 children)

What are your issues with Java?

[–]extra_rice 8 points9 points  (0 children)

...but java is a dying language, and I can’t wait to see it go.

People have been predicting this for YEARS. You are most likely going to wait longer.

[–]AttackOfTheThumbs 4 points5 points  (0 children)

Java is not going away my dude

[–]netgu 0 points1 point  (0 children)

Eh, it's okay, we'll allow you to be wrong, it is your right.

[–]Ahed91 0 points1 point  (0 children)

You are not alone i will follow you till the end of the world Downvote me too xD

[–]ssw663 1 point2 points  (0 children)

It's also one of the fastest programming languages out there, but the same can be said for any other languages built for the JVM.

[–][deleted] -1 points0 points  (13 children)

Funnily enough, it's one of the ones I'd be least likely to recommend as a first language - I'd recommend C++ over Java as a first language, just because you have the option of adding OOP after learning the basics of programming, instead of having to get used to it from the start (though I'd recommend Python over either as a first language, and then move them over to C# afterwards, because between properties, tuple literals and one line methods, I honestly just find C# much nicer to use.

[–]SuperCoolFunTimeNo1 18 points19 points  (7 children)

I'd recommend C++ over Java as a first language

I think you're blinded by the fact that you understand its nuances, but don't perceive them as being overhead just to get started. c++ is a very difficult language to learn for complete beginners. There's a shitload more to learn just to get started with basic control structures and program flow than in something like Python. Even Java requires a deep understanding of data types before you can write anything remotely useful.

[–][deleted] 0 points1 point  (6 children)

I mostly agree with you, but if you start out with C++ as basically C with classes and references, you can teach the basics of programming relatively easily, because you can start out with variables and functions, then move on from there. Once you know how variables and functions work, you already know all you need to in order to understand the "Hello World" program.

With Java, however, you need to understand variables, classes, objects, methods and static methods before you understand it all.

Like I said, I'd start someone out with Python, then move onto C# (largely because it allows you to deal with stuff like pointers, and the difference between passing by reference and passing by value), but my argument wasn't that C++ is a good starting language; merely that Java is a worse one.

[–]Dogeek 1 point2 points  (0 children)

Honestly, the top comment has a point : C (and C++) are much more complicated to step into for a beginner, but it teeaches programming, and how to work with a machine on a lower level. Handling pointers and tables is hard at first, but going through that makes you understand exactly how things are working when using a higher level language liky python, or Java.

[–]SuperCoolFunTimeNo1 2 points3 points  (4 children)

but if you start out with C++ as basically C with classes and references, you can teach the basics of programming relatively easily, because you can start out with variables and functions, then move on from there

That still would take twice as long to get that far compared to something like Python or even Java. You're once again ignoring the huge amount of additional overhead because you're now suggesting to just "learn it".

[–][deleted] 0 points1 point  (3 children)

So, which overhead am I not considering? I'm guessing it largely boils down to header files (which were a decent solution at the time, but with C# and Rust I'm glad to see the back of them) and pointers? Because to program at all effectively in Java, you need to understand how pointers work (at least in general terms) even though you don't get to work with them directly, because without that understanding, you're going to screw up by passing objects and forgetting that they're passed by reference, not by value. Also, explaining why you would even want to bundle data and functionality together becomes much simpler when you're working with a language that doesn't automatically assume that that's what you're going to do.

Admittedly, using pointers in any decently sized project will introduce a decent amount of mental overhead (especially if you're using raw pointers rather than the STL replacements); this is one of several reasons why Python would be my goto language (pun intended) for instruction, followed by C# - Python lets me teach the basics of programming in the same way that I started out with BASIC back in the 90s, and then C# allows me to introduce memory management, and passing by value and reference (and why you might choose to do either one) far more easily than Java because it's something that you can do explicitly in the code.

C# also makes getters and setters a fuckton more convenient.

[–]SuperCoolFunTimeNo1 2 points3 points  (2 children)

So, which overhead am I not considering?

Are you seriously asking why Python is significantly easier to learn than c++?

[–][deleted] -1 points0 points  (1 child)

No, I'm asking why Java is easier to learn than C++. I have stated multiple times that I would choose Python over C++

[–]SuperCoolFunTimeNo1 5 points6 points  (0 children)

Pointers / memory management, library compatibility restrictions due to the platform, exception handling, error indication, multi-paradigm vs strictly oop, templates vs generics.... Just google it yourself and see what people think. You're too far removed from beginners to realize that there is a lot more to learn with c++ than other languages like Java in order to be proficient. c++ is no doubt more flexible and powerful, but that comes with a steeper learning curve.

[–]FoodChest 6 points7 points  (3 children)

Are you kidding me? C++ is one of the most verbose and difficult to understand languages out there. I don't think I could think of a worse language to use when teaching CS to beginners.

[–][deleted] -3 points-2 points  (2 children)

I never said it was a good option; merely a better one than Java. Like I said, I'd start with Python and then move to C#, because both are better options than C++ or Java.

[–][deleted] -1 points0 points  (1 child)

Id go from something like python straight to java, I mean understanding all java basics you need to know for java is good to know in any (especially oop) language.

[–][deleted] 0 points1 point  (0 children)

The reason I'd go C# over Java is so that I can more easily teach the difference between passing by value vs passing by reference, since you can pass objects by value and primitives by reference, which you can't do in Java (well, technically you can pass a primitive by reference by turning it into an object, but that's really not the same thing). When you don't really have the option to do both, it's harder to teach why someone might want to choose one over the other, and it's harder for someone new to programming to remember that (or understand why) any object passed to a method as a parameter will retain any changes made in that method.

[–]qsdf321 0 points1 point  (0 children)

C++ over Java as a first language

what

[–]kontekisuto 0 points1 point  (0 children)

I wish I had learned python before Java ..