News for hackers. Stuff that matters.
Re:To write better code, read Virginia Woolf by gengkev on Saturday May 21, 2016 @07:58PM (#11746794)
Hmm. It seems that in languages such as C and Python, the bottom-to-top order is encouraged, because functions can't reference other functions that are defined below them. But because that ordering constraint doesn't apply for classes, I find myself going in the other direction for single-file Java programs where a containing class for methods is required.
Re:To write better code, read Virginia Woolf by shoo on Saturday May 21, 2016 @10:18PM (#11747126)
> It seems that in languages such as C and Python, the bottom-to-top order is encouraged, because functions can't reference other functions that are defined below them.

This is not true for Python.

This is also not true for C if you forward declare the functions!

Re:To write better code, read Virginia Woolf by gengkev on Saturday May 21, 2016 @10:43PM (#11747178)
In Python, I believe function declarations work dynamically, just as variable declarations do. When I'm writing Python scripts, I usually have some code at the global level that calls functions, which must then be above that code. (This is in contrast to a compiled language like C, or JavaScript, which hoists function and var declarations.)

This can be worked around by stuffing everything into a main method and putting if __name__ == '__main__': main() at the bottom of the file (which I usually do anyway). But the mere requirement that you must remember to do so, just as you must remember to forward-declare functions in C, is still an incentive to work from the bottom of the file upwards.

Re:To write better code, read Virginia Woolf by mercurial on Sunday May 22, 2016 @03:24AM (#11747655)
Unfortunately, it's quite true for Ocaml, which is mildly annoying.
Re:To write better code, read Virginia Woolf by jacquesm on Sunday May 22, 2016 @07:26AM (#11748165)
It's a vestige from the time where compilers were working from disk and laying out your program 'declarations first' would speed up the compilation process considerably.