News for hackers. Stuff that matters.
Re:Is your programming language unreasonable? (2015) by vram22 on Saturday October 10, 2020 @02:40PM (#24740921)
Interesting. Can you explain, with a somewhat simple example, how this can be efficiently implemented, or at all? I mean preserving the appearance of immutability at the source language level, while mutating the original structure under the hood for performance.
Re:Is your programming language unreasonable? (2015) by Athas on Saturday October 10, 2020 @04:19PM (#24741576)
Any vectorised operation in Numpy is an example of this. The pure subset of Numpy can be used to write useful programs, but the Numpy functions/methods are mostly implemented in impure C.

Another example is completely pure array programming such as in Accelerate[0] or Futhark[1].

[0]: http://www.acceleratehs.org/

[1]: https://futhark-lang.org

Re:Is your programming language unreasonable? (2015) by senkora on Sunday October 11, 2020 @09:49PM (#24750738)
A somewhat related idea is called "benign effects." The idea is that you write code with an immutable interface that uses mutation in its implementation.

So there are "effects" (non-functional state changes) that are encapsulated ("benign").

I learned this term in reference to Standard ML at CMU.

This is different from what you're asking because it isn't a compiler optimization and it isn't actually checked by the language at all, but it works pretty well in practice.

It's like unsafe in Rust: you write most of your code assuming a useful property that you then break in the small percentage of code that needs to break it.

Re:Is your programming language unreasonable? (2015) by kdmccormick on Saturday October 10, 2020 @10:23PM (#24743363)
Not very knowledgable on this myself, unfortunately, but I believe that in graphics programming, shaders written in GLSL often take the form of a series of functional, mathematical transformations of vertices. Those transforms are run in the GPU as highly parallelized array operations, probably using a lot of mutable state. But those details are mostly hidden from the shader programmer.
Re:Is your programming language unreasonable? (2015) by zabzonk on Saturday October 10, 2020 @03:26PM (#24741220)
C++ supports this via the mutable keyword https://stackoverflow.com/questions/105014/does-the-mutable-... though not particularly for performance purposes.
Re:Is your programming language unreasonable? (2015) by vram22 on Sunday October 11, 2020 @01:21AM (#24743896)
Thanks to all who replied.