News for hackers. Stuff that matters.
Re:What's New in Python 3.11? by systemvoltage on Monday June 27, 2022 @06:34AM (#31892665)
I want a programming language that’s boring. It should have things that Python has including classes. Fast and compiled. No need to try new things.

A pythonic C++ that doesn’t smell bad.

I wish Go had classes. I like those damn things. Extending a Dog from Animal with all the methods and data in one place is nice.

Re:What's New in Python 3.11? by kortex on Monday June 27, 2022 @10:22AM (#31894971)
> A pythonic C++ that doesn’t smell bad.

Obligatory...try Rust?

But actually, try python with mypy and mypyc. It's still a little experimental, but if you stick to simple constructs it works well, and you can compile straight python to fast, static libraries, without using goofy cython syntax.

Re:What's New in Python 3.11? by bostik on Monday June 27, 2022 @12:13PM (#31896670)
If by extending you mean that you want to have a type that includes ALL the functionality of another type, without needing to fill in each method, that's already supported.

In your new struct definition, include the desired base type as a member - without giving it a name. That embeds the unnamed member directly, and your new type automatically gets all the interfaces and their underlying implementations. As a python-person I always found this a somewhat odd mechanism, but from a functionality perspective it satisfies what I have wanted to do.

Guess that's what people mean by composability.

Re:What's New in Python 3.11? by gunapologist99 on Monday June 27, 2022 @03:10PM (#31899300)
You should check out Nim. I wish more people would! https://nim-lang.org/
Re:What's New in Python 3.11? by xigoi on Monday June 27, 2022 @04:49PM (#31900598)
I like Nim, but it's not for someone who likes classes.
Re:What's New in Python 3.11? by nimmer on Wednesday June 29, 2022 @05:01PM (#31925656)
Nim supports classes and methods.
Re:What's New in Python 3.11? by xigoi on Wednesday June 29, 2022 @05:14PM (#31925795)
It has methods, but doesn't really have classes. And class-oriented programming is unidiomatic in Nim.
Re:What's New in Python 3.11? by chakkepolja on Monday June 27, 2022 @12:32PM (#31896956)
I think you can reasonably represent inheritance using struct embedding, and that's quite idiomatic in Go.
Re:What's New in Python 3.11? by francoispon on Monday June 27, 2022 @06:50AM (#31892769)
can't you get away with just composing the structs, sure not exactly the same but does a good job still