Show HN: Mys – an attempt to create a statically typed Python-like language
github.com
github.com
You might want to also look at Shedskin, https://github.com/shedskin/shedskin which converts implicitly typed Python programs to C++
Shedskin uses the Python interpreter if I remember correctly. I aim not to.
[1]: http://nuitka.net/
[2]: https://cython.org/
It doesn't compile to C but to an IR, but some ideas around typing might be similar.
All of this to say, the OPs language seems much more Pythonic. The key words, the built in functions, the class system, all seems designed to match Python as closely as possible.
It’s interesting to see how well the typed Python syntax maps to a static implementation of Python. The speed should probably be a lot faster than CPythin too for many cases.
L = []
L.append(L)P.S.: Might make sense to try to get to a common type-safe language spec?
I don't understand the question. Can you rephrase it? =)
p.s. And I wasn't aware of Cocopy either. Having a list of similarities and differences of all three might be useful...
Rust-like borrow checking with a Python-ish syntax, compiles to C++ or Wasm
Crystal: https://crystal-lang.org/
Sorbet: https://sorbet.org/
I have nothing else to say except that I want this to happen. Python is an amazing language which is missing two things - static types and speed. I starred your repo and am looking forward to seeing it progress.
Small nitpick about the title: Python is strongly typed.
Python determines the types at runtime, but it is very clear about what few operations you're allowed to do on any given set of types.
def foo():
return 1 + "2"
Another example showing Python is untyped: x = 1
x = "2"
x clearly has no type. No variables in python have types.Your first example demonstrates that python does not have compile time type checking
Your second example demonstrates that python variables can dynamically change types.
>>> 1 + "2"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
https://dev.to/jiangh/type-systems-dynamic-versus-static-str...The program '1 + "2"' is a perfectly valid python program with well defined behavior (it signals a TypeError). This demonstrates that you can in fact add integers to strings in python. Of course whether or not you can add integers to strings is completely orthogonal to whether or not a language is typed. Both typed and untyped languages may overload the addition operator.
"A type system is a tractable syntactic method ... Terms like 'dynamically typed' are arguably misnomers."
https://stackoverflow.com/questions/9154388/does-untyped-als...
I still prefer the term dynamically typed, because there are useful distinctions about value types to be made among such languages, such as those described in striking's link.
It's like the discussion is untyped, and the downvotes are runtime errors that would have been caught if terms were agreed upon ahead of time.
Sorry about the confusion. Mys is statically typed. I changed the HN post from strongly to statically to make it clear.
... or let the attacker execute arbitrary code.
See "What to know before debating type systems":
http://blogs.perl.org/users/ovid/2010/08/what-to-know-before...
I see this claimed a lot, but haven’t seen any evidence.
Benefits of Type Inference for an Object-Oriented Real-Time Language
https://www.researchgate.net/publication/220391749_Benefits_...
EDIT: Granted, this particular paper may be more claims without solid evidence.
There are probably other languages that would serve the same purpose, but oh well, I can't resist creating another. =)
https://github.com/python/mypy
Its a compiler that support subset of python and mypy's team including Guido work on it. It would be great if this kind of efforts have been done on more realistic project.