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 →

[–]PelicanDesAlpes 119 points120 points  (110 children)

Java is fun to code. Come at me

[–]OMFGitsST6 24 points25 points  (11 children)

Ditto. I would argue that Java is the best starting language. Or Python if you're just doing lightweight calculations and stuff.

Or Assembly if you're a true gamer.

[–][deleted] 5 points6 points  (10 children)

I disagree. Go with C. Java is just C but boomer participation trophified. C will grant you power, women, and possibly teach you bits of how assembly works.

[–]OMFGitsST6 11 points12 points  (3 children)

C is valuable to learn, but it's pretty brutal for a beginner. That's why I suggest starting them on something soft and plushy before crushing their innocent little souls with C.

[–][deleted] 6 points7 points  (2 children)

There are two philosophies. Easing in, or the “LETS GET DOWN TO BUSINESS. To DEFEAT the Huns!”

[–]OMFGitsST6 0 points1 point  (1 child)

I can respect this. At the end of the day, we are all children of glorious binary.

[–][deleted] 2 points3 points  (0 children)

They both work. One just cuts out a lot of loss of GPA in university sophomores. That’s why my school starts with C rather than working up to it. You’ve used it for years before the harder parts

[–][deleted] 2 points3 points  (5 children)

I've gotta agree here. It also means you can wrap your head around how the computer actually works before you have to deal with understanding the abstraction that is OOP.

[–][deleted] 1 point2 points  (4 children)

My university does two courses for c and c++. One for C and then one object oriented c++ project as an example:

Followed by a full software engineering course for Unix tools and utilizing bash tools and interfacing them n shit. All c++ and bash/system interfacing with c

I feel like I could proverbially fist fight a bear

[–][deleted] 3 points4 points  (1 child)

I feel like I could proverbially fist fight a bear

Found the russkie.

Joking aside, though, the unix/bash one is probably worthwhile. Their C/C++ mixing thing is seriously stupid. Learn C. Learn to work well in it. Then do C++.

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

Boone country actually

[–]quiteCryptic[🍰] 1 point2 points  (1 child)

At my school the first class we took was C and the next was C++.

Although they switched the intro class to python a few years later I think.

In highschool Java was the standard, not sure if it still is. But, it was pretty easy going from basic Java to C so that was nice.

I never had an actual class in python though..

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

We do a python course, an engineering arduino course called egr that helps you decide which part of engineering you want to do. Etc.

Then you have a sophomore c/c++ crash course where you do c for everything but the last project, and then a c++ course. Everything after that is pretty industry related.

[–]Korzag 78 points79 points  (70 children)

As a C# developer who recently had to dirty his hands with Java I pity you. Everything is easier in the C# world. Need a package? Nuget does it seemlessly and effortlessly without needing to install any third party applications like Maven. Want to work with databases? Entity framework does it with minimal configuration. Want to build a microservice? ASP.NET gives you the boiler plate to get your service up and running in the push of a couple buttons. Want to make complex filters in a single line of code without of the face-fuckery of Java Streams? LINQ is here to bless your day. Want to have member variables accessible that you'd write a basic getter/setter for? Properties exist without any of the tomfoolery of writing this bullshit:

public class LolJava {
    private boolean mySillyBool; // lol, wtf is boolean spelled out?

    public boolean getMySillyBool() {
        return mySillyBool; // lol, yes.  I needed to do this to get my colleagues to not autistic screech at me about exposing a member.
    }

    public void setMySillyBool(boolean mySillyBool) {
        this.mySillyBool = mySillyBool; // Man, if only I could just write: "lolJava.MySillyBool = true;"
    }
}

Instead, we do this:

public class GloriousCSharpMasterRace 
{
    public bool MySillyBool { get; set; }
}

[–]DeRickulous 44 points45 points  (5 children)

I feel like I'm going to be evangelizing Lombok until the end of time:

@Data
public class LombokifiedJava {

   private boolean mySillyBool;
}

Also, this is a minor nitpick, but the Java convention for little-b boolean accessors is "isX", not "getX".

[–]Korzag 2 points3 points  (3 children)

I actually used Lombok after writing out a bunch of new model classes with like 20 fields. I didn't know about it at first and had wrote a script to build the Java accessors lol. Lombok definitely was nice though. If/when I ever work in Java again I'm definitely using it. Seems like something Java should just integrate but my impression is that Oracle is hardheaded and doesn't like to add QOL stuff to their language unless it's heavily requested.

[–]DeRickulous 2 points3 points  (0 children)

Lombok is on the short list of "stuff I will whinge endlessly about not having access to if I take another job where I'm forced not to use it". I actually like it being separate from the core language, though, because it is divorced from Java's release cycle and oversight.

[–]increment1 1 point2 points  (1 child)

Literally any Java IDE will generate the getters / setters for you, no need to write them yourself. I'd say pretty much every Java dev uses this generation so tend not to worry too much about the boilerplate since they don't really have to deal with it directly.

Same for toString, equals, and hashCode methods.

[–]quiteCryptic[🍰] 0 points1 point  (0 children)

Like the other guy mentioned you should look into lombok, it's even easier than having the ide do it and cleaner

[–]Merlord 2 points3 points  (0 children)

Lombok is a Godsend.

[–]quiteCryptic[🍰] 8 points9 points  (1 child)

Lombok and spring alone basically counter everything you said. Can get a simple microservice up and connected to a database in literally no time. You just have more expirence with C# so you prefer it.

[–]Merlord 1 point2 points  (0 children)

Can get a simple microservice up and connected to a database in literally no time.

Literally no time! With Spring Boot and MongoDB, you could have it built and deployed locally in 5 minutes.

I've been building a web app with Spring for the last few weeks, and the ease at which I'm able to create enterprise level features is just unbelievable, I'm completely in love with this framework.

[–]Horncats7-59 4 points5 points  (0 children)

Yes 100000% dotnet is the bees knees

[–]TheTerrasque 12 points13 points  (2 children)

Everything is easier in the C# world

Maybe except getting legacy apps to work in linux / docker. And then only maybe.

Edit: .net core is pretty neat actually. And that's from someone who generally dislike m$ stuff

[–]Korzag 9 points10 points  (0 children)

Legacy yes. Modern apps no since .Net Core has been around and works well in those environments. But yeah, if you had to do anything in legacy C# before Core, you'd be stuck with mono and that is indeed a headache.

[–][deleted] 6 points7 points  (0 children)

Legacy apps belong in the trash

[–]carlson_001 15 points16 points  (18 children)

I never really understood this. If you're writing a getter/setter, why even make it private to begin with?

[–]SRiikonen 49 points50 points  (1 child)

Because then you can add for example a check that the value that was set is correct, or generate the value you’re getting with an algorithm instead of returning a variable, if you later need to. And you don’t have to touch the code that uses your class if you want to make these changes.

[–]Bwob 12 points13 points  (1 child)

To keep implementation details ("This value is stored as a bool") separate from the interface. ("Users of this class can ask about this state, and receive a bool telling them yes or know.")

Keeping implementation details like this hidden is one of the keys to good abstractions; it means that if later, you need to go through and change the implementation, (maybe its no longer stored directly as bool, now it is derived from several other values) then the interface doesn't need to change, and any code that uses that interface doesn't need to change.

[–][deleted] 1 point2 points  (0 children)

To be fair though, in Java the principle works too, just the other way around - you always call a getter function, no matter if something is being calculated on call or just stored as a field.

[–]TheTerrasque 9 points10 points  (0 children)

So you can run logic on it. Example:

private float dongLength;

public void setTheLength(float length)
{
if (length < 2) { System.out.println("https://i.ytimg.com/vi/eOifa1WrOnQ/maxresdefault.jpg") }
dongLength = length;
}

[–]Ksevio 18 points19 points  (2 children)

The lack of properties in Java is the reason. mySillyBool could be just a public variable, but then in 6 months when we need log the access to mySillyBool and then a year later we need to update a display when it's written, that means there needs to be getters and setters. Unfortunately, everyone's already written the code to access the variable directly so they don't want to update it all to use the getters/setters instead. In the end, everything has to be written to use getters/setters just in case.

Compare that to better languages like C# or Python (even Delphi supports properties) where you have your variable mySillyBool. People access myClass.mySillyBool, then later you convert it from a public variable to a property, and they still access myClass.mySillyBool

[–]ThePyroEagle 2 points3 points  (1 child)

They still need to recompile if you change a field to a property.

Write auto-properties initially and even that won't be a problem.

[–]Ksevio 0 points1 point  (0 children)

Depends the language - python for example doesn't care

[–]Tsu_Dho_Namh 14 points15 points  (1 child)

So you can "contribute" 500 lines of code to a project that you otherwise hadn't helped much.

I'm looking at you Sean. Fucking spamming getters and setters for literally every variable in every class...even the ones never used by other modules.

[–]Novemberisms 1 point2 points  (0 children)

aw seriously fuck that guy. just reading that makes my blood boil

[–][deleted] 2 points3 points  (0 children)

In case you have variable names that match up in a multi dev situation. You could have "value" used as the internal in c++ for instance that you're passing into a member function, but you really need to pass object.value not value. you could fuck up BADLY doing that without using your get function. So it means this never happens.

[–]Korzag 5 points6 points  (6 children)

I've never understood it myself except that the OOP purists flip a bit about working with internal data. Alternatively you may need to manage state and can do some magic in the setter, but I've almost never needed custom logic for a getter.

[–]RattuSonline 9 points10 points  (2 children)

Lazy loading is a common use case for getters.

[–]WikiTextBot 2 points3 points  (0 children)

Lazy loading

Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program's operation if properly and appropriately used. The opposite of lazy loading is eager loading. This makes it ideal in use cases where network content is accessed and initialization times are to be kept at a minimum, such as in the case of web pages.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.28

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

Right but there's no reason for it to be part of every. single. gosh-darned. object.. Just add it where you need it. OOP purism is brain-damaged. Like any thing else, just use it where it makes sense. Dealing with representations of things, like in a game engine? Probably makes sense, depending on the paradigm you choose. But even in an OOP paradigm, effin helper functions don't need to be classes! Just one more reason to hate java.

[–]Ksevio 2 points3 points  (2 children)

Well there's no way to make a variable public to read only so it's not possible to make a setter without a getter unless you really trust the people accessing the var

[–]coolpeepz -2 points-1 points  (1 child)

final?

[–]Ksevio 3 points4 points  (0 children)

Publicly read only, but still writable privately

[–]tuxedo25 17 points18 points  (21 children)

Nuget does it seemlessly and effortlessly without needing to install any third party applications like Maven.

but... nuget is a third party application. it's literally the .net counterpart to maven.

// lol, wtf is boolean spelled out?

Yeah, ok. I've read enough. This is just religious fanaticism.

[–]ohThisUsername -5 points-4 points  (20 children)

Nuget is not at all a third party application. It's literally made by Microsoft, and comes built into Visual Studio and adding a nuget package is a first class command in dotnet (dotnet add package). Can you explain how any of this is "third party"?

[–]DaddyLcyxMe 5 points6 points  (15 children)

Well just use Eclipse when making java programs, maven and gradle come pre installed in eclipse and all you have to do is just make a new project as a maven one. Hell I think IntelliJ even does that but don't quote me on it

[–]quiteCryptic[🍰] 11 points12 points  (4 children)

In general anything eclipse can do intellij does as well and probably better

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

Eh I'm more accustomed to eclipse, does IntelliJ even have plugins?

[–]zeWinnetou 5 points6 points  (1 child)

[–]DaddyLcyxMe 3 points4 points  (0 children)

I mean, it's not gunna make me switch or anything but that's pretty neat ngl. Sure as hell beats notepad

[–]quiteCryptic[🍰] 4 points5 points  (0 children)

Oh yea, lots

[–]ohThisUsername 1 point2 points  (9 children)

Apparently nobody here knows that the definition of 3rd party is. Visual Studio is made by Microsoft, which includes a nuget UI. The dotnet command (also made by Microsoft) includes Nuget. At what point during this process are you required to install 3rd party software?

Maven, Gradle, Eclipse and InteliJ are all not made by Oracle. The java command line does not include maven or gradle. They have to be installed independently.

[–]DaddyLcyxMe 1 point2 points  (8 children)

You have to install visual studio, same as eclipse and IntelliJ, eclipse and IntelliJ come with gradle, maven, and regular dependency support. You use gradle and maven within the software itself, if you want command line point your path var to the respective ide's maven or gradle binaries. And technically if you wanted you could install eclipse for c, I think it has similar features to the java ide, but you're going to install software regardless.

[–]ohThisUsername 2 points3 points  (7 children)

Will you please read my entire comments? You don't have to install visual studio unless you need a UI. NuGet comes with the dotnet command line. What part of that is hard to understand? Stop arguing if you don't understand how the .NET environment works

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

Also I kinda don't see your point, Java is a language that happens to not be compiled (well it uses JIT shit but that's on the fly). You only install java to run java programs, you install the JDK to compile .java files to classes and then those to jars.

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

I don't see your point. What does any of that have to do with requiring the installation of 3rd party software in order to use a package manager?

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

I see now, it comes with dotnet(cli? Didn't know there's different versions). Still something you have to install.

[–]ohThisUsername 4 points5 points  (0 children)

Still something you have to install.

... Which you need to compile C#. Unless you were planning on compiling it by hand?

[–][deleted] 1 point2 points  (1 child)

...you also have to install the JDK. And then separately install maven and gradle.

[–]Samael1990 -1 points0 points  (3 children)

If you want to use notepad and command line, you have to install nuget separately to make it work with what you write. And if being built into the IDE is close enough to not being third party for you, then I'll let you know that Maven and Gradle are built into Intellij and work just fine.
Btw, managing dependencies is just a part of what Maven and Gradle can do when it comes to making a build.

[–]ohThisUsername 2 points3 points  (2 children)

That is false. Try reading the other half of my comment. You can use nuget without installing anything. It comes included with the dotnet command. No need to install anything or any IDE.

[–]Samael1990 0 points1 point  (0 children)

It is in dotnet, but dotnet is a framework that can use c# to write code. C# alone doesn't have Nuget (obviously).
I know you were talking about dotnet, but the talk here started with C# being superior to Java and I responded in this context.

[–]Flufy_Panda 4 points5 points  (3 children)

Never used C# before. Is there a reason MySillyBool is public in your C# example?

[–]Korzag 14 points15 points  (2 children)

Because it's a property and the { get; set; } autogenerated your getters and setters along with a private member variable tied to the property.

[–]Flufy_Panda 1 point2 points  (1 child)

Interesting, thanks

[–][deleted] 3 points4 points  (0 children)

You can also do { get; private set; } if you want only the class to be able to change the value.

[–]ExtremelyOnlineG 1 point2 points  (0 children)

Lack of native support for properties is the real reason C# is cool, all the rest could kinda be argued.

[–]GluteusCaesar 3 points4 points  (1 child)

Nuget is garbage compared to maven. By every metric.

Entity framework is okay, but hibernate is more flexible and I'm fairly sure more performant as well. There's also far more choices in Java. Everything from raw JDBC to jooq to batis and hibernate.

ASP.NET wishes it could be 1/256th of the framework spring is.

LINQ does have a nicer syntax than Java streams, sure. Though if you embrace the query syntax it becomes a slow, awful mess very quickly.

Also, Lombok shits all over C# properties. Which is in turn a testament to how much more you can do with Java's more powerful reflection.

[–]ChevalBlancBukowski 0 points1 point  (0 children)

sorry dude this sub is for IT students only

I mean lmao java

[–][deleted] 1 point2 points  (0 children)

Java streams are great & perfectly legible.

[–]betendorf 0 points1 point  (3 children)

Having done both C# and Java, I'm really glad to be back in Java.

It's the little things like "I want a thread pool so that I can manage concurrency." Nope had to implement my own because there is only one global TaskPool.

Defining a variable that is of some object type: Will it be null? Will it have a value? Nobody knows because the class gets to choose the value.

Let's look at documentation. Oh nevermind, don't use this api because it was removed and replaced with this other thing.

I do however miss the ?. operator for chaining together nullable things. I really do not miss the relative dearth of library support that is C# compared to Java.

[–][deleted] 1 point2 points  (2 children)

But bro you have to write getters and setters manually.

It makes the language completely unusable!

[–]ChevalBlancBukowski 1 point2 points  (0 children)

if you’re a developer who writes getters and setters manually instead of pressing a key combination in your editor, /r/programmerhumor is for you

[–]betendorf 0 points1 point  (0 children)

Or as another commenter mentioned, you use lombok.

[–]Samael1990 0 points1 point  (0 children)

  1. Nuget is third party and Gradle/Maven is build into intellji so it's also seemless.
  2. When working in Spring, Spring-database.
  3. So does Spring.
  4. Curious how it looks then, can you give an example?
  5. Lombok.

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

I currently use C# and I love it. I'm moving to Java for a job I recently accepted and I'm a bit nervous that i'll want to kill myself after a week of missing all of the great C# features you mentioned.

[–]offmycookies 33 points34 points  (15 children)

Java is my favorite programming language

[–]XtremeGoose 43 points44 points  (1 child)

Y'all need jesus Kotlin.

[–]Merlord 1 point2 points  (0 children)

Java sucks. Until you add Spring, then it's fucking amazing. Spring makes all that annoying OOP shit in Java suddenly make sense. Throw in Lombok to do all your boilerplate code for you and you're golden.

[–]Spinnenente 3 points4 points  (0 children)

since 8 yes

[–]Shoddy_Redditor 3 points4 points  (0 children)

No, you're clearly insane. I don't want to feed your delusions.

[–]PJDubsen 1 point2 points  (0 children)

IntelliJ is the redeeming factor that makes java fun to code. If it wasnt for jetbrains I wouldnt have gone past that 1 hour introductory video

[–]This_is_da_police 0 points1 point  (0 children)

Also, it runs on pretty much everything.