Posted by azhenley 10/31/2025
df = pd.concat(df,other_df)
df = df.select(...)
...
My eyes hurts, when I see it. It makes me avoid python.
I bet the reason for this mutable code is a missing simple pipes syntax.
I love pipes. In R can do: df |>
rbind(other_df) |>
select(...)
It feels much better.Typically you align a pipeline like so:
df
|> rbind(other_df)
|> select(...)
But these topics are largely left to code formatters these days. df = pd.concat(df,other_df).select(...)- https://github.com/elixir-explorer/explorer - https://hexdocs.pm/explorer/Explorer.html
https://github.com/hsutter/cppfront/wiki/Design-note%3A-cons...
An important thing to keep in mind is just how far compilers have come over the least 40 years. Often, with immutable languages, they can do extremely efficient compile only optimizations because of said guaranteed immutability by default.
Its not true in every case, of course, but I think for most situations compilers do a more than good enough job with this.
clc
lda value
adc #1
sta value
lda value+1
adc #0
sta value+1
value .byte 0,0
These constraints are pretty much built into my concept of programming and it would take great effort to break out of it. It feels nice doing: x = 20
x = x + func(y)
x = x / func(z)
And it would feel weirdly wasteful to do: x = 20
x1 = x + func(y)
x2 = x1 / func(z)
Like, I know that variables are no longer a scarce resource, but my brain still wants to conserve them.Ultra-pedantic const-correctness (vs tasteful const-correctness on e.g. pass-by-reference arguments or static/big objects) catches nearly no bugs in practice and significantly increases the visual noise of your code.
If you have luxury of designing a new language or using one with default mutability then do so, but don't turn C coding styles into C++-envy, or C++ coding styles into Rust-envy.
It's worth it, though. Every variable that isn't mutated should be const. Every parameter not mutated should be const, and so should every method that doesn't mutate any fields. The mutable keyword should be banned.
`let` is so 2020. `const` is too long. `static` makes me fall asleep at the keyboard. `con` sounds bad. How about
`law`?
law pi = 3.142 (heh typing on Mac autocompleted this)
law c = 29979245
law law = "Dredd"
or `set` or `once` or `make`?I think it never gained traction but it would have been nice to have this in Java
val firstName = "Bob";
val lastName = "Tables";
var fullName = "";
fullName = firstName + " " + lastName;Also related, it annoys me that Java has final but otherwise poor/leaky support for immutability. You can mark something final but most Java code (and a lot of the standard library) uses mutable objects so the final does basically nothing... C++ "const" desparately needs to spread to other languages.
There's nothing in it to say it's specifically for defining a value only ONCE.
Similar to how "tail recursion can (usually) be lifted/lowered to a simple loop...", immutability from language statements can often be "collapsed" into mutating a single variable, and there may be one or two "dances" you need to do to either add helper functions, structure your code _slightly_ differently to get there, but it's similar to any kind of performance sensitive code.
Example foo(bar(baz(), bar_alt(baz_alt(), etc...))) [where function call nesting is "representing" an immutability graph] ...yeah, that'd have a lot of allocations and whatever.
But: foo().bar().bar_alt().baz().baz_alt().etc(...) you could imagine is always just stacking/mutating the same variable[s] "in place".
...don't get hung up on the syntax (it's wildly wrong), but imagine the concept. If all the functions "in the chain" are pure (no globals, no modifications), then they can be analyzed and reduced. Refer back to the "Why SSA?" article from a week or two ago: https://news.ycombinator.com/item?id=45674568 ...and you'll see how the logical lines of statements don't necessarily correspond to the physical movement of memory and registers.
> Having all the intermediate calculations still available is helpful in the debugger