Swift has gone opensource

Quick heads-up that Swift has just gone opensource.

I've been going through last years WWDC Swift-related videos.  I think it's an amazing language.  It seems to be pulling the best bits from Objective-C, C++, JavaScript and Python.

What it seems to be lacking at the moment is C++ interoperability.

So I'm sure you core Jucers are keeping a beady eye on this one -- multiplatform development in Swift would rock!

π

I really like Swift.  But each (automatic!) update to Xcode seems to break some previously working language feature... 

Just a heads up on this, I've just been playing around translating some of my iOS View Controller code for my app to Swift. Its been a bit of a faff and a little learning curve but I so far much prefer Swift to Objective C. Only reason I looked into it was coding in Objective C was starting to annoy me. Although you can't interop between Swift and C++ you can between Swift and Objective-C++ so it does not make it much different to Objective-C and Swift interop. To call Objective-C classes from Swift you need a <ProjectName>-Bridging-Header.h  (which Xcode will generate for you and you just fill in the gaps). To call Swift from your Objective-C or JUCE Objective-C++ (.mm file) you #import <ProjectName>-Swift.h which Xcode will magically create for you (i.e. you do not need an actual file with that name).

Once all thats set up you can happily call Swift classes as if they were Objective C, and vice versa. Some hoops to jump through and things to learn especially with regard to init functions and UIViewControllers but feels worth it for a much nicer coding experience when there is a need to do things in iOS native land.

[EDIT: I realise this is not applicable to the "Open Source" aspect of Swift - only iOS and OSX development]

1 Like

Big problem far as I see is Swift is single-inheritance. C++ is multiple. 

 

Whats the general feeling here ?

 

In an ideal world with unlimited JUCE developer resources etc - would ppl like to see a JUCE for Swift and prefer to write cross-platform using it ? 

Seems to me it pretty much limits one to Mac platforms.  C++ is library and 3rd pty API king of course. 

 

No expert on multiple inheritance here. But I seem to remember, that multiple inheritance is not a good thing. JAVA has only single inheritance, too, I think?

I don't think Swift would (currently) be a good choice for multi-platform development like we have with JUCE. But it is a great alternative to Objective-C for writing UI code.

Why wouldn't it be a good thing? It's not good to use it when it's not need, but it does have some good benefits. For instance, the way you use Listeners in JUCE wouldn't be possible without multiple inheritance

I'm not familiar with Swift, but usually languages with single inheritance will allow you to derive from multiple interface classes which are essentially like C++ classes whose functions are all pure virtual functions. So you can still do the Observer/Listener pattern.

1 Like

Yeah, I just meant you can't add something like a Listener like you would in C++. Using multiple inheritance for that just seems a lot better to me.

yes - that was kind of where i was going with this - doesn’t seem like JUCE would map easily onto Swift due to things like lack of M.I. Same goes for all the other Java-imitator languages.

Have you learned how to inform Juicer which file is the bridging header?

I’m now using JUCE to create a static library for iOS projects (included in an Xcode project) so in my case Projucer does not need to be aware of it.

1 Like