According to the book Code Complete, the bracket should be put on the first line (which is referred to as the control statement) because it's misleading to put in on the second line since it doesn't show the logical structure of the code. If viewed from a graphical perspective, the second approach looks like this:
Where lines A-E represent the following, which is simliar to the second approach declared in this question.
A function foo ()
B {
C print "Hello";
D print "World";
E }
Which you can see is misleading because you can't tell if line B is subordinate to line A or if line B is its own separate statement
EDIT: In case the image is too abstract, here's a quick explanation of why the curly bracket is often included on the first line along with the control statement
Functions have two main elements:
- the control construct
- the function's statements
By putting the curly bracket on the second line (line B in the image) it is neither in the control statement nor is it part of the function's statements.
EDIT 2
IMO, each line of code should have a purpose to save vertical space to view more lines at once on my screen and to preserve the logical meaning of the code. Therefore, when the brace is on the same line as the function declaration then it is thereby associated with the statement that it opens. However, when it is on a line on its own (line B in my example) AND it is not indented to show subordinance to the function declaration, then it breaks the logical meaning of the code because it is neither a associated with a control construct nor is it a function statement. So, by putting the brace on the same line as the function declaration, then every line of code serves a purpose, it holds the logical meaning of the code, and it saves my screen space.
function foo() { // brace is on the same line and it's associated with the statement that it opens
print "Hello"; // this line does something
print "World"; // this line does something
} // this last brace terminates the function which is part of the control construct