Click here to Skip to main content
15,887,175 members
Home / Discussions / Web Development
   

Web Development

 
QuestionJS Arrow functions this & setTimeout scope Pin
Member 1618344416-Jan-24 1:46
Member 1618344416-Jan-24 1:46 
AnswerRe: JS Arrow functions this & setTimeout scope Pin
Jeremy Falcon25-Jan-24 4:31
professionalJeremy Falcon25-Jan-24 4:31 
QuestionWordPress for Windows Pin
Richard Andrew x647-Jan-24 4:24
professionalRichard Andrew x647-Jan-24 4:24 
AnswerRe: WordPress for Windows Pin
jschell8-Jan-24 5:52
jschell8-Jan-24 5:52 
GeneralRe: WordPress for Windows Pin
Richard Andrew x648-Jan-24 13:49
professionalRichard Andrew x648-Jan-24 13:49 
Questionhow PHP works Pin
mike741126-Dec-23 10:24
mike741126-Dec-23 10:24 
AnswerRe: how PHP works Pin
Richard MacCutchan26-Dec-23 21:47
mveRichard MacCutchan26-Dec-23 21:47 
GeneralRe: how PHP works Pin
trønderen27-Dec-23 8:09
trønderen27-Dec-23 8:09 
There is not a clear, absolute distinction. Old style interpreters would interpret the statements of a loop from source code on every iteration of the loop, and similar with other constructs.

To speed up execution, interpreters began (at least 25 years ago, maybe earlier) when analyzing a statement, to leave the analysis in a memory cache. So for a loop, the analysis was done the first time through. Following iterations skipped the analysis step, and rather picked up the analysis from the cache.

As this became more common, the analysis results became more formalized into some variant of P-code, suitable for direct interpretation. When done as a separate step, for an entire program or program module (e.g. the classic Pascal compiler from ETH Zürich), it is always called a compiler. So when the php runtime system does the same thing for a loop, you might say that it is a compiler, compiling that loop.

Another change over time: The first interpreters to save analysis results for later use did it line by line, or statement by statement. More recent interpreters compile larger units, e.g. a complete method, in order to apply optimizations such as moving invariants out of loops, calculating common expressions once only etc.

If the generated code follows a well defined grammar, the runtime compiler may save it to a file or cache. Compare it to dotNet: The IL code(*) of an assembly is compiled to binary machine code by the "jitter" (Just In Time compiler) first time it is run. The jitter also saves the binary code in a (persistent) disk cache that is usually not seen by neither programmer nor user; it is in a file space managed by the jitter alone. Next time the same assembly is run, the jitter first looks in its cache: If an already compiled version is found there, it is loaded, and the JIT compiling is bypassed.

A similar (persistent) caching (of P-code) might be employed by an interpreter. It should not affect the source language - the same source may be interpreted on one machine, compiled to P-code on the fly on every execution on another machine, while a third machine may have an interpreter looking in its cache for an already compiled variant.

This may be applied to a lot of different languages: You could make an interpreter to P-code on the fly, for subsequent immediate interpretation by an interpreter. Usually, you think of Java as a compiled language, but if you integrate JVM with the compiler, they might appear externally just as 'interpreted' as, say, PHP.

(*) dotNet IL code and P-code are at comparable abstraction level. The difference is that P-code is designed to be directly interpreted by a virtual machine; it is complete and ready for running, like a binary machine code (although not the machine code of the real machine you are running). IL code has a lot more 'loose ends' that must be tied up; there are more final decisions to be taken, but then there is more freedom when generating final binary machine code for that specific real machine. You cannot move this binary code to another machine; it may have a CPU missing a few instruction set options (the jitter makes binary code to make use of anything that is available), or maybe a completely different binary instruction set. P-code (usually) can be moved to other machines of arbitrary architecture and instruction set.

Note that P-code (or bytecode) is not a single firmly defined format. There are different P-codes, Java bytecode is not identical to the classical Pascal P4-code (although it is said to be heavily inspired by P4).
Religious freedom is the freedom to say that two plus two make five.

GeneralRe: how PHP works Pin
Richard MacCutchan27-Dec-23 21:19
mveRichard MacCutchan27-Dec-23 21:19 
GeneralRe: how PHP works Pin
trønderen28-Dec-23 7:08
trønderen28-Dec-23 7:08 
GeneralRe: how PHP works Pin
Richard MacCutchan28-Dec-23 21:46
mveRichard MacCutchan28-Dec-23 21:46 
AnswerRe: how PHP works Pin
Member 102471327-Mar-24 23:56
Member 102471327-Mar-24 23:56 
Questionweb development project Pin
Kateyi19-Dec-23 21:01
Kateyi19-Dec-23 21:01 
AnswerRe: web development project Pin
Richard Deeming19-Dec-23 21:21
mveRichard Deeming19-Dec-23 21:21 
AnswerRe: web development project Pin
Bohdan Stupak4-Mar-24 23:22
professionalBohdan Stupak4-Mar-24 23:22 
AnswerRe: web development project Pin
Member 102471328-Mar-24 0:01
Member 102471328-Mar-24 0:01 
QuestionWeb Development Pin
Mohd Faiez16-Dec-23 3:22
Mohd Faiez16-Dec-23 3:22 
QuestionBreakpoint issue with Visual Studio Pin
Lloyd Dupont3-Dec-23 14:36
Lloyd Dupont3-Dec-23 14:36 
AnswerRe: Breakpoint issue with Visual Studio Pin
Lloyd Dupont3-Dec-23 20:37
Lloyd Dupont3-Dec-23 20:37 
GeneralRe: Breakpoint issue with Visual Studio Pin
jschell4-Dec-23 3:41
jschell4-Dec-23 3:41 
GeneralRe: Breakpoint issue with Visual Studio Pin
Lloyd Dupont6-Dec-23 12:42
Lloyd Dupont6-Dec-23 12:42 
GeneralWant to Build a Web-based Video Platform Pin
Trevor Judd3-Nov-23 5:13
Trevor Judd3-Nov-23 5:13 
GeneralRe: Want to Build a Web-based Video Platform Pin
Richard MacCutchan3-Nov-23 4:45
mveRichard MacCutchan3-Nov-23 4:45 
GeneralRe: Want to Build a Web-based Video Platform Pin
Trevor Judd3-Nov-23 4:52
Trevor Judd3-Nov-23 4:52 
GeneralRe: Want to Build a Web-based Video Platform Pin
Richard MacCutchan3-Nov-23 5:15
mveRichard MacCutchan3-Nov-23 5:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.