I've been finding myself doing more and more Java coding as of late (including rewriting several C/C++ CFX tags in Java). For the most part I have gotten used to the language (although I've found myself wanting to use C style preprocessor directives like #ifdef on more than one occasion). But the one thing I cannot get used to is not having an equivalent of the printf() functions (printf() sprintf() etc.). Fortunately I have found several third party printf() packages, but honestly, I consider the omission of printf() functionality in the core API a major oversight.
I Miss printf()
·
7 Comments
M
mark
Valid points.
I've been happy without printf (sprintf and the like) but that's just been me.
I come from more of a Java BG than C/C++, so it all just depends on what you are used to :o).
I always found printf and the like kinda irritating. Just my perspective I suppose.
B
Ben Forta
Mark, no, printf() is not about concatenation. printf() (and related functions) provide the ultimate string creation and parsing capabilities. Using sprintf(), for example, you can create a string that contains other strings, numbers, dates, and all sorts of formatting, all in a clean format. Yesterday I needed to construct a string that contained several other strings, a date, an error code, and more. I had to write several lines of code using concatenation and valueof() methods, that's just plain ugly. I could have done it in one line of code with sprintf().
J
Jonas Galvez
Yeah... That's one of the things I always wanted to see in Java. I've been playing with Python lately and I found it wonderfull to see that kind of functionality as a native feature of the language.
M
Mark
Why?
I can't see any reason why you would need to have a printf functionality in java. Considering things like concatenation can be done by operators, what does it matter?
(Not to say that there IS no reason, I just can't think of one)
S
seancorfield
Java 1.5 brings true "varargs" syntax so you will soon be able to have a C-like printf() suite of functions.
H
Herman
Perhaps you should take advantage of the OOness of Java and get in the practive of using and overloading the ever-present toString() method.
M
mike
i dont miss printf, i use it every day along with a few other va_arg'd routines ive writen myself.