Earlier quoted context omitted.
Would you work in a programming language called Hitler? Any multinational company needs to do their research before deciding on a name.
Well, you already have java formal verification tool named Bandera http://bandera.projects.cs.ksu.edu/people.shtml (which name is obviously choosen by Oksana Tkachuk, one of the tool authors)
Swift is like Kotlin
311–320 of 364 posts
Re: Swift is like Kotlin
#312The article is missing the similarities between Swift Optionals and Kotlin Nullables. Swift code: var name: String? name? ///returns a safe value name! ///returns an unsafe value and throws an exception in case of a nil value if name != nil { ///Now we can use name! forcing unwrap because we know it's not nil } if let unwrapedName = name { /// Here we can use unwrapedName without forcing the unwrap } The null checks…
var name: String?
// some code
name?.let {
// here name is not nil and can be accessed via variable "it"
}
// or
name?.let { name ->
// here name shadows the previous variable, and is not nil
}Re: Swift is like Kotlin
#313Re: Swift is like Kotlin
#314Earlier quoted context omitted.
You can have immutability by making the setters methods of a class private. So if you combine it with "val" you have immutable objects. It is a bit more job in kotlin but as it is also object oriented programming you can achieve exactly what you want. And for structures you have list, mutablelist, map, mutablemap, etc. What else do you want?
Looks like there is some distinction between Mutable, Read-only View and Immutable. According to this http://stackoverflow.com/questions/33727657/kotlin-and-immut... Kotlin does not support true immutability. For immutability to be practical one would need to implement structural sharing in their collections otherwise copying would be prohibitively expensive. This Java library seems to be trying to implement this. ht…
out of curiosity, what cases will you use an immutable collection instead of a read-only? I cannot imagine any use case where immutable is a gain over read-only.
Re: Swift is like Kotlin
#315Earlier quoted context omitted.
You can have immutability by making the setters methods of a class private. So if you combine it with "val" you have immutable objects. It is a bit more job in kotlin but as it is also object oriented programming you can achieve exactly what you want. And for structures you have list, mutablelist, map, mutablemap, etc. What else do you want?
Looks like there is some distinction between Mutable, Read-only View and Immutable. According to this http://stackoverflow.com/questions/33727657/kotlin-and-immut... Kotlin does not support true immutability. For immutability to be practical one would need to implement structural sharing in their collections otherwise copying would be prohibitively expensive. This Java library seems to be trying to implement this. ht…
Re: Swift is like Kotlin
#316I find it very annoying that Google and Apple are creating new languages to solve similar problems and not worrying about cross platform. If you write for Apple you've been told to use Objective-C and Swift. If you're on Android it's Dart and now Kotlin. None of that stuff is used for Windows or Linux development or even mobile on the other OS. I'm not a fan of proliferation of "platforms" but when it goes beyond lib…
Re: Swift is like Kotlin
#317Earlier quoted context omitted.
Looks like there is some distinction between Mutable, Read-only View and Immutable. According to this http://stackoverflow.com/questions/33727657/kotlin-and-immut... Kotlin does not support true immutability. For immutability to be practical one would need to implement structural sharing in their collections otherwise copying would be prohibitively expensive. This Java library seems to be trying to implement this. ht…
I get your point now. Yes, it is read-only, not immutable. For me, I only need read-only. I think kotlin wasn't meant to be pure functional. I see it as object oriented with some functional programming. out of curiosity, what cases will you use an immutable collection instead of a read-only? I cannot imagine any use case where immutable is a gain over read-only.
Consider the situation where you had a linked list with 10,000 elements and you wanted to return a new list with one new element added to the 'head' of the list. With "read-only" you would literally have to make a new linked list with 10,001 elements which would kill performance.
While semantically correct, immutability via deep-copying is very impractical. So, immutability (of Collections in particular) needs to be implemented via structural sharing of elements.
In the above example, with structural sharing, the new list would have the new element and inside would point to the old 10,000 element list but the whole 'structure' would appear to you as just a normal list.
Re: Swift is like Kotlin
#318Earlier quoted context omitted.
Looks like there is some distinction between Mutable, Read-only View and Immutable. According to this http://stackoverflow.com/questions/33727657/kotlin-and-immut... Kotlin does not support true immutability. For immutability to be practical one would need to implement structural sharing in their collections otherwise copying would be prohibitively expensive. This Java library seems to be trying to implement this. ht…
You now have https://github.com/Kotlin/kotlinx.collections.immutable
This needs to be built into the language or somehow standardized by the community.
With lack of standardization of immutable collections, there would be lots of different ways that libraries would implement immutability. This would result in losing one of the main benefits of functional programming (i.e. awesome composability).
Re: Swift is like Kotlin
#319Kotlin lacks the ability to do true functional programming that Swift has. Swift has pattern matching, recursive data structures (edit: specifically ADTs with enums or case classes is what I was thinking of here, should have written algebraic data types), tail call optimization, even some form of type classes, immutability (thanks @tmail21), and so on. Kotlin does not have any of these (edit: this is now partly false…
Maybe you haven't checked out Kotlin lately? Kotlin has somewhat pattern matching: https://kotlinlang.org/docs/reference/control-flow.html#when... Tail call optimization: https://kotlinlang.org/docs/reference/functions.html#tail-re... Type classes: https://kotlinlang.org/docs/reference/sealed-classes.html And I'm not sure what you mean by recursive data structures. Basically every C style language I'm aware of can co…
Sealed classes are an odd/wonky take on sum types, they're not even remotely close to type classes.
Re: Swift is like Kotlin
#320I like swift's conditionals without brackets, OTOH the syntax for string interpolation is ugly
Ugh, I know it's something that literally every programmer on earth can and often does bikeshed, but Swift just got string interpolation syntax wrong . Parentheses are something that are often part of the interpolated expression... they shouldn't be part of the interpolation syntax itself.
Why not? It's not like there's any conflict. You can use parens inside the interpolated expression just fine.