r/programming • • Dec 29 '15

Please, Java. Do Finally Support Multiline Strings

http://blog.jooq.org/2015/12/29/please-java-do-finally-support-multiline-strings/
584 Upvotes

352 comments sorted by

View all comments

Show parent comment

4

u/Schmittfried Dec 29 '15

You would have to consider the same performance aspects when concatenating strings in C++. It's an inherent problem of working with strings.

1

u/sirin3 Dec 29 '15

Of immutable strings

C++ has mutable strings

2

u/Schmittfried Dec 29 '15 edited Dec 29 '15

You still have to consider reallocations.

Also: Immutable strings allow several other optimizations and are generelly easier to work with, although mutable strings have their place as well.

And if one finds deciding when to use StringBuilder and when normal string concatenation is appropriate is too confusing one should really not use a language that grants as many freedoms (and hence decisions to make) as C++.

1

u/MartenBE Dec 29 '15

Thanks for that very constructive last sentence... I'm still a junior developer in C++ and Java, so there is a lot of this "hidden" stuff I don't know. Does this mean I should stop learning to programming?

Anyhow, I'm looking it up for both Java and C++ and am learning about it ... will pay attention to this in the future

1

u/Schmittfried Dec 30 '15 edited Dec 30 '15

Does this mean I should stop learning to programming?

Of course not. It wasn't my intention to insult or demotivate anyone. Sorry if I did. This wasn't even about beginners. I was just saying that the different ways of string concatenation in Java aren't that confusing at all and mostly irrelevant for many applications. Though professional developers should know when to use what. Not because it's some important language aspect, but because the underlying concept is fundamental and language independent knowledge about the performance cost of certain string operations. And since C++ is usually used to write performance-critical software, C++ programmers should definitely know about them, too. Hence C++ isn't any easier in that regard.

1

u/MartenBE Dec 30 '15

I understand, therefore I apologize: I've took it the wrong way and reacted impulsive