4 ms·
A binary coder for Swift
- pirocks 9y agoInteresting how this has 57 points and as of now no comments.
- victor106 9y agoHow stable are swift releases now? What are some good resources to start learning swift?
- nikivi 9y agoFor learning Swift, we made an interactive map of all the best resources : https://learn-anything.xyz/programming/programming-languages/swift https://learn-anything.xyz/programming/programming-languages...
- heifer2822 9y agoI think, as a starting place, Apple's Swift Programming Guide is hard to beat
- penpapersw 9y agoIn my experience, it's difficult to go through because it's so comprehensive and thorough, and I guess it has to be because it has to assume the lowest common denominator audience. Personally I'd like a shorter guide that assumes you know a few languages (C#, ObjC, JS, Java) and skips a bunch of the tedium of how programming languages work in general and gets right to what's different about Swift. It may seem like it does that, but look at their page about control flow[1] and tell me it's not an unreasonably long-winded way of explaining switch, for, for-in, while, break, continue, and if. [1]: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/ControlFlow.html#//apple_ref/doc/uid/TP40014097-CH9-ID120 https://developer.apple.com/library/content/documentation/Sw...
- heifer2822 9y agoI agree but Swift is a new enough language that I'm not sure such a resource exists yet. When I learned Swift I just skimmed through the parts that weren't interesting and that worked for me. It was a good overview of the language. As an aside, the book, Advanced Swift, by the objc folks is fantastic but assumes you already know Swift. It's not what you're looking for, but something to move onto after you grasp the basics.
- unkown-unknowns 9y agoMaybe there is room for a publisher that makes books for people that already know how to program?
- dep_b 9y ago1.x was rough every point release broke major stuff 2.x was stable all through, but a lot of work to migrate from 1.x 3.x minor changes but a big renaming effort leading to a lot of work in accepting proposed changes in Xcode. Laborious more than difficult 4.x most projects I've tested just compile. On the road to a stable ABI
- userbinator 9y agothe numbers are byte-swapped to be endian agnostic Regardless of how fast it is, it seems wasteful to do all this byte-swapping when the vast majority of systems today, outside of more specialised applications, are little-endian.
- invokestatic 9y agoMost network protocols, including TCP and UDP, are big endian, so little endian really isn't that ubiquitous. And I imagine a big use case for the binary coder will be for networking.
- unkown-unknowns 9y agoBut even though the protocols are big endian, is it generally the case that you always make the data itself big endian? (Asking out of ignorance, not rhetorically or sarcastically.)
- nemo1618 9y agoIt's up to the programmer. In the systems I've worked on, we always sent the data itself in little endian.
- userbinator 9y agoTCP/UDP/IP are BE, but that's largely an artifact of the time they were invented (when the LE/BE split was more even), hence networking hardware is probably where BE is still commonplace. Most application protocols I've worked with are LE; serialisations like Avro, BSON, capnproto, protobufs, etc. come to mind, as well as numerous other proprietary ones. ASN.1 is a notable exception, but it's also much older.
- DSMan195276 9y agoYou can do byte-swapping in one instruction on x86, so it really isn't something worth worrying about. There aren't many big-endian systems out there, but it doesn't really matter that much. If you wanted to, you could change this so it always stores the numbers in little-endian (and does a swap on big-endian systems) but a lot of the uses of this will likely be for networking, and people generally expect big-endian in that situation.