Looking for LLVM-based language which allows to reload part of binary on-the-fly - jit

Are the any GIL-less LLVM-based languages, targeted mainly for JIT-execution which allows to reload PART of the code on the fly?
Like re-compile 1 class, and reload it without stopping the whole program.
Anyone tryed that?
Any chance on doing that with clang (surely, with great deal of developers caution, restriction and manual state handling)?

I think that this is a dynamite idea, and a feature that I would love to have! Have you given any thought to how you would like to interface with the feature?
obj1 = Foo()
compiler.Recompile(Foo, '/some/path/myapp/newsrc/foo.blah');
obj2 = Foo()
// Would this be True?
type(obj1) == type(obj2)
I assume that you expect existing instances to remain unchanged by the recompile?
This seems like it would be easier with functions, as long as they kept the same prototype, but doing it with classes seems like it would get messy.
Also, what to do about threading?
Thread.start(wait 1; bar();); // bar is a function
compiler.Recompile(bar, '/some/path/myapp/newsrc/bar.blah');
Lets say that in our thread we start calling "bar" during the recompile. Does the call block until the recompile is done and then call the new function? Does the old function still exist until the compile is complete? What if we have a function pointer, after the recompile, where does it point? To the original function or to the new one?
Does anyone have any thoughts on how this could be implemented in a strait forward way?

Hmm, can't think of anything off the top of my head. The only major product I can think of is JRebel, but that's for Java.

Apparently, it does not exist yet.

Related

How to create a closure from String in Dart?

How to use dart-mirror API to create a anonymous closure dynamically?
Like as the interpreter, compile the code during run-time.
var funcstr='bool (String s){ return (s==null); }';
var func=parseStr(funcstr);
// func(s)-> s==null;
var r=func('false');
// r=false;
so, how to do with "parseStr"?
my project:
http://github.com/stevehsu77/surebet
At the moment there is no way to do this. Dart has no eval and no code generation at runtime.
But it is something Gilad Bracha (the language spec lead of Dart) wants to have (https://groups.google.com/a/dartlang.org/forum/#!topic/misc/6O4g7eEHgOU) at least for the development environment.
Also
We’d like to support more powerful reflective features in the future. These would include mirror builders, designed to allow programs to extend and modify themselves, and a mirror-based debugging API as well.
https://www.dartlang.org/articles/reflection-with-mirrors/
So it'll probably be supported some time in the future. But right now it's not possible.
As mentioned above, Dart does not have eval, however it is possible to load new source code in another isolate using spawnUri().
I am not sure if there are any examples of how to use this. Perhaps post a message on the dart discussion group.
Using isolates and spawnUri() is quite a different than using eval, so it may not be the right fit for your project.

Cocos2d/directC pointer inheritance; adding children vs changing data

OK so like a lot of us novice codehacks, I've gotten to the point where, through trial and error, I can throw together a relatively fun and reasonably stable game without really understanding WHY a lot of my code works, and I have a poor understanding of pointers and data management. I've tried studying, but since I lack a formal academic background in computer science and have 15 years of experience coding, the introductory stuff is way too easy, and the advanced stuff uses a ton of terminology I don't understand paired with code that I do.
I'm trying to understand why it is that sometimes I can define a new variable, point it at another variable, and then change the pointed data indirectly, and sometimes I can't. Here's an example where it DOES work as I expect:
NSString *myString = [MySingleton sharedMySingleton].singletonString;
myString = #"Hello there!";
[myString retain];
By changing the locally defined "myString" i can cause changes to the singleton string.
Here's an example where it DOESN'T work as I expect:
HUDLayer *windowBox = shopWindowBox;
[windowBox addChild: shop];
[windowBox retain];
In this case, HUDLayer is just an essentially blank file, and "shop" is a menu containing my store, and "shopWindowBox" is an instance of HUDLayer. If I call the code with [shopWindowBox addChild: shop], it works, but as soon as I try to define a new HUDLayer and point it, it doesn't work.
I understand that I'm doing a very fundamentally different operation, in one case I'm changing the contents of a string, and in another case I'm adding a child. The conclusion I've come to is "you can't add children to a pointed data", but am I really understanding this correctly, an if so why not?
I found a code error in a different block that was setting its visibility to FALSE.
I was attempting to make the code more plug-and-play by changing "shopWindowBox", "unitWindowBox", and "unlockablesWindowBox" all to be locally defined variable with windowBox, but my "hideUnitWindowBox" and "hideUnlockablesWindowBox" functions were setting the visibility of my shop window to FALSE after populating it.
I guess pointers not only work as I expected, they work BETTER than I expected... I stupidly merged 4 different windows into a single window using pointers.

How to properly debug OCaml code?

Can I know how an experienced OCaml developer debugs his code?
What I am doing is just using Printf.printf. It is too troublesome as I have to comment them all out when I need a clean output.
How should I better control this debugging process? special annotation to switch those logging on or off?
thanks
You can use bolt for this purpose. It's a syntax extension.
Btw. Ocaml has a real debugger.
There is a feature of the OCaml debugger that you may not be aware of which is not commonly found with stateful programming and is called time travel. See section 16.4.4. Basically since all of the information from step to step is kept on the stack, by keeping the changes associated with each step saved during processing, one can move through the changes in time to see the values during that step. Think of it as running the program once logging all of the values at each step into a data store then indexing into that data store based on a step number to see the values at that step.
You can also use ocp-ppx-debug which will add a printf with the good location instead of adding them manually.
https://github.com/OCamlPro-Couderc/ocp-ppx-debug

Is there an ObserveOnDispatcher for Windows Store Apps?

I'm using reactive extensions (well, trying, learning) in a windows store app. I have a series of async operations that will eventually navigate to an authorization web page for RTM. Given the reading I've done, I would expect to write something like the following:
var result = rtm
.GetFrob()
.Select(s => rtm.GetAuthenticationUrl(s))
.ObserveOnDispatcher()
.Do(uri => AuthWebView.Navigate(new Uri(uri)))
.First();
However, I can't seem to find a method ObserveOnDispatcher, and further there is no Scheduler.Dispatcher property either, leading me to think on a Windows Store application there is something deeper gong on with the main UI thread and how you reference it.
GetFrob, btw, creates an IObservable sequence using Observable.FromAsync (if that helps with this).
BTW, if I remove that line, I fail in the call to the Navigate as posting it from the wrong thread. So, what is the proper thing to do here to make sure I'm back on the correct thread?
BTW, Excuse the ".Do" operation here, I know it isn't "nice", however, I'm still experimenting in throw-away code.
Many thanks in advance!
Argh. Apparently I just am not good enough at search. :(
Turns out that adding the nuget package Rx-Xaml includes the proper assemblies for the scheduler, etc. Details can be found on the main Rx blog. Of course, my app is back to hanging now, but that may be due to something else dumb on my part.

Alternative to Html.Button<T>?

I know the Html.Button has been moved to the Microsoft.Web.Mvc namespace, but I really miss the generic versions that used to exist in the early Previews.
All I want the Html.Button to do is to hit an action in my controller, but I'd rather not write the JavaScript in the onClickMethod argument.
In my previous project I just snagged the generic Html.Button code from a previous preview release, but that doesn't seem like the best approach as things progress. There were also Html.NavigateButton... where is that and why should I have to recreate it?
How is everybody else doing this?
The problem with the generic versions is that filters are allowed to change the actual name of the action away from the name of the method (like the [ActionName] attribute).
Yes, they really screwed up with Html.Button and Html.CheckBox in CTP5. I hope they return to the previous behaviour.

Resources