ccompilationinterpreterentry-pointinterpretation

Can a Interpreted language have a entry point


I want to know, do only compiler based languages use a entry point, or if a interpreter based language can also use entry points, if yes then please give 1 example.


Solution

  • I shell scripts starts at the beginning of the script file. A python program starts at the beginning of the python file. In both cases you can call that the "entry" point.

    The decision, if a program starts at the beginning of the file (like in both the examples above) or starts at a specific function (like main) has nothing to do with the decision to make a language compiled or interpreted. It is a mere language design consideration.

    Addition
    It is actually a quite common for example in python to do something like

    # include statements and
    # class definitions and
    # function definitions go here
    
    def main():
        pass    
        #do main stuff here
    
    if __name__ == "__main__":
        main()
    

    This defines a main function and the first non-definition statement calls it, if the module is the main program file.