Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Chris Ahlstrom Newsgroups: comp.os.linux.advocacy Subject: Re: Why Python When There Is Perl? Date: Wed, 3 Apr 2024 08:28:07 -0400 Organization: None Lines: 57 Message-ID: References: <17be420c4f90bfc7$63225$1585792$802601b3@news.usenetexpress.com> Reply-To: OFeem1987@teleworm.us MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 03 Apr 2024 12:28:10 +0200 (CEST) Injection-Info: dont-email.me; posting-host="4f192940848a230e4019e60c0cbac98b"; logging-data="4124948"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18acgGjUOTbF2ispiT+eaxM" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:uR4o0dFphTo0LuSYjgmOhysGGG0= X-User-Agent: Microsoft Outl00k, Usenet K00k Editions X-Slrn: Why use anything else? X-Mutt: The most widely-used MUA Bytes: 3775 Lawrence D'Oliveiro wrote this copyrighted missive and expects royalties: > On Tue, 2 Apr 2024 08:51:57 -0400, Chris Ahlstrom wrote: > >> Lawrence D'Oliveiro wrote this copyrighted missive and expects >> royalties: >> >>> On Sun, 24 Mar 2024 09:39:21 -0400, Chris Ahlstrom wrote: >>> >>>> C++ can do template metaprogramming. >>> >>> Python doesn’t need two different languages for “compile-time” versus >>> “run-time” programming; it uses the same language for both. >> >> I think that Alexander Stepanov would say..... [some incomprehensible >> C++ technical term] > > Also, consider enums. I think C++ only has the old, boring, C-style enums. Nah, it also has "enum class" etc. https://en.cppreference.com/w/cpp/language/enum > Java managed to introduce quite an advanced enum facility, with the > ability to attach custom methods and attributes to enum instances. The C++ enum-class is scoped and strongly typed, thus a bit restrictive. Implicit conversion (e.g. to int or char) is not supported. In some cases, it is useful to write free functions or operators to do things with them. It gets tiresome peppering code with static_cast<>. > Python offers the same sort of thing as Java. Only, whereas Java enums are > a feature that is built into the core language, Python does it as a > standard library module, written in pure Python. > > How do we do it? Metaclasses! (Also descriptors help.) > >>> Function definitions and class definitions are not declarations: they >>> are just forms of assignment statement. >>> >>> And then there are metaclasses ... >> >> I wonder if the C++ metaclass proposal ever made it into C++. Will have >> to check.... > > I’ll be waiting. Sounds like not. Apparently not considered worth the effort in the end. After all, we already have abstract base classes and templates. -- In the plot, people came to the land; the land loved them; they worked and struggled and had lots of children. There was a Frenchman who talked funny and a greenhorn from England who was a fancy-pants but when it came to the crunch he was all courage. Those novels would make you retch. -- Canadian novelist Robertson Davies, on the generic Canadian novel.