This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Symmetryc's profile picture

Apple's New Programming Langauge - "Swift"

Started by Symmetryc, 05 June 2014 - 08:17 PM
Symmetryc #1
Posted 05 June 2014 - 10:17 PM
Hey guys. I just saw Apple's new language, Swift, the other day and I thought I'd make a discussion on here about it. What do you guys think?

Link - https://developer.apple.com/swift/
Edited on 05 June 2014 - 08:18 PM
amtra5 #2
Posted 05 June 2014 - 10:40 PM
Looks really good and somewhat similar to lua, though I find the "1 type only" arrays and variables could be a bit of a drawback.
oeed #3
Posted 05 June 2014 - 10:43 PM
I got 10.10 the other day, so after my exams finish (today) I might check it out and report back on what I think.
awsmazinggenius #4
Posted 05 June 2014 - 11:44 PM
Looking great, I hope it will eventually be able to do everything Obj-C can as I have a dislike of Obj-C.
Cranium #5
Posted 06 June 2014 - 12:31 AM
I wonder if they'll have to put you through an approval process before being able to write any programs using it?

</iOS apps joke>
Bomb Bloke #6
Posted 06 June 2014 - 02:42 AM
The main catch is that it's only really of value for producing software for Apple's eco-system. Their computer branch has never really been large slice of the market and I can't see that ever changing. In recent years they've mostly been concentrating on porting their iOS ideas into OS X, but iOS itself has been rapidly losing market share to the likes of Android.

Apple would indeed love for coders to take on their proprietary language - time spent on that is experience those coders won't be gaining on platforms Apple doesn't control. And "control" is indeed the word for it; Cranium's joke would be funnier if it weren't likely true.

In short, it might be fun to play with, but no matter how good it is I wouldn't base a career on it unless I was committed to using Apple's stuff for everything else in my life.
awsmazinggenius #7
Posted 06 June 2014 - 04:47 AM
Surely nothing is stopping anyone to write something to make Swift work on other platforms using the language spec, like how this project (http://www.gnustep.org/resources/ObjCFun.html) ports Obj-C to other platforms. (I haven't looked at that link, just googled up "objective c on windows")
apemanzilla #8
Posted 06 June 2014 - 05:01 PM
I got 10.10 the other day, so after my exams finish (today) I might check it out and report back on what I think.

How? The download for 10.10 beta isn't available yet, even to people with developer accounts…
oeed #9
Posted 07 June 2014 - 12:25 AM
I got 10.10 the other day, so after my exams finish (today) I might check it out and report back on what I think.

How? The download for 10.10 beta isn't available yet, even to people with developer accounts…

No, developers were able to download it day 1.
Edited on 09 June 2014 - 09:57 PM
awsmazinggenius #10
Posted 07 June 2014 - 06:19 AM
(I haven't tried Swift yet, it just seems cool, looking at the iBook documentation and stuff. Sorry for any confusion.)

I wish I was registered as an OS X developer, that UI is so awesome. That icon for the Finder seems, well, odd to me though. I was wondering why Apple didn't give OS X a flat look in Mavericks to match iOS, but here it is, I guess. I am definitely a fan of the new iOS UI, and I like this new UI too.

EDIT: Looks like I made the first 1 million (knowing my luck, I was probably the millionth person :)/>) to try out Yosemite as a customer in Apple's beta program. Yay. Sexy UI. I (think) I'll be able to use Swift too. (Waiting for the install to finish right now :)/>)
Edited on 07 June 2014 - 04:25 AM
6677 #11
Posted 07 June 2014 - 10:44 PM
Looks really good and somewhat similar to lua, though I find the "1 type only" arrays and variables could be a bit of a drawback.
Most programming languages and almost every compiled one (such as swift) do this. Lua is a minority group in that regard.
Looking great, I hope it will eventually be able to do everything Obj-C can as I have a dislike of Obj-C.
Confirmed that swift can fully utilise Cocoa. Swift can also call Objective-C libraries and vice versa.
Surely nothing is stopping anyone to write something to make Swift work on other platforms using the language spec, like how this project (http://www.gnustep.o...es/ObjCFun.html) ports Obj-C to other platforms. (I haven't looked at that link, just googled up "objective c on windows")
Objective-C although used by Apple was not created by them. It has featured in the GNU compiler collection (including MinGW and cygwin on windows too) since 1988. It was actually made by 2 guys from a small company called Stepstone, work was thought to have started as early as 81. It was only later that NeXT eventually picked up on it and started using it themselves, they were responsible for adding Objective-C supporting in GCC.



OpenStep, GNUstep and Cocoa are technically independent from Objective-C even if they are somewhat related. Apples Cocoa API is based upon OpenStep which itself was developed by NeXT before apples acquisition of them.
Apple may have popularised it, but it existed long before they used it.










For now I am sidestepping swift. I don't own any apple hardware and have no intention of ever acquiring it so it is entirely useless to me. In future I suspect there will be a 3rd party who extend GCC to support it and eventually MinGW will update to feature the updated GCC too. Then I will be *remotely* interested in it, personally I don't like the syntax particularly and don't see what it brings to the table except unsubstantiated performance claims from apple.
I won't believe apples performance claims until they back it up with hard data. I want full source code, the hardware used and the actual test data of which they supplied none. They told us what test they used but did not show the actual algorithm implemented and this would not be the first time apple have taken an outlier performance test and then stuck it in their marketing bull as gospel truth (and I am not picking on apple for this, tons of people do it, never believe the marketing unless its backed with hard evidence, it just happens to be apple are notorious for this).
Its of no worry though, no doubt people will test it independently and we'll see if apples claims hold true in the real world. My guess, its performance will alter negligibly from other compiled languages such as C, Objective-C and C++. Short of hand crafting ASM, there is little room for performance gains.

The syntax to me looks like a horrid bastardization of javascript and python. I was going to include C in there but javascript itself uses a C inspired syntax so I think that covers it. Still, whatever works.
apemanzilla #12
Posted 09 June 2014 - 06:42 PM
I got 10.10 the other day, so after my exams finish (today) I might check it out and report back on what I think.

How? The download for 10.10 beta isn't available yet, even to people with developer accounts…

No, developers were able to download it day 1.

Where? I signed up (I have a developer account) and only got a message telling me that I'd be emailed when the beta was available. :/
Sxw #13
Posted 12 June 2014 - 01:16 AM
You probably signed up for the public beta. Mac devs ($99/year) get it day one.
apemanzilla #14
Posted 12 June 2014 - 07:38 PM
You probably signed up for the public beta. Mac devs ($99/year) get it day one.
I have a dev account. (I don't know why I bother paying for it as I rarely do much with it, but I have one…)
oeed #15
Posted 12 June 2014 - 11:34 PM
You probably signed up for the public beta. Mac devs ($99/year) get it day one.
I have a dev account. (I don't know why I bother paying for it as I rarely do much with it, but I have one…)

If you have a paid OS X dev account then you can download the beta.
apemanzilla #16
Posted 14 June 2014 - 03:36 PM
Odd. I'll try again in a bit.
Sir_Mr_Bman #17
Posted 14 June 2014 - 04:16 PM
Personally, I hate Apple.
They don't try to play well with Windows machines, the program languages they use are obscure, and I hate the UI.

As a developer however, swift looks really supper cool. It's a little bit like Java, Objective-C and Lua (from what I can tell).

That being said, I don't like not having semi colons. The semi colon is my sanity check (along with
printf("Debug: it works?")
), and removing that is going to kill me.
Edited on 14 June 2014 - 02:16 PM
theoriginalbit #18
Posted 14 June 2014 - 05:02 PM
That being said, I don't like not having semi colons. The semi colon is my sanity check
they're optional, just like Lua.
Lyqyd #19
Posted 15 June 2014 - 02:31 AM
Personally, I hate Apple.
They don't try to play well with Windows machines, the program languages they use are obscure, and I hate the UI.

That doesn't add anything to the topic at hand. Further comments in this vein in either direction will result in this topic being locked.
ElvishJerricco #20
Posted 17 June 2014 - 09:14 PM
Lots of languages lately have been incorporating a lot of ideas from functional languages, and functional languages themselves have been getting more popular. I greatly appreciate the concepts of functional languages but the imperative style of OOP is just so much easier to program in and so much more practical. So I'm really happy with the way Swift takes all the best concepts from each style and incorporates them into one awesome language. There's a powerful type system, no more "million dollar mistake" of unexpected null, and a really good OOP system.

I've only got three complaints. The first is the way dictionaries and arrays are handled. Sometimes they pass by reference, sometimes making a change changes the reference you're using, sometimes it passes by value sort of…. It's a mess.

The second one is the inheritance model. It's got a pretty traditional "One super class plus any number of protocols" way of doing things. I imagine this is mostly because it's based on the ObjC runtime, which only supports that. But I would have loved to see the super class done away with, and instead allow method implementations in protocols, like default methods in java interfaces. Any number of super classes, and any unimplemented methods mean you either need to implement them or declare your class as non-concrete. The ability to have defaults in a protocol is just too valuable.

And the final complaint is operators. I've got no problem with custom operator idea. But the way they did it is kinda silly. You declare an operator, then declare implementations of that operator based on the parameters. It would have been better if operators were declared as methods in a protocol that needed to be implemented. Something like this.


protocol Adding<T, V> {
	func +(rhs: T) -> V
}

class SomeClass: Adding<String, SomeClass>, Adding<Int, Int> {
	func +(rhs:String)->SomeClass { ... }
	func +(rhs:Int)->Int { ... }
}

x:Int = SomeClass() + "Hey" + 3 // now legal

This would also require the ability to implement the same protocol any number of times for differing generics, which also needs to be included. Anyway the reason for stuff like this is to make operators generic. For example a function that takes parameters that implement the Num protocol (which would be a protocol extending Adding, Subtracting, Dividing etc…) can use those operators on unknown types.
Edited on 19 June 2014 - 05:48 AM