4,485 karma · joined Jun 30, 2015 (11y ago) · 2,043 submissions
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
Regarding your skeptism of immutable data structures, it's best to think of immutable data and data structures as copy-on-write instead of update-in-place. This is a technique that is currently very underused, for example most programming languages do not come with "persistent" copy-on-write collections.
Here is an example text editor built using immutable data structures in C++: https://github.com/arximboldi/ewig
Advantages are excellent support for concurrency (background save works while you edit) and trivial support for undo/redo.
comment 6y ago · link · parent
What nearly every language calls a variable today, is probably better described as a "reference" or "assignable", but sadly that ship has sailed and we'll forever be inconsistent with the math terminology for that one. Immutable variable is therefore a useful synonym for "proper variable".
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
You can mutate state on the inside, but still provide a "pure" mathematical function on the outside. For example, a root finding solver. The general problem/feature with objects, is that when a method returns, the object may be in a different state (and often is). Such state changes are hidden but not "encapsulated" as they still contribute to the global state of your application. In other words, the global variables are still there, you've just organised them into modules.
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
https://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/b...
comment 6y ago · link · parent
With a statically typed language, the choice is up to you. Every statically typed language is just a "dynamically typed" language with the ability to statically assign types. For example, you can type the variable as an "Int" or for more runtime flexibility, a "Variant" (if using C++).
comment 6y ago · link · parent
If I could get all the games and educational apps we use on the iPad on another platform, I would ditch Apple in a heartbeat.
comment 6y ago · link · parent
"The expression problem is a new name for an old problem. The goal is to define a datatype by cases, where one can add new cases to the datatype and new functions over the datatype, without recompiling existing code, and while retaining static type safety (e.g., no casts)."
With a sufficiently expressive language, the expression problem can be solved, sometimes in multiple ways. However, the solutions often involve boilerplate, trickery or advanced type system features. A proposed solution to the expression problem may be impractical, but that is subjective and really a separate discussion.
I guess you could view the problem as a sort of lens with which to evaluate a language. E.g. Can this language solve the expression problem and what does the best solution look like?
comment 6y ago · link · parent
is a great example of using ideas from functional programming and category theory to improve on the visitor pattern, such that the expresson problem can be solved.
The value of such mathematics is that it enables us to formalise some of these patterns and generalise them.