In C and C++ (and probably other languages), you need to have at least a declaration of functions and fields before you can use them:
#include <iostream> int main(int argc, char **argv) { printout(); return 0; } void printout() { std::cout << "TEST" << std::endl; } % g++ main.cpp main.cpp: In function ‘int main(int, char**)’: main.cpp:4:3: error: ‘printout’ was not declared in this scope; did you mean ‘printf’? 4 | printout(); | ^~~~~~~~ | printf Other languages like Java allow you to use methods before declaring them:
public class main { public static void main(String[] args) { printout(); } private static void printout() { System.out.println("TEST"); } } % javac main.java % java -cp . main TEST What are the advantages at either compile-time or run-time of requiring functions to be declared before they are executed?