People who know what they're talking about don't need PowerPoint -- Steve Jobs
Ramblings of
Alex Lovett
RSS
Twitter
Tumblr
Youtube
LinkedIn

Navigation:

Up a Level - error_log - Experiments - Store

Documents:

Unity5 - Reality_2.0 - Math_Art - error_log - Lilly - Drawing - GameDesign - Inspiration - XFactor - Valideus - Food - WheelReview - GKN - Lumen - WishList - RoundTree - Painting_with_Light - House - Website - Fridge
Tags: - Apple - Tech - Games
Show comments

Nerding out over here with the new Swift programming language from Apple
Read the ebook, quite impressed with how elegant it is, minimal but powerful pushing the functionality to the frameworks like Cocoa and SpriteKit, GCD for asynchronous code and so on.

Most importantly is, I can already write code in Swift, I cannot even read most code in Objective-C

Super nerd points for writing Swift code in a command line terminal window:



Even bigger nerd points for doing the same with C# and Unity:



I'm already jealous of a few of the language features that C# is missing, like easy to read write Tuples, and the range syntax '0.0....120.0' nice they stole that from Python I think.

The fact that it looks so much like a script language, yet is really compiled down to machine code is a key detail here. The fact it looks like a script but has no garbage collection is also significant. So very very glad I chose to learn C# instead of Objective-C as it has pretty much already taught me to write in Swift, people going from Objective-C to Swift will probably find it harder

:-D



Also very jealous of the ability to write into this realtime 'playground' where it runs your code as you write while showing visual representations of values, code ran over time even fully rendered graphics object on the right side of the screen. The Ability to scrub your playback back in time.... awesome.

The fact it is a closed spec/compiler and will only run on Apple devices, well what do you expect.

And this had to be done with the new playground:



My talents are wasted

But swift is really elegant and minimal, while allegedly very very fast.



versus c#



So very very similar looking to C#.. and semi colons are ugly

Also I just I write a nice script that you can drag/drop a Unity project folder onto and it will inject preset hardlinks ( like symlinks but craftier ), so say you have a Standard Unity Project folder with a bunch of utility scripts, standard images and stuff you like to always have in a project, it can link to that ( can show a lis. t of items to pick from if you only want to include some not all of the items also ), and another script you can drag the folder/folders onto that will remove those links. Tested it all and It's completely safe regarding deletion. Which means I can finally start using separate Projects for things instead of lumping everything into one big monolithic super project that takes over 10 seconds to compile every time I change something in the editor :-S

Producitivty Ho!

Trying to implement something similar to Swifts built in language support for Tuples





Creating a generic list of an anonymous type, simple enough

But how do I return an anon type from a method?

Using anonymous types and casting using an extensions method, is how:



Once you hide all that extensions method stuff away It's not too ugly, you are left with a function that returns an object. And you take the result and just do:

whateverResult.CastTo( new{ name="", age="" )

And then you can access the properties as per usual, but this will get real ugly for lists of anon types, and yes I realise I have age as a string not an int

And yes with dynamic type you can probably do this nicely, but I target iOS with is ahead of time compilation AOT, so cannot do dynamic

Still.. .swift is better

And next C# has Tuples but they are completely useless ( thought I think they are improving this in C# 6 )



You can't name there arguments, and it looks ugly as sin, I hate angle brackets

I also saw someone creating a class that inherits from the Tuple type, allowing you to add names to it... not sure why you would ever do that.. I guess it saves you having to implement IComparable, IStructuralEquatable and friends on your own custom type.



So back to using 'out' parameters, which are kinda nasty... very nasty really, just not as nasty as the above


Show comments for 'Nerd Day with Swift'
You have reached the end of this page - But there's more! Click Older for more
Subscribe to my News Feed.. or screw you then!
Boring damned people. All over the earth. Propagating more boring damned people. What a horror show. The earth swarmed with them -- Charles Bukowski
Copyright © 2006 - 2024 - Alex Lovett
Site and content designed, built and massaged by
Alex Lovett
( HD6 / HeliosDoubleSix )
contact me by email:
Page Rendered in: 0.031 seconds, like a boss