I have so much trouble when trying to refactor projects bigger than a few hundred lines in python. If I could integrate this into Jupyter easily I'd be excited to try it out.
Erg: a statically typed language that is Python compatible
61–70 of 194 posts
Re: Erg: a statically typed language that is Python compatible
#62Earlier quoted context omitted.
Why so averse to direct Python?
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.
now you can have succint code and fast repl (ala sml) but you don't get the libs
Re: Erg: a statically typed language that is Python compatible
#63Does anyone know if Erg code can be (ergonomically) called from python? I think that'd be the real killer feature, being able to write erg modules and pull it into the greater python ecosystem as easily as native python.
* looks like the project is nary a few weeks old? Can't really dig into the git history on mobile, it freezes my browser
Re: Erg: a statically typed language that is Python compatible
#64Earlier quoted context omitted.
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.
Pydantic requires inheritance and requires a modified mypy because it uses types its own way rather than the python way.
Oh, typedload is faster than pydantic, despite being pure python instead of an .so file.
Re: Erg: a statically typed language that is Python compatible
#65Earlier quoted context omitted.
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.
Anyway I tried it on a mypy clean codebase and it gave a gazillion false positives so I never bothered to integrate it more properly.
Re: Erg: a statically typed language that is Python compatible
#66Earlier quoted context omitted.
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.
The fact that it's written in js, probably not by python developers makes me distrust it. Anyway I tried it on a mypy clean codebase and it gave a gazillion false positives so I never bothered to integrate it more properly.
Last I used it, it was miles ahead of mypy in terms of speed, easy-of-use (it's an LSP!), correctness (simply has less bugs), and feature completeness (has implemented every new static typing feature that I've wanted to use months ahead of mypy).
The maintainer was also super-responsive on Github: replied to my issues in hours/minutes, and often released minor versions with bugfixes one or two days after issues are reported.
Re: Erg: a statically typed language that is Python compatible
#67Earlier quoted context omitted.
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.
You can also approach this from the other direction: why not start with a dynamic language for the rapid prototyping and gradually introduce typing as the code stabilizes? Python and Typescript do this.
Re: Erg: a statically typed language that is Python compatible
#68Re: Erg: a statically typed language that is Python compatible
#69Earlier quoted context omitted.
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.
I wrote typedload before pydantic was a thing. It's faster and actually works well with mypy and python's type system. Pydantic requires inheritance and requires a modified mypy because it uses types its own way rather than the python way. Oh, typedload is faster than pydantic, despite being pure python instead of an .so file.
I'm pretty sure that serde, the rust library that Pydantic uses, is faster than the JSON parser written in C in the python standard lib, so I'd be very surprised if your pure python validation library beat pydantic.
Re: Erg: a statically typed language that is Python compatible
#70But not really a pythonic syntax. Reminds me more of ruby? i.e.: > 2.times! do!: