Stalin: a global optimizing compiler for Scheme
github.com
github.com
I think a lot of this can be done now with C++'s template metaprogramming, or in fact using D's CTFE which is quite a pleasure to use. Had Java been not so broken for numeric stuff, its late inlining facilities would have helped too. I have played with this a long time ago and at that time nothing I tried, (not even Fortran) could match it for the same algorithm. Although my fortran would have left a lot to be desired. I had very little idea about what I was doing with the piece of Fortran code.
There is a Fortran name for what I was using, it eludes me now, but the integrator was essentially a coroutine which would yield control to the function computer and resume integrating once it was computed. Its quite amazing that Fortran has coroutine facilities, they call it something else.
EDIT:
Java is not smart about using SSE and such SIMD instructions, this is really a pity. C#, F# are better about this unfortunately its a Microsoft only thing, yes I am aware of Mono. The other problem is that JAVA is over specified. Java compilers have very little room to maneuver. For example arguments of a function are supposed to be evaluated left to right, there goes an opportunity for low level parallelization. C compilers makes no such guarantees and can in principle parallelize such instances. The other problem is that unless one uses low level loops, Java produces just way too many temporaries which on one hand stresses the garbage collector and on the other wastes time instantiating and filling the temporaries only to be garbage collected away. In Java the only form of polymorphism is runtime polymorphism via virtual functions. Compile time polymorphism can be a lot more efficient. For example if accessing (i,j)th entry of matrix is a virtual function that all but ensures that your FLOPS will sink like a stone. Have it as a CRTP in C++ all that will get inlined, and if you are lucky unrolled and then SIMD'ized. That said Java numerics has improved quite a bit lately.
Regarding C's whole program analysis, my comment was about the state of the affairs then, but even now owing to the semantics of the language whole program analysis in C is orders of magnitude more difficult than in Functional languages. The latter has much more semantic information to play with. This was supposed to be mitigated some with the introduction of __restrict__ but it did not quite deliver on the promise. But cat'ing the entire code to one file and compiling it does definitely speed up the runtime, poor man's whole program analysis ! Now you do have support for whole program analysis and link time optimization that this is no longer such a necessity.
C compilers can do that with whole-program optimization:
1. Clone the function taking the callback, and set that parameter constant so the value of the callback is known.
2. Change the indirect calls to direct calls.
3. Inline the new direct calls.
Of course, the library has to be statically linked, but that's not a problem for scientific users.
Remember, if you optimize something yourself, just make friends with a compiler engineer and get them to add it!
I'm curious, what makes Java an especially poor choice for numerically intensive computing? Is the JIT penalty too high, or is it something else entirely?
My guess is that there are problems with things like the way all objects are on the heap, and probably other things too.
ftp://ftp.ecn.purdue.edu/qobi/fdlcc.pdf
Although the subject is nominally closure conversion, he describes how flow analysis is used to propagate information about values around the compiler's model of the program. Because the analysis is on a whole program basis it need not be very conservative - in a whole program compiler you never have to give up and do something the slow way because a value might be used in a place you can't see.This aggressive flow analysis gives the compiler enough information to pick nice flat C-like representations, inline objects inside other objects, use more specialised calling conventions, etc.
For example, a whole program compiler might determine that the elements of an array are never compared with eq or have their mutable parts assigned to, which could allow the elements to be inlined into the array. Doing this is tough or impossible in a traditional compiler because the contents of files that have yet to be compiled is unknown, forcing the compiler to assume the worst.
Pretty neat stuff.
Another example of that, to me, is the google closure compiler for javascript (in advanced mode).
The PR situation stemming from stalin's name is a bit unfortunate, but you can always fork and rename it, if you want to work with it, right?
Also, I'm pretty glad that I live in a time where people are free to argue whether jokes about genocidal dictators are acceptable and in the place where I can read them doing so, from the other side of the globe.
[0] http://justindomke.wordpress.com/2009/02/23/the-stalin-compi...
Indignation over the name is off-topic. So is indignation about indignation over the name, and so on.
If you had the guts you could say that indignation about the name is not welcome, or will be censored, or is a distraction and an uninteresting subject here on HN. But the project has a name, and the connotations of that name are relevant, as with every project. If the project were named "the impeach obama compiler" or "darren wilson" or "gas the jews" the idea that issues related to the name were "off topic" would be even less tenable than it is now.
I enjoy the maturity of the commenters on HN, and of the mods as well. But please have the intellectual honesty and backbone to be upfront about what you're doing.
Thank you.
(I will say, substantive discussion for a topic like this seems hard. The people really interested in this are those who haven't heard of it, which means they will have little input. From what I've seen, topics like this usually grow slowly as experienced people post interesting anecdotes or general PL tangents, and others hop on).
No idea why they are there.
Stalin is an amazing piece of software. Its quite unbelievable how much it can optimize code written in a dynamically typed language like Scheme to give C code run for its money on speed for things like numerical integration etc. All those who keep chanting the trope that you need to get low level for speed, that high level languages cannot be fast, would do well to study it. I am glad to see it on Github.
Compile times are near epic, but run times are worth marveling, if not for anything else but to see that such a thing is possible
@bio4m Can we drop that sanctimonious tone please. @vomituddle does have a point, it tickles me a great deal to think USA, a country responsible for the political extermination of one ethnicity and the enslavement of another has this chip on its shoulder as if they are the shining epitome of freedom/democracy that everyone should bow to. Christsake ! get real. Had Hitler won, it is not inconceivable that the Godwin's law would have been quite different, it might as well have picked some US slave runner founder.
Finally, had Stalin been not named Stalin how else would one have StalinGrad, a derived tool for gradient based optimization. Its worth it many times over just for that pun.
EDIT: Yeah the downvotes and flags, they solve so many problems. Funny to have one of the few first comment about the software to be voted and flagged down below vapid calls to political correctness.
@scarmig that lynched guy was someones grandparent too, same applies to native Americans women and children burned in their enclaves with escape routes sealed (if you, and I dont mean scarmig in person, are not familiar its quite instructive to find out how the mystic river got its name, such incidents were hardly one off). I myself have family ties with one of the more recent mass upheavals (if I may avoid the genocide term) but from a different part in space and time. On a somewhat different note, its a strange small world, Stalin, Hitler and native Americans ! I remember your comment from a few days ago.
Yes, really. "And you lynch negroes" notwithstanding. (And, yes, I'm also that guy who is more than happy to puncture American propagandistic historiography.)
HN doesn't even let me post the alternative names as the post gets autodeleted. so some names are really, really bad - but hey, let's offend people for fun.
as if the whole sexism debate wasn't enough.
as to why it is more offensive than genghis khan, i guess it needs to be explained to the ignorant neckbeard crowd: there are enough people still alive today that suffered due this mass murderer.
if even russia does not use his name for say naming an aircraft carrier (as opposed to g.w.bush) you should know it is bad.
this name was picked on purpose, to offend. not a common name, as some other ignorant shits in here have claimed.
It's especially farcical given that without the name and the resulting offended people, butthurt Russians, and random assholes yammering about "political correctness", this post would have probably never made the front page.
And I've also found https://github.com/n4kz/stalin.js by a russian guy - Joseph Stalin => stalin.js - Badass mustache compiler
just like the people most offended by nazi glorification do not live in germany. just like people offended by war japan glorification do not live in japan. just like people offended by confederate glorification are not white. sexism, not male, etc etc etc.
is it that hard of a concept? empathy towards others?
Randomly googling for "Igor Stalin", I found a Facebook page and YouTube channel.
Are there famous Stalins besides the well-known tyrant? Wikipedia informs me that "The Stalin" were a Japanese punk band, and some rapper called Jovan Smith took on J. Stalin as a stage name, and an Indian politician called M. K. Stalin. All of these names are derived from the infamous dictator, though. So it's very hard to connect anything which uses that name to anything else.
"The Stalin" chose their name evidently because "Joseph Stalin is very hated by most people in Japan, so it is very good for our image." LOL, facepalm
Making jokes about any mass murderer trivializes their victims.
Uh, no. Comedy is the one realm within human discourse where we're allowed to discuss things and the normal rules don't apply. This has been the case since time immemorial and it's not about to change now.
Now I have to think about whether I would be ok with other potentially offensive names... Boko Haram, the packet capturing tool. It even has the 'Islamic State' functionality that removes HTTP headers from their respective packet bodies. Hmm..
Pity about the name though. It would've been more appropriate to name it on one of the "victorious" tyrants of our age. Perhaps one of "Columbus", "Churchill", "Reagan", or for that touch of infamy "Nixon". Pfft.
Its predecessor, CMUCL, did have a mode called "block compilation" that has some similarities: http://common-lisp.net/project/cmucl/doc/cmu-user/compiler-h.... It isn't currently present in SBCL; it was axed as part of the CMUCL->SBCL cleanup. I've occasionally heard suggestions of adding similar functionality to SBCL, but I'm not sure there's any active work on it.
Lucid CL had two compilers, a fast incremental one and a slow one, capable of block compilation. KCL (the early Lisp to C compiler) used block compilation. LispWorks should also support it in some form.
Usually 'block compilation' in Lisp means compiling a set of functions together, instead of compiling each function individually. This block compilation for example then can reduce function call overhead.
In its more primitive for a single file of source is seen as a block. But compilers also support block compilation of several files together.
Block compilation in Common Lisp was and is used mostly for application delivery, where the program is static and dynamic features can be removed. Thus a delivered program is more static, but also 'faster'.
The main place I've personally encountered people who care about block compilation in CL isn't so much delivery (as in, to an external client) as getting it ready to run "for real", mostly numerical stuff that is being prepared to run in batch mode on a giant dataset. I guess that's a kind of deployment though, even if the operator and developer is the same research group.
I could be imagining things, but one downside I think I see in not having block compilation in SBCL is that people writing numerical code targeting it have a tendency to pack as much as possible into flet and labels, using one big function as the poor man's compilation block (since within a single function most of CL's dynamic features aren't in play).
I tend not to like code like that when hacking on it. Besides often reading less clearly and sometimes leading to duplicate or near-duplicate code, separate functions are more flexible: they can be dynamically redefined while tinkering with things, they can be called on their own, etc. Of course, that's precisely why the compiler can't perform certain optimizations on full calls. But I think people would be more free with the defun if they knew the compiler would take care of optimizing everything when deployed.
That's often called 'delivery' in Lisp. It means creating an executable application or library. It does not mean the actual act of shipping something to external clients.
If you compile your code to create an application which then is used in 'production' (internal or external), this is the process of 'delivery'.
http://franz.com/support/documentation/current/doc/delivery....
http://www.lispworks.com/documentation/lw61/DV/html/delivery...
the amerikan founding fathers have committed acts of genocide (and numerous other crimes) against Native Americans and Africans and yet someone decided it would be a good idea to print them on dollar bills
The naming seems like a stretch to me, and I don't appreciate the theme to be honest. If you're going for any sort of recognition of the brand then this is going to get buried under results for Joseph Stalin.
Very poorly named I would have expected something better coming for Purdue University. I'm sure they wouldn't appreciate this much either.
would like to see more of this for hardcore stuff like this:
eternal virgin
smelly neckbeard
aspy social retard
and then, let's make it clearer in case my sarcasm needs a tag :
were nigger, kike, wetback already taken?
yes, words matter you fucking morons. needs to be explained to a profession that relies on precise language aka code to accomplish anything.
I also vaguely remember that the name was chosen as a counter to Dylan (DYnamic LANguage), but can't find the reference now.