4 ms·
> it's brilliant can you share what you find 'brilliant' about it?
by lovelyviking 5y ago
> it's brilliant
can you share what you find 'brilliant' about it?
- mrtksn 5y agoI'm not an expert on programming languages and for me they are the format that I obey to express myself to the computer to make it do things, Therefore I won't be able to tell you what are the strong points and advantages of Swift over other alternatives. What I can tell you though, is that the language is easy to read thanks to the choices they made in the way the syntax is and the language has enough abstraction tools to let me keep the parts of the code that I'm not actively working on away. For example, I like to use the property wrappers and extensions to put away the code that I'm done working on. I also like that its strongly typed but also gives me enough wiggle room with generics. I like the concept of protocols to vaguely define the basics of some kind of data structure and be able to pass around different flavours of it as if I'm on a weakly typed language where functions can take whatever you throw at them. Another thing that I like about swift is that the toolset Apple provides. I used to do JavaScript as my main language but I got sick and tired of the amount of effort to keep the stack together. Endless number of tools that have many alternatives that do the same thing in a slightly different way, hours and days spent in configuring them is something that I don't want to go through anymore. With Swift and the tools that Apple provide(various frameworks and xCode) starting something new to thinker on is as simple as creating a new Word document. It reminds me of the PHP workflows a bit, where you type your code in a text fil, put it in a folder and see the results immediately. Essentially, I like the comfort of using Swift.
- cableshaft 5y agoProperty Wrappers seem pretty neat, I wasn't aware of that new feature. Thanks for mentioning it. https://www.swiftbysundell.com/articles/property-wrappers-in-swift/ https://www.swiftbysundell.com/articles/property-wrappers-in...
- Jtsummers 5y agoBecause it's a bit of a pet peeve of mine, what you term "strong" and "weak" are more typically called "static" and "dynamic" typing. They do not correspond to "strong" and "weak" as a general rule. Python, for instance, is "strongly" typed (try printing the result of `2+"3"` in its REPL) but also dynamically typed. Neither "strong" nor "weak" typing is well-defined, but the most consistent differentiator is about implicit conversions or casting. Like in Perl you would get "5" as a result of printing out that previous expression.
- mrtksn 5y agoThanks for the elaboration.
- Someone 5y ago“Endless number of tools that have many alternatives that do the same thing in a slightly different way” I think that is a risk that almost invariably comes with being open and popular. I saw the same thing with C# vs Java. In Java, you don’t have a logging API, you have a meta-logging API into which you can plug multiple logging libraries. Similarly, there used to be (maybe still are) zillion of viable options for parsing XML, json, different build systems, etc. That brings flexibility, but at the price of having to spend time picking the best tool and anxiety about the grass at the other side, maybe, being greener. Often, eventually, the dust settles and a clear winner emerges, but that’s not a given, and doesn’t help you when you have to make choices before the dust has settled. I don’t follow JavaScript closely, but I think it definitely still is in the “before the dust has settled” phase.
- interpol_p 5y agoNot the OP but someone who also finds Swift brilliant I really enjoy the value types — real structs with copy-on-write behaviour (internally). So there's a lot of freedom to model your application with a single source of truth that can be updated in a transactional way, diffed, unified, intersected, without worrying about any leftover state causing bugs Protocols and protocol extensions are very powerful. Allowing you to write a generic interface and then add explicit functionality to anything which adopts that interface in a very clear way In combination with pattern-matching enums which can store uniquely typed data with their cases, it makes it very easy to model complex systems in a readable, maintainable way The combination of all these things, plus powerful generics and a very thoughtfully designed set of foundation APIs, makes it very pleasurable to write and read Swift code The new async/await functionality also seems like it was considered for a long time. It manages to stop you from doing stupid things with threading at compile time by being conservative about how you can use structures concurrently
- secretsatan 5y agoI switched to almost pure swift for a new app after having worked with obj-c a couple of years ago. TBH, when I first encountered swift I hated it, mostly because I felt it was always nagging me about optionals coming from rather fast and loose obj-c code. I eventually embraced it and the new App greatly benefitted, hardly any bugs out in the wild compared to our other apps, we mostly just get crashes from Apple code. Code is reeadable and easy to understand (although there is still some terrible code in the app from when I was still getting my head around it, but it works fine). It has some frameworks and protocols I've started to use extensively, the codable protocol is especially useful for web interface, combine is coming on in leaps and bounds. I still don't trust SwiftUI, even Apple's demo projects don't always implement things correctly and don't display properly if you use the wrong device in the wrong orientation. So I still use IB (New swift developers don't like it, it is a pain and hard to use for apps that run on all devices in multiple orientations, but for what it is, I've used worse in my career)