Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Will Unity Ever Support Apple's Swift?

Discussion in 'Scripting' started by xJadonx, Jul 13, 2015.

Thread Status:
Not open for further replies.
  1. xJadonx

    xJadonx

    Joined:
    Jun 19, 2015
    Posts:
    8
    Just a simple question really. I'm curious as to if Unity will ever implement Apple's Swift Language? If not, why?
     
    Jessy likes this.
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    First of all you'd have to tell us why. I can see no benefit in doing so.
     
  3. xJadonx

    xJadonx

    Joined:
    Jun 19, 2015
    Posts:
    8
    Really it could just be another language to use for people who feel they want to migrate from Xcode to Unity. Just something else besides C# and Javascript.

    Honestly I think it would be cool to see a node based visual scripter native inside Unity. I have NO idea why that's not a thing yet.
     
  4. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    439
    Im not a swift programmer myself. It would be cool for unity to support more languages but that comes at a cost as compiling will be slower with more languages.
     
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    No, it comes at a cost of breaking Unity if you want IL2CPP. A better angle would be Unity having some sort of pluggable interface at a future date...
     
    apsdsm and Polymorphik like this.
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    I'd like to see Swift replace Unityscript. The syntax is similar enough that porting existing code wouldn't be hard, and it's a fully-developed language, whereas Unityscript development unfortunately stopped some years ago. In any case, there's no reason why adding languages would have any effect on compiling times.

    --Eric
     
    TaleOf4Gamers, rikey, apsdsm and 3 others like this.
  7. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    I think Swift would be an awesome addition to Unity. Plus it would be a perfect sales pitch to current Xcode developers.
    http://feedback.unity3d.com/suggestions/swift-support
    As long as it spits out standard DLLs I don't see how it would effect IL2CPP. It's about creating a .Net Swift compiler.
     
    kirill290292 and Kiwasi like this.
  8. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,732
    If you can build or find a compiler from swift to .NET IL, then you are good to go.
     
    PraetorBlue likes this.
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    ... but it's not for everyone and it's going to stress Unity in a number of areas: language features, documentation, examples, tutorials and so forth.

    It is also incredibly niche. But that doesn't make it worthless, it just means Unity can't make a decision to do it just for swift. It needs to allow people to use their own choices at their own risk and responsibility, some kind of glue. That makes everyone happy. Loads of people have their preferred language that's always going to be best for them.
     
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,732
    I wasn't imply that Unity should support it. Just that it's already possible if someone loves the language that much.
     
  11. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    681
    I see Swift as a combo of Python and Javascript. Both languages which I don't like that much lol. Im still willing to try swift though. Also, as hippocoder said, it would really create a problem where documentation and tutorials would suddenly become obsolete. If anything, Unity should create some sort of Javascript to Swift converter and include both Swift and Javascript. Over time, Unity will just ease Swift into the engine and remove Javascript at Unity 6 when the converter is mature and works with a high success rate.

    However I would love to try out Swift and see what all the fuss is about ;)
     
  12. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    I did and it's not for me :) Might appeal to people who loved blitzbasic and fancy a flexible way to work. For me, I just need *what is guaranteed to work*
     
  13. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    Say Unity would added Swift support.. Unity-Swift could become a derivate so far from the original swift... that programmers with swift knowledge would not even benefit from it.

    Just like UnityScript derivates from Javascript so much, to an extend that no one with Javascript experience does really benefits from learning UnityScript instead of C#...

    Personally, I'm really happy with C# and I could care less if UnityScript support is eventually drops. (And even lesser if about adding more languages like swift.) In fact I would be worried that adding another language, means less time developing/fixing new features.
     
  14. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,479
    i rather see a focus on features and docs, instead of supporting more languages. C# just makes sense if your working in mono/.net
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    No idea why you think that would happen. Has Unity C# deviated so far from the original C#? No, not at all. Unityscript is a custom language, and not Javascript. The idea of Swift in Unity is for it to be Swift, not a custom language.

    That's nice. This topic isn't for people who are really happy with C#.

    --Eric
     
    MitchStan and flutterShift like this.
  16. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    I was drawing a parallel to the many new comers that think going with UnityScript because they have Javascript experience is the best route to go. A lot of people, at first, think that UnityScript is Javascript. I'm not saying it is. But I certainly was one of them in my beginning. Hey I guess naming it Javascript and giving it the .js extensions doesn't help either.

    When is giving my opinion not allowed in here?
    If there is no place for argumentation in here: this wouldn't be a forum.
    And I didn't stop at I'm really happy with C#, Goodnight... My paragraph was basically an argument on why I would not see the arrival of a new programming language in Unity too well:

    To get back on topic and answer the original question: No I do not think that Unity will ever support Apple's Swift.
     
    Last edited: Jul 13, 2015
  17. eisenpony

    eisenpony

    Joined:
    May 8, 2015
    Posts:
    907
    I'm not sure I understand all the implications but it seems to me IL2CPP almost solves this. There are a number of languages which can be used to create .net IL: C#, F#, IronPython, IronRuby, etc.. if we can compile from IL to CPP, then wouldn't any language that can create .net IL be supported by Unity? In that case, someone just needs to write a .net IL compiler for Swift, which personally, I think has a decent chance at happening. (Sorry for the link to a chm file but apparently Microsoft thought it would be easier to archive it's old TechNet magazine articles in this antiquated format)
     
  18. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    I'd rather see the Unity devs use their time to develop a native Blueprints like visual scripting tool which will have more utility then a niche syntax.
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Not really. I think at the beginning it was supposed to be "almost Javascript" though. But the point of Swift in Unity is that it would be Swift, not "a new language sort of vaguely similar to Swift".

    You don't need IL2CPP for anything; that's an unrelated step that works on code that's already converted to CIL. "All" you need is a Swift -> CIL compiler. Such as the Boo -> CIL and Unityscript -> CIL compilers that already exist. You can already use other languages in Unity such as F# by compiling into DLLs, but that's not really an ideal way to work.

    --Eric
     
  20. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    So it very much makes sense to *not* support swift but instead support the LanguageX -> CIL step. If I recall one of the Unity guys did express this on skype and had a good discussion on it.

    Speaking of which can you just bite the bullet and join Unity and mods on slack? it's quite trouble free I assure you... and we'd love to have you :p
     
    Kiwasi likes this.
  21. phocker

    phocker

    Joined:
    Sep 12, 2010
    Posts:
    57
    I would like Unity to ONLY support C# and forget wasting time with the other languages!
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    I don't know what that means....

    Sure, and while we're at it, let's just have one operating system, and one game engine, and one phone, and one console, and one everything. Forget choice, it's a waste of time. Let's just force everybody to use the slightly-less-bad-version-of-Java, whether they like it or not, it's for their own good.

    --Eric
     
    calmcarrots likes this.
  23. eisenpony

    eisenpony

    Joined:
    May 8, 2015
    Posts:
    907
    Great. So aside from a Swift to .net compiler what would be needed to get language support into Unity? A language extension to MonoDevelop?

    I would expect an avatar of Spock to more understanding of IDIC
     
  24. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,004
    They killed off Boo because nobody was using it. I'm assuiming that with the community being kinda C#-centric (and javascript-hostile, for good reasons), you'd have to have a lot of people wanting a singular different language before they'd even consider it.

    Using fringe languages is a pain in the butt. I'm working at a company that made a Unity game in Boo. Having it work with Unity 5/IL2CPP is not fun.
     
    Jessy likes this.
  25. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    If they added Swift I would assume that it would follow the Swift spec 100%. Not like UnityScript where it's just sort of like JavaScript, Swift in unity would be the real deal.
     
  26. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,732
    Currently this is only possible as far as CIL supports swift functionality.
     
  27. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,479
    i know there are defiantly some mis matches between what swift has and cil, so i don't think a 100% compatibility swift for unity would happen. If swift has to be modified like javascript for unity it breaks the whole purpose of doing so.
     
  28. phocker

    phocker

    Joined:
    Sep 12, 2010
    Posts:
    57
    Ok, perhaps I was not thinking logically there. Good point on having a choice. But, not Swift!
     
  29. CodePlaysMC

    CodePlaysMC

    Joined:
    Jul 15, 2015
    Posts:
    1
    I am a current Swift, Java, and C# developer. I would choose Swift over Java and C# any day.
     
    dafasion, Jessy and HonorableDaniel like this.
  30. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Well, that was unexpected. Get on it, Unity, no excuse not to integrate it now. ;) This is interesting too: 'Silver comes with a unique feature called "Oxidizer" that lets you convert C#, Java and Objective-C code into Swift with a single click.'

    --Eric
     
    TaleOf4Gamers likes this.
  32. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    Yea what's even weirder is that swift isn't even open sourced yet.
     
  33. xJadonx

    xJadonx

    Joined:
    Jun 19, 2015
    Posts:
    8
    I have no idea why scripting nodes are not built into unity already. I wish they would implement them already.
     
  34. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    They already addressed it in the recent unite video, they said that they tried it twice already with no luck.
     
  35. AhrenM

    AhrenM

    Joined:
    Aug 30, 2014
    Posts:
    73
    This is meant 'mostly' in jest ;)

    The phases of Unity language support
    =============================
    1) Oh joy is me, Unity supports my favourite language!
    2) More joy, look I’m pushing game objects around with my favourite language!
    3) Wait...this language feature I use all the time isn’t supported...
    4) ...and this one doesn’t serialize.
    5) But maybe, if I write a custom handler and a bunch of helpers that hook into a call and re-dimension the...
    6) ...one month later...
    7) I remember when I used to write functional code....
    :p
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    Nothing like that has happened with any language in Unity, so I'm not sure where the "jest" is coming from. Especially since they haven't added any languages since the early days of Unity 1, so there's no trend to extrapolate from. Unless you're referring to C# not being updated for several years, but somehow I doubt that's preventing anyone from writing functional code.

    --Eric
     
    Kiwasi likes this.
  37. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,327
    Agreed. Unfortunately, there is not yet an optimal solution for Unity, because Swift hasn't reached feature parity with C#. I estimate one more year before deprecating any other language options will have the greatest return on developer productivity and happiness.
     
  38. cybertree

    cybertree

    Joined:
    Jun 19, 2015
    Posts:
    100
    Hi,I know this thread is old but anyone can read it so...
    I think unity may add support for swift but I doubt it's going to be soon. RECENTLY they said that swift was going open source so until it does get open source unity bassicly can't start developing a version of swift for unity. It would take some time to make... And also swift is only Mac, IOS and soon Linux benefit so until windows and play station is benefited I doubt they make it.

    I like C# and UnityScript. Swift is good and simple. I hope Swift does come to unity.
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    There's nothing stopping anyone from implementing Swift regardless of it being open source. As mentioned earlier in the thread, it's already been done (just not in Unity). Also it has nothing at all to do with platforms. Once Swift is compiled to CIL, it's completely irrelevant what language that CIL came from. Unityscript, Boo, and C# all end up as the same CIL, for example.

    --Eric
     
  40. cybertree

    cybertree

    Joined:
    Jun 19, 2015
    Posts:
    100
    Yes. I also think that unity isn't going to add swift if nobody asks for it. Once it gets enough requests it will probably support it.
    So if you want swift in unity don't forget to ask for it!
     
  41. Pi_3-14

    Pi_3-14

    Joined:
    May 9, 2012
    Posts:
    168
    I've just tipped my remaining votes into https://feedback.unity3d.com/suggestions/swift-support

    There is too much knee-jerk "don't change anything, I've only just got my head around C#" content in this thread. As the thread grows, fewer people will read all the way through, more will surely give the same knee-jerk response: "I like it the way it is -- don't change anything!" If C# is the extent of your experience, then please take that into account, and observe the natural tendency of the mind to protect/preserve its reality model, by championing that with which it is familiar.

    In the last three years I have acquired JS, C++11, Python, Swift. Prior to that I was using C#, ObjC, C. I can't imagine someone with a broad perspective opposing adoption of Swift. It is by far the most plausible candidate.

    As pointed out, the heavy lifting has been done: http://elementscompiler.com/elements/silver/

    Can anyone outline what needs to be done by Unity to integrate this? Silver can convert Swift -> IL, maybe MonoDevelop can take care of debugging? Is it possible that we don't need Unity to do anything? Maybe we can do it ourselves?
     
    Last edited: Nov 29, 2015
    Jessy likes this.
  42. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,732
    This. Simply create a dll from your swift compiler and drop it in the assets folder.
     
  43. Pi_3-14

    Pi_3-14

    Joined:
    May 9, 2012
    Posts:
    168
    Interesting! IIUC the standard C# scripts get compiled into ./library/scriptassemblies/Assembly-CSharp.dll

    The next challenge would be debugging. And I don't understand the mechanisms in any detail. I suppose when you hit play, Unity compiles your C# scripts into that ./library/scriptassemblies/Assembly-CSharp.dll, launches the Mono runtime (pointing it to that .dll). And then when you attach MD debugger, I suppose it attaches to this runtime.

    So MD has to be communicating with the runtime, 'go to next statement / enter scope / exit scope / etc.' -- but this is nothing to do with Unity. It is MD's problem!

    I wonder whether MD could be extended to handle different languages.

    I also kind of wish Unity would acquire Script Inspector 3, and create a genuine IDE.

    BTW, I notice "F# SUPPORT" https://feedback.unity3d.com/suggestions/f-support has attracted 10 times the votes Swift has. And a cursory search suggests F# is similar to Swift. Hardly surprising, once one language comes up with a new mechanism, it's not long before every language has some implementation of it. Look at Lambdas! So I suppose this enquiry is better directed as "It would be nice if Unity were to support any language that compiles into .NET IL."
     
  44. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,732
    It does. Just drop the compiled assembly into you assets folder. Didn't I just say that?
     
  45. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,479
    If the users can figure, it out go for it, such is just dropping in a dll. But I really don't want Unity Tech putting there time into adding more languages. C# is good enough and I rather see Unity Tech spending there time fixing bugs and making 5.x stable.
     
    Kiwasi likes this.
  46. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,732
    For new language support were to be prioritised, I would go for the latest C# and .NET framework. That will make more of a practical difference then any new languages.
     
    passerbycmc likes this.
  47. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,479
    Agreed, since i learned C# and .net before unity i run into a lot of problems of using language features unsupported by Unity or using parts of the .net library that don't exist in the old mono unity uses.
     
    Kiwasi likes this.
  48. Pi_3-14

    Pi_3-14

    Joined:
    May 9, 2012
    Posts:
    168
    Yes, but it isn't as simple as "Just drop the compiled assembly into you assets folder."

    Because to work productively you need some kind of debugging environment.

    So I'm trying to figure out a rough roadmap of what is involved in supporting another language to the same level as C#.

    I'm not convinced it is a lot of work for Unity. It looks to me as though the external debugger / code editor takes on 99% of the work.

    But it would help to have a clear conceptual map of what happens when you press the play button, and then attach MonoDevelop Debugger.

    If we can see clearly what needs to be done, we will be in a much better position to umm and arr over the merits of supporting different languages.

    Unity is currently going through a boom, as a result of their in-game advertising initiative. They are recruiting heavily, and I don't think they are stretched for resources at this moment in time. So I don't think its a case of "they only have so much effort, they should put it into stabilising".
     
  49. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,479
    It is a case of that though, have you tried to use 5.2 in production? Nowhere near polished enough with critical bugs blocking release all over. I would like them to expand and support the newest .net and C# 6. But i don't see a huge value in supporting more languages. Since it is a huge cost for them to properly support them especially considering that they would have to write their documentation for yet a other language.

    I really see no issue with saying you need to use Language X to use this engine. It allows for the community to not be fragmented offering better material for beginners. Also for the experienced programmers learning and jumping languages is easy and they can be productive with in a few hours in a new language.
     
    Kiwasi likes this.
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,250
    They don't do that now; they have a tool which automatically converts code.

    There's no indication of that, in fact the opposite.

    Except for the reason why they offered a choice of languages in the first place, of course.

    --Eric
     
    Kurt-Dekker likes this.
Thread Status:
Not open for further replies.
unityunity