New Apple Coding Language + Live Coding = WOW
Monkey Archive Forums/Digital Discussion/New Apple Coding Language + Live Coding = WOW
| ||
http://www.apple.com/apple-events/june-2014/ Check it out :-) |
| ||
Memory is managed automatically, and you don’t even need to type semi-colons. https://developer.apple.com/swift/ No semi-colons? Finally! |
| ||
it is similar to python with brackets. |
| ||
iTunes link for the reference book, it's free: https://itunes.apple.com/gb/book/swift-programming-language/id881256329?mt=11 Looks pretty clean actually. I hate Obj C, so... |
| ||
That's great indeed! Well done Apple! |
| ||
Swift and the XCode environment just remind me of things Bret Victor has been talking about for some years now. Still, it's really cool. |
| ||
no semicolons? I'm sold. I want to see what a For loop looks like though. |
| ||
for loops: |
| ||
The more I look into it the more I like it. Btw, here is the free book/docs: https://itunes.apple.com/us/book/the-swift-programming-language/id881256329?mt=11 |
| ||
New target for MonkeyX? ;) |
| ||
New target for MonkeyX? ;) It would be interesting to take advantage of metal in some way. |
| ||
ObjectiveC is a very bad and unreadable language... So it is not very hard to create someting better... It looks like Haxe - but without semicolons and without multi-targets |
| ||
OMG it has the keyword "LET".... 1980s BASIC here we come!! |
| ||
My God that is disgusting. I'd rather Objective-C. Looks to me like they're just reinventing the wheel for the sake of pleasing the Apple fanboys. |
| ||
Sure LET stands for CONST. Clear and meaninful. To be honest a language dedicated only (for what I know...) to Apple's ecosystem is quite boring and not so useful. More interesting the METAL thing (a sort of highly optimized OpenGL for Apple A7). A sort of AMD-Mantle in the Directx field. |
| ||
I have always liked he type faces on MAC, Windows just cannot do it as nice. |
| ||
I don't understand why they couldn't just make a live testing environment for an existing popular scripting language like Lua, JavaScript, or Python. They have the resources to pull it off. Inventing a new language for it seems so unnecessary and causes unnecessary work for developers to adapt to learning this new language construct. But hey, whatever. I'm going to keep using Monkey X and my MiniC version, *cough* I mean Lua and JavaScript's bast*rd child. |
| ||
Apple only or cross-platform(probably Apple only I know but I can't find the link to confirm it)? |
| ||
I believe it's built into XCode, which means it's for Apple only. I could be wrong; so don't quote me on it. |
| ||
It looks pretty nice but I don't ever envision myself investing the time to learn anything again that isn't cross platform(unless I am doing something embedded that is very specific.) |
| ||
For system API programming you don't have much choices. You can only use Objective-C for Cocoa programming. I think it is good to have an alternative to Objective-C on Mac OS X for system API programming (writing libs). On all other systems, direct API programming is usually done with languages of the C-family (C, C++, C#), and Apple's Objective-C is different from that. With Swift they add now a 2nd language for Cocoa/API programming. Objective-C: ITableView *myTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; [myTableView insertSubview:mySubview atIndex:2]; [myTableView layoutIfNeeded]; UIColor *color = [UIColor colorWithRed:0.5 green:0.0 blue:0.5 alpha:1.0]; Swift: let myTableView = UITableView(frame: CGRectZero, style: .Grouped) myTableView.insertSubview(mySubview, atIndex: 2) myTableView.layoutIfNeeded() let color = UIColor(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0) In my opinion Swift is more readable. Especially using the dot syntax to access members and methods, like C++/C#/Java/Haxe/Monkey X/... I see it just as an alternative to Objective-C on Apple systems, and I think I will use Swift for Cocoa programming in the future, instead Objective-C. |
| ||
Heres an example of a simple OSX application written in Swift and Objective C: Swift code TestAppDelegate.swift Import Cocoa Class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet var window: NSWindow @IBOutlet var first : NSTextField @IBOutlet var last : NSTextField @IBOutlet var full : NSTextField func applicationDidFinishLaunching(aNotification: NSNotification?) { // Insert code here to initialize your application } func applicationWillTerminate(aNotification: NSNotification?) { } @IBAction func buttonClicked(sender : AnyObject) { full.stringValue = first.stringValue + “ “ + last.stringValue let myPopup:NSAlert = NSAlert() myPopup.messageText = “Hello”; myPopup.informativeText = “Full name is: \[full.stringValue]” myPopup.runModal() } } Objective C code TestAppDelegate.h #import <Cocoa/Cocoa.h> @interface TESTingAppDelegate : NSObject <NSApplicationDelegate> @property(weak) IBOutlet NSTextField *first; @property(weak) IBOutlet NSTextField *second; @property(weak) IBOutlet NSTextField *full; @property(assign) IBOutlet NSWindow *window; @end TestAppDelegate.m #import "TESTingAppDelegate.h" @implementation TESTingAppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application } - (IBAction)buttonClicked:(id)sender { self.full.stringValue = [NSString stringWithFormat:@"%@%@", self.first.stringValue, self.second.stringValue]; NSAlert *alert = [[NSAlert alloc] init]; alert.messageText =@"Hello"; alert.informativeText = [@"Full name is " stringByAppendingString:self.full.stringValue]; [alert runModal]; } @end To me the Swift code is a lot simpler and easy to read... but there are some very strange design decisions in Swift... |
| ||
FlappySwift https://github.com/fullstackio/FlappySwift |
| ||
Its far simpler and more approachable for beginners than ObjectiveC. That said I don't know why they kept the IBOutlet/IBAction junk thats been a legacy of ObjC and very quirky. Other languages just instantiate of type UIButton or UILabel or whatever and the class itself has the methods and properties for handling the events, makes it much easier. Gary |
| ||
Very impressive movement from Apple. Where this language originally comes from? Is this the actual implementation? http://swift-lang.org/main/ I watched the video on youtube and here's my opinion: Pros: - Impressive language, looks like a more advanced Javascript. - Works flawlessly along side with the C based stack. - It works as easy as a scripting language - Can be compiled to native code thanks to LLVM (though Apple loves LLVM long time, since all of it's development stack is currently works in LLVM) - Looks like beginners will love it (this is a very positive thing, more flappy bird clones please :) ) Cons: - Looks like an experimental toy language, we will need to see it how will it come within 3 years from now. - For use only within in the Apple ecosystem (either you're in or you're out, nothing more to discuss) - Not open source (technically you don't care as long as it works and you work with it, but if you are more into stuff like decision making, like politics/marketing/management then you will surely can make up your mind). - Personal view: It looks like they want to deprecate Objective C. |
| ||
nice |