Csound Csound-dev Csound-tekno Search About

[Csnd] Compilers and interpreter

Date2012-11-23 20:38
FromCacophony7
Subject[Csnd] Compilers and interpreter
Assuming that Csound is a compiler, I was wondering if it included an
interpreter.
Java, for instance, requires both a compiler and an interpreter.

I'm just curious about how Csound works.



--
View this message in context: http://csound.1045644.n5.nabble.com/Compilers-and-interpreter-tp5718284.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2012-11-23 21:46
FromSteven Yi
SubjectRe: [Csnd] Compilers and interpreter
Csound is really an interpeter more than a compiler.  Compilers are
usually defined to be something that parses code and generates
something that is later executed, while interpreters parse then
immediately executed.

Java is actually more of a compiler than an interpreter, as it
generates bytecode that is then executed by the Java Virtual Machine.

On Fri, Nov 23, 2012 at 8:38 PM, Cacophony7  wrote:
> Assuming that Csound is a compiler, I was wondering if it included an
> interpreter.
> Java, for instance, requires both a compiler and an interpreter.
>
> I'm just curious about how Csound works.
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Compilers-and-interpreter-tp5718284.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>

Date2012-11-23 23:30
FromMichael Gogins
SubjectRe: [Csnd] Compilers and interpreter
The distinction between compiler and interpreter is too simple. Csound
is a runtime compiler and a dynamic language.

An interpreter just has a bunch of logic switches that look at tokens
in the source code and executes the appropriate machine language code.
Consequently, changes that you make in the source code are instantly
executable.

A static compiler (like C) parses the source code into an abstract
syntax tree, then generates machine language code from the AST, then
saves the machine language code in files, then uses a linker to
assemble the various machine language files into a pure machine
language executable file (a program).

Other kinds of static compilers generate "bytecoce" for a virtual
machine, not for the actual physical machine. Java is a static
compiler for a virtual machine of this kind.

A runtime compiler or dynamic compiler (like Csound) parses the source
code into an abstract syntax tree, and then parses that into some sort
of "bytecode" which contains precompiled chunks of machine language
code, which then executes on a virtual machine. This is sort of
intermediate between a static compiler and an interpreter. It is
called "dynamic" because changes you make in the source code appear to
be instantly executable, even though in fact the compiler does parse
code into an AST and then prepare it for execution on a virtual
machine. It just happens so fast you don't really notice.

Most new languages are dynamic languages: Python, Lua, Scheme,
Javascript (which is not another kind of Java but a separate
language), Csound, SuperCollider, Perl, all are dynamic languages.

The languages that most critical software (the stuff that runs your
jet planes, your automobile engines, your air defense radars and such)
and most shrink-wrapped applications (such as word processors or Web
browsers) are statically compiled, usually C++ or C, or older stuff or
scientific stuff might be in Fortran (also statically compiled). That
is because such programs almost always run faster. Some business
software and many Web applications are written in Java or .NET
languages (which also are bytecode compilers).

This gets even more complicated because many dynamic languages and
bytecode compilers have just-in-time compilers, which act like a
static compiler and save compiled code in a memory cache or even on
disk. The code generated in this way runs as fast as C or C++ code.
Lua and Java have excellent just-in-time compilers. Again, the
just-in-time compilation happens without you really noticing, in the
background as your program runs.

Regards,
Mike


On Fri, Nov 23, 2012 at 3:38 PM, Cacophony7  wrote:
> Assuming that Csound is a compiler, I was wondering if it included an
> interpreter.
> Java, for instance, requires both a compiler and an interpreter.
>
> I'm just curious about how Csound works.
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Compilers-and-interpreter-tp5718284.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>



-- 
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com

Date2012-11-24 16:25
FromSteven Yi
SubjectRe: [Csnd] Compilers and interpreter
Thanks Victor and Michael,

I think my simple answer was a bit too simple. :) As Victor pointed
out, Csound does compile down in memory first into an efficient data
structure, then is run separately.  It does not generate a machine
code executable in a way, say, gcc or clang does, that is later
executed by a user, but it could, and there is a compilation step.

I think I confused the tools of compiling and interpreting with what
generally discussed as compiled or interpreted languages.  Thinking
about the topic, it's quite interesting as languages too aren't one or
the other; Haskell for example can be interpreted with ghci or
compiled with ghc.

Also, Java does have both a compiler and interpreter, with the first
phase being javac compiling to bytecode, the bytecode then being
interpreted by the JVM.

I think my previous thinking was in regards to steps from source to
execution, if there is an intermediary step or not (byte code, machine
code).

Thanks to the OP for the question and again to Victor and MIchael for
the clarifications!

steven



On Fri, Nov 23, 2012 at 11:30 PM, Michael Gogins
 wrote:
> The distinction between compiler and interpreter is too simple. Csound
> is a runtime compiler and a dynamic language.
>
> An interpreter just has a bunch of logic switches that look at tokens
> in the source code and executes the appropriate machine language code.
> Consequently, changes that you make in the source code are instantly
> executable.
>
> A static compiler (like C) parses the source code into an abstract
> syntax tree, then generates machine language code from the AST, then
> saves the machine language code in files, then uses a linker to
> assemble the various machine language files into a pure machine
> language executable file (a program).
>
> Other kinds of static compilers generate "bytecoce" for a virtual
> machine, not for the actual physical machine. Java is a static
> compiler for a virtual machine of this kind.
>
> A runtime compiler or dynamic compiler (like Csound) parses the source
> code into an abstract syntax tree, and then parses that into some sort
> of "bytecode" which contains precompiled chunks of machine language
> code, which then executes on a virtual machine. This is sort of
> intermediate between a static compiler and an interpreter. It is
> called "dynamic" because changes you make in the source code appear to
> be instantly executable, even though in fact the compiler does parse
> code into an AST and then prepare it for execution on a virtual
> machine. It just happens so fast you don't really notice.
>
> Most new languages are dynamic languages: Python, Lua, Scheme,
> Javascript (which is not another kind of Java but a separate
> language), Csound, SuperCollider, Perl, all are dynamic languages.
>
> The languages that most critical software (the stuff that runs your
> jet planes, your automobile engines, your air defense radars and such)
> and most shrink-wrapped applications (such as word processors or Web
> browsers) are statically compiled, usually C++ or C, or older stuff or
> scientific stuff might be in Fortran (also statically compiled). That
> is because such programs almost always run faster. Some business
> software and many Web applications are written in Java or .NET
> languages (which also are bytecode compilers).
>
> This gets even more complicated because many dynamic languages and
> bytecode compilers have just-in-time compilers, which act like a
> static compiler and save compiled code in a memory cache or even on
> disk. The code generated in this way runs as fast as C or C++ code.
> Lua and Java have excellent just-in-time compilers. Again, the
> just-in-time compilation happens without you really noticing, in the
> background as your program runs.
>
> Regards,
> Mike
>
>
> On Fri, Nov 23, 2012 at 3:38 PM, Cacophony7  wrote:
>> Assuming that Csound is a compiler, I was wondering if it included an
>> interpreter.
>> Java, for instance, requires both a compiler and an interpreter.
>>
>> I'm just curious about how Csound works.
>>
>>
>>
>> --
>> View this message in context: http://csound.1045644.n5.nabble.com/Compilers-and-interpreter-tp5718284.html
>> Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>
>
>
>
> --
> Michael Gogins
> Irreducible Productions
> http://www.michael-gogins.com
> Michael dot Gogins at gmail dot com
>
>
> Send bugs reports to the Sourceforge bug tracker
>             https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>

Date2012-11-24 23:14
FromRobert or Gretchen Foose
SubjectRe: Re: [Csnd] Compilers and interpreter
Mike, thanks very much for this explanation.  It has clarified 
for me some things about which I'd wondered for a while.
Bob Foose

On 13:59, Michael Gogins wrote:
> The distinction between compiler and interpreter is too simple. Csound
> is a runtime compiler and a dynamic language.
>
> An interpreter just has a bunch of logic switches that look at tokens
> in the source code and executes the appropriate machine language code.
> Consequently, changes that you make in the source code are instantly
> executable.
>
> A static compiler (like C) parses the source code into an abstract
> syntax tree, then generates machine language code from the AST, then
> saves the machine language code in files, then uses a linker to
> assemble the various machine language files into a pure machine
> language executable file (a program).
>
> Other kinds of static compilers generate "bytecoce" for a virtual
> machine, not for the actual physical machine. Java is a static
> compiler for a virtual machine of this kind.
>
> A runtime compiler or dynamic compiler (like Csound) parses the source
> code into an abstract syntax tree, and then parses that into some sort
> of "bytecode" which contains precompiled chunks of machine language
> code, which then executes on a virtual machine. This is sort of
> intermediate between a static compiler and an interpreter. It is
> called "dynamic" because changes you make in the source code appear to
> be instantly executable, even though in fact the compiler does parse
> code into an AST and then prepare it for execution on a virtual
> machine. It just happens so fast you don't really notice.
>
> Most new languages are dynamic languages: Python, Lua, Scheme,
> Javascript (which is not another kind of Java but a separate
> language), Csound, SuperCollider, Perl, all are dynamic languages.
>
> The languages that most critical software (the stuff that runs your
> jet planes, your automobile engines, your air defense radars and such)
> and most shrink-wrapped applications (such as word processors or Web
> browsers) are statically compiled, usually C++ or C, or older stuff or
> scientific stuff might be in Fortran (also statically compiled). That
> is because such programs almost always run faster. Some business
> software and many Web applications are written in Java or .NET
> languages (which also are bytecode compilers).
>
> This gets even more complicated because many dynamic languages and
> bytecode compilers have just-in-time compilers, which act like a
> static compiler and save compiled code in a memory cache or even on
> disk. The code generated in this way runs as fast as C or C++ code.
> Lua and Java have excellent just-in-time compilers. Again, the
> just-in-time compilation happens without you really noticing, in the
> background as your program runs.
>
> Regards,
> Mike
>
>
> On Fri, Nov 23, 2012 at 3:38 PM, Cacophony7  wrote:
>> Assuming that Csound is a compiler, I was wondering if it included an
>> interpreter.
>> Java, for instance, requires both a compiler and an interpreter.
>>
>> I'm just curious about how Csound works.
>>
>>
>>
>> --
>> View this message in context: http://csound.1045644.n5.nabble.com/Compilers-and-interpreter-tp5718284.html
>> Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>              https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>>
>
>
>