#Dynamic imports in go

10 messages · Page 1 of 1 (latest)

earnest spindle
#

Compiled programming languages are typically much faster than interpreted programming language. Indeed, the compilation step produces “machine code” that is ideally suited for the processor. However, most programming languages today do not allow you to change the code you compiled. It means that if you find out which function you need after the ...

random veldt
#

Probably no.
Why would you wanna do that?

#

Very bad idea, even in non-compiled languages

earnest spindle
#

i mean, they literally give u a dynamic import function

#

but anyways thanks

old seal
# earnest spindle In js its not a bad idea when you need to import all files from a folder dynamic...

its the same as injecting code at runtime, which is a very bad idea.
if you need to call certain function or do call different implementation of that func, you can do so with if statement.
if you need to switch between implementation based build target, we have go build tags for that.
~
if you need it, then just import it. it does not matter when or where.
~
dynamic import is a big no. if you mean hot code reload or hot code swapping like erlang has. i agree, its a nice feature. though a proper caching and great compilation speed might just do as well.

#

dynamic import make sense in js, because it can decrease web page load time. but i didn't see why its good for server side app.

earnest spindle
#

i was planning to do automatic command handlers

#

for discord bot