Live data from Hacker News

Erg: a statically typed language that is Python compatible

github.com

61–70 of 194 posts

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

#61
post #8

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.

We have a 50kloc all-python backend, with very high (>90%) type integration (that last mile is hard). I've done pretty big (thousands of loc) refactors and it's pretty painless. Night and day compared to the pre-typed python days.

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

#62
post #4

Earlier 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.

casual and fast prototyping

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

#63
This is exactly the sort of thing I've been looking for. Not sure how production-grade it is* but definitely gonna use it for some scripts and data processing. I love python, most of all its ecosystem, and use types extensively, but it still misses some things I wish it had better support for. Namely: immutability, and explicit side effects, which are both prominent features of Erg. So this is super exciting.

Does 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

#64
post #57

Earlier 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.

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.

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

#65
post #56
post #34

Earlier 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.

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.

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

#66
post #65
post #56

Earlier 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.

I absolutely feel comfortable vouching for Pyright!

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

#67
post #52

Earlier 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.

I do think that's helpful compared to the strict alternative, but much of the up-front cost is still there. You still write most things twice, and the static type checker still slows you down when prototyping. You'd still be tempted to write bad code to work around the insufficiently-expressive type language, rather than write it in the most natural way, and only give up when it's too hard.

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

#69
post #64
post #57

Earlier 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 would be very interested in seeing some benchmarks!

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

#70
post #11

But not really a pythonic syntax. Reminds me more of ruby? i.e.: > 2.times! do!:

This is what is putting me off the most of this, the syntax feels very unreadable for something that is meant for python, which has a very readable and open syntax, even typescript's sometimes messy typing is for the most part more readable than this
Post reply on HN