Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Changing a program while it is running

Name: Anonymous 2007-08-06 7:11 ID:c7V00J+8

If you use some Satori-Level language, can you change the program while it is running -- replacing functions and such?

Name: Anonymous 2007-08-06 7:22 ID:nXB9qMQ9

Yes.

Name: Anonymous 2007-08-06 7:23 ID:GKte7u8O

Examples: Lisp, Python, Erlang

Name: Anonymous 2007-08-06 7:33 ID:xzVjAPOB

Examples: Ruby Ruby Ruby Ruby Ruby.

Name: Anonymous 2007-08-06 7:41 ID:c7V00J+8

Working code examples please!

Name: Anonymous 2007-08-06 7:45 ID:Heaven


 (define a
       (lambda (n) (* n n)))
 (define a
       (lambda (f x) (f x x)))
 (a + 4)


run it and you will see there's no error when you try to replace the definition of the function a

Name: Anonymous 2007-08-06 8:00 ID:c7V00J+8

I'm talking about changing things in some external way... like if I want to patch my server with a fixed function without starting it.  And I don't really want to have to build stuff into the application.

Name: Anonymous 2007-08-06 8:05 ID:nXB9qMQ9

like if I want to patch my server with a fixed function without starting it.  And I don't really want to have to build stuff into the application.
What? Just leave a REPL open and patch to your heart's content. You can do this with any halfway decent language.

Name: Anonymous 2007-08-06 8:10 ID:c7V00J+8

>>8
Ah, you might be right!  Thanks.

Name: Anonymous 2007-08-06 8:19 ID:Heaven

If it's a script, you could keep each function in a different file, and have the server re-include that function's file when you patch it.

Name: Anonymous 2007-08-06 8:22 ID:Heaven

>>10
Massive failure.

Name: Anonymous 2007-08-06 9:12 ID:BXSqkEvF

you cant do it with ruby

Name: Anonymous 2007-08-06 10:23 ID:5JobxYSp

>>12
Sure you can, here, run this:

def doSomething
    print 'foo', "\n"
end

lded = Hash.new

while true
    doSomething
    sleep 1
    Dir.glob('foo/*.rb' ) do |f|
        if lded.include?(f) == false or lded[f] < File.mtime(f)
            lded[f] = File.mtime(f)
            instance_eval(IO.read(f))
        end
    end
end


Then just drop replacements in "foo/". For example this:
def doSomething
    print 'bar', "\n"
end

Name: Anonymous 2007-08-06 10:53 ID:XWfw/75Y

You can do anything with Ruby.™

Name: Anonymous 2007-08-06 11:04 ID:BXSqkEvF

>>14
yeah, but only because its written in C

Name: Anonymous 2007-08-06 11:13 ID:xzVjAPOB

>>5
No, not really - it could have been written in any language including Ruby.













It would just be even more epically slow.

Name: Anonymous 2007-08-06 11:14 ID:xzVjAPOB

>>16 EDIT : >>15 tl;dr tl;dr tl;dr

Name: Anonymous 2007-08-06 11:21 ID:Heaven

>>14
You can do anything with any turing complete language.

Name: Anonymous 2007-08-06 11:33 ID:XWfw/75Y

>>18

But you can do anything with Ruby.™

Name: Anonymous 2007-08-06 11:35 ID:SHqmvWtk

In fact, Ruby is one of the most Touring complete languages known to mankind.

Name: Anonymous 2007-08-06 11:51 ID:BXSqkEvF

>>20
too bad ruby on rails is slow as fuck

Name: Anonymous 2007-08-06 11:59 ID:XWfw/75Y

Ruby can be optimized by implementing it in Ruby itself. Because with Ruby, you can do anything.™

Name: Anonymous 2007-08-06 13:06 ID:c7V00J+8

>>21
moar liek ruby on fails am i rite lolololol

Name: Anonymous 2007-08-06 13:25 ID:5/ywElYJ

Ruby. It's the new basic. ™

Name: Anonymous 2007-08-06 13:33 ID:Heaven

I’M GUIDO
SON OF A BITCH RUBY
RUBY IS PIG
DO YOU WANT REFLECTION?
DO YOU WANT GARBAGE COLLECTION?
RUBY IS PIG DISGUSTING
MATSUMOTO IS A MURDERER
FUCKING RUBY

Name: Anonymous 2007-08-06 13:56 ID:Heaven

I thought JRuby was pretty darn fast?

Name: Anonymous 2007-08-06 14:02 ID:5JobxYSp

>>26
IronRuby?

Name: Anonymous 2007-08-06 14:04 ID:Heaven

>>25
oh god i lol'd

Name: Anonymous 2007-08-06 14:22 ID:BXSqkEvF

>>25
LMAO

>>28
you dont understand sage

Name: Anonymous 2007-08-06 16:02 ID:c7V00J+8

I’M MATZ
SON OF A BITCH PYTHON
PYTHON IS PIG
DO YOU WANT FUNCTIONAL PROGRAMMING?
DO YOU WANT INDENTATION?
PYTHON IS PIG DISGUSTING
GUIDO IS A MURDERER
FUCKING PYTHON

Name: Anonymous 2007-08-06 18:28 ID:I0mfdSLP

>>1
Take a look at the kernel functions in windows, or pretty much anything from MS (incl. DX), they all have a prologue which looks like:

mov edi, edi

which is basically a 5-byte NOP. The reason? So they can place an unconditional jmp instructions (which is 5 bytes) to fixed functions, effectively producing hot-fixes, without having to reload the module. Pretty neat if you ask me.

Name: Anonymous 2007-08-06 18:32 ID:Heaven

>>14
it's no wonder shii-chan was written in ruby

Name: Anonymous 2007-08-06 19:13 ID:NJaw9+dT

>>31
So that's why Windows is so damn slow. It's constantly moving edi.

Name: Anonymous 2007-08-06 19:15 ID:c7V00J+8

>>31,33
/r/ -OMG optimized binaries.

Name: Anonymous 2007-08-06 19:42 ID:I0mfdSLP

>>33
mov reg32, reg32
is only 2 clock cycles, according to the Intel Opcodes and Mnemonics manual.
I imagine the CPU can do some specially trickery during the prefetch stage to skip actually reading the instruction. Can any CPU gurus confirm?

Name: Anonymous 2007-08-06 23:24 ID:WZ+avijf

Any fucking language with any fucking sort of `eval` statement (or even without it — you will just have to work on some mechanism to dynamically load functions and update call tables etc)Thread over.

Name: Anonymous 2007-08-06 23:49 ID:BXSqkEvF

>>36
no we don't do it like this in lisp

Name: Anonymous 2011-03-31 12:06

I am the phantom autist

Name: Anonymous 2011-03-31 12:06

I am the phantom autist

Don't change these.
Name: Email:
Entire Thread Thread List