1

I'm just learning about bash and when I saw that bash uses 'echo' I tried to search for the relationship between PHP and bash and it seems like people are building programs were bash script and PHP scripts are mixed together.

Do scripting languages like Javascript and PHP use shell scripts to work? Do PHP and Javascript interpreters in any way dependent on shell scripts?

Is this any different when it comes to compiled code? (I know that the separation of scripting languages and compiled languages are not that clear cut since you can compile Javascript and interpret some of the languages which are normally compiled. So in this part of the question I'm asking whether there is any difference when it comes to compiled code, regardless of language.)

2 Answers 2

2

There is no relation at all between "echo" in bash and "echo" in PHP. They just happen to share the same keyword for the same action, they do not depend on each other. Often times the design of some languages influences another languages, and those that design new languages features often took inluence from existing languages. These are why many languages uses $prefix for variables, why some keywords are commonly seen across languages, and why many languages uses curly braces for block separation. While they may copy the syntax or the general design of the feature, they are usually independently implemented.

Do scripting languages like Javascript and PHP use shell scripts to work? Do PHP and Javascript interpreters in any way dependent on shell scripts?

No they don't use shell scripts to work. Both the shell and these languages depends on the operating system's stream writing interface. Say in Linux, if you want to print to stdout, you need to do a write() system call to the kernel by causing a software interrupt with the syscall id for the write() syscall, the pointer to the data that you want to write, and the file number for stdout which is 1. Whether you use the shell, an interpreted language, or a compiled language, they all will have to, call the write() syscall to write to the stdout. Some languages may only allow you to write regular string, others might provide basic formatting features, but all of these will end up with a write() syscall.

2

They don't. The codebase behind the runtime environments and libraries may use shell scripts as glue, but runtimes of languages like JavaScript and PHP don't depend on them. The use of commands like echo and printf are indicators of the languages the creators were influenced by, such as C and shell. This also holds true for compiled languages.

Step back for a moment and wonder if the presence of constructs like if and for and while mean that the execution of shell scripts depend on C or vice versa.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .