←back to thread

414 points henry_flower | 1 comments | | HN request time: 0s | source
Show context
digitalsushi ◴[] No.43108644[source]
Spock levels of fascinating from me. I want to learn how to compile a pdp11 emulator on my mac.
replies(4): >>43108726 #>>43108732 #>>43108743 #>>43109755 #
snovymgodym ◴[] No.43108726[source]
https://opensimh.org/

Works great on Apple Silicon

replies(1): >>43108833 #
haunter ◴[] No.43108833[source]
What’s the difference between an emulator and a simulator in this context?
replies(3): >>43108965 #>>43108980 #>>43119814 #
o11c ◴[] No.43108980[source]
In theory, an emulator is oriented around producing a result (this may mean making acceptable compromises), whereas a simulator is oriented around inspection of state (this usually means being exact).

In practice the terms are often conflated.

replies(2): >>43110169 #>>43111430 #
codr7 ◴[] No.43110169[source]
The difference is about as crystal clear as compiler/interpreter.
replies(1): >>43116620 #
Imustaskforhelp ◴[] No.43116620[source]
compiler creates a binary in elf format or other format which can be run given a shared object exists.

Intepreter either writes it in bytecode and then executes the bytecode line by line ?

Atleast that is what I believe the difference is , care to elaborate , is there some hidden joke of compiler vs intepreter that I don't know about ?

replies(3): >>43117570 #>>43119591 #>>43119624 #
dpassens ◴[] No.43117570[source]
I assume GP meant that a lot of compilers also interpret and interpreters also compile.

For compilers, constant folding is a pretty obvious optimization. Instead of compiling constant expressions, like 1+2, to code that evaluates those expressions, the compiler can already evaluate it itself and just produce the final result, in this case 3.

Then, some language features require compilers to perform some interpretation, either explicitly like C++'s constexpr, or implicitly, like type checking.

Likewise, interpreters can do some compilation. You already mentioned bytecode. Producing the bytecode is a form of compilation. Incidentally, you can skip the bytecode and interpret a program by, for example, walking its abstract syntax tree.

Also, compilers don't necessarily create binaries that are immediately runnable. Java's compiler, for example, produces JVM bytecode, which requires a JVM to be run. And TypeScript's compiler outputs JavaScript.

replies(3): >>43117637 #>>43118771 #>>43119639 #
1. amszmidt ◴[] No.43119639{3}[source]
While an interpreter can do optimizations, they do not produce "byte code" -- by that time they are compilers!

As for the comparison with the JVM .. compare to a compiler that produces x86 code, it cannot be run without an x86 machine. You need a machine to run something, be it virtual or not.