Live data from Hacker News

Erg: a statically typed language that is Python compatible

github.com

81–90 of 194 posts

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

#81
post #38

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.

- Huge ecosystem. - Common stuff (opening files, dealing with databases, string processing, math, regexps) is very easy. Sane defaults. - Works well with the existing C ecosystem. It's not a "rewrite everything in X" language. - It's everywhere, most machines run Python just fine. - It doesn't treat Windows like a second-class citizen. - It doesn't force upon you a programming model that you might or might not care a…

To be fair, Microsofts citizen status is self inflicted. There was a time when they were actively hostile to programming languages not built in house. See, for example, Java. https://en.m.wikipedia.org/wiki/Embrace,_extend,_and_extingu...

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

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

Many reasons, many are of course pretty subjective, but it's been called 'executable pseudocode' for good reason. Out of all the languages I've used, it gets in the way the least, and often by a pretty wide margin.

I agree that working with Python code from an undisciplined/sloppy/inexperienced developer can be a pain (although in those situations I've found code from those same developers in others languages to be a problem too, but maybe worse in Python? I dunno), but in the hands of a solid dev, Python code is so readable and easy to follow, that to me code in other languages often feels much noisier. YMMV of course.

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

#83

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.

Oh, man, have I got a treat for you: go checkout hylang.org - Hy is a lisp that (ab)uses the python AST to give you access to the entirety of python, but gives you a pretty lisp syntax.

I've always been super interested in Hy but couldn't ever get it working. Any suggestions for forums or good installation instructions or tutorials? I live Clojure and also have to deal with a lot of Python at work so would be awesome to use lispy syntax to write my Python stuff

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

#84

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…

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

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

#85

Not sure why I'd want to use this, presuming I was already happy with python. Especially now that python's type hinting is more mature. Looking through the feature set the main thing it seems to provide is a type system, but with a syntax I don't like as much as python's type hinting.

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/

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

#86
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

To provide some rationale, the '!' syntax distinguishes declarations from imperative constructs or effectful statements. You will see similar syntactic sugar in Haskell (do notation), F# (computation expressions), and probably others - they are often abstractions for specific monad-wrangling patterns, and won't look out of place for many in a more functional-style language.

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

#89
post #75

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.

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

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

#90

Earlier quoted context omitted.

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

Sorry, but MyPy and friends can barely hold a candle to what actual static-typing systems do - Rust, Haskell, OCaml, Typescript, even .Net (C#/F#) offer more safety and guarantees.

Type hints in python are _just that_, they're hints. The whole "typed" python ecosystem relies on packages and the language using them, using them correctly, and using them consistently. In my experience so far, I've seen little widespread use, and nothing from core python, which is a huge hole IMO.

Post reply on HN