From: Alejandro Colomar <alx.manpages@gmail.com>
To: tuhs@tuhs.org
Subject: [TUHS] Re: [TULSA] Re: python
Date: Thu, 3 Aug 2023 19:29:00 +0200 [thread overview]
Message-ID: <8e45b8b1-cf3c-e47c-bd15-d19a2ae5cc1d@gmail.org> (raw)
In-Reply-To: <202308031657.373GvVvW008640@ultimate.com>
On 2023-08-03 18:57, Phil Budne wrote:
> On the subject of "no printf", there is not one, not two, but THREE
> ways to format strings, easily compounded with print:
>
> print("%s %s" % ("hello", "world"))
> print("{1} {two}".format("hello", two="world"))
> print(f"{greeting} {populace}")
>
> I'm pretty sure the last method (which initially made me vomit, due to
> violating my hardwired ideas about complicating the lexer, as if it
> can even be thought of as a separate layer), BUT I Seem To Recall that
> it allows a class to implement a formatting method, which may (or may
> not) work for complex numbers.
Actually, there's no need to move away from printf(3) for customization.
glibc provides register_printf_specifier(3), register_printf_modifier(3),
and register_printf_modifier(3), with which you can register %S for
printing your very nice struct. You can even register modifiers, such as
%vS for printing your structure in a different manner.
Of course, those APIs are not portable, but that's a matter of porting
them; you don't need to invent a completely new formatted print variant
just to do that.
How does one even specify the equivalent of "%+'0#8.5f" in the new {}
formats??
Of course, there may be reasons to move away from printf(3): C++ seems
to have a faster thing with std:format (or so they claim; I didn't try
it). But if speed is not a problem, I'd keep the good ol' syntax that
everybody knows. No need to make everybody learn a "cool" new print
function, that probably won't be as tunable as printf(3) is.
Another thing is type safety. printf(3) is actually type-safe. At least
as long as you use powerful compilers that can diagnose misuses of
printf-like APIs. GCC provides [[gnu::format()]] for a reason. And if
you customize printf with your own formats, Clang has tools for checking
those too.
>
> Type "hinting" has been mentioned: again, it's almost like a whole new
> version of the language. You need to pick a type checker, and likely
> turn up the knobs to achieve any actual safety, and then deal with the
> fact that not all packages supply hints out of the box. It kind of
> offers the desert-topping/floor-wax dichotomy: You can easily/quickly
> write small programs with dynamic typing for quick one-offs, AND write
> better armored code for libraries & production code.
>
> On tabs vs spaces: Python3 forbids mixing them. Again, fascist, but
> "it's for your own good".
>
> So yes, Python sucks, but I continue using it, and unlike sendmail
> (which I continue to run, as I have a 200+ line .mc file it would take
> me at LEAST a week to replicate the effects of in another MTA), I
> don't tell people Python is unsuitable at any speed.
>
> I'd probably happily write Go or Rust, given a situation (existing
> project/program) where its use was inevitable, and I DO have a program
> I think is a good candidate for rewriting in Go, but on the whole,
> it's a useful tool for many kinds of programmers, and in many
> situations, which I think is somewhat remarkable.
I'll go a little step further, and claim that newlines being significant
is another bad decission. It's one of the things I dislike from
languages, including sh(1). My scripts end up having a lot of escaped
newlines, because I find the pipe to be more readable and pleasant as
foo \
| bar
rather than
foo |
bar
While I can forgive that in the shell, because interactive mode is as
important as scripts, I can't do the same with Go. Go is a programming
language, and having newlines be significant is nonsense. Saving from
typing ;s is a similar excuse that the one python used for saving typing
{}s. And the consequence is that due to that fascist rule of go, I
can't put the opening brace of a function declaration in a new line; it
must be sticked to the same line as the function declarator.
I never enjoyed Go, and that was the main reason. In any case, I never
found a need for it. Most (all?) of what I do can be done with sh(1)
or C.
Alex
next prev parent reply other threads:[~2023-08-03 17:29 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-30 18:22 [TUHS] Re: Cool talk on Unix and Sendmail history, by Eric Allman Norman Wilson
2023-07-30 21:43 ` Rob Pike
2023-07-30 23:34 ` George Michaelson
2023-07-30 23:59 ` Erik E. Fair
2023-07-31 0:26 ` Warner Losh
2023-07-31 22:57 ` Grant Taylor via TUHS
2023-07-31 23:05 ` Warner Losh
2023-08-01 2:45 ` Grant Taylor via TUHS
2023-08-01 1:51 ` Niklas Karlsson
2023-08-01 2:47 ` Grant Taylor via TUHS
2023-08-01 3:20 ` Theodore Ts'o
2023-07-31 0:41 ` segaloco via TUHS
2023-08-01 9:22 ` Marc Donner
2023-08-01 10:58 ` Erik E. Fair
2023-08-02 0:37 ` Dave Horsfall
2023-08-02 14:52 ` Ron Natalie
2023-08-02 21:14 ` Grant Taylor via TUHS
2023-08-02 22:20 ` segaloco via TUHS
2023-08-02 22:37 ` Warner Losh
2023-08-02 23:49 ` Rich Salz
2023-08-03 0:51 ` [TUHS] Re: python Larry McVoy
2023-08-03 1:20 ` George Michaelson
2023-08-03 2:53 ` Bakul Shah
2023-08-03 2:55 ` segaloco via TUHS
2023-08-03 3:24 ` George Michaelson
2023-08-03 3:32 ` Warner Losh
2023-08-03 3:55 ` Bakul Shah
2023-08-03 8:32 ` Rob Pike
2023-08-03 14:19 ` Bakul Shah
2023-08-03 14:56 ` Dan Halbert
2023-08-03 15:20 ` will.senn
2023-08-03 22:05 ` Dan Cross
2023-08-04 0:24 ` John Cowan
2023-08-04 15:17 ` Dan Cross
2023-08-05 4:44 ` Bakul Shah
2023-08-03 15:41 ` John Cowan
2023-08-03 2:07 ` Clem Cole
2023-08-03 2:21 ` Pete Wright via TUHS
2023-08-03 2:56 ` Warner Losh
2023-08-03 12:36 ` Mike Markowski
2023-08-03 13:29 ` Rob Pike
2023-08-03 15:24 ` emanuel stiebler
2023-08-03 15:39 ` Steffen Nurpmeso
2023-08-04 1:01 ` Larry McVoy
2023-08-04 1:28 ` segaloco via TUHS
2023-08-04 1:58 ` Adam Thornton
2023-08-04 15:04 ` Dan Cross
2023-08-04 15:10 ` Larry McVoy
2023-08-03 16:57 ` [TUHS] Re: [TULSA] " Phil Budne
2023-08-03 17:00 ` Rich Salz
2023-08-03 20:35 ` [TUHS] Split addressing (I/D) space (inspired by the death of the python... thread) Will Senn
2023-08-03 21:05 ` [TUHS] " Kenneth Goodwin
2023-08-03 21:10 ` Ronald Natalie
2023-08-03 21:16 ` Warner Losh
2023-08-03 21:24 ` Ronald Natalie
2023-08-03 22:34 ` Kenneth Goodwin
2023-08-03 21:05 ` Ronald Natalie
2023-08-03 21:44 ` Clem Cole
2023-08-03 22:08 ` Will Senn
2023-08-03 22:54 ` Clem Cole
2023-08-03 23:08 ` Dave Horsfall
2023-08-03 23:15 ` Clem Cole
2023-08-04 0:38 ` John Cowan
2023-08-03 17:29 ` Alejandro Colomar [this message]
2023-08-03 17:51 ` [TUHS] Re: [TULSA] Re: python John Cowan
2023-08-03 18:05 ` Alejandro Colomar
2023-08-03 21:29 ` Dan Cross
2023-08-03 23:55 ` [TUHS] printf (was: python) Alejandro Colomar
2023-08-04 16:06 ` [TUHS] " Dan Cross
2023-08-04 16:57 ` Alejandro Colomar
2023-08-04 21:16 ` Dan Cross
2023-08-03 21:02 ` [TUHS] Re: [TULSA] Re: python Steffen Nurpmeso
2023-08-03 23:47 ` Larry McVoy
2023-08-03 23:54 ` Will Senn
2023-08-04 19:20 ` [TUHS] " Ed Bradford
2023-08-04 19:47 ` Larry McVoy
2023-08-05 5:40 ` Ed Bradford
2023-08-02 23:33 ` [TUHS] Re: Cool talk on Unix and Sendmail history, by Eric Allman Dave Horsfall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e45b8b1-cf3c-e47c-bd15-d19a2ae5cc1d@gmail.org \
--to=alx.manpages@gmail.com \
--cc=tuhs@tuhs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).