this post was submitted on 28 Feb 2024
136 points (95.3% liked)

Programming

16144 readers
277 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

Hello!

I just wanted to make a post to share my excitement over discovering programming with Java. For context, my previous knowledge of any programming language barely extended into classes as I always struggled with understanding more than the basic basic things (classes? like what you wear on your face? get and set what? the table?).

I really liked the idea of programming though! So over the years (maybe 15-20?), I tried learning (and failed) with different languages, hoping something would help things click. I've tried C#, Basic, JavaScript, HTML/CSS and more but never Java. As to why not, I have no clue.

The reason for Java, now, is that I've been playing Minecraft a lot recently (my adhd thanks you Mojang) and I figured, why not give it a try? So I started a free online course covering the basics: variables, methods, objects... A week later, and after a lot of DuckDuckGoing, I now understand not only the basics but classes, IO, exceptions, and so much more! I'm currently wrapping my head around Generics but I'm having a wonderful time with it. After that, who knows :)

Take care and thank you for reading!

top 28 comments
sorted by: hot top controversial new old
[–] [email protected] 16 points 4 months ago (1 children)

I applaud your success! I'm curious though: what is it about C# that made it inaccessible compared to Java? The two are extremely similar, so much so that I think you'd have to learn for more than a year before you start noticing any differences.

[–] [email protected] 8 points 4 months ago (1 children)

I was thinking the same thing, until I read Minecraft. Java mods...

[–] [email protected] 7 points 4 months ago (1 children)

Motivation is one hell of a teacher.

[–] [email protected] 5 points 4 months ago (1 children)

That's exactly where my mind was going. Learn Java and maybe one day I can make a Minecraft mod lol. I'm not modding yet but just the idea of doing it gave me the kick I needed to get started learning.

[–] abhibeckert 4 points 4 months ago (1 children)

Find someone else's open source mod and try to change how it works.

[–] [email protected] 2 points 3 months ago

This - and don't worry that this is somehow "cheating". It's how a ton of programmers got their start. Old farts like me learned a lot by messing around with GORILLA.BAS

[–] [email protected] 14 points 4 months ago (1 children)

Virtual high five! Keep it up, I'm always happy to see someone find joy and a sense of accomplishment in programming things.

Check out polymorphism and concurrency when you feel you're solid enough on the other things. Concurrency/threading can be a bit weird to wrap your head around, but essential to build powerful things. (See Reader-/Writer problem to start)

[–] [email protected] 3 points 4 months ago

Thank you! I will write those down for later reference :)

[–] agent_flounder 6 points 4 months ago

That's kickass, way to go! Online learning is the way to go. I have a hard time learning stuff directly from a book (ADHD may be why idk). Something about the structure and pace and external motivation of a course does the trick for me. That's how I learned AngularJS, anyway. All kinds of stuff you can do with Java: Desktop apps, web apps, etc etc.

[–] [email protected] 6 points 4 months ago

Nice work!

Without formal a formal education program, finding the right subset of a new skill or hobby is probably the best way to hook yourself in so it's easier to keep at it long enough to really start learning. It sounds like concepts are finally sticking for you because you have an immediate and fun application for them.

I hope more people continue to find unconventional paths into the field like you did, keep going with it.

[–] [email protected] 5 points 4 months ago (2 children)

Do you mind sharing links to the courses you found ? I've been teaching Java to students who almost never wrote code before, and I'm always looking for beginner-friendly resources I can recommend to them.

[–] [email protected] 3 points 4 months ago (1 children)

Sure! The course that finally worked for me is at Codecademy. I'm only doing the free content but it's broken down in ways I can understand, with immediate examples after the explanations. It has you create a small program after each short lesson and keeps slowly building up. There are hints for each task as well, which has helped me tremendously as well.

It reminds me of freeCodeCamp's courses, but for Java. It's also not so wordy (no offense to FCC), which is great for keeping my focus on the content.

I'm currently on the 'Learn Intermediate Java' course but I started with the 'Learn Java' course.

https://www.codecademy.com/learn/learn-java

[–] [email protected] 2 points 4 months ago

Thanks for the detailed answer about your learning experience and for the link 👍 ! I'll make sure to check it out.

[–] Serinus 3 points 4 months ago (1 children)

If you teach them factories in tyool 2024, I swear I will find you and I will take away every color compiler and runtime you have outside of Radio Shack Level 1 BASIC (TRS 80).

[–] [email protected] 1 points 4 months ago

I am not an actual teacher, I only supervise practical computer science work aside from my dev job, so I have no saying in what is taught. But don't worry, this is only a very basic introductory course, no factories, not even inheritance. Only classes, attributes and methods.

[–] [email protected] 4 points 4 months ago

That's great to hear! Always nice more new programmers. Minecraft modding is great, and it also provides you with a platform with a lot of reach and a lot of really amazing devs willing to help. My most successful project to date has been a simple Minecraft mod. Keep it up and good luck on your modding adventures!

[–] Fades 3 points 4 months ago

Modern Java is great! Kotlin too

[–] aluminium 2 points 4 months ago

Very cool. Thats in a way the beauty of Java. It offers you just enough Tools for Object Oriented Programming to get everything done in some way (maybe not the most elegant or efficient way, but in a way).

[–] [email protected] 2 points 4 months ago (1 children)

If you are interested in pushing more, there are other JVM languages.

Scala was my first functional programming language after doing Java -> Groovy -> Scala. All 3 can access the entire Java ecosystem and are compatible with each other. Scala is like having Generics for your Generics (Higher Kinded Types).

[–] [email protected] 4 points 4 months ago (1 children)

Don't forget kotlin

Probably my favourite of the java/c# family

[–] treesoid 2 points 4 months ago

And with good support for modding Minecraft

[–] [email protected] 2 points 4 months ago (1 children)

I never got the point of using classes from tutorials, all those animals/cars/person examples were utterly useless to me, but then i started writing C++/Qt and then Flutter and i think i got it...

[–] [email protected] 1 points 3 months ago

Classes are Data plus the code required to modify that Data. The idea is to encapsulate data modifications into one thing (a Class) that knows how to modify all the Data as a single unit. This lets us write some code to describe, say, a Scrollbar widget. The Class for the widget combines all the Data for a Scrollbar (position, orientation, bar size, total size, etc) with the methods that read or modify that data (scroll up/down, change size, draw, etc).

That's the first Big Idea of OOP - that data should be grouped with the functions that modify it. If you don't have that - as in C - you have to write functions that only work on a given data type but which are namespaced separately. You get functions like void set_scrollbar_pos(void* scrollbar, word pos) which become verbose in a large project. (I'm not saying this is the worst thing in the world, just a different style.)

The second Big Idea of OOP is message passing. Now that we have code and Data bundled together, it would be nice if Objects that share functions of the same essential type and intention could be swapped out interchangeably. So instead of directly invoking a function on an Object, we send a 'message' that says something like 'if you know how, please draw yourself on screen, relative to X,Y'.

Of course, since plain English is hella verbose, the actual message is going be something like "draw, X,Y" and the Object receiving the message then sorts out if it has a method called "draw" that can use the provided X and Y. If so, it runs the code to do so. If not, you get an error.

Messages like this mean that you can swap out compatible Classes for one another. E.g. you can ask any collection of widgets to .draw themselves with a single method and let the compiler/interpreter generate the machine code as needed. That reduces the amount of boilerplate for engineers by a lot! Otherwise, trying to work with any collection of heterogeneous Objects (like a List of every Widget contained in a Window) would need to have essentially the same code rewritten for every different Type needed - a combinatorial explosion of code!

Tl;Dr -

  • Classes help organize code and simplify state management by combining data with the functions that manipulate that data.

  • Classes reduce the amount of boilerplate code needed by allowing methods with the same "shape" to be called interchangeably.

Everything else about OOP is essentially built off these two ideas. I hope that helps.

[–] nivenkos 2 points 4 months ago

Check out the Nand2Tetris course on Coursera for building your own Java too.

[–] [email protected] 1 points 3 months ago

Congrats! Java is a good language to learn, and it's gotten a lot better over the years. The tooling and the ecosystem are very mature. Enjoy your newly found super powers!

[–] Asudox -2 points 4 months ago (2 children)

Is Java really that fun? I really hate boilerplate languages.

[–] abhibeckert 1 points 4 months ago* (last edited 4 months ago)

Java's not my favourite language either, but the only "nice" language on his list is C# and particularly if he was using it in a .NET context then it's got a steep learning curve:

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();

Working with closures and run loops is a pretty rough starting point compared to other languages where you start with just print "Hello World". Those concepts are relatively simple for someone experienced but a beginner can easily hit a brick wall they can't climb over.

[–] [email protected] 1 points 3 months ago

"Fun" is in the eye of the beholder.

If OP is having fun with Java, that's awesome.