How bad for TeX is omitting braces {}, even if the result is the same?

The LaTeX book consistently uses {} in all cases so all the examples use that form, you always see a^{2} even though everyone knows that a^2 works just as well and arguably improves the look of the source.

When the command taking the argument is a macro and the argument is necessarily a single token, most people drop the brackets as a matter of course so

\newcommand\foo{abc}
\setlength\textwidth{10cm}

rather than

 \newcommand{\foo}{abc}
 \setlength{\textwidth}{10cm}

and that is effectively standard LaTeX syntax now as well.

However the equivalence between a single unbraced token and a brace group is most consistently implemented for macros. For TeX primitives sometimes they are equivalent and sometimes not. So you can go

\fbox{a}    \fbox a

and they do the same thing (although I would never do the latter) but

\hbox{a}

boxes a but

\hbox a

produces

! Missing { inserted.
<to be read again> 
                   a

More problematic are places where people omit brackets, relying on the parsing rules of a TeX primitive, which then breaks when you later load a package that redefines the command to give extra functionality.

A common example is sub or super scripting. You can go

$a^\frac12b$

which produces a to the half times b, but often it would be nice to redefine the ^ character to be an active character (or \mathcode"8000 character) with definition defined by \def or \newcommand If you do that, any properly braced usage still works but an example such as the above would then be equivalent to

$a^{\frac}12b$

The frac would then raise an error that it was missing its arguments.

A usage such as

 $a^{\frac{1}{2}}b$

would work whether the arguments of ^ where parsed as a TeX primitive superscript or as a macro.

Thus users ignoring the rules in the LaTeX book and not always bracing arguments can cause problems and limit the scope of package designers. (The standard LaTeX2e \frac and \mathrm and friends were explicitly designed to cope with that unbraced superscript use, on the grounds that keeping users happy was probably better than assuming they followed instructions.)


There are a few places in TeX where braces are a required part of the syntax but those are few. When it comes down to arguments then TeX accepts a single token without surounding braces so \mathrm i would work if "typeset". But try this:

\newcommand\x{log}

\tableofcontents

\section{$\mathrm \x$}

and you will get a subtle error in your output (but no error message):

enter image description here

The reason is that \x is suddenly turned during processing into its components so what LaTeX sees when typesetting the TOC is $\mathrm log$ and thus only picks up "l" as the argument.

For this reason, the LaTeX manual claims that all arguments have to have braces even if this is technically not true.

Personally, I do not use braces in all such cases, but whenever the single token is a command one better think twice before omitting the braces because even if it appears to work it may not do so.


(Disclaimer: The question clearly says "even when the result is the same", which I answer by saying that when the result is the same, the result is the same. However, there are (numerous) examples when the result is not the same, see e.g. Frank Mittelbach's answer!)


There is only one valid answer in my opinion: From the TeX's point of view, if there is no difference, there is no difference (what a nice tautology). So from the TeX's point of view, it is not "bad".

As people say in the comments, the second point is about the legibility of your code to humans, and this really depends on what human we're speaking about. You have people who are very strict on using braces, and you have people like me who got used to omitting them and got used to reading codes like \bar\theta, \frac12, \frac1n etc.


Mimicking David Carlisle's answer in What does \z@ do? and echoing egreg's comment, the following MWE

\documentclass{article}
\def\a{\setbox0=\hbox{$\frac12\ \bar\theta$}\relax}% No braces
%\def\a{\setbox0=\hbox{$\frac{1}{2}\ \bar{\theta}$}\relax}% Braces
\def\b{\a\a\a\a\a\a\a\a\a\a}%         10
\def\c{\b\b\b\b\b\b\b\b\b\b}%        100
\def\d{\c\c\c\c\c\c\c\c\c\c}%      1,000
\def\e{\d\d\d\d\d\d\d\d\d\d}%     10,000
\def\f{\e\e\e\e\e\e\e\e\e\e}%    100,000
\def\g{\f\f\f\f\f\f\f\f\f\f}%  1,000,000
\def\h{\g\g\g\g\g\g\g\g\g\g}% 10,000,000
\begin{document}
abc \h
\end{document}

compiles without braces in 1m11s and with braces in 1m13s. A minor (perhaps negligible) difference in time. This was on a linux machine with AMD Turion 0.55GHz.


UPDATE: Another test, with 100M instances of \frac12 vs \frac{1}{2} on a newer machine (Intel i5, 3.10GHz, linux) shows typical times 3m42s vs. 3m52s, that's a negligible difference of 100ns per \frac.