|
hey, thanks for this! swift reads like a collection of best practices enfleshed, and it will make mac+ios dev way more pleasant. instead of being a step down from the JVM, the CLR, the web etc, now it feels mostly like a step up. my favourite features: let, enum, and real first class functions, rather than faking them with delegate or SAM types. least favourite is the array stuff, and collections in general. there doesn't seem to be anything equivalent to scala.collection or System.Linq. perhaps those things don't work so well without GC and complex monad comprehension syntax? but they are Extremely useful.
|
# ¿ Jun 6, 2014 07:22 |
|
|
# ¿ Apr 29, 2024 07:06 |
|
speaking of which, is typealias-in-protocol semantically equivalent to a hypothetical Protocol<T>? that is, does it have any special features or restrictions that generic protocols wouldn't, if they existed?
|
# ¿ Jun 8, 2014 21:22 |
|
can you perhaps writecode:
|
# ¿ Jun 11, 2014 20:46 |
|
Ender.uNF posted:Where did you find @conversion? dumped the LLVM IR which implements the few builtin conversions. lord funk posted:Can you explain why it would be bad to have this project wide? If it's a valid conversion, what's the harm? implicit conversion is a powerful feature, but it introduces unpredictability: by including a file in your project, you can change the meaning of another file, reducing the type-safety it previously had. if it becomes a documented feature of swift, i'll probably do something like put the implicits in a separate project and import that only in source files which i want to use them, making it opt-in. the other thing i was going to mention is that this particular conversion will behave differently on 32- and 64-bit systems, but rjmccall already demonstrated an implicit-free way around that: rjmccall posted:
|
# ¿ Jun 12, 2014 06:08 |
|
rjmccall posted:They don't lose information, they just keep it in associated types, which admittedly makes it awkward (impossible?) to talk about Sequences of specific types as types rather than as generic constraints. is there a moral equivalent, in Swift, of this C# code? code:
|
# ¿ Jun 12, 2014 06:19 |
|
ah, i hadn't realised you could express a constraint on a type's associated type like that. covers some major use cases at least
|
# ¿ Jun 12, 2014 10:30 |
|
code:
code:
- classes can't have a variable size layout (some IRgen issue) - generic types can't contain static/class variables - dispatch_once doesn't seem to correctly infer the types of its arguments
|
# ¿ Jun 15, 2014 15:57 |
|
sadly, just resetting a flag is not thread-safe - particularly if the calculated T doesn't fit in a CASable word
|
# ¿ Jun 18, 2014 08:21 |
|
whoa, that is a caveat you might want to document - the book does not mention it
|
# ¿ Jun 18, 2014 08:28 |
|
yeah, and my Lazy<T> implementation above uses a semaphore check which does not spin if the sempahore is already signalled. after the first init it's basically Just A Branch. i don't think that's too high a cost for making avoiding a situation where *reading* an otherwise-immutable property can be unsafe, something you'd never have to worry about with unlazy values.
|
# ¿ Jun 18, 2014 11:14 |
|
https://devforums.apple.com/message/989944#989944 arrays are being given consistent semantics, i'm very happy to see this change
|
# ¿ Jun 21, 2014 12:47 |
|
man, i'm getting tired of writing code:
code:
|
# ¿ Jun 21, 2014 18:14 |
|
Sinestro posted:Also, GC sucks on anything but a big computer, and still sucks even then for large applications. I'd personally rather ARC just get smarter. Reference counting is a form of GC. It isn't necessarily lighter-weight, even; ARC isn't fast. it is low latency compared to a traditional mark and sweep collector, but has lower throughput than state of the art generational hybrids. Latency V throughput is a good tradeoff for phones maybe! Predictable responsiveness is great. Memory leaks are less great, and you couldn't fix them just by making it smarter. It would require core language design changes - ownership tracking, maybe memory regions. Rust is attempting this, and includes a form of reference counted pointer that uses lifetime polymorphism, but so far Mozilla has found that even once you add all that complexity it isn't easy to break cycles, unless you jump straight to value semantics. (nice to hear about the ()->T to ()->() conversion in the works!)
|
# ¿ Jun 21, 2014 20:42 |
|
it'll be interesting to see idioms develop. right now there are a lot of different ways to manage the API boundary and optionality. you could write this:code:
code:
code:
|
# ¿ Jun 22, 2014 12:22 |
|
failable initialisers are cool. sort of. i've often lamented the inability of constructors to fail and the factory patterns this creates. that said, it feels like they're there for "the wrong reasons" - interoperability with old two-phase-construction apis.. but hey, if they can be wrapped sufficiently for the static analysis to be reliable, that's fine. presumably this is another nail in the coffin of exceptions on the cocoa platform.
|
# ¿ Oct 22, 2014 07:15 |
|
will rethrows be the story for GCD async?
|
# ¿ Jun 20, 2015 09:10 |
|
rjmccall posted:rethrows as currently defined doesn't help a whole lot with async, because right now async is kindof a callback-hell situation, and it really needs a more holistic solution. maybe some kind of Future-ish type which encapsulated throws-ness in the same way as rethrows, so that it became a throws operation to get the ultimate result once something in the chain was given a throws closure... actually, is that possible as a library using overload-on-throwsness?
|
# ¿ Jun 20, 2015 20:24 |
|
cocoa's explicit method names were useful in a more dynamic language and time, where messaging was rarely or barely type-checked. if xcode's completion and overlays for swift have finally stabilised, the types in the function signatures will be a better guide than verbose naming ever was, and the names become redundant. this is kind of an extreme version of the anti-comment argument - names shouldn't repeat or attempt to informally specify information which can be *verifiably* encoded as types.
|
# ¿ Jan 30, 2016 23:34 |
|
tbh going "full java"/.net is what i like about the change. i suppose reaction is going to vary by direction of entry to the language (though i was an objc programmer once in days of yore)
|
# ¿ Jan 31, 2016 01:47 |
|
tbh it's just kind of hard to take the 'catastrophe' pov seriously having spent years programming in each of cocoa, java and .net. they're directly comparable stacks - OO application development languages with large standard libraries and managed memory and so on, where you write a lot of business logic and classes with names like CustomersView or StoreNotifyingDelegate. objective-c has always been the standout for extremely verbose method names, which made some degree of sense as it had far less type-safety and worse tooling - but this is no longer the case. Swift has a real type system and automated refactoring capabilities, and we've been able to observe for years that these things are a sufficient or superior alternative to repeating type names in method names. you're talking about falling back to Hungarian notation, for goodness' sake.. people used to make the same arguments for why that would be a clearer way to code, and they haven't proven out. i'm not fond of the gerunds, which may just be unfamiliarity. on the jvm or clr the famous example would probably be yourInput.TrimCharacters(Whitespace) ..but of course the real function signature is String TrimCharacters(CharacterSet trimming). there's the exact same information as was present in stringByTrimmingCharactersInCharacterSet, in a form which is enforced by the compiler and which doesnt add noise to the process of scanning code for semantic correctness and functional comprehension. we should not be optimising for the authoring ability of beginners who aren't aware of docs or ide mechanisms. this stuff is read far more than its written, by developers who are neither novices nor experts. what's useful to them is a clear layout of the flow of well-named data between well-named operations; types are almost irrelevant. types are the thing the compiler checked, so you don't have to worry about those!
|
# ¿ Feb 4, 2016 05:54 |
|
Subjunctive posted:In my experience of questionable success, you can optimize for beginners, for mastery, and for extensibility (it being obvious to a library author what the Swifty thing is, and to a consumer how it fits together), all largely by one principle: I agree, but it doesn't sound like that principle helps us make a decision here. "Always repeat type names" and "never repeat type names" would both pass...
|
# ¿ Feb 4, 2016 06:22 |
|
"20 years behind the state of the art in academia"
|
# ¿ Feb 4, 2016 08:00 |
|
it's a very strange thing to get het up about, since unless you actually *forbid* nonvirtual methods people who care about api design will still be designing their inheritance contracts accordingly.
|
# ¿ Jul 20, 2016 19:57 |
|
man, "public open" made way more sense than the accessibility default magically changing when you un-final the type :/
|
# ¿ Jul 21, 2016 20:35 |
|
rjmccall posted:If it's not public already, you don't need to un-final the type. Solution: don't think of open as un-final'ing the type. that's reasonable. I'd forgotten about the nuanced nature of internal accessibility in swift - good to see these things being experimented with rather than just copying past systems
|
# ¿ Jul 22, 2016 06:35 |
|
using mailing lists isn't for old people, it's for people whose job regularly, rather than peripherally, involves this sort of collaboration. as soon as you are involved in the development of more than one thing, mailing lists for each is superior because it lets you have a single mail client rather than separate accounts on multiple differently-interfaced websites
|
# ¿ Aug 1, 2016 08:10 |
|
|
# ¿ Apr 29, 2024 07:06 |
|
lord funk posted:Model View Controller (MVC). live from wwdc! https://www.youtube.com/watch?v=YYvOGPMLVDo
|
# ¿ Jan 23, 2017 06:35 |