Java or Kotlin

Discussion in 'Programming' started by Chokoladekiks, Jul 21, 2018.

  1. Hey there Spigot,

    So I finally decided to take a swing, at making my own plugins (like basic... Like there should already be a better optimized plugin, but I need to start somewhere). I've read some other posts, where the discussions about kotlin vs java among devs. But as I'm 100% new to java, I figure I could start with the best lanugage. I have a basic understanding of python.

    What would you recommend, and do you recommend any youtube guides/articels? I prefer guides, where I'm not just told, what to do, but why.
     
  2. Kotlin is built on top of Java, so you'll need to learn Java first fully. Here are some good resources to learn Java:
    https://www.udemy.com/java-the-complete-java-developer-course/
    https://learnjavathehardway.org

    After you have a pretty good understanding of Java, you can move onto Kotlin (something you should definitely do, it's really good and makes life so much simpler). You'll be able to pick up Kotlin quite quickly afterwards (talking about an hour or so for basics):
    http://kotlinlang.org/docs/reference/
     
    • Like Like x 1
    • Winner Winner x 1
    • Useful Useful x 1
  3. and here are some more: https://github.com/EbookFoundation/free-programming-books/blob/master/free-programming-books.md#java
     
    • Winner Winner x 1
  4. Thanks for differentiate the differens between kotln and java. Time to use a lot of hours...

    And thanks for the hints. Looking at udemy as and option :)
     
    • Informative Informative x 1
  5. JanTuck

    Supporter

    On top of the JVM but made interoperable with java.
     
  6. Kotlin is its own language. It is built on bytecode, which the JVM uses. Due to the ecosystem of Java, which is the JVM's main language, one needs to know Java in order to properly do Kotlin. Kotlin is 100% interoperable with Java, unlike other languages like Clojure which is only compatible one way (Clojure -> Java, instead of Clojure <-> Java)
     
  7. Choose what you prefer, sometimes Kotlin isn't just your cup of tea.

    In my opinion? I really prefer Kotlin, but I like Java too, however you should start with Java and then migrate to Kotlin, while you don't need to know Java to learn Kotlin, you need to at least know how to read Java code.
     
  8. Another thing to consider, there's way more resources for Java than Kotlin online. Everything you could possibly ask about Java has probably been asked and answered by Jon Skeet on StackOverflow before. If you're lucky, you might find two other Kotlin devs in the wild, so if you're just starting out, definitely go with Java.

    I mean, once you're fluent in either of the two you'll be able to switch to the other with ease. They're different in some design choices, but they're not fundamentally different.
     
  9. And don't forget that IntelliJ IDEA has an excellent Java to Kotlin converter, throw a Java code on a Kotlin class, IDEA will ask if you want to convert, click yes and boom, converted.

    (Sometimes this fails, so keep that in mind, but it is an excellent tool if you want to find out how to do X in Kotlin)
     
  10. omfg, that man has answered half of my questions
     
  11. Use whichever you like more, and don't give into peer pressure. (Yes, I'm looking at the extreme fanboys who claim the other language should've died yesterday).

    Just be aware that fancy features come with a fancy cost.
     
    • Agree Agree x 1
  12. Here is some good posts exploring Kotlin's hidden cost.

    https://medium.com/@BladeCoder/exploring-kotlins-hidden-costs-part-1-fbb9935d9b62
    https://medium.com/@BladeCoder/exploring-kotlins-hidden-costs-part-2-324a4a50b70
    https://medium.com/@BladeCoder/exploring-kotlins-hidden-costs-part-3-3bf6e0dbf0a4

    And here is a good post that benchmarks every thing the author discovered:

    https://sites.google.com/a/athaydes.com/renato-athaydes/posts/kotlinshiddencosts-benchmarks

    But to everyone: Don't freak out just because "omg Kotlin is a bit slower than Java let's migrate to Java again!!!", if you are thinking like that, you should use C instead of Java ;)

    Those hidden costs won't make your server drop from 20 TPS to 1 TPS, if you really think Kotlin is having a bad time in your server, profile it, check if it is really Kotlin that is causing those issues, and then recode the method in Java and see if the performance improves.

    And of course, have fun! :)
     
  13. As mentioned by Proximyst, Kotlin is its own language. You do not need to understand and know Java to learn and use Kotlin (or any other JVM-based language for that matter). Learning any language that shares anything with another language is going to make it easier to pick up the second language by the reasoning that you don't have to relearn what you already know. But Kotlin and Java have just as many differences as they have similarities. Learning Java first may be a good idea, but not for the sole purpose of learning Kotlin. What a strange thing to claim.

    Again, no. Kotlin is a perfectly fine language to start out with, and you don't need to know Java to pick it up. And Kotlin isn't "built on bytecode"; it compiles to bytecode (among other things such as JavaScript and even native machine code with Kotlin Native).
     
    • Agree Agree x 1
  14. Realistically, in an ecosystem where every lib is written in Java or Scala, you need to know Java to know how to work with them.

    Furthermore, how are you supposed to use certain Kotlin features such as @JvmStatic without knowing what static is, since Kotlin does not have a concept of static.
     
  15. Why? How can you make such a grand statement without backing it up in any way? You don't need to know C++ to work with Java, even though the JVM is written in C++. You also don't need to know how ArrayList is implemented to litter your codebase with it, and I'm pretty sure that even though a Deque would be better fit for some of your use cases, you can make do with Set and a few loops. I'm absolutely 100 % certain you can't explain to me how HotSpot's garbage collector or JIT compiler work, but you still have an object bonanza in your programs and I'm sure your code runs as fast as it can - you don't disable the JIT compiler when you run your programs just because you don't know how it works, do you?

    You probably didn't know anything about static, void, arrays, Java's type system, the System class, classes in general, or String literals when you wrote your first Hello World in Java - or maybe you did, but at some point this was all new to you, but that didn't stop you from learning, did it? If we had to understand everything going on at lower or sibling levels of what we do, mankind would still be stuck in the Stone Age. You're standing on the shoulders of giants. Always respect those giants, but realize that your potential is not bound to the ground they stand upon.

    Besides, can you actually give an example of a beginner program or Bukkit plugin context where the JvmStatic annotation is necessary? I can't.
     
    • Agree Agree x 1
  16. Because you don't interact with the JVM. You can think of the JVM as an interpreter, you never touch it, it just reads your code, hence why there are many that are written in many different languages. For example, the Sun JVM is written in C, whereas the first IBM JVM was written in SmallTalk, a language which practically no one knows.

    Not really relevant, I didn't say you need to know how the internals of the JVM works.

    I can give you a pretty good overview of how both work, but I don't know the complete internals of how they work, and neither does anyone on this entire forum tbh.

    What

    This is like saying "You should dive straight into Spigot without learning Java first" - sure it's possible to pick it up as you go, but it's a really terrible idea.

    Sure - when making custom Bukkit events you need to apply it to the handlerList variable in your companion object.
     
    • Agree Agree x 2
  17. You don't "interact with Java" when writing Kotlin code. You "interact" with libraries and frameworks compiled to Java bytecode, and the interoperability between the two languages makes the implementation language completely irrelevant - for beginners at least. I don't see how Googling up Java history is relevant to the discussion, but your arguments only back up my point - I can write perfectly good Kotlin code, "interacting" with many different libraries written in Java without ever knowing they are written in Java. Learning Java is not a requirement for getting started with Kotlin.

    No, it's very relevant. You are blindly using the Java standard library all the time. You don't need to know the implementation details to use them. You can use ArrayLists in Java without knowing about their internals, and the same applies to Kotlin. Knowing Java is not a requirement to learning Kotlin.

    Nobody cares what you know or don't know. This is not about you. This is about being helpful and supportive of a beginner looking to take their first steps into the world you claim to be so profoundly intimate with. The last thing you should be doing is discouraging them by making wild statements of absolutes like "you'll need to learn Java first fully". Where does this statement even come from? The languages share the JVM and Java was there first, so it's a requirement? Give me a break...

    There's this idiotic obsession with sounding "hard" and "seasoned" and "above the rest" in this community, it's so flipping revolting. People care more about their "image" than they care about genuinely helping other people out, and as a result, we have a bunch of "first"-posters spreading misinformation and making confusing, backhanded comments about stuff they don't know as much about as they insinuate. It's pitiful.

    Allow me to elaborate: your entire point is based on the notion that as a requirement for being able to learn one thing, you need to learn about whatever that thing springs from. This is boulderdash. That's like saying you need to learn how to change tires on a car to be able to drive it. Or like saying you need to know Java 4 to use Java 5, because Java 5 was built on top of Java 4. It just doesn't make any sense. The interoperability is pretty key here, but you seem to be completely dismissing it.

    No, it's like saying "you should dive straight into Kotlin without learning Java first". If you're going to use analogies to back up your points, you have to move both the source and the target. Spigot and Kotlin aren't comparable.

    In fact, I think that it would make perfect sense to learn some fundamentals first, but those fundamentals shouldn't be Java, if Kotlin is what you want to learn. It's an unnecessary extra step, and especially with your wildly unrealistic expectation of learning Java "fully" - what makes you think you have learned the language "fully"? Aren't you writing plugins regardless?

    Don't be fatuous. In what way is that a "beginner" context? You're a smart guy, I'm sure you can come up with hundreds of beginner projects that don't require custom events.
     
    • Agree Agree x 2
  18. @Chokoladekiks if you want to get started with Kotlin, you do not need to learn Java first. Since you have a basic understanding of Python, you shouldn't feel too much friction working in Kotlin, but you'll need to get familiar with the statically typed nature of the language and start using the curly braces on your keyboard a bit more.

    From a completely objective perspective, you'll have a much easier time finding lots of learning material on Java than on Kotlin, and since Kotlin is a newer language whose primary target audience is Java developers, a lot of the Kotlin material is likely going to be presented with an assumption of a basic understanding of Java. I'm sure there's "Kotlin for complete beginners" or "Kotlin for Python programmers" stuff out there, though. The two languages differ in a lot of ways that might make things confusing if you try to mix them up and learn both at the same time, but if you aim for Kotlin first, you're very likely going to pick up the important Java bits along the way.
     
    • Agree Agree x 2
  19. @garbagemule but would it be worth using kotlin? I havent really started yet, do to privat life. So no time is "wasted" :)