title: Swift to JavaScript transpiler - possible?
body: <p>As an iOS developer coding in Swift, I find it increasingly annoying to have to coordinate the same code written in Swift with front-end developers coding in JavaScript. It would be much neater to implement common functionality in one place and then translate to JS, right?</p>
  
  <p>I've started to wonder if a Swift to JS compiler was feasible? Perhaps not to share the full code, but some generic common functions at least.</p>
  
  <p>I found this transpiler online: <a href="http://www.shiftjs.com" rel="noreferrer">SwiftJS</a>. Sadly, this one doesn't really cut it.</p>
  
  <p>The following code:</p>
  
  <pre><code>let a = [1, 2]
  print(a.count)
  </code></pre>
  
  <p>returns <code>Invalid Swift code</code> in the demo. Which doesn't instil confidence. Never mind the more intricate bits like optionals or function overloading.</p>
  
  <p>I was wondering about starting a transpiler project, but then I realised there were many pitfalls. For instance this code:</p>
  
  <pre><code>var a = [1, 2]
  var b = a
  b.append(3)
  </code></pre>
  
  <p>should make <code>a</code> equal to <code>[1, 2]</code> and <code>b</code> equal to <code>[1, 2, 3]</code>. In JavaScript, both would be <code>[1, 2, 3]</code> as they're passed by reference and not by value.</p>
  
  <p>Would it be at all possible to write a proper transpiler?</p>