Comparisment

   - compare programming languages by example

44

Program entry point

The entry point where execution of the program begins.

Created by sam

Add a new answer

Either add an answer for a new language or add an alternative solution.
A description is only necessary when the code is not suitably 'obvious' or to justify an alternative approach.

Haskell

main :: IO ()
main = putStrLn "Hello World!"

The entry point to a haskell program is a function with an 'IO' type named 'main'.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Python

def main():
  print("Hello World!")

In the module '__main__', the function 'main' is the entry point.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Python

def main():
  print("Hello World!")

if __name__ == '__main__': main()

All code at the top level is executed when a module is imported. It is common to test whether the current module is being imported or interpreted at the top level as a 'main' module and to automatically execute 'main' if so.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.