Live data from Hacker News

Erg: a statically typed language that is Python compatible

github.com

121–130 of 194 posts

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

#121
post #43

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.

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 aro…

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

I honestly don't see that. Could you provide some examples?

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

#122
post #98

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…

What i don't like about python: The goddamn versioning and packaging problems. About 5 years ago python was incredible. You could pop out a project quickly because there were very few packages that made breaking changes over their development, so you could often use your standard workflow with the set of packages you we're comfortable with, even if there were new versions available that day. Now, Nvidia and Google ru…

I feel this comment in my bones.

I went from loving Python to hating it with a seething rage.

Python package managers are all so bad that the only reasonable solution is Docker containers or vendoring everything (not easy). And even so, I've had untouched Docker builds still die because dependencies mysteriously get yanked or changed.

God, I hate Python so much now.

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

#123
post #89
post #75

Earlier quoted context omitted.

Anecdote, but I like the Python community's emphasis on "readability counts". I did not get that from e.g. Ruby. Python's internals are also relatively accessible and easy to work with, so it's smooth sailing once you have that need. The language starts out easy, and grows with you. Of the languages I've tried (and there are many), only Smalltalk and the Lisp family were comparable in expressiveness. The language mos…

Python is among the least-readable languages for me. The lack of whitespace and brackets around code blocks just make it look like the "wall of text" that everyone hates in emails. And then there's the fact that Python has significant characters that are literally unreadable because they're invisible (semantic whitespace).

You can add empty lines before and after blocks. The only thing that matters is the indentation. If you see code without empty lines separating different steps, that's pretty badly written Python.

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

#124
post #89

Earlier quoted context omitted.

Python is among the least-readable languages for me. The lack of whitespace and brackets around code blocks just make it look like the "wall of text" that everyone hates in emails. And then there's the fact that Python has significant characters that are literally unreadable because they're invisible (semantic whitespace).

I never got the point against meaningful whitespace. It's indentation. You already indent blocks anyway; the only difference is that you don't need braces or begin/end. I also did not understand your point about "lack of whitespace" around blocks. The only difference between blocks in Python and other languages is that the block start uses a colon instead of an opening brace and you don't have a line for the closing…

As someone who recently switched to opening curly brackets on new lines and did some Python coding last week I kind of agree - you either put in empty lines everywhere or you have a continuous block of code through all scopes. It's a matter of preference and you can still work with it of course, but I've learned to appreciate reducing code density.

And regarding the syntax, using curly brackets like in C-like languages only takes one more symbol per scope and the difference in readability (where a scope ends etc.) is bigger for me. Also while indentation in Python kind of works as syntax it's not ideal as it can lead to literally invisible syntax errors, and imho the syntax isn't strict enough as Python allows you to have a different indentation width in every single scope.

That said it's still a great language for little experiments. Similar to Bash, despite Bash being not the best designed language to put it mildly.

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

#125
post #89
post #75

Earlier quoted context omitted.

Anecdote, but I like the Python community's emphasis on "readability counts". I did not get that from e.g. Ruby. Python's internals are also relatively accessible and easy to work with, so it's smooth sailing once you have that need. The language starts out easy, and grows with you. Of the languages I've tried (and there are many), only Smalltalk and the Lisp family were comparable in expressiveness. The language mos…

Python is among the least-readable languages for me. The lack of whitespace and brackets around code blocks just make it look like the "wall of text" that everyone hates in emails. And then there's the fact that Python has significant characters that are literally unreadable because they're invisible (semantic whitespace).

And yet I notice that you separated the paragraphs in your post using semantic whitespace rather than "BEGIN PARAGRAPH" / "END PARAGRAPH" or something similar, and it seems perfectly readable to me.

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

#126

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…

> Also, in Python integers do not overflow, unlike in Rust, C and other buggy languages. There is no such thing as a buggy language. Software can be buggy (or language implementation), but not the language. And the reason you do not have integer overflow is because integers are implemented as integer objects of arbitrary size, which is great if you're doing something quick and dirty, but could be disastrous for a ser…

>could be disastrous for a serious work.

How so?

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

#128
post #85

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…

Most recently, Python 3.11 changed syntax to allow for variadic generics: https://peps.python.org/pep-0646/#grammar-changes The other case that I remember off the top of my head is Python 3.6 adding annotations for variables that aren't created via function definitions: https://peps.python.org/pep-0526/

I actually meant to refer to PEP 526 when I said "python 3.5", thanks for that correction!

Also thanks about pointing out the syntax change for variadic generics! I still think my overall point about pace of "syntactic innovation" in static typing remaining slow stands, though. Just comparing equivalent typescript and python constructs:

This in TS:

  { member?: string, other_member: string }
is currently in python:

  from typing import TypedDict

  class SmallerObj(TypedDict, total=False):
    member: str

  class Obj(SmallerObj):
    other_member: str
Python 3.11 will shorten the above to:

  from typing import TypedDict, NotRequired

  class Obj(TypedDict):
    member: NotRequired[str]
    other_member: str

But still ...

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

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

Amateur coders always have flocked to the simple and unfashionable stuff. Basic used to be big for this reason. Javascript took off for this reason as well. Web designers could just copy paste javascript fragments in their web pages and get some simple things working. And python seems to appeal to a lot of amateur coders with non computer science backgrounds. At least I know a lot of people with physics, chemistry, bio medical, etc. backgrounds that seem to mainly know python.

Objectively, none of these languages are particularly good at what they do and there are other languages that tend to be preferred by people who code for a living. But these are harder to learn and have higher barrier for entry. You typically need some theoretical background and experience.

I've used all of the above BTW. I learned programming using the manual that came with my Commodore 64 in the eighties (Basic, obviously). I kind of like Python for some things. Javascript is fine for simple things. None of these are my first choice of language but I can work with these languages. They are very approachable languages. Just open an editor and start adapting code.

There's a lot of language snobbery out there where objectively, the advantages aren't that huge or dramatic as people like to believe.

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

#130
post #80

Earlier quoted context omitted.

>you'd still have to write everything twice: once in the real language, and once again in the type language Hmm, no I don't? Actually, 99% percent of the time I'm writing haskell, I can just write it like it's a dynamically typed language and the compiler/lsp will just say "Hey, I can see this is an int/string/list/whatever, want me to annotate that for you"? Hindley–Milner type systems are way way too powerful and I…

I haven't worked with Haskell enough to fully object to this, so any complaints I could come up with would be second hand, so I'll abstain. I don't feel fluent in Haskell yet, but my impressions so far were mostly not negative. I'm mostly complaining about static typing in the style of Mypy/Pyright and Java (and half of Scala, the other half is like Haskell). You know, the static typing one is likely to encounter in…

Scala is going to get "full" dependent types at some point. It's work in progress for a long time already (and it's actually quite close by now).

Besides that your argumentation makes no sens anyway whatsoever:

Fully dependent languages are undecidable by type inference alone. So you're forced "to write everything twice" especially in such a powerful language. But that's actually the whole point of it! Like you duplicate large chunks of your code when writing tests to verify your code in a dynamic language that exact same "duplication" in code when using proper static types is what actually helps to avoid casual errors. But the difference is of course that in the later case the machine can verify that both parts match up (which it can't in case of usual tests!).

On a side note: Why have you such strong opinions about typed languages if you didn't had much used a proper one at all as you say? Of course a type system like that of Java or C/C++ is a huge PITA, but that says nothing at all about static typing in general. Actually quite the contrary as Java's type system is especially painful (and therefore you need to cast your way through the whole time, which is not what static types are for in the first place). But you make general statements about static typing here the whole time. That doesn't seem justified imho.

Post reply on HN