Live data from Hacker News

A binary coder for Swift

mikeash.com

1–10 of 24 posts

Re: A binary coder for Swift

#5
the 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.

Re: A binary coder for Swift

#7

the 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.

Most 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.

Re: A binary coder for Swift

#8

How stable are swift releases now? What are some good resources to start learning swift?

I think, as a starting place, Apple's Swift Programming Guide is hard to beat

In 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/Sw...

Re: A binary coder for Swift

#9

the 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.

You 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.

Re: A binary coder for Swift

#10

Earlier quoted context omitted.

I think, as a starting place, Apple's Swift Programming Guide is hard to beat

In 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…

I 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.

Post reply on HN