Show HN: A Python with Hindley-Milner-like type annotations, compiling to C
github.com
github.com
A Python-like systems programming language. This means that the design borrows as much from Python as makes sense in the context of a statically-typed, compiled language, and tries to apply the Zen of Python to everything else. The most important design goals for Runa are developer ergonomics and performance. The compiler is written in Python and targets LLVM IR; there's no run-time. More information can be found on the project website.
I've never really played with it, but cython does have mappings between python builtin types and STL containers, as well as letting you create C++ classes using cython syntax that you can inherit from and access in python.
Even for things like ints, floats, etc - if you want to see a significant speed up, you have to convert them into c ints and floats.
https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programm... http://nim-lang.org/
Haven't played with it myself, as I'm still waiting for a compiler to show up in Debian, but I plan to.
It's clear now that you want at least enough type inference in a language that LHS types of assignments and variable creations are inferred when possible. When you have that, as in Go, Rust, and even C++ to some extent, most of the declarations are in function definitions. There, you want them for documentation purposes anyway.
C++ can also infer return types, the following is a valid C++14 function definition
auto foo() {
auto curry = [](auto x) {
return [=](auto y) { return x + y; };
};
auto add42 = curry(42);
return add42(58);
}
which incidentally gets compiled to this: 0000000000000000 <foo()>:
0: mov $0x64,%eax
5: retq> "yeah, you need a shower now, doncha"
I saw that there is a requirements.txt file, but it's blank. This project amazes me, knowing it exists gives me motivation to get better
That is all...
BTW I really like the idea of a typed, compilable Python, keep it up!
Classes/records are not implemented yet, but I can imagine that we have two cases:
<object_with_known_exact_class>.<method>
then we'll just convert that to a normal function invocation in c(because we'll be able to detect the exact ancestor which defines the method and the method) <an_instance_of_some_class>.<method>
if we only know that an object is an instance of a class, we can wrap the invocation in an inline switch on the type field of the object.(instances would map to C structs).