Live data from Hacker News

Show HN: Mys – an attempt to create a statically typed Python-like language

github.com

31–40 of 57 posts

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#31
post #23
post #22

Before making Yet Another Language, I'd like to see a good analysis of the options and trade-offs they offer: what does each design choice make easier and harder. There is probably no free lunch, but maybe we can find a better lunch by balancing things carefully.

For me it's pretty simple. I love Python. I like speed. I like embedded. This is an attempt to take advantage of Python's type hints to create fast and hopefully small binaries that can be executed on embedded devices limited amount of resources (both CPU and RAM). There are probably other languages that would serve the same purpose, but oh well, I can't resist creating another. =)

Have you look at mypyc?

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.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#32
post #9

Earlier quoted context omitted.

I would call Python untyped

You would be wrong. Try adding a string and number together. That's a type error. Unlike in JS or C, where a lot of these conversions are implicit and only warn if anything. 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.

I wouldn't call C untyped because implicit conversions happen all the times. It's just that it assumes that since you declare your variables with a type, when you assign them, you know what is going to happen.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#33
post #31
post #23

Earlier quoted context omitted.

For me it's pretty simple. I love Python. I like speed. I like embedded. This is an attempt to take advantage of Python's type hints to create fast and hopefully small binaries that can be executed on embedded devices limited amount of resources (both CPU and RAM). There are probably other languages that would serve the same purpose, but oh well, I can't resist creating another. =)

Have you look at mypyc? 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.

It compiles statically typed Python modules to CPython C extension modules. I do not know the details, but it sounds like that's a major difference to Mys.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#34

I was once toying with the idea to create a statically-typed Python-like language, and I had the perfect name for it: Typhoon... ;)

Alternate idea: a language called Typon in which the compiler paves over typos of keywords and symbol names.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#35

Earlier quoted context omitted.

You would be wrong. Try adding a string and number together. That's a type error. Unlike in JS or C, where a lot of these conversions are implicit and only warn if anything. 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.

I wouldn't call C untyped because implicit conversions happen all the times. It's just that it assumes that since you declare your variables with a type, when you assign them, you know what is going to happen.

I'm not calling C untyped either. It's weakly (statically) typed.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#36

Earlier quoted context omitted.

You would be wrong. Try adding a string and number together. That's a type error. Unlike in JS or C, where a lot of these conversions are implicit and only warn if anything. 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.

I wouldn't call C untyped because implicit conversions happen all the times. It's just that it assumes that since you declare your variables with a type, when you assign them, you know what is going to happen.

Barely anything is truly untyped nowadays, I can think only of assembly.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#37
post #9

Earlier quoted context omitted.

I would call Python untyped

You would be wrong. Try adding a string and number together. That's a type error. Unlike in JS or C, where a lot of these conversions are implicit and only warn if anything. 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.

I can import this with no errors, so Python is untyped:

    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.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#38
post #37

Earlier quoted context omitted.

You would be wrong. Try adding a string and number together. That's a type error. Unlike in JS or C, where a lot of these conversions are implicit and only warn if anything. 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.

I can import this with no errors, so Python is untyped: 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.

I'm not sure if you're being serious, but Im going to assume you are.

Your first example demonstrates that python does not have compile time type checking

Your second example demonstrates that python variables can dynamically change types.

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#39
post #37

Earlier quoted context omitted.

You would be wrong. Try adding a string and number together. That's a type error. Unlike in JS or C, where a lot of these conversions are implicit and only warn if anything. 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.

I can import this with no errors, so Python is untyped: 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.

  >>> 1 + "2"
  Traceback (most recent call last):
    File "", line 1, in 
  TypeError: unsupported operand type(s) for +: 'int' and 'str'
https://dev.to/jiangh/type-systems-dynamic-versus-static-str...

Re: Show HN: Mys – an attempt to create a statically typed Python-like language

#40

Strongly typed? You mean statically typed? See "What to know before debating type systems" : http://blogs.perl.org/users/ovid/2010/08/what-to-know-before...

> Type inference is generally a big win. I see this claimed a lot, but haven’t seen any evidence.

Might depend on what "win" is supposed to mean in this context. If it's intended to mean "languages with type inference are more productive", then sure, evidence would be nice. If it's intended to mean "type inference helps cut down on the need for explicit type annotations", I don't think evidence is really necessary.
Post reply on HN