Michael,

I agree that this is probably more useful in the long-term. Thank you for
adding the detail.

Cheers,
Chris


On Tue, Sep 4, 2018, 21:08 Michael Jones <michael.jo...@gmail.com> wrote:

> I might tell students step by step:
>
> machine code is understood and executed by a machine.
> -> the intel instruction to increment a register is decoded and executed
> by the CPU's hardware.
>
> virtual code is understood and executed by a program that pretends to be
> some virtual CPU.
> -> a Java VM might run on an intel CPU and understand and execute Java
> virtual machine instructions.
>
> -> a Java VM might run on an intel VM that actually runs on an ARM CPU...
> -> ...like a Russian matryoshka doll, there can be any number of outer VMs
> before the innermost real CPU.
>
> operating systems provide protection, resource allocation, and services.
>
> most languages offer programs at least some operating system like services
> via a runtime service layer
> -> in C, this was initially "crt0" the thin c runtime
> -> in Go, the service layer is richer, offering thread management and
> goroutine multiplexing, garbage collection, and more.
>
> the Go runtime is written in Go mostly and uses C or assembler to connect
> to the host operating system.
> the Go runtime is linked with the developer's Go code, and the two of them
> are constitute the output of go build or go install
>
>
>
> On Tue, Sep 4, 2018 at 5:15 PM Christopher Nielsen <m4dh4t...@gmail.com>
> wrote:
>
>> Hi Pablo,
>>
>> Yes, that sounds like a reasonable differentiation for students. Of
>> course, it is more complex than that, but it's a good first principles
>> introduction.
>>
>> Cheers,
>> Chris
>>
>>
>> On Tue, Sep 4, 2018, 16:57 Pablo Rozas Larraondo <
>> p.rozas.larrao...@gmail.com> wrote:
>>
>>> Thanks for the answers. I asked this question because I'm preparing some
>>> tutorials to explain Go to students and I'm thinking about potential
>>> questions and discussions.
>>>
>>> If I understand it correctly we could say then that Go's runtime has
>>> things in common with a VM's runtime (I'm thinking mostly in Java's) such
>>> as GC, goroutine (thread) scheduling, etc. However, Go's runtime cannot be
>>> considered a VM because it does not compile code to an intermediate
>>> language, it executes compiled native code instead.
>>>
>>> Cheers,
>>> Pablo
>>>
>>>
>>>
>>> On Wednesday, September 5, 2018 at 3:01:52 AM UTC+10, Jake Montgomery
>>> wrote:
>>>>
>>>> There are a lot of differences, and for the answer to be complete, you
>>>> would need to specify which language you wanted to compare it to. But on a
>>>> really simple level, thwd's answer is more or less correct. A VM language
>>>> is usually compiled into an instruction set for that VM. The VM then
>>>> provides a lot of "special sauce." Go is (usually) compiled directly into
>>>> machine code to be executed directly on the target system.
>>>>
>>>> One consequence of this is that the executable can be run without
>>>> having any other software installed on the machine. It also  means that the
>>>> code for the stuff you inquired about such as the garbage collector,
>>>> goroutine scheduling and stack management, is all present in the single
>>>> executable compiled by go.
>>>>
>>>> As for learning more, it depends somewhat on what your experience level
>>>> is, and why you want to know. If you are relatively new to programming, I
>>>> would recommend just using go for a while, without worrying too much about
>>>> the "magic."  If you have a strong background already, you could start
>>>> learning about the stuff you mentioned. Garbage collection would be an
>>>> interesting place to start. I don't know of any one resource, but there are
>>>> a number of interesting videos (gophercon, ect) by principal architects on
>>>> the subject. Keep in mind that all these things are constantly evolving, so
>>>> any information you get may not apply to the latest version of the
>>>> language.
>>>>
>>>> Good luck.
>>>>
>>>>
>>>>
>>>> On Tuesday, September 4, 2018 at 10:50:03 AM UTC-4, thwd wrote:
>>>>>
>>>>> A virtual machine has its own instruction set. Go compiles to machine
>>>>> code for a given target (which could be a virtual machine).
>>>>>
>>>>> On Tuesday, September 4, 2018 at 12:27:49 PM UTC+2, Pablo Rozas
>>>>> Larraondo wrote:
>>>>>>
>>>>>> The Go documentation provides some explanation about the difference
>>>>>> between Go’s runtime and a virtual machine here:
>>>>>>
>>>>>> https://golang.org/doc/faq#runtime
>>>>>>
>>>>>> Does anyone can recommend a good place to learn more about this? I’d
>>>>>> like to better understand how Go’s garbage collector, goroutine 
>>>>>> scheduling
>>>>>> and stack management are handled by the runtime and how it is different
>>>>>> from a virtual machine.
>>>>>>
>>>>>> Thanks,
>>>>>> Pablo
>>>>>>
>>>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to golang-nuts+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> *Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>*
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to