3 ms·
That makes sense, since you want to quickly prototype code (ignoring those annoying type annotations :D) and as the code matures, you want the extra details ins
by dkersten 16y ago
That makes sense, since you want to quickly prototype code (ignoring those annoying type annotations :D) and as the code matures, you want the extra details inserted to help achieve higher performance. Get it right, THEN get it fast.
In my case, I try to have the compiler deduce the information to make it fast, where it can, but fall back to JIT when it can't, or where running the application is the best way of figuring out what needs to be optimized. The missing link between what I'm doing and what you are suggesting is that the runtime should be able to dump metadata for the compiler to use next time around. I'm going to have to think about this a bit, I think there may be some great applications of this idea, eg, turning assertion failures into unit test stubs. It would be great if the compiler and runtime worked together to help you program 1) more efficient programs and, probably more importantly, 2) correcter, less error prone programs. I love the concept of the compiler "hardening" code that was detected to produce errors in a previous run, especially if the JIT compiler can remove checks that are not needed.
- stcredzero 16y agoIMO, Doing this sort of approach within the micro-iterations of an individual programmer's edit-compile-test cycle is not quite the best place to do this. I envision the "hardness level" of a code base to be about the same throughout one iteration/release. This gives time for the production application to generate runtime profile data from actual use. In this case, the more data, the better. This data can then be massaged and verified by programmers using suitable tools and their in-depth knowledge of the application. (So runtime traces which contradict each other's type inferences can be looked at, etc.) Such tools can also apply a set of massaged type annotations to a branch of the code base, which can then be tested and merged back into the main branch of the application. I think this is a very natural pace of this level of change for most shops. This technique can also be adapted to apply to specific sections of code which need to be optimized, or can be applied incrementally across a code base over time.
- tlack 16y agoAn easy/fun testbed for this idea might be Erlang's new type specs: http://www.erlang.org/doc/reference_manual/typespec.html http://www.erlang.org/doc/reference_manual/typespec.html You could write a parse transform that wraps all exported funs in a module in some kind of type analyzing shim function, which would eventually output type specs as an .hrl you could -include(). Type specs will eventually be used by Dialyzer and other Erlang tools to issue warnings and optimize code, so the effort wouldn't be in vain. Seems like a quick way to figure out the feasibility of your excellent idea.
- dkersten 16y agoI envision this to take place in staged releases, eg, during an automated nightly build, rather than during the programmers normal code-compile-run cycle. For example, production code usually turns off a lot of runtime assertions, so this might only be applied to development builds. Having said that, a JIT compiler blurs the line between debug/development and production builds, since the JIT compiler could dynamically insert or remove debug, profiling or tracing code. I like the idea of being able to connect testing tools to a running production system (eg, when an error or bug is detected) and the JIT compiler would insert the required code to make this work for the duration of the test session. The debug information that was generated could then be applied to the next build of the development version (which would include new type annotations, unit test stubs, profile information for the code optimizer and whatever else).
- stcredzero 16y agoI envision this to take place in staged releases, eg, during an automated nightly build, rather than during the programmers normal code-compile-run cycle. Cool! the JIT compiler could dynamically insert or remove debug, profiling or tracing code. I like the idea of being able to connect testing tools to a running production system (eg, when an error or bug is detected) and the JIT compiler would insert the required code to make this work for the duration of the test session. That's going much farther than I'd envisioned it! The mind boggles.
- dkersten 16y agoTheres obviously a lot of work to be done before we get there, but a world where you can have all the powerful features of dynamic runtimes/languages without sacrificing efficiency would certainly be welcome. We'll see how my own experiments work out. If anyone would like to chat about the idea, feel free to send an email to my username at gmail.