News for hackers. Stuff that matters.
Re:Immutable Data Structures That Are Compatible with Normal... by setzer22 on Sunday August 13, 2017 @04:12AM (#15002054)
There is a huge loss in usefulness for immutable objects when immutability is not a default and you have that many different implementations.

The thing I like about immutability in languages that implement it by design is that you know that if you get an data structure, it is immutable. In the world of javascript, you not only have to worry about whether an object you get from a library is immutable, but which kind of immutable implementation is using. Moreover, that information is not easily available in the type signatures, so you have to go to the library author's documentation, if any! That, to me, is a complete mess.

Re:Immutable Data Structures That Are Compatible with Normal... by Rotareti on Sunday August 13, 2017 @08:10AM (#15002590)
I totally agree with you. I wish we had a built-in immutable array type and a built-in immutable object type. I love the way it's done in Python, where you have Lists vs Tuples and Class Objects vs NamedTuples. You can consume them the same way:

    my_list = [1,2,3] # mutable
    my_tuple = (1,2,3) # immutable
    my_clsobj = myclass(foo=1, bar=2)  # mutable
    my_namedt = mynamedt(foo=1, bar=2) # immutable

    my_list[0] # 1
    my_tuple[0] # 1
    my_clsobj.foo # 1
    my_namedt.foo # 1
Re:Immutable Data Structures That Are Compatible with Normal... by macintux on Sunday August 13, 2017 @02:08PM (#15004065)
More generally, this is why I don't find languages that add "functional" features very compelling.

Behavior is so well-defined in a functional system that it's intensely frustrating dealing with any imperative/OO language.