3 ms·
For instance tight while loop with ++ increments where needed. You can't do that in Swift. Or one liner if in the middle of other code. I am using a lot of dif
by binaryapparatus 9y ago
For instance tight while loop with ++ increments where needed. You can't do that in Swift. Or one liner if in the middle of other code.
I am using a lot of different languages so 'what I am used to' means lots of different stuff. Ruby has some of C beauty. Python does not. Haskell is probably most beautiful of them all. All individual and from my point of view of course.
- melling 9y agoPerhaps you can be less abstract and illustrate your point with sample code. In most comparisons, Swift looks a lot nicer. https://h4labs.wordpress.com/2016/02/09/should-i-use-objective-c-or-swift-for-writing-ios-apps/ https://h4labs.wordpress.com/2016/02/09/should-i-use-objecti... The ++ operator was removed from Swift. Haskell uses ++ for concatenation. The case where ++ to add 1 is desirable occurs much less often than a variable declaration, which is better in Swift.
- binaryapparatus 9y agoFor instance C copy routine: while (*d++ = *s++); Or sort in Haskell: qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
- melling 9y agoWhat’s the value of the Haskell code? It’s a great language but not really supported on iOS. Would love for it to be. Back to the one idiomatic C example. The few places where it’s terse does not make up for the many other places where it’s not. You also have memory management with malloc for additional code. If you compare nontrivial code, Swift is a more modern, safer, less verbose, etc way to develop iOS apps vs Objective C.
- binaryapparatus 9y agoSwift wants to be much more than just iOS specific language so it is fair to compare its pros and cons with other general purpose languages. If you look at iOS only then there is not much to compare to, just ObjC and few JS abominations. Staying iOS specific is not what Swift wants to be.
- ridiculous_fish 9y agoC-style strcpy in Swift is a little verbose: func strcpySwift(_ d:UnsafeMutablePointer<CChar>, _ s:UnsafeMutablePointer<CChar>) { for i in 0... { d[i] = s[i] if s[i] == 0 { return } } } Haskell-style sort in Swift is pretty nice: func qsort<T:Comparable>(_ arr:[T]) -> [T] { var xs = arr[...] guard let x = xs.popFirst() else { return [] } return (qsort(xs.filter{$0 <= x})) + [x] + (qsort(xs.filter{$0 > x})) }
- lobster_johnson 9y agoHaskell is beautiful, but it's worth mentioning out that Haskell's quicksort is not written that way, because in this case beautiful means incredibly slow (and also because that's not even quicksort, which is an algorithm defined by how it modifies data in-place). The real quicksort implementation uses mutable arrays to perform an in-place sort, and isn't beautiful at all.
- swah 9y agoYeah, some are very superficial still they bother me every time. A map in lisp/python/js vs a for-loop in Go/C, for simple transformations.