|
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 28, 2024 22:09 |
|
rjmccall posted:Also I feel very slightly bad for randomly making fun of Ada. Only very slightly, though. I'm sure Ada can handle it. It has features for everything else.
|
# ? Jun 6, 2014 07:42 |
|
It would be cool to be able to specify how Objective-C code gets presented to Swift (rdar://17184411), like with JavaScriptCore's JSExportAs(), so I could omit class prefixes or move the first parameter name out of the function name in favor of a label. The level of Objective-C integration is impressive. I'm looking forward to converting piecemeal.
|
# ? Jun 6, 2014 08:36 |
|
Found a fun crash. Paste this into a playground:code:
I know you're not supposed to use let now, but I didn't when I wrote this code and then the segfault actually happened in a completely different file a good fifteen minutes of work later. Beta tools are fun Dessert Rose fucked around with this message at 08:45 on Jun 6, 2014 |
# ? Jun 6, 2014 08:39 |
|
Axiem posted:Oh, and I think I heard an Apple Engineer today slip up and use the code name for Swift instead of Swift. Those in Apple: any idea if it is actually a Firefly reference? (Or is it just as likely to have been the wrong word, but not the codename) So uh, since you don't work at Apple: what was it? Serenity?
|
# ? Jun 6, 2014 13:13 |
|
I think he was trying to be nice by not revealing what her heard because, as rjmccall had mentioned earlier, they try to keep their non released names quiet?
|
# ? Jun 6, 2014 14:15 |
|
Doh004 posted:I think he was trying to be nice by not revealing what her heard because, as rjmccall had mentioned earlier, they try to keep their non released names quiet? This. I would rather not incur the wrath of the Apple gods. Instead, I will note that in the Stump the Experts, one of the questions for the audience was "What was the code name for iCloud?", and after the audience gave the correct answer, one of the experts said (paraphrased) "When they first started the MobileMe replacement, the chosen code name was 'Mavericks', but we all thought it was a stupid name, so we decided to name it after a beer instead--thus, Newcastle"
|
# ? Jun 6, 2014 15:23 |
|
code:
|
# ? Jun 6, 2014 15:33 |
|
Any access to some of the lower level obj c runtime? Like associated objects ?
|
# ? Jun 6, 2014 18:14 |
|
Hughlander posted:Any access to some of the lower level obj c runtime? Like associated objects ? We have plans in this area.
|
# ? Jun 6, 2014 18:49 |
|
quote:
Why yes that is definitely a constructive and useful suggestion for Swift
|
# ? Jun 6, 2014 19:22 |
|
The Advanced talk was great. I'm glad the syntax mungling examples were tempered by words of caution. Generics are fantastic. Can't believe the code you guys had on screen for the memoization example. There's a whole class of young programmers who are going to be introduced to FP through Swift.
|
# ? Jun 6, 2014 19:57 |
|
Doctor w-rw-rw- posted:Why yes that is definitely a constructive and useful suggestion for Swift Expected Results: I'm writing objc Actual Results: I'm not writing objc? wtf is going on??
|
# ? Jun 6, 2014 20:05 |
|
Vanadium posted:Expected Results: I'm writing objc Expected Results: this is a language I already know Actual Results: I have to learn a new thing?? gently caress you Apple!!
|
# ? Jun 6, 2014 20:56 |
|
Filburt Shellbach posted:The Advanced talk was great. I'm glad the syntax mungling examples were tempered by words of caution. I've got a couple questions I haven't seen asked, sorry if they were already asked and I missed em... Is Swift going to enable better refactoring support in Xcode? I really, really miss Resharper when doing ObjC dev Also, I'm writing an iPhone app that makes a lot of use of raw C byte arrays for performance, is there a performant way to allocate and read/write a raw c-style array with Swift, or should I leave that bit in ObjC?
|
# ? Jun 6, 2014 21:02 |
|
I just got the chance to really play (ha) with the Playground, building a feature in my app, and it is a dream. The fact that it doesn't link with the rest of your project is a downside, but it's also an upside. I think if that does get added it needs to be optional. It doesn't take that much time to make mock pieces that your code actually needs to touch; we're not trying to write an entire app in here, just a small piece of code that you'll take into the main project when you're done. Then you can visualize the progress through your algorithm with graphs. You might say, well, how is a graph of my variable actually useful? And maybe a graph isn't your first choice for representing the data, true. But we're not creating reports to show to other people, here. It is useful to be able to see the value of this variable every time we went through the for loop. I wrote a reasonably complex (for me) algorithm this way, debugging it fluidly and quickly because I didn't have to plow through six layers of my app to test that it worked how I expected, getting instant visual feedback on the changes I was making and how they changed the behavior of my algorithm. And when I was done, I just checked the .playground file into my repo, because next time I want to tweak that algorithm or try a different thing or write more unit tests, I already have the environment where all those mock objects are defined, all those graphs are nicely laid out. This is really, really good.
|
# ? Jun 6, 2014 21:03 |
|
So this is now a thing: http://terribleswiftideas.tumblr.com
|
# ? Jun 6, 2014 21:42 |
|
toiletbrush posted:Is Swift going to enable better refactoring support in Xcode? I really, really miss Resharper when doing ObjC dev Swift should certainly make it easier to do good tooling like this. I shouldn't speculate about specific future work, though. toiletbrush posted:Also, I'm writing an iPhone app that makes a lot of use of raw C byte arrays for performance, is there a performant way to allocate and read/write a raw c-style array with Swift, or should I leave that bit in ObjC? UnsafePointer has alloc and dealloc operations.
|
# ? Jun 6, 2014 22:03 |
|
Doh004 posted:I think he was trying to be nice by not revealing what her heard because, as rjmccall had mentioned earlier, they try to keep their non released names quiet? Yeah they got sued by Carl Sagan of all people regarding a code name. Are y'all gonna let me program kexts with this?
|
# ? Jun 6, 2014 22:15 |
|
rjmccall: I saw that Chris retweeted someone talking about the -Otime flag to disable runtime safety checks. I have to assume this wasn't a general endorsement of using that flag, right? Am I missing something here? Unless your code is basically a series of proofs a la Haskell, I don't know why you'd want to opt out of that.
|
# ? Jun 6, 2014 22:39 |
|
Doctor w-rw-rw- posted:http://openradar.appspot.com/17180612 I recognize that guy from the Objective-C mailing list. Not that people shouldn't give their critical opinions, but he doesn't even like ARC and has been working on a perpetually delayed Objective-C performance tuning book that is arguably obsolete now for most readers.
|
# ? Jun 6, 2014 23:09 |
|
Meat Street posted:rjmccall: I saw that Chris retweeted someone talking about the -Otime flag to disable runtime safety checks. I have to assume this wasn't a general endorsement of using that flag, right? Am I missing something here? Unless your code is basically a series of proofs a la Haskell, I don't know why you'd want to opt out of that.
|
# ? Jun 6, 2014 23:41 |
|
Plorkyeran posted:Turning off runtime safety checks just to make fast enough code faster is obviously dumb, but sometimes it'll make the difference between being able to use Swift with the checks only enabled in dev builds and having to write the code in something far less safe like C. A certain level of performance is sometimes a hard requirement. I assume you can turn them off per file, right? So you could write a tiny core that doesn't check anything and only expose it via an interface that does.
|
# ? Jun 7, 2014 00:08 |
|
I'm not sure if the Xcode UI actually exposes it, but optimizer flags are in general per-file.
|
# ? Jun 7, 2014 00:32 |
|
toiletbrush posted:
Get App Code it's by Jet Brains the same guys that make Resharper and it gives the full Inteli-J/Resharper refactoring experience to objective C and C++. I drank the kool-aid so hard there.
|
# ? Jun 7, 2014 02:41 |
|
I can't stand actually editing anything in AppCode, but I still use it fairly regularly just for the refactoring tools. I'd prefer something integrated into Xcode, but the tools are totally worth the minor hassle.
|
# ? Jun 7, 2014 02:49 |
|
Meat Street posted:rjmccall: I saw that Chris retweeted someone talking about the -Otime flag to disable runtime safety checks. I have to assume this wasn't a general endorsement of using that flag, right? Am I missing something here? Unless your code is basically a series of proofs a la Haskell, I don't know why you'd want to opt out of that. Plorkeyran said basically everything I would have, so I'll just note for the record that it's -Ofast.
|
# ? Jun 7, 2014 04:02 |
|
Are you supposed to have to annotate an NSManagedObject subclass with @objc? I was under the impression that you didn't, but I couldn't get instance methods to work until I added it. The strange thing is that I can call class methods on another NSManagedObject subclass without it. Which one is the bug?
|
# ? Jun 7, 2014 04:24 |
|
Did you annotate the properties as NSManaged?
|
# ? Jun 7, 2014 04:31 |
|
Plorkyeran posted:I can't stand actually editing anything in AppCode, but I still use it fairly regularly just for the refactoring tools. I'd prefer something integrated into Xcode, but the tools are totally worth the minor hassle. It's increasingly off topic but make sure you are giving the VM 4 gigs through the options and 3.0 fixes the bug of files outside the project root which caused me heartache.
|
# ? Jun 7, 2014 06:15 |
|
Doctor w-rw-rw- posted:Did you annotate the properties as NSManaged? Yes. Also it apparently only works if I actually specify the name of the class. @objc isn't sufficient. I'm not sure it actually works, though, because when I try to assign to an instance variable inside the class, it crashes. I'm about to give up on converting my model to Swift for now and just try my luck at the controller layer.
|
# ? Jun 7, 2014 07:02 |
|
Dessert Rose posted:Yes. Also it apparently only works if I actually specify the name of the class. @objc isn't sufficient. You've posted no example code, so we can only spitball and hope we don't run into the same issue. If you could please share?
|
# ? Jun 7, 2014 07:45 |
|
I am disappointed in the intermediate Swift talk. One of the speakers said that F1 cars do not have turbos in one of his examples. GET WITH THE TIMES! (All F1 cars are turbocharged starting this year.) Other than that, that talk did an awesome job selling some of the power in Swift. I'm definitely going to jump into the advanced stuff this weekend. I was unreasonably excited to see that you can do pattern matching with ... and _ in the middle of case statements. It reminds me of the fun I had playing with Prolog in college.
|
# ? Jun 7, 2014 11:00 |
|
ManicJason posted:I was unreasonably excited to see that you can do pattern matching with ... and _ in the middle of case statements. It reminds me of the fun I had playing with Prolog in college. The insane power of the case statements in Swift is one of my favorite features of the language. It just gives you so much power compared to most languages.
|
# ? Jun 7, 2014 15:31 |
|
I've been racking by brain over some difficulty getting some complex mathematical expressions to compile involving CGRects and CGFloats, and I finally managed to distill it down to this problem:code:
|
# ? Jun 7, 2014 16:29 |
|
I'm screwing around in a playground this morning, and noticing that my quick little fibonacci function isn't benefitting from any tail recursion. Is this due to the playground environment, or does Swift really not have any tail call optimization?
|
# ? Jun 7, 2014 16:54 |
|
Axiem posted:The insane power of the case statements in Swift is one of my favorite features of the language. It just gives you so much power compared to most languages. I'm hearing the usual slew of things about swift, "It's proprietary" (yep, and it locks you in just as much as using objective-c does) but isn't really a language or platform for anything but apple dev. However one thing I am hearing over and over is both the enums and case statements. I dunno about using swift but I certainly hope other languages pinch them.
|
# ? Jun 7, 2014 16:58 |
|
Flobbster posted:I've been racking by brain over some difficulty getting some complex mathematical expressions to compile involving CGRects and CGFloats, and I finally managed to distill it down to this problem: The book calls out that Swift does not do any automatic conversion, you must explicitly do it. It's under "The Basics", "Integer and Floating-Point Conversion": quote:Conversions between integer and floating-point numeric types must be made explicit:
|
# ? Jun 7, 2014 17:12 |
|
Bug Dump! rdar://17215811 - Improve Swift Closure Syntax rdar://17215836 - Swift: Provide runtime introspection/reflection capabilities with language syntax rdar://17215845 - Swift should use consistent keywords rdar://17215852 - Swift should provide explicit syntax for user-defined attributes rdar://17215880 - Swift should provide a macro-like language extension system rdar://17215884 - Swift: Any should be capable of containing a function/closure rdar://17215895 - Swift should adopt a state of the art error handling mechanism "If Swift is intended to some day write operating system code, drivers, etc then it would be nice to have a way to write robust code that doesn’t abort the kernel (or the current I/O thread) because someone forgot that an integer value can overflow if a driver receives a malformed packet." rdar://17215909 - Swift: Array and Dictionary’s behavior is inscrutable rdar://17215916 - Swift extensions should use associated objects to allow addition of stored properties to objects rdar://17215920 - Swift: functions that define argument names should allow passing arguments in any order. rdar://17215927 - Swift should provide an async/await-like abstraction over GCD For those wanting to test this stuff in a VM: I thought I'd setup a 10.10 VM and install the Xcode beta in that. Don't do it. For whatever reason it is horribly ungodly slow; something is wrong with how VMWare Fusion is hosting 10.10. It is literally unusable - the pauses waiting for intellisense to popup are maddening. Use a 10.9 VM to test stuff out; it works much better.
|
# ? Jun 7, 2014 17:19 |
|
|
# ? Apr 28, 2024 22:09 |
|
rdar://17216333 - I should be able to include 'nil' in a switch statement over a nullable enum. I suppose I could just add "None" as an enum case as a temporary workaround. Maybe I should stop thinking in nullable-by-default patterns. Doctor w-rw-rw- posted:You've posted no example code, so we can only spitball and hope we don't run into the same issue. If you could please share? I haven't made the effort to trim it down into a good example case, because it involves having a full Core Data stack. Here are the parts that are the problem, but I have a feeling this will not actually reproduce it: Quest.swift: code:
code:
|
# ? Jun 7, 2014 18:07 |