Messages vs. Constants?

383 views
Skip to first unread message

socratesJ

unread,
Dec 9, 2011, 6:42:01 PM12/9/11
to google-we...@googlegroups.com
Since the Messages interface offers a superset of the functionality available with the Constants interface, why would one ever prefer to use Constants? Does Constants offer any benefit over Messages when parameter substitution isn't needed?

Thomas Broyer

unread,
Dec 9, 2011, 8:20:36 PM12/9/11
to google-we...@googlegroups.com
Messages is only about strings, while Constants can contain numbers, booleans, arrays of strings, etc.

socratesJ

unread,
Dec 9, 2011, 9:38:49 PM12/9/11
to google-we...@googlegroups.com
Ah, right. But for non-parameterized strings, is there any reason to use Constants? Any compiler optimization that you don't get with Messages?

Thomas Broyer

unread,
Dec 9, 2011, 9:48:18 PM12/9/11
to google-we...@googlegroups.com
No; in this case, Messages or Constants will produce the exact same code: the constant string is inlined, and then possibly "interned" (i.e. moved to a global constant) by the compiler; and the Constants or Messages generated class is completely compiled out.
Reply all
Reply to author
Forward
0 new messages