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.
-
2https://en.wikipedia.org/wiki/Entry_point so many languages to choose from. Perl, PHP, Ruby are interpreted. Also "beginning of a script" is also an entry point. – KamilCuk Feb 19 '22 at 11:06
-
Perl is compiled – stark Feb 19 '22 at 13:04
2 Answers
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.

- 3,346
- 6
- 22
A typical way a program is started in Linux is by a shell calling fork+execve. The new process is loaded and begins execution at the entry point specified by the format of the executable; for example ELF. In the case of an interpreted language, the executable is the interpreter specified on the first line after #! such as /usr/bin/python.

- 12,615
- 3
- 33
- 50