Should I represent database data with immutable or mutable data structures?

后端 未结 3 2176
清歌不尽
清歌不尽 2021-02-13 23:13

I\'m currently programming in Scala, but I guess this applies to any functional programming language, or rather, any programming language that recommends immutability and can in

3条回答
  •  隐瞒了意图╮
    2021-02-13 23:46

    "Interacting with the real world" has nothing to do with whether you use mutable or immutable data structures. This is a furfy that is repeated all too often and it is great that you have questioned it.

    While it is typically more healthy to dismiss garbage like this, you might be interested in a cursory debunking: http://blog.higher-order.com/blog/2012/09/13/what-purity-is-and-isnt/

    However, I strongly recommend dismissing it and moving on.

    Onto your question, you say you have boilerplate when you want to perform operations on your immutable data structures. In fact, there is very well established theory that solves this problem to a large extent. Here is a paper written about it using Scala:

    http://dropbox.tmorris.net/media/doc/lenses.pdf

    Hope that helps.

提交回复
热议问题