|
Doctor w-rw-rw- posted:
|
# ? Jun 3, 2014 22:02 |
|
|
# ? May 28, 2024 16:20 |
|
lord funk posted:Yeah me too. Same. While we're on the topic of playground bugs… are you supposed to be able to import UIKit into playgrounds? I've tried 'import UIKit' in all the configurations I could think of, including in an iOS project — but every time I just get "No such module 'UIKit'".
|
# ? Jun 3, 2014 22:11 |
|
WORLDS BEST BABY posted:Same. While we're on the topic of playground bugs… are you supposed to be able to import UIKit into playgrounds? I've tried 'import UIKit' in all the configurations I could think of, including in an iOS project — but every time I just get "No such module 'UIKit'". Playgrounds, for now, seem to be OS X only, without the simulator environment, so if that's intended it doesn't seem to be supported, currently.
|
# ? Jun 3, 2014 22:58 |
|
Doctor w-rw-rw- posted:Playgrounds, for now, seem to be OS X only, without the simulator environment, so if that's intended it doesn't seem to be supported, currently. Thanks, that seems to be it.
|
# ? Jun 3, 2014 23:16 |
|
I think y'all talked about this earlier, but the stuff about collections being copies but arrays being references unless the length changes and then it's a copy seems a little weird to me. Is that normal?
|
# ? Jun 4, 2014 00:19 |
|
lord funk posted:Yeah me too. Filed.
|
# ? Jun 4, 2014 00:20 |
|
rjmcall, I just watched the SotU part on Swift. All I can say is: Thank you, thank you, thank you. extensions and generics alone will make my life so much easier. I cannot wait to start beating on it and porting an app or two to see how easy it is (seems like really really easy).
|
# ? Jun 4, 2014 00:23 |
|
Why is @lazy the only keyword with the @ prefix? Why not just lazy?
|
# ? Jun 4, 2014 00:24 |
|
bumnuts posted:Why is @lazy the only keyword with the @ prefix? Why not just lazy? There's a ton of attributes with the @ prefix. A list is in the book, in the chapter called "Language Reference", in the section called "Attributes".
|
# ? Jun 4, 2014 00:41 |
|
Any chance of getting the RC4 benchmarks in Obj-C and Swift posted? Curious what the code was that was 1.7X faster in swift.
|
# ? Jun 4, 2014 01:10 |
|
bumnuts posted:Why is @lazy the only keyword with the @ prefix? Why not just lazy? I don't know if they plan on supporting custom attributes but @ is the syntax for attributes in general.
|
# ? Jun 4, 2014 01:22 |
|
rjmccall posted:
I was just reading about this. If I'm understanding correctly, it can be any sequence of the following 14 characters: / = - + * % < > ! & | ^ . ~ https://developer.apple.com/library...097-CH27-XID_48
|
# ? Jun 4, 2014 01:24 |
|
Looking forward to the inevitable Brainfuck.swift.
|
# ? Jun 4, 2014 01:34 |
|
If Swift is a recent name, what did you guys call the language internally while you were developing it?
|
# ? Jun 4, 2014 01:47 |
|
LP0 ON FIRE posted:I was just reading about this. If I'm understanding correctly, it can be any sequence of the following 14 characters: / = - + * % < > ! & | ^ . ~ . is restricted. You can also use non-ASCII characters; we haven't decide exactly which set, but it'll include the math symbols for sure. lord funk posted:If Swift is a recent name, what did you guys call the language internally while you were developing it? I don't know why, but we never disclose stuff like that. It's not unlikely that somebody will slip up and say it at some point, though.
|
# ? Jun 4, 2014 02:05 |
|
rjmccall posted:. is restricted. You can also use non-ASCII characters; we haven't decide exactly which set, but it'll include the math symbols for sure. Awesome! Someone in another thread about Swift wanted to use ∈ really badly.
|
# ? Jun 4, 2014 02:11 |
|
Is there any chance at being able to use this for cross-platform dev in the future? If it outputs LLVM, and integrates with C libraries, it should be feasible once it hits open source, right? Or is too much useful stuff tied up in Cocoa that you'd lose most of the nice bits if you were trying to build on Linux or Windows.
|
# ? Jun 4, 2014 02:18 |
|
Having some problems with interop. The docs seem to suggest that I should import "ModuleName-Swift.h" into all the ObjC files that need to have access to Swift classes. My module name is for sure AdultQuest because Xcode generated "AdultQuest-Bridging-Header.h" for the other side. I don't see AdultQuest-Swift.h in my project anywhere, though, and when I try to import it, I get an error complaining that it's unable to find it. Also, when I had a protocol defined on the ObjC side which used UIKit classes, I couldn't use any classes that implemented that protocol in my Swift classes; I got compile errors about UILocalNotification being an unknown class. I converted that one to Swift and now it works fine, but now I'm stuck with this bridging issue which is much more painful. I'm having a blast with the language so far though. Yes let's please convert two files into one that's half the length of either one. spongeh posted:Is there any chance at being able to use this for cross-platform dev in the future? If it outputs LLVM, and integrates with C libraries, it should be feasible once it hits open source, right? Or is too much useful stuff tied up in Cocoa that you'd lose most of the nice bits if you were trying to build on Linux or Windows. I don't see any reason why the core language couldn't be ported. This isn't like Objective-C where really the only reason anyone would write code in it is because of Cocoa.
|
# ? Jun 4, 2014 05:42 |
|
So while trying to fiddle with Unit Testing, I've gotten to the point where I want to create mocks. I've imported the mocking framework that I want to use into the Xcode project as a subproject. I'm able to use it fine with Objective-C code in the project, and create mocks no problem. However, I can't get Swift to recognize that it's there (or, therefore, let me use the methods to mock something). What is the name of the module? I'm trying "import Stubble", and it says there is no such module. In Objective-C, I just need to "#import <Stubble/Stubble.h>", and it works. Or is there other voodoo I need to incant to make it work? (Or is this going to be answered in the Integrating Swift talk?) Edit: I do have a bridging header in my Test project now that has the "#import <Stubble/Stubble.h>" in it. That doesn't throw an error, but doesn't otherwise seem to do anything. Axiem fucked around with this message at 06:22 on Jun 4, 2014 |
# ? Jun 4, 2014 05:53 |
|
nebby posted:for future reference, this is a classic fallacy: for future reference, this is a classic fallacy: https://en.wikipedia.org/wiki/Argument_from_fallacy
|
# ? Jun 4, 2014 06:32 |
|
Dessert Rose posted:Having some problems with interop. The docs seem to suggest that I should import "ModuleName-Swift.h" into all the ObjC files that need to have access to Swift classes. It sounds like Xcode decided to name your bridging header "AdultQuest-Bridging-Header.h" for some reason. The file name isn't magical, and I assume there's a build setting for it somewhere. Basically, Swift "includes" it to find local definitions from your project that it should make visible to Swift files. Not sure what's going on with your protocol. I know there's an occasional issue where we import protocols as FooProto instead of Foo, but IIRC that should only happen when there's an actual name conflict with an ObjC protocol (which live in a different namespace in ObjC).
|
# ? Jun 4, 2014 07:04 |
|
Swift code:
code:
|
# ? Jun 4, 2014 07:13 |
|
Yes. That one is definitely on the list. As a workaround, you can probably afford to add AnyObject to the protocol constraints on your type parameter.
|
# ? Jun 4, 2014 07:25 |
|
spongeh posted:Is there any chance at being able to use this for cross-platform dev in the future? If it outputs LLVM, and integrates with C libraries, it should be feasible once it hits open source, right? Or is too much useful stuff tied up in Cocoa that you'd lose most of the nice bits if you were trying to build on Linux or Windows. There's a significant amount of code dedicated to Cocoa-specific interop, but non-Darwin platforms should just never trigger it by virtue of not having ObjC/CF code. I expect that a port would need to duplicate a pretty simple subset of the ObjC runtime (just for class-layout resilience) and then be done. Obviously, if you want a Windows port to e.g. import COM types as Swift classes, that is (1) implementable but (2) significantly more work.
|
# ? Jun 4, 2014 09:27 |
|
Mind you, this is coming from a non-iOS developer, but is there any reason for variables in strings to be surrounded by parentheses, with the opening one escaped? All the examples of strings with variables I've seen use this, and I haven't seen any other methods of using variables in strings. An example from the docs regarding Strings and Characters: code:
Unless Swift has a string format method that I haven't been able to find, but it seems like an odd design choice to me.
|
# ? Jun 4, 2014 11:08 |
|
Is there any plan to build out the collections a bit more? I'm necessarily asking if you're going to do completely reimplement Scala's collection library, but man would that be convenient sometimes.
|
# ? Jun 4, 2014 11:50 |
|
ATM Machine posted:This just seems really strange when a curly bracket is rarely used outside of maths, music and programming; parentheses are used quite commonly by comparison, so it seems strange on first glance that to pass a variable into a string, you have to escape a character for it. The way Perl and PHP do it is bad, for all the obvious reasons, and that only works if you have $ in front of all your variables. The way Ruby does it is bad because it introduces a second escape character, #. Having a naked curly bracket would be surprising and weird. It makes sense to reuse the existing escape character.
|
# ? Jun 4, 2014 12:04 |
|
The optimizer seems to do some really weird things for me. I ported this benchmarking simulation to Swift. After long periods of toying around with different things I actually got out something that performs nicely: http://tstm.info/files/nbody.swift But for some reason I still have to do very odd things to be able to make it performant. In the function advance() I'm doing an extra code:
If I take it away, and replace the advance() function with something like this: code:
Also, I've found that using a static or a dynamic Array to store the bodies in will result in lots and lots and lots of retain/release, and that's why I had to go and use a static-size ContiguousArrayBuffer instead of an Array. As for the actual results, with the weird "optimizations" I had to do, I can run 5 000 000 iterations of nbody in ~3.8 seconds on my rMBP. The original Java code I ported does the same in 0.9s - swift is slower but not by that much, and I'm sure there could be other things still going wrong.
|
# ? Jun 4, 2014 13:36 |
|
So is there a way to explicitly define a main() entry point for a program written in Swift? The iBook that's available online doesn't specify anything (it just says that stuff in global scope gets executed first) and I don't have access to the Betas so I can play around.
|
# ? Jun 4, 2014 15:36 |
|
rjmccall posted:It sounds like Xcode decided to name your bridging header "AdultQuest-Bridging-Header.h" for some reason. The file name isn't magical, and I assume there's a build setting for it somewhere. Basically, Swift "includes" it to find local definitions from your project that it should make visible to Swift files. There is a build setting for it, but it starts out generated from your module name. It's just how I know for sure what the module name is. I thought maybe this could be due to some circular dependency issues, but now I'm thinking it's because the Swift part of my code isn't compiling properly. Also, I think I have a reproducible segfault in the compiler, which I'm going to try and trim down. Unfortunately for me, it's in one of the core methods of my main model class. (Which should really be broken into pieces.)
|
# ? Jun 4, 2014 16:48 |
|
WORLDS BEST BABY posted:Thanks, that seems to be it. Nevermind. I think that Xcode might have a right-sidebar option for iOS playgrounds.
|
# ? Jun 4, 2014 19:51 |
|
What's the difference between Array<String> and String[]? Are they just two different ways of describing the same thing?
|
# ? Jun 4, 2014 20:18 |
|
Yep, though I think it was mentioned in the book that String[] is the preferred style.
|
# ? Jun 4, 2014 20:19 |
|
Doctor w-rw-rw- posted:Nevermind. I think that Xcode might have a right-sidebar option for iOS playgrounds. Oh hey, they hid that well! Unfortunately, after selecting iOS in the platform dropdown all I get is "Error running playground. Cannot find suitable target device". Thanks anyway. Edit: Got it. For whatever reason playgrounds require at least one device profile to be added in iOS Simulator, and I didn't have any. WORLDS BEST BABY fucked around with this message at 20:38 on Jun 4, 2014 |
# ? Jun 4, 2014 20:20 |
|
Filburt Shellbach posted:Yep, though I think it was mentioned in the book that String[] is the preferred style. Nice, I prefer that too
|
# ? Jun 4, 2014 20:25 |
|
Read some of the book while flying this morning, excited to start trying it out. Thanks for answering our questions rjmccall!
|
# ? Jun 4, 2014 20:39 |
|
I've now converted a couple of tiny classes to Swift for fun. It's certainly much cleaner looking than the code it replaced. I think the language's true potential won't be clear until the Cocoa APIs start to be rewritten with Swift in mind. It looks like a modern, friendly language until you try to do something that would be simple in a scripting language like capture substrings using regular expression matches. Then you're neck deep in objective C APIs, creating NSRegularExpression objects with bitmask options and pointer based error handling to do something that is baked into strings in a scripting language.
|
# ? Jun 4, 2014 20:39 |
|
Yeah, on that note. What's the easiest way to go from an NSSet to a strongly typed Swift array?
|
# ? Jun 4, 2014 21:07 |
|
set.allObjects as Foo[]
|
# ? Jun 4, 2014 21:28 |
|
|
# ? May 28, 2024 16:20 |
|
Ouch?
|
# ? Jun 4, 2014 21:44 |