PDA

View Full Version : Interpreter (computing)



DirectuX
03-11-2018, 21:29
Hi,

note: this is not a question about the difference between interpreter and compiler.

according to wikipedia (https://en.wikipedia.org/wiki/Interpreter_(computing)),

An interpreter generally uses one of the following strategies for program execution:


parse the source code and perform its behavior directly;
translate source code into some efficient intermediate representation and immediately execute this;
explicitly execute stored precompiled code[1] made by a compiler which is part of the interpreter system.



in which category do thinBasic fall ?

from a general point of view, what prevent an interpreter to generate a compiled executable ?

ReneMiner
04-11-2018, 10:43
Yes, I also always asked myself how it works.

I came to the conclusion it must be some kind of magic that I will never ever understand and instead of wasting my time to think about how it works I will just accept that it works and use it.

:)

John Spikowski
06-11-2018, 10:59
My understanding is thinBasic executes text code statement by statement.

DirectuX
15-11-2018, 16:03
My understanding is thinBasic executes text code statement by statement.
I agree that's what's an interpreter. So if in the end some code is executed, there seems not much difference to put this code in cache memory for subsequent execution ?

ReneMiner, you're an philosopher :drink:

John Spikowski
16-11-2018, 10:40
I think the goal of a BASIC interpreter is to minimize the number of steps to its simplist form for any given task. If raw speed is what you're after, write an extension in a compiled language and call its functions.

DirectuX
17-11-2018, 09:54
If raw speed is what you're after
You didn't get it John. It's a general discussion: why developing an interpreter and stop there, not proposing a compiler along ?

John Spikowski
18-11-2018, 00:24
I think you missed my point. It has nothing to do with compilers. It's about calling efficient libraries from your interpreter to gain speed.

ReneMiner
18-11-2018, 11:21
...why developing an interpreter and stop there, not proposing a compiler along ?

To me it should be easy to replace, improve or just read the code.
If compiled it would be a problem to me to study other users scripts as well as to use them as a skeleton that I could extend with own ideas and functions.
If the interpreter itself runs at extraordinary speed and maintains a program with the advantages of a flexible, changeable code - why would I want to compile it?
Imagine there's a typo in the UI or small bug to fix, or even you want to try to your needs changed parameters - if compiled you need the sources to do it yourself and probably also the compiler and additional time.

Also your own scripts... you publish them, others read them and can see how you solved a problem. Next time another user writes a script and he will be faster because you did the thinking already and he learned from your solution - do not say copied!
Or even the other way around: another user reads your published script and brings you to the idea to try to solve the problem another way and you learn.

That's what I would call communication, exchange, growth.
Interpreted, readable languages seems to me, are able to progress much faster in efficiency because the ones who are really interested can easily share ideas and discuss problems.
The conditions for any language to be interesting enough, so people will try it out and use it, are that they are able to find working solutions for their own ideas by logic thinking, a good documentation and other users who can give advise or at least understand the problem = a living community.

Compiled... kind of encrypted, unreadable... Hmm, maybe to finalize a project like to create an executable...
If speed were the reason to compile a program then perhaps the programmer as first should check if he can improve his code to run faster without to compile it than to rely on the compiler.

DirectuX
18-11-2018, 12:09
why would I want to compile it?

to gain speed.

:cry:





Let me refocus the discussion...
I am not looking for obfuscation. I am not looking for a speed solution.
I hoped a kind discussion about software.




from a general point of view, what prevent an interpreter to generate a compiled executable ?


Or maybe I was not sufficiently eloquent about my thoughts, but can't think of an another way to ask this. Below, I try to reformulate the question:
From a general point of view, why languages that have an interpreter doesn't have a compiler as well, as, from my understanding so far, there is not a so big step from interpretation to compilation ?

John Spikowski
19-11-2018, 04:20
One thing I like about Script BASIC is it runs as a shared object. (DLL, SO, ...) When running in a threaded model having your interpreter always resident in memory helps. SB also precompiles its code in a continuous memory binary format before execution. The script never starts and a error returned if the program is unrunnable.