Magic

Magic

190k Downloads

questions about java

disp88 opened this issue ยท 2 comments

commented

I'm kinda dumb.

I admire your work, though! It's amazing. Anyway, this isn't much of an issue, it's rather an issue I have with myself specifically.

I don't know where to start exactly when it comes to learning Java for beginners and that's partially explained in the first line of this comment and the other part is that I look like even more of a beginner than I am because I only know very basic things e.g simplistic data structure parts and control flow parent/child class, the public/private/protected thing,...but all in all the stuff is amateurish. Furthermore, I don't know what an API is or why some people import a bunch of stuff at the beginning of their big plugin things.

I was wondering if you could give me some pointers on where to start, cause I've seen you entertain me quite a lot. Tips in general are fine, as well.

commented

Hello!

So, first off it's great that you want to get into programming! It's challenging but very rewarding.

Without knowing your exact skill level, I would say there is a progression that can make a lot of sense. Something like:

  1. Start with some visual coding- the kind of thing you'll find on code.org. They may seem kind of childish, but it's a good way to get a footing on basic logic and control flow. If you feel like you're beyond this level, that's ok, it's maybe still fun to play around with.

  2. Move on to some basic scripting language. This could be Javascript, or maybe even Skript. Javascript has some advantages in that it's easy to get going with, you can use platforms like jsfiddle.net to get instant feedback on your code.

  3. Do some generalized learning about object orientation, if you end goal is to get into Java. I am honestly not sure of a good place to learn this, but maybe codeacademy (?). This is more about book learning, and less about practical application. You want to have the concepts down.

  4. Then move on to Java. I would not start with something like a Bukkit plugin, but rather try making a simple program. There are probably some good tutorials out there, maybe the Sun ones... not sure.

Somewhere around step 3 you should definitely get a good IDE. I use IntelliJ, Eclipse works great too. For something like Java this is crucial to your learning process.

Now sadly I'm kind of bad at giving real examples, I learned Java a long time ago, partly in a school setting, so none of the ways I've learned really apply anymore, I never had to go fishing around on the Internet for tutorials or anything like that.

Once you've got a good handle on Java, writing a Bukkit plugin can be a very rewarding way to expand your skill set with it. It's a lot of fun to be able to see the effects of your code in-game, but it's also really important to understand the basics of object orientation and the structure of a Java class before trying to delve into the Bukkit API.

Some basic answers to some of your general questions:

  1. In Java you must have an import at the top of every class file for each other class you want to use. These could be classes from the Bukkit API, or core Java classes, or some other class of your own. The more imports you see, the more classes are used in there.

  2. An API stands for Application Programming Interface. Originally the meaning here was a an interface (a set of functions to call or classes to use) that is provided by an operating system to an application developer. This would be what someone writing a program or app would use to interact with the computer. Things like writing files, putting graphics on the screen.

More generally it now refers to an interface some piece of software exposes so other pieces of software can interact with it.

The most obvious example is the Bukkit API. This is an interface exposed by the Bukkit code that lets plugins interact with core Minecraft server code.

Some plugins (like Magic) also offer an API so that other plugins can interact with them.

For the most part it's just a way of defining a strict contract. Something that one program says should not change, so other programs can safely use it. Otherwise, if I were to just start calling functions inside the mcserver code, for instance, that may work now but is not guaranteed to work in the future. An API is (more or less) guaranteed to have the same behavior and to continue to provide the same functions from version to version.

Well I hope some of that helps... feel free to ask more questions, I'm not sure how much I can help but I will certainly try!

commented

Yes, most certainly, it helps! Thank you! I didn't think I would receive such a comprehensive and beautiful response! I can see that you are very passionate about what I'm trying to dive into. Thank you for your generosity and knowledge!