10 ms·
As someone who refused to sink any significant time into Swift until they open-sourced it, I have found it to be the most productive statically-typed, native la
by AsyncAwait 11y ago
As someone who refused to sink any significant time into Swift until they open-sourced it, I have found it to be the most productive statically-typed, native language out there. Its type system feels like the best of C# and Rust, while it feels that the speed at which one can pick it up is not that much greater than that of Go despite being a much richer language, (I've started learning in January and am at the level now where I can take on a fairly complex Swift project and feel comfortable about being able to finish it in time, plus I now use Swift for almost any programming task, 90% of them at least).
Plus, you have to give Apple credit for getting the open-source release right, (GitHub, pull requests, proposals, mailing lists, frequent dev builds, Linux support - I guess Chris Lattner has been the one driving this, but I have to give credit to Craig Federighi and Tim Cook for letting him do it.)
The only part that frustrates me is that SourceKit seems to crash every other minute for no apparent reason - but that is no fault of the language itself.
Swift is the first piece of Apple software I'm genuinely excited for.
Congrats to everyone who contributed to the 2.2 release
- wyldfire 11y ago> the best of C# and Rust e.g.? I've only just scratched the surface of Rust and dismissed C# as a Java clone (but maybe I shouldn't have?). What's some examples of the best of Swift that you see?
- chadzawistowski 11y agoOne case where C# is far superior to Java is generics. Generics were a cutting-edge feature in 2005. Microsoft took the opportunity to start from scratch, and released the .Net Framework 2.0 without backwards-compatibility, and with full support for generics. A List<String> is actually a List of String. When Sun released Java 5, they didn't want to disrupt the established Java ecosystem. Their implementation is called "type erasure". As an example, List<String> is actually just List<Object>, with automatic runtime typecasting to String. https://docs.oracle.com/javase/tutorial/java/generics/erasure.html https://docs.oracle.com/javase/tutorial/java/generics/erasur... Java's solution works well enough, but it breaks down in certain scenarios, such as multiple levels of generics. For example, when getting an element from a List<List<String>>, Object is not cast to List<String> (which doesn't really exist), but merely List. C#'s implementation of generics became even more sophisticated with C#4, which introduced covariance and contravariance. https://msdn.microsoft.com/en-us/library/ee207183.aspx https://msdn.microsoft.com/en-us/library/ee207183.aspx
- santaclaus 11y ago> Generics were a cutting-edge feature in 2005. Generics have been around since at least the early '80s.
- chadzawistowski 11y agoWell, "cutting-edge" in enterprise technology. Another interesting failed prototype on the JVM was the language "Pizza" https://en.wikipedia.org/wiki/Pizza_%28programming_language%29 https://en.wikipedia.org/wiki/Pizza_%28programming_language%...
- nostrademons 11y agoAda isn't enterprise technology? https://en.wikibooks.org/wiki/Ada_Programming/Generics https://en.wikibooks.org/wiki/Ada_Programming/Generics http://www.cs.dartmouth.edu/reports/TR86-104.pdf http://www.cs.dartmouth.edu/reports/TR86-104.pdf (From 1984.)
- lern_too_spel 11y agoWhen does it matter what an element from a List<List<String>> is cast to at runtime? In a properly-written statically-typed program, types are a compile-time construct (ignoring the machinery of dynamic linking and method call semantics in particular implementations, which don't matter to the programmer), and though you may use them at runtime via reflection, I would argue that 99% of the time that you do, you're writing bad code. http://stackoverflow.com/questions/20918650/what-are-the-benefits-of-javas-types-erasure http://stackoverflow.com/questions/20918650/what-are-the-ben...
- dkharrat 11y agoType erasure introduces limitations on what you can do at runtime that forces a developer to write code to workaround it. For example, in Java you can't write a generic method that instantiates an object based on the type of the generic. The workaround is typically to pass in the Class type as an additional parameter to the method, which in theory should not be necessary. A lot of JVM-based languages are required to introduce additional complexity in the language to simulate reified generics (e.g. Scala's Manifest/TypeTag classes).
- peripitea 11y agoHaving worked with both for several years, I would rate C# as a much better language than Java. The language by itself is noticeably better, but the difference is even more pronounced if you include the ecosystem -- Visual Studio vs. Java IDEs, the class libraries, ASP.NET MVC vs. Struts and its ilk. I would check it out if you have the need to do any Windows-related programming. (Not sure how great the support is outside Windows.)
- meddlepal 11y agoUh, when was the last time you worked with Java? Struts isn't a popular framework anymore and hasn't been for awhile. IntelliJ absolutely trounces VSS and some combination of Spring Boot, DropWizard or Vert.x blows ASP.NET MVC away. Not to mention the whole ecosystem is a hell of a lot more open. There is a library for just about anything under the sun.
- mhd 11y agoEnterprise environments tend to be very conservative when it comes to stuff they let you install or even use. Often you can't just drop JARs in there, never mind use your own JRE. So you're often stuck with technology that sites like these consider quite ancient… It gets even worse on desktops, as sysadmins might be able to isolate a server enough to allow some "new" tech, but vetting a new Java version or library for a few thousand office desktops is a task nobody really wants to do. So I wouldn't be surprised to still see some Java 1.4 Swing apps in use at big insurance or pharma companies. (And if I'd had to pick between that or do a web app that supports their IE8 browsers…)
- Recurecur 11y ago"Enterprise environments" also have to be very conservative about security issues - which often means they're forced to update to currently supported versions of software. Java 8 is the only version currently receiving security updates. The same thing applies to many other software packages, including browsers, Linux and Spring. Sane IA folks don't like to deploy known security holes. It sounds like you're dealing with some backwards-thinking folk. ;-)
- raverbashing 11y ago"and dismissed C# as a Java clone" It definitely looks like that, but I'll take C# over Java any day Java API looks like it was built by the worse bureaucrats they could find and one piece doesn't fit another except in a very specific (non-obvious) way
- AsyncAwait 11y agoSome of the things off the top of my head in no particular order; protocols, (closer to traits than interfaces), Optional types, (elsewhere no null types), pattern matching (if let, case let), guards, (so you can cover your preconditions nicely), immutable let bindings first, var variables second, (with mutability being tied to the binding outsite of reference types/classes), tuples, lazy evaluation, flexible closure syntax, fairly powerful type inference, enums as tagged unions, (or as standard C enums if you want), extensions - even for core structures if you need it - straighforward way to define custom or overload existing operators, type system powerful enough to be able to implement a fairly convincing Functor, Applicative or Monad without much effort, structs AND classes, most things are value types... But most importantly to me, Swift is composed in such a way that it just 'clicks' for me, ie many times many times I can guess how something is likely called or how it will behave without looking at the docs and I have a solid chance of being right - that 'intuitiveness' is something that is lacking in many other languages I've used over the years. In regards to C#, by now it is definitely not just a Java clone anymore, in particular saner type system and much more functional features edge it for me over Java, plus the speed of evolution is much greater in the C# land. If you want to see how C# and Java differ but are tied to the JVM, try Kotlin: http://kotlinlang.org http://kotlinlang.org - it's fairly similar in feel to C# and has 100% Java compatibility.
- apetrovic 11y agoI love Swift dearly - I spent two years in Objective C land, after 8 years of C# and 10-ish years of C++ pain, and started using Swift day to day from Swift 1.2. But the current version have one big gaping hole: generic protocols are utter shit. For the uninitiated: Swift generic protocols don't have generic parameters, they have type constraints. Which means that a function can't return generic protocol. Which is the stupidest thing ever. There's a way to dance around that restriction, by making an intermediate class to do type erasure by hand (why I should do that? That's compiler's job), but still - Swift crew are obviously very talented bunch with a good taste, how they allowed such nonsense from the start? PS I don't want to sound too negative, Swift replaced C# as my favorite language, 95% of the time it's joy to use (especially after Objective C, I never agreed with that language), it's just - the generic protocol thing drives me mad.
- AsyncAwait 11y agoYeah, somewhat related to that; it's not currently possible to have typealias for a type with generic parameters, one has to wrap it in a struct or an enum, however Swift is very much not done and they're catching up quickly, so I'm optimistic, especially now that we can see and affect what's coming next.
- melloclello 11y agoGeneric typealiases are coming, thank goodness: http://ericasadun.com/2016/03/08/generic-typealiases-are-a-thing/ http://ericasadun.com/2016/03/08/generic-typealiases-are-a-t...
- AsyncAwait 11y agoAwesome! This is what I'm talking about; now that Swift is open-source we can see which improvements have landed and what is coming next. Thanks for the link.
- lmm 11y agoHave you used OCaml? Swift seems very similar to OCaml from what I can see - without the nice module system, but perhaps with a more familiar syntax.