←back to thread

414 points henry_flower | 1 comments | | HN request time: 0.001s | 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 #
Imustaskforhelp ◴[] No.43118771{3}[source]
Then what is the difference, I always thought of Java as closer to python in the sense that it's running the byte code. And python also has bytecode.

I don't know what the difference is , I know there can be intepreters of compilers but generally speaking it's hard to find compilers of intepreters

Eg C++ has compilers , intepreters both (cpi) , gcc

Js doesn't have compilers IIRC , it can have transpilers Js2c is good one but i am not sure if they are failsafe (70% ready) ,

I also have to thank you , this is a great comment

replies(2): >>43119705 #>>43119734 #
1. amszmidt ◴[] No.43119705{4}[source]
The easy definition is that an interpreter takes somethings and runs/executes it.

A compiler takes the same thing, but produces an intermediate form (byte code, machine code, another languages sometimes called "transpilar"). That you can then pass through an interpreter of sorts.

There is no difference between Java and JVM, and Python and the Python Virtual Machine, or even a C compiler targeting x86 and a x86 CPU. One might call some byte code, and the other machine code .. they do the same thing.