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
# Might be valid Python code? Not certain...
# Why do all the languages I'm familiar with have to do stupid things like System.out.println() or printf("%d/n", n)...
# Might be valid Python code? Not certain...
# Why do all the languages I'm familiar with have to do stupid things like System.out.println() or printf("%d/n", n)...
# Might be valid Python code? Not certain...
# Why do all the languages I'm familiar with have to do stupid things like System.out.println() or printf("%d/n", n)...
What is wrong with System.out.println()? Sure the name is long but it allows to easier place a new line. Sure just writing \n at the end of the string is easy but when you are dealing with something else like an integer it means you either need to make a complete different call other wise or append the new line to it. (unless System.out.println(21,"\n") is valid syntax, in that case no idea)
I thus personally find it a pretty logical inclusion as it easily shows that you want a new line without extra calls.
As for printf, I have no idea why people want stuff like that. Seems to me like it will more often cause bugs as the order is very important.
Also, learn lua then I don't think it has much useless stuff if it has anything. Well, it does have print() and io.write() to put stuff in the console however both have plenty of differences.
print() automatically puts a \n at the end, io.write does not
io.write() can be used to write to files, print() can not
print() automatically executes a tostring(), io.write() does not
io.write() is consistent with what io.write("some text", "some other text") looks like throughout different interpreters, sadly the same can't be said about print("some other text","some other text")
What is wrong with System.out.println()? Sure the name is long but it allows to easier place a new line. Sure just writing \n at the end of the string is easy but when you are dealing with something else like an integer it means you either need to make a complete different call other wise or append the new line to it. (unless System.out.println(21,"\n") is valid syntax, in that case no idea)
I thus personally find it a pretty logical inclusion as it easily shows that you want a new line without extra calls.
As for printf, I have no idea why people want stuff like that. Seems to me like it will more often cause bugs as the order is very important.
Also, learn lua then I don't think it has much useless stuff if it has anything. Well, it does have print() and io.write() to put stuff in the console however both have plenty of differences.
print() automatically puts a \n at the end, io.write does not
io.write() can be used to write to files, print() can not
print() automatically executes a tostring(), io.write() does not
io.write() is consistent with what io.write("some text", "some other text") looks like throughout different interpreters, sadly the same can't be said about print("some other text","some other text")
When writing my own code, sure, I'd be fine with System.out.println() or weird printf format strings, but in my above post, I wanted to use the simplest syntax possible so that all the noncoders reading this thread would be able to understand it.
As for why printf with its weird format strings is useful, it just prints stuff directly to the output, rather than toString'ing stuff, concatenating the strings, and then printing them. It's faster.
Also, printf is the only function in the C standard libraries that can print more than a single character. They don't really give you a lot of choice.
2736 ah, I was thinking about the php thing which doesn't print directly. That would indeed make it faster though I still prefer lua's approach of just being able to pass multiple things.
print("something ","like ","this ", "and" ,1,2,4,1)
or print(unpack({"test ",1,2,10,"lol"}))
both don't need any concatenating (which in lua is ".." btw)