6 ms·
This could be really cool given that Swift is already very JavaScript-like (Edit: TypeScript, really). A JavaScript-like that you can run on the web and is just
by _bxg1 8y ago
This could be really cool given that Swift is already very JavaScript-like (Edit: TypeScript, really). A JavaScript-like that you can run on the web and is just faster out of the box is appealing.
Now if only Apple would put more effort into cross-platform support for Swift...
- robbyking 8y agoHow is Swift JavaScript-like?
- _bxg1 8y agoSyntactically it's like someone took TypeScript and said, "what are a couple of tweaks we can perform to make it slightly more ergonomic, and also how do we get rid of the garbage collector".
- jdmoreira 8y agoNo. They are both typed languages but the feature set is not even comparable. Swift is a huge language
- _bxg1 8y agoI'm not saying they're equivalent, I'm saying if you're used to reading TypeScript then Swift will be very familiar, syntactically. That matters if you're thinking about splitting your codebase across two languages.
- jjtheblunt 8y agoSwift is not at all Javascript-like, I think. Interesting.
- boringuser1 8y ago>Now if only Apple would put more effort into cross-platform support for Swift... You made the mistake of thinking Swift is a programming language and not just the Apple API.
- _bxg1 8y agoSwift currently supports Linux and has unofficial support for Windows. It's open-source and compiles via LLVM. Commercially Apple has been unenthusiastic about fleshing out its support for non-Apple platforms, but the open-source community has partly filled that gap and there's lots of enthusiasm in the community. Given the recent decline in Apple's hardware sales, they could be heading for a Microsoft-like rebirth into a company that's forced to play nicer with others. https://forums.swift.org/t/swift-as-a-cross-platform-language-and-windows-support/12547 https://forums.swift.org/t/swift-as-a-cross-platform-languag...
- boringuser1 8y agoThere is almost zero application for Swift outside of an Apple environment. I'm willing to bet there is precisely zero production code written in Swift for Windows (or Linux). Anyhow, the Windows API (.net, C#) is better and has a brighter future and present.
- favorited 8y agoI know multiple teams who have Swift in production on Linux servers
- boringuser1 8y agoAlright, well, don't do that.
- maxdesiatov 8y agoWhy not?
- Eric_WVGG 8y agoWhy not? Dive in, the water’s great. https://vapor.codes https://vapor.codes
- hellofunk 8y agoSwift is like JavaScript/TypeScript only if you don't know Swift that well... They are so different, only very superficial comparisons of syntax would lead to such a statement.
- bobbylarrybobby 8y agoRight, both have sort of C-style syntax. That’s pretty much the beginning and end of their similarities.
- _bxg1 8y agoI don't know Swift that well, but this was my immediate impression when I spent a couple hours with it (and I've used C, C++, Java, C#, Python, etc.). The array/dictionary literal syntax (especially dictionaries) was probably the main thing. Lots of languages have similar array syntax (though fewer have the auto-grow behavior), but I can't think of another C-like language with first-class, dedicated dictionary syntax. C-likes also don't often have first-class functions/closures, or named function parameters (JS doesn't technically have the latter, but it effectively does with object destructuring; this is one of the syntax niceties Swift added). I didn't mean to imply they had an overall similar set of features, so much that someone who's comfortable with TypeScript would have a pretty easy time warming up to Swift, which matters on the web.
- hellofunk 8y agoSyntax is ultimately a fairly minor aspect of languages. The reference and value semantics, the memory management, the type system, the language runtime, these are what really create a development experience in a particular language. And they are on nearly opposite sides of the spectrum between Swift and JavaScript. If you are only superficially doing something in the language, a somewhat trivial project or just experimenting, then they might seem more similar than they really are.
- paavohtl 8y ago> C-likes also don't often have first-class functions/closures I think C is the only remaining C-like language not to have first-class functions. And there are compiler extensions for that too.
- matthewmacleod 8y agoYou're getting a bit of flak for this, but I actually think it's a valid comparison. While it's not intentional, but there's a fair level of similarity between the techniques I find myself using in Typescript and Swift – to the point where I've been able to transcribe some Swift code into Typescript when porting between platforms. Something to do with the "feel" of the language, maybe? Swift is definitely one of my favourite languages to work with – something about the style of programming it invites just seems to click with me. I agree it would be really nice to use it more extensively, because so far it's just been a single-purpose language and that seems like a bit of a shame.
- nicoburns 8y agoI agree. And I think Rust is like JS too. I think it's the mix between functional and imperative code. Under the hood, JS and python are very similar, bit idiomatic JS and idiomatic Python couldn't me different. To me, idiomatic Swift/Rust feels like idiomatic JS, whereas idiomatic Go is more like idiomatic Python.