Live data from Hacker News

Erg: a statically typed language that is Python compatible

github.com

91–100 of 194 posts

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

#91

Nim is a statically typed language that is syntactically close to Python and there are some attempts at integrating the two.

Erg looks fun for small programs. Though Erg's syntax choices seem less Pythonic than I'd expected. Interesting though, some of the idioms seem handy.

Though Nim definitely can be described as a statically typed Python-compatible language! I haven't used them but https://github.com/Pebaz/nimporter https://github.com/yglukhov/nimpy both seem great. Nimporter in particular looks fantastic for writing fast python libraries.

Actually come to think of it that might be the easiest way to write fast KiCad 6 plugins.. I really want to try making a native KiCad autorouter. But I don't want to figure out the C++ plugin setup and since KiCad 6 the Python APIs seem better documented and supported anyways. Problem is that Python would likely be too slow. Nimporter could be perfect. It looks really simple to setup.

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

#92

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…

Wow, I thought Rust's integers would let you handle integer overflows.. Apparently thats not the case and overflows are only checked in debug builds and then they just panic. Huh.

After programming in Nim (and Python back in the day), I've become used to being able to detect integer overflows as a normal exception. At least for signed ints, since not all CPU support efficient overflow detection on unsigned ints. Its handy to to let uints wrap as sometimes thats what you want. I figured all new languages would do similar things.

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

#93
post #73

Earlier quoted context omitted.

I suspect the same. People adopt Python because its clean syntax and REPL make the language approachable and easy to get started and then the huge library ecosystem helps you glue together (in a good way) powerful systems. But how many Python users and libraries actually use the language’s extremely dynamic runtime behavior? Something they’re paying for with a big performance penalty and surprising bugs.

Numpy uses magic methods (Python's version of operator overloading). Django uses metaclasses. Pytest dynamically rewrites assert statements using AST. I'd say it's pretty common, at least in libraries. I certainly depend on Python's dynamism when fully leveraging the REPL.

Indeed, these capabilities of the language are some of its strengths, even if we don't all trust ourselves to use them. The casual programmer doesn't know how or why numpy works, and we don't play with magic methods except out of curiosity. The people who do maintain numpy are using more formal methods to ensure its quality.

In the case of Python, the things that professional caliber programmers can use to extend its functionality, and the things that the rest of us can use to be productive, are the same language and are not hidden from one another. This is not the case in some languages of the past, e.g., you could use objects in Visual Basic but not build them without another language or eventually a special version.

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

#94
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’ll also vouch for it.

Plus, at least half a dozen highly funded people have tried to recreate TypeScript and have failed. Microsoft is flawed, but they can make a mean type checker.

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

#95
post #38

Earlier quoted context omitted.

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

Nah, it is only for UNIX folks that see UNIX everywhere, and start complaing when an OS isn't POSIX compatible.

Even on those days there were always Java alternatives to chose from, J++ wasn't required.

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

#96
post #95

Earlier quoted context omitted.

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

Nah, it is only for UNIX folks that see UNIX everywhere, and start complaing when an OS isn't POSIX compatible. Even on those days there were always Java alternatives to chose from, J++ wasn't required.

I mean, you can say 'nah' all you'd like, but there's a whole section in that link on their hostility to Java. Including choice anti-competitive gates quotes!

Can't say I'd blame any language dev who saw that, and said 'no thanks'.

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

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

> It doesn't force upon you a programming model that you might or might not care about. It's not a puzzle language where everything is a monad, or everything is a class, or everything is some weird widget. Write the damn code.

Yeah, I second this. There is some foot guns you'll hit in python, but the amount of foot guns I've hit in C++ and golang are 10x that of python.

The other thing is that over time, the python devs actually strive to make development easier, and they try to resolve foot guns where they can. In golang, e.g., Rob Pike is very opinionated about how software should be written, and it's carried forward in the language. Python on the other hand, recommends people be "pythonic", but only encourages it, and doesn't enforce it upon the user.

> I'd still rather write medium-to-large pieces of software (say 10,000+ LOC) in something else (Java, C#, C++, something boring like that), but it's pretty much unbeatable for small programs as far as I'm concerned.

What I've learned is the python requires unit tests, as does golang, or basically any language that can throw a null pointer err.

If you write your code modularly and have good unit tests around your code, it works amazingly well. I've been a part of good and bad large python projects. The best ones have really good unit tests around their code.

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

#98

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…

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 ruined everything. Python is the ML language, so every package likely depends somehow on tensorflow or some GPU acceleration. This is a problem because every damn version of ' insert tf/pytorch/Jax/cuda/etc ml package here' only works with that exact version configuration ONLY ( and honestly, it probably doesn't actually work anyway). So, if you have an idea of using two packages together that aren't already in a package - be prepared to spend the next month trying in despair to get that to work (and probably ultimately give up).

It's insane to me that the workflow of today necessitates (in python anyway) setting up multiple docker containers to talk to each other, simply because python packages seem to have no problem making breaking changes every freaking week.

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

#99
post #95

Earlier quoted context omitted.

Nah, it is only for UNIX folks that see UNIX everywhere, and start complaing when an OS isn't POSIX compatible. Even on those days there were always Java alternatives to chose from, J++ wasn't required.

I mean, you can say 'nah' all you'd like, but there's a whole section in that link on their hostility to Java. Including choice anti-competitive gates quotes! Can't say I'd blame any language dev who saw that, and said 'no thanks'.

That did not change the fact that Java worked perfectly alright on Windows, the same cannot be said for many FOSS languages that insist all OSes are UNIX clones.

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

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

- 1 Numpy and Scipy are nice for both scripting, and as a super-calculator with ipython. (albeit poorly documented)

- Django is a robust, batteries-included web framework that doesn't have an analog in, for example, Rust.

Post reply on HN