Live data from Hacker News

Erg: a statically typed language that is Python compatible

github.com

41–50 of 194 posts

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

#41

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.

No shortage of options, e.g. Dg, Mochi, Coconut, and Hebigo (based on Hissp[1]).

[1]: https://github.com/gilch/hissp

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

#42

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.

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

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

#43
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.

Python is statically typed though. [1][2][3][4]

These aren't just some third-party tools bolted on. The type annotation syntax is built into the language[5] and standard library[6][7].

I personally find static typing to be more trouble than it's worth most of the time. Industry typing metalanguages are not expressive enough to deal with even fairly basic real-world programs and force you to write bad code to work around the type checker's stupidity. And, of course, you still have to write tests. Maybe someday they'll catch up to Idris. Python's static typing is no better, but at least it allows you to turn it off when it's not worth it.

[1]: https://github.com/microsoft/pyright

[2]: https://github.com/python/mypy

[3]: https://github.com/google/pytype

[4]: https://github.com/facebook/pyre-check

[5]: https://peps.python.org/pep-3107/

[6]: https://peps.python.org/pep-0484/

[7]: https://docs.python.org/3/library/typing.html#module-typing

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

#44

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.

Because you can do a lot with little typing and there are lots of great libraries. Python is probably the best choice when you need to get something done quick or calculate something when performance is not important. It is also not an exotic functional language without loops and filled with linked lists. Also, in Python integers do not overflow, unlike in Rust, C and other buggy languages. If you name a language, wi…

>There should be type hints.

"Hey, this variable is probably of this type. Now go on, run the code and launch a debugger the same way you would if there was no hint just to make sure it's correct. Oh, and don't forget to check all the possible code paths that lead to this to make sure you've exhausted all possibilities."

Don't get me wrong, type hints are cool but they're just a toy compared to proper static typing.

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

#45

It would be nice if someone created a typescript for python. Something that allows us to wrangle control and sanity over reams of legacy untyped python madness.

I think both `erg` and statically typed Python are both attempts at doing exactly that. May be what you mean is a static typing solution for Python whose syntax is a superset of Python syntax (which I don't think `erg` is), but isn't identical to Python's syntax( ie, it is a strict superset, which statically typed Python's syntax isn't). Typescript is exactly that for JS. In that case, I agree with you that such an a…

Related question, how does typescript’s gradual typing system work? Are there any resources on how they implemented and architected it?

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

#47

Earlier quoted context omitted.

Because you can do a lot with little typing and there are lots of great libraries. Python is probably the best choice when you need to get something done quick or calculate something when performance is not important. It is also not an exotic functional language without loops and filled with linked lists. Also, in Python integers do not overflow, unlike in Rust, C and other buggy languages. If you name a language, wi…

>There should be type hints. "Hey, this variable is probably of this type. Now go on, run the code and launch a debugger the same way you would if there was no hint just to make sure it's correct. Oh, and don't forget to check all the possible code paths that lead to this to make sure you've exhausted all possibilities." Don't get me wrong, type hints are cool but they're just a toy compared to proper static typing.

> Oh, and don't forget to check all the possible code paths that lead to this to make sure you've exhausted all possibilities."

This is literally what mypy does.

There's no difference between a mypy-enabled codebase and a java codebase in terms of static typing (other than that mypy actually supports a generally richer type system).

Like yes if you aren't validating the type hints you aren't getting the value, but if you are, you don't need to run the code! I get most of my python errors at compile time, and you can too. I promise.

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

#49

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.

Because you can do a lot with little typing and there are lots of great libraries. Python is probably the best choice when you need to get something done quick or calculate something when performance is not important. It is also not an exotic functional language without loops and filled with linked lists. Also, in Python integers do not overflow, unlike in Rust, C and other buggy languages. If you name a language, wi…

>no type hints in many libraries, some libraries are not type-hint friendly.

>There should be type hints.

So, is it one or the other?

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

#50

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

Neither does typescript. All the types are removed at runtime, it's up to you to ensure that your build process and tooling correctly validates the types. The same is true for python, and the ecosystem has really great tools for doing this.
Post reply on HN