Live data from Hacker News

Erg: a statically typed language that is Python compatible

github.com

51–60 of 194 posts

Re: Erg: a statically typed language that is Python compatible

#51

Earlier quoted context omitted.

Slightly related question: why do people love Python so much? Or, any dynamically typed language? There's almost nothing that has frustrated me more in a professional setting than trying to figure out what some dynamically typed code is doing and ensuring I don't break anything by making changes.

I have a hunch that a lot of Python users didn't carefully evaluate the language on its merits, but rather, just started using it. In my own case, I was using Visual Basic 6 before Python, and mostly Turbo Pascal before that. A huge attraction of Python was the libraries -- scipy, matplotlib, etc. In fact when a lot of people say they're using "Python," they're actually referring to Python plus a large collection of…

I suspect the same. People adopt Python because its clean syntax and REPL make the language approachable and easy to get started and then the huge library ecosystem helps you glue together (in a good way) powerful systems. But how many Python users and libraries actually use the language’s extremely dynamic runtime behavior? Something they’re paying for with a big performance penalty and surprising bugs.

Re: Erg: a statically typed language that is Python compatible

#52

Earlier quoted context omitted.

>ensuring I don't break anything by making changes I think this is a problem in both static and dynamic languages and is pretty much solved in the same way: you test your code.

But is it the same problem, really? Static typing eliminates a whole class of issues that dynamic typed languages don't. Of course you can still have logical bugs, but it's definitely not the same thing. I don't know how to put it better, but you should try writing haskell sometime and you'll see what I mean.

And static languages introduce a whole class of issues that dynamic languages don't have to deal with. You have to learn a separate metalanguage just for the types that isn't expressive enough to do things that are easy in a dynamic language, and even if it were, you'd still have to write everything twice: once in the real language, and once again in the type language. And then you still have to test, don't pretend you don't. If tests are both necessary and sufficient, then why bother with the type language? The static typing is not worth the cost.

Re: Erg: a statically typed language that is Python compatible

#53
post #34

Earlier quoted context omitted.

This is sort of speculation on my part: The fact that static typing PEPs can't easily introduce syntactic changes to the language (I don't think there has been a syntactic change introduced because of static typing ever since Python 3.5) will really hold back Python's static typing from being ergonomic at least, and "fully capable" at the worst. I think that limitation of statically typed Python alone is enough to gi…

I was just playing around with Python 3.10 for the first time today. I made an algebraic/sum-type (dataclasses + typing.Union), then did some structural pattern matching on a value of that type (match statement), and Mypy could tell me statically when the pattern matching wasn't exhaustive! I think it's pretty damn amazing how well Python has been able to evolve into the realm of static typing. And no unofficial supe…

Mypy can work really well in many cases, but we seem to get bitten by bugs on a daily/weekly basis. There are >1,000 currently open on Github [0], so it doesn't take much effort to hit one. And having the type-checker tell you that something's not valid when it actually is is a real turn-off...means that we end up with code that's riddled with "# type: ignore", which kind of defeats the point.

Pylance (the VSCode built-in linter, based on Pyright I believe) tends to do a better job than Mypy, but not as easy to integrate into CI. It's a real shame that the Python ecosystem doesn't have anything nearly as robust as TypeScript.

[0] https://github.com/python/mypy/issues?q=is%3Aopen+is%3Aissue...

Re: Erg: a statically typed language that is Python compatible

#55

At this point I'm open to try anything that will give me access to the python ecosystem without having to code in Python. From the FAQ it looks like Erg code gets transpiled to python bytecode.

If your problem is with the runtime cost of python, do consider transpilers such as py2many that generate rust code.

In order for this to succeed, python libraries would have to be rewritten without the C API in the dialect/subset of python supported.

I wonder if erg could strive to use a subset of python mostly and innovate narrowly in just a couple of places to make python more functional.

Re: Erg: a statically typed language that is Python compatible

#56
post #34

Earlier quoted context omitted.

This is sort of speculation on my part: The fact that static typing PEPs can't easily introduce syntactic changes to the language (I don't think there has been a syntactic change introduced because of static typing ever since Python 3.5) will really hold back Python's static typing from being ergonomic at least, and "fully capable" at the worst. I think that limitation of statically typed Python alone is enough to gi…

I was just playing around with Python 3.10 for the first time today. I made an algebraic/sum-type (dataclasses + typing.Union), then did some structural pattern matching on a value of that type (match statement), and Mypy could tell me statically when the pattern matching wasn't exhaustive! I think it's pretty damn amazing how well Python has been able to evolve into the realm of static typing. And no unofficial supe…

Mypy still couldn't handle recursive types, last I checked. Pyright can do it, but seems to have trouble with even basic type inference. The annotation syntax is working OK, although it tends a bit verbose, but the type checkers are still crippled IMHO.

Re: Erg: a statically typed language that is Python compatible

#57

Earlier quoted context omitted.

why not use the built in typing? https://docs.python.org/3/library/typing.html

it doesnt enforce the types in any way

Use pydandic for serde/IO validation, and mypy --strict. And minimize cheating e.g. Any. I think you'll find it extremely stable and a totally different beast than usual python.

Re: Erg: a statically typed language that is Python compatible

#58
post #52

Earlier quoted context omitted.

But is it the same problem, really? Static typing eliminates a whole class of issues that dynamic typed languages don't. Of course you can still have logical bugs, but it's definitely not the same thing. I don't know how to put it better, but you should try writing haskell sometime and you'll see what I mean.

And static languages introduce a whole class of issues that dynamic languages don't have to deal with. You have to learn a separate metalanguage just for the types that isn't expressive enough to do things that are easy in a dynamic language, and even if it were, you'd still have to write everything twice: once in the real language, and once again in the type language. And then you still have to test, don't pretend y…

So why not static with the ability to ignore hinting or similar? C# does this.

I think function definitions should be statically defined, but the actual body of a function could easily stay largely dynamic.

Re: Erg: a statically typed language that is Python compatible

#60

Earlier quoted context omitted.

Slightly related question: why do people love Python so much? Or, any dynamically typed language? There's almost nothing that has frustrated me more in a professional setting than trying to figure out what some dynamically typed code is doing and ensuring I don't break anything by making changes.

I have a hunch that a lot of Python users didn't carefully evaluate the language on its merits, but rather, just started using it. In my own case, I was using Visual Basic 6 before Python, and mostly Turbo Pascal before that. A huge attraction of Python was the libraries -- scipy, matplotlib, etc. In fact when a lot of people say they're using "Python," they're actually referring to Python plus a large collection of…

Python's popularity has grown pretty steadily over decades. It retains users because of its merits and became popular in multiple niches more or less independently.
Post reply on HN