Is Java a gift to modders?

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

brujon

New Member
Jul 29, 2019
496
0
0
Can tell you one thing, if Minecraft were written in C++, you'd still have Thermal Expansion. :) Lua or Python? Absolutely not. They are scripting languages for a reason - the lack of braces is a deal-killer.

And I say that as somebody who has effectively written a baremetal embedded implementation of a bootloader and network stack in Python. I cannot stand it.

Do you think that if Minecraft was made in C++ instead of Java, it would run more smoothly? I see this spouted as absolute truth more often than not, but would be nice to see what a real programmer that has actually delved into the minecraft code has to say about this.
 

Fuzzlewhumper

New Member
Jul 29, 2019
500
0
0
Without going into detail, yeah - I think the choice of Java for Minecraft made the modding community larger and more robust than some other language choices.
 

Malkuth

New Member
Jul 29, 2019
314
0
0
Not sure.. I read a few responses on this thread and I think they are correct cause minecraft on Xbox is C++ and they don't have mods yet.. Might be cause its Xbox... But I also heard they are trying to add it... So I don't know.. LOL..

But its funny you mention it this way.. cause minecraft if actually Java... and C++ when you consider the xbox version... Then add the Smart Phone version... And it will make your head spin.. hhahaha.
 

KirinDave

New Member
Jul 29, 2019
3,086
0
0
Can tell you one thing, if Minecraft were written in C++, you'd still have Thermal Expansion. :) Lua or Python? Absolutely not. They are scripting languages for a reason - the lack of braces is a deal-killer.

And I say that as somebody who has effectively written a baremetal embedded implementation of a bootloader and network stack in Python. I cannot stand it.

I'm not a fan of Lua or Python myself outside limited use cases, but dude. This is a funny place to draw the line. :D

Java is valuable inasmuch as it's a way to transition more people to Scala and Clojure. Both languages are excellent and eminently practical for high speed software (provided Java is also available as a sort of "C" for interoperability and to write certain types of exhausting code that the HLL cannot express well.

Would we have FTB and such if Minecraft was build with C++?

Both Java and C++ are equally bad as languages go. Anyone who says, "I like the way I do things in Java!" is ignorant of the competition or is one of those people who mistakes emotional and time investment for actual delivered value. Both should be fixed, post haste.

Because which would you rather write?

Code:
// Given a Collection col of Plugin, we'd like to produce a new collection which is every member of col with the function "Minecraft.registerPlugin" and then produce
// a list of results.
 
// Java using java.util.*
LinkedHashMap<Plugin, Result> result = new LinkedList();
for(Plugin p : col) {
  try {
    Result ir = Minecraft.registerPlugin(p);
    result.put(p, ir);
  }
  catch(Exception e) { /* ... */}
}
 
;; Clojure, note we don't need to be aware of the return type and we're quite succinct.
;; We still end up with a Key-Value pairing. The downside is that we don't have type checking
;; but in practice, this is usually superior code because we are less brittle in the the face of
;; unimportant details like the return type of registerPlugin.
;; Also, it looks like it has more parenthesis, but it only has 2 more. And if you count ALL matched
;; delimiters, Clojure has less than Java!
(into {} (map #(try (Minecraft/registerPlugin(%)) (catch Exception e ...)) col))
 
// Scala, we can do even better! We get all the benefits of type checking but without
// the pain of having to type the types. They're only important when we need them to be.
col map { plugin =>
  try { (plugin, Minecraft.registerPlugin(plugin)) }
  catch { case e: ... } } toMap

The only reason I don't use Scala is the build system is sort of agony lately.
 

King Lemming

New Member
Jul 29, 2019
664
0
0
I'm not a fan of Lua or Python myself outside limited use cases, but dude. This is a funny place to draw the line. :D

Maybe, but I'm completely serious. Code syntax should have clear demarcation - while indenting your code is unquestionably good, the whole tab vs space thing is a pile of frustration.

Yes, Java has a lot of boilerplate and repeated syntax, as do C++ and C. But there's a certain charm to being explicit.
 
  • Like
Reactions: Whovian

Whovian

New Member
Jul 29, 2019
1,181
0
1
Do you think that if Minecraft was made in C++ instead of Java, it would run more smoothly? I see this spouted as absolute truth more often than not, but would be nice to see what a real programmer that has actually delved into the minecraft code has to say about this.

It would probably run a bit more smoothly (assuming the C++ programmers aren't rubbish,) given that Java runs on a virtual machine, but most of Minecraft's lag is due to shoddy coding.

Back to the point at hand, without getting involved too much in this argument, I can say three things.

One. Yes, the lack of cross-platform support would make modding much harder in other compiled languages such as C++, C, Objective-C (plus Windows users probably wouldn't be able to play it in that case,) and even C#, though it's usually run on a virtual platform.

Two. Some people would say scripting languages are more convenient, some would say less. They're definitely easier to learn, but large projects are often difficult. APIs would probably need to be very easy to use if, say, Python were the modding language.

Three. All languages have their own merits and fallbacks. The modding community would probably be much different, but still very much present, if Minecraft (or at least mods) were written in C++, Lua, Python, or even the infamous J (though, in that case, most of the modders would also be mathematicians. So maybe mods would tax the computer significantly more than Vanilla. No offence to mathematicians such as me.) The modders would either already know how to or learn to take advantage of the quirks of the particular language. So maybe not reflection, but using multiple inheritance in the (rare) situations in which it works great?
 

Greyed

New Member
Jul 29, 2019
445
0
0
Maybe, but I'm completely serious. Code syntax should have clear demarcation - while indenting your code is unquestionably good, the whole tab vs space thing is a pile of frustration.

The whole tab vs. spaces thing was settled over a decade ago. Anyone who doesn't have an editor which treats spaces at the leading edge of the code needs to get out of the 90s. Not only that, but the spaces/tab argument is independent of braces. The years, literal years, of arguing I saw over which is more appropriate for C code prior to ever hearing of Python still gives me nightmares, along with fits of excessive hyperbole.

As for a lack of braces in general, hogwosh. It is completely insane that you have one method of communicating code structure to the human (indention) and another for the computer (braces). I have never run into an instance in all my years of Python coding where the indention caused me problems. I only wish I could say the same when it came to braces in Perl or C. Next you'll be telling me that semicolons are a must, too.
 

KirinDave

New Member
Jul 29, 2019
3,086
0
0
Maybe, but I'm completely serious. Code syntax should have clear demarcation

I agree, but this is not an argument for or against whitespace sensitivity. It's an argument for what kind of indications are suitable.

while indenting your code is unquestionably good, the whole tab vs space thing is a pile of frustration.

It was a pile of hurt a decade ago. The industry has unquestionably settled on spaces. Google, Facebook, Microsoft, Sony, Id, Nvidia, Intel, even most EA houses. All of them mandate space-based demarcation. No serious code editor gives you any trouble over this.

Even in 2003 when I was interning at Lockheed Martin people were already standardizing on spaces. I remember one day an older "chief architect" walked up to the lead engineer and started an argument that tabs allowed flexible indenting and the lead engineer cut him off, "Pardon me, but Federal Health and Safety mandates you stand at least 10 paces away from me before you start masturbating furiously all over this project. I'm going to step over here where I can do real, meaningful work."

Yes, Java has a lot of boilerplate and repeated syntax, as do C++ and C. But there's a certain charm to being explicit.

I am not in the business of charming or being charmed. I'm in the business of making performant, stable, maintainable software. :) The biggest weakness of Java's approach is that it is explicit about things that shouldn't be explicit and frustratingly implicit about things that you'd wish you didn't need to be. The real strength of the clojure example is that "map" is highly tuned, generic, reuable code that you never need to write. The best studies we have suggest code error rates (as a function in the domain of a single person's output) are constant over line-numbers if other factors are accounted for. Therefore, reducing boilerplate reduces errors, which increases project velocity and reduces fielded errors.

It would probably run a bit more smoothly (assuming the C++ programmers aren't rubbish,) given that Java runs on a virtual machine,

If anything this probably makes minecraft run faster because of the way the JIT works out. Only the very best programmers with the very best techniques can consistently beat Java's JIT over micro-optimized regions. And tree-tracing JIT optimizations frequently capture latent optimizations that only a compiler (or someone mentally being the compiler at a high level) can clearly see.

Two. Some people would say scripting languages are more convenient, some would say less. They're definitely easier to learn, but large projects are often difficult. APIs would probably need to be very easy to use if, say, Python were the modding language.

I hate the phrase "scripting language." It is nonsense.

Minecraft could trivially implement a scripting layer for mods and it'd work very well. Many major games have adopted this approach quite successfully. World of Warcraft's scripting layer is quite sophisticated. The most widely deployed """"scripting"""" language is JavaScript, and people use it to write and run sophisticated, graphics rich applications every day.
 

King Lemming

New Member
Jul 29, 2019
664
0
0
Next you'll be telling me that semicolons are a must, too.

They're not a must, but again - clear demarcation of the end of a statement is nice.

You don't have to agree with me on any of this stuff, obviously. But in the case of TE, you can't say my preference for specificity produces buggy code. ;)
 
  • Like
Reactions: Xeonen

Greyed

New Member
Jul 29, 2019
445
0
0
You don't have to agree with me on any of this stuff, obviously. But in the case of TE, you can't say my preference for specificity produces buggy code. ;)

Well, of course. Correlation does not equal causation.

And don't get me wrong, I'm a big fan of TE. It is probably the mod that is the top of my list when it comes to mods I include in my world, and I've ditched quite a few venerable mods over the past few months.

But if you will allow me a bit of snark to go with that heaping of butt smooching, are you saying your changelogs never included an indication of a bug fix. For if they have, we can say that your preference for specificity hasn't prevented buggy code, either. ;)
 

KirinDave

New Member
Jul 29, 2019
3,086
0
0
They're not a must, but again - clear demarcation of the end of a statement is nice.

You don't have to agree with me on any of this stuff, obviously. But in the case of TE, you can't say my preference for specificity produces buggy code. ;)

This is a function of your ability. If anything, your ability is counteracting Java's tendency to produce brittle code. It is definitely okay for someone to say this.
 

brujon

New Member
Jul 29, 2019
496
0
0
When i see these discussions, it tends to make my head spin... Most i did of coding was a little bit of IRC scripting and BASIC turtle stuff.
 

Bigglesworth

New Member
Jul 29, 2019
1,072
0
1
A modding API would not benefit the community because we already have a very good one: Forge.

Because forge itself couldn't benefit GREATLY from an official API?

Forge and all the mods we have are based off one big hack. We need an official API.[DOUBLEPOST=1366831927][/DOUBLEPOST]
Can tell you one thing, if Minecraft were written in C++, you'd still have Thermal Expansion. :) Lua or Python? Absolutely not. They are scripting languages for a reason - the lack of braces is a deal-killer.

And I say that as somebody who has effectively written a baremetal embedded implementation of a bootloader and network stack in Python. I cannot stand it.

It would be simple with an official API, (I think youre smart enough to triumph over the everest that is lack of braces) Not anything like writing a baremetal embedded implementation of a bootloader, so the comparison is strange and way off. if you ended TE dev tomorrow and opened it up to the community (great mod love the work smooch smooch) and suddenly the mod language became Python, someone else would continue especially when coding for it would have been made much much easier and more of the community would have teh capability to be involved in bug fixing and testing resulting in better mods in general faster.
 

King Lemming

New Member
Jul 29, 2019
664
0
0
It would be simple with an official API, (I think youre smart enough to triumph over the everest that is lack of braces) Not anything like writing a baremetal embedded implementation of a bootloader, so the comparison is strange and way off.

TE at this point is over 400 java files. I'll even acknowledge that with a proper official API, I could maybe cut that in half. I still would not want to code 200 Python files.
 

Bigglesworth

New Member
Jul 29, 2019
1,072
0
1
Even in 2003 when I was interning at Lockheed Martin people were already standardizing on spaces. I remember one day an older "chief architect" walked up to the lead engineer and started an argument that tabs allowed flexible indenting and the lead engineer cut him off, "Pardon me, but Federal Health and Safety mandates you stand at least 10 paces away from me before you start masturbating furiously all over this project. I'm going to step over here where I can do real, meaningful work."


LOL[DOUBLEPOST=1366832589][/DOUBLEPOST]
TE at this point is over 400 java files. I'll even acknowledge that with a proper official API, I could maybe cut that in half. I still would not want to code 200 Python files.
Can't blame you there, but i think you could (if this theoretically happened) employ a bunch of code monkeys to do that sort of gruntwork for free and then oversee the general quality yourself. Tons of people would be glad to help out with such a project. Of course i can understand authors wanting more control than that ect ect
 
  • Like
Reactions: EternalDensity

Greyed

New Member
Jul 29, 2019
445
0
0
TE at this point is over 400 java files. I'll even acknowledge that with a proper official API, I could maybe cut that in half. I still would not want to code 200 Python files.

See, that just confuses me. Reduce the amount of work, both in terms of overall complexity of the project, as well reduced code syntax based on sensible, intuitive and well-established standards or, no thanks prefer to have braces. I just... can't grok it. :(

Can't blame you there, but i think you could (if this theoretically happened) employ a bunch of code monkeys to do that sort of gruntwork for free and then oversee the general quality yourself. Tons of people would be glad to help out with such a project. Of course i can understand authors wanting more control than that ect ect


*raises hand* I'd love to contribute to the modding community. But not so much that I'd want to delve into the boilerplate horror that is Java. I know I should learn it, I really should. But every time I sit down to do so I run into the same conceptual problem. "Wait, it takes me 6 times the lines, each line being twice as verbose, to do the same thing as in Python? This is good, how?" And yeah, I could deal with braces again if I had to. That's not the issue. :)
 

Sphinx2k

New Member
Jul 29, 2019
195
0
0
*raises hand* I'd love to contribute to the modding community. But not so much that I'd want to delve into the boilerplate horror that is Java. I know I should learn it, I really should. But every time I sit down to do so I run into the same conceptual problem. "Wait, it takes me 6 times the lines, each line being twice as verbose, to do the same thing as in Python? This is good, how?" And yeah, I could deal with braces again if I had to. That's not the issue. :)

When i read this I can only think of personal preference. I am not a full time programmer but for me i write a much better code when it is well structured. One thing i found out for myself was that if doing math at school. The moment i switched from me hard to read quick writing to a cleaner writing math became much easier for me.
Back to programming, i write maybe more in Java and need more time to do that than in other programming languages, but in the end save time be understanding the code more quickly and track errors.

I come from Pascal, over C++ to Java with a little bit C#, Lua, Phyton. If someone understands to think in code it is not to hard to switch die Programming language, mostly it is learning a new syntax. But as i said programming is a hobby for me so someone doing this as is job is certainly having a different view on this.
 

Mash

New Member
Jul 29, 2019
892
0
0
I need to start coding, if for no other reason than to be able to understand any of this jargon.

I suppose it's unfortunate that every time I've tried, I sucked hardcore at it.
 

Greyed

New Member
Jul 29, 2019
445
0
0
When i read this I can only think of personal preference. I am not a full time programmer but for me i write a much better code when it is well structured. One thing i found out for myself was that if doing math at school. The moment i switched from me hard to read quick writing to a cleaner writing math became much easier for me.

Oh, I agree. It is very much personal preference. However, I did want to address the latter half the quote above. Don't mistake verbosity for structure. To me Java is more verbose than Python, but not more structured. If you can reduce verbosity and sacrifice nothing of structure, then why not do it? And at the most basic, that is what the brace/no-brace discussion is when it comes to Python. Yes, having braces there explicitly states where the block begins and ends. But the indention does, too. By losing the braces we've lost no structure.
 

BananaSplit2

New Member
Jul 29, 2019
102
0
0
It definitely did. Writing Mods in C++ would be much harder and only the best programmers would actually release Mod. (look at terraria and it's lack of good mods, cause it's written in C++)