Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by dochtman on Friday June 26, 2015 @09:30AM
(#9784143)
Those who like this might also like my language project, Runa:
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.
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by david-given on Friday June 26, 2015 @04:12AM
(#9782950)
Have you tried Nim? The syntax is Python-inspired rather than Python-like, but it seems to combine a lot of the nice features of dynamic languages with the rigour of a static language.
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by dagw on Friday June 26, 2015 @04:03AM
(#9782928)
Have you looked at cython? It's (optionally) typed, fast (with only a little bit of effort extra effort over writing normal python), makes the GIL optional (for a reasonable subset of cases) and, most importantly, stable and ready to use today (so no waiting).
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by kevin_thibedeau on Friday June 26, 2015 @08:32AM
(#9783847)
+1 for cython. The only criticism I could make is that the real speedups come when you can avoid using PyObjects which means the easiest way to employ it is in the inner loops of numeric code where it truly is phenomenal. Complex data structures have to be boiled into C-style structs to get any significant speedup with them although there is still a base level performance boost from having everything compiled into cpython API calls.
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by dagw on Friday June 26, 2015 @09:33AM
(#9784166)
Complex data structures have to be boiled into C-style structs to get any significant speedup
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.
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by Fede_V on Friday June 26, 2015 @09:48AM
(#9784280)
Yes, that's correct, but if you are using semi-complex objects, then you have to invoke the python interpreter and lose most of the advantage of going to Cython in the first place.
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.
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by Animats on Friday June 26, 2015 @02:13AM
(#9782730)
There have been other typed Python variants. RPython, in which PyPy was written, is sort of one. Shed Skin tried to do it entirely via type inference, which is really hard across functions.
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.
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by bkeroack on Friday June 26, 2015 @09:14AM
(#9784040)
The value-add here is that it compiles to C and therefore the type enforcement is done at compile time. If you are OK with interpreted Python and runtime checking you can use https://github.com/prechelt/typecheck-decorator/
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by alehander42 on Friday June 26, 2015 @09:23AM
(#9784092)
That looks cool! It's pretty different though, it's more like a "design by contract" tool.
I have a similar one, more Python2 style dsl (it supports also function overloading through a kind of pattern matching) https://github.com/alehander42/py-matchete
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by alehander42 on Friday June 26, 2015 @11:04AM
(#9784929)
Well yeah, but I wanted to experiment with the language type system(it started from HM, but it can go anywhere).
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).
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by lorenzhs on Friday June 26, 2015 @05:27AM
(#9783147)
Nice. I wanted to find out how well it performs (with a simple summing task) but I gave up before I had managed to loop over a range. I'll check back in a week or two ;)
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by alehander42 on Friday June 26, 2015 @08:42AM
(#9783895)
It does support `for ... in range(start, end)` and `while` now. You can check out two summing examples in the examples dir too. It typically gives ~ 6-7x speedup on my machine.
Re:Show HN: A Python with Hindley-Milner-like type annotatio...
by agumonkey on Friday June 26, 2015 @08:58AM
(#9783975)
Well considering the amount of courses now in python, who knows what will be asked to and done by students. Maybe it will land before guile-emacs is stable.
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.
https://github.com/djc/runa/
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.
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.
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.
http://mypy-lang.org/
C++ can also infer return types, the following is a valid C++14 function definition
which incidentally gets compiled to this:> "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:
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) 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).