Hacker News new | ask | show | jobs
by benj111 2620 days ago
Can someone give me some pointers to reading material on this.

I'm aware of hot code reloading for interpreted languages, google just gives links to web page loading. I'm also aware of it at the OS level. I don't really understand why you'd want this in a compiled language.

4 comments

> why you'd want this in a compiled language.

Shared-library-based plugins, kernel modules, ...

> I don't really understand why you'd want this in a compiled language.

Why not?

If you understand why people have it in interpreted languages, why do those reasons not apply to compiled languages?
Because for an interpreted language you can use it for interactive development. I had thought different reasons would apply to a compiled language but judging by the other replies obviously not!
One can use compilers for interactive development, too. That's not a feature of being 'interpreted'.
Interpreters tend to have repls, which tends to influence how development happens. I'm not stating an absolute law though.

I think you may be misinterpreting my original question. It was asked out of ignorance, it wasn't a challenge. I was hypothesising some kind of self modifying code, or realtime adaptive optimising or something. I was attempting to show you my current level of knowledge so you could ELI7 instead of 5 :)

It's mostly just that the feature is always useful (that's why it's present so often in interpreted langauges), but muuuuuch harder to do for non-interpreted languages. Notably, a subsequent goal for the Nim feature is indeed to add a full-blown REPL to Nim too, I believe. Also, worth to note that some non-interpreted languages do also have REPLs, e.g.: Haskell, OCaml, C++ (! — see CLING).
I'm aware of plenty of exceptions myself.

Forth, and I've even come across an ASM REPL.

Theres exceptions the other way, Awk is interpreted but doesn't as far as I'm aware have a REPL, Sed doesn't either. But then both of those have varying implementations, so there could be exceptions to the exceptions.

The very term REPL comes from a language that's been used compiled to native code since 1960s (Lisp)

In fact, "compiled" programs on many platforms require an interpreter to set them up by dynamic code loading (including modifications if needed).

In ELF header, it's called "program interpreter", which gives a path to a program that understands this particular file and can assembly a running image in memory

> Can someone give me some pointers to reading material on this.

Wish I could help you with this, but I have been out of the loop with Nim recently.

> I don't really understand why you'd want this in a compiled language.

Quick iteration in development. Not needing to manually recompile every time you make a small change.

or recompute the data you're working with.