You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
- 2I would think a game is one of the worst possible examples to demonstrate the supposed "benefits" of enforced immutability. Things are constantly moving around in a game, which means you've got to be rebuilding your game state all the time. And if everything is immutable, that means that you have to not only rebuild the game state, but everything in the graph that holds a reference to it, or that holds a reference to that, and so on recursively until you're recycling the entire program at 30+ FPS, with tons of GC churn to boot! There's no way you get good performance out of that...Mason Wheeler– Mason Wheeler2012-01-12 05:51:17 +00:00Commented Jan 12, 2012 at 5:51
- 7Of course games are hard with immutability - that's why I chose it to demonstrate that it can still work! However you'd be surprised what persistent data structures can do - most of the game state doesn't need to be rebuilt, only the stuff that changes. And sure there is some overhead, but it's only a small constant factor. Give me a enough cores and I'll beat your single-threaded C++ game engine.....mikera– mikera2012-01-12 06:06:32 +00:00Commented Jan 12, 2012 at 6:06
- 3@Mason Wheeler: Actually, it is possible to get virtually equal (as good as with mutation) performance with immutable objects, without much GC at all. The trick in Clojure is using persistent data structures: they're immutable-to-the-programmer, but actually mutable under the hood. Best of both worlds.Joonas Pulakka– Joonas Pulakka2012-01-12 08:16:39 +00:00Commented Jan 12, 2012 at 8:16
- 4@quant_dev More cores are cheaper than better cores... escapistmagazine.com/news/view/…deworde– deworde2012-01-12 11:13:43 +00:00Commented Jan 12, 2012 at 11:13
- 6@quant_dev - it's not an excuse, it's a mathematical and architectural fact that you are better having a incurring a constant overhead if you can make up for it by scaling your performance near-linearly with the number of cores. The reason functional languages will ultimately offer superior performance is that we have come to the end of the line for single core performance, and it will all be about concurrency and parallelism in the future. functional approaches (and immutability in particular) are important in making this work.mikera– mikera2012-01-12 11:21:18 +00:00Commented Jan 12, 2012 at 11:21
| Show 6 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you