News for hackers. Stuff that matters.

lyinsteve

Re:Understanding Objective-C by transpiling it to C++ on Saturday December 02, 2023 @10:44PM (#38504620)
The Swift optimizer has matured dramatically since 2017, to the point where I think this benchmark would almost certainly not result in a 3x power usage/4x slowdown compared to C.

On the current benchmark game, many of the purely algorithmic benchmarks are close to C performance, but many of these benchmarks seem to be stale and haven't been touched in quite a while. It would be nice if someone went through and rewrote these using current idiomatic Swift (where many of the "use unsafe bits for speed" tricks are unnecessary) and see how it really stacks up.

Re:Catching integer overflows in C on Wednesday August 22, 2018 @12:12AM (#17816237)
I don’t know much about rust specifically, but the overflow traps happen in debug (i.e. -O0) builds, and are not emitted when optimizations are enabled.

LLVM’s constant folding and canonicalization passes will convert (x * 2) / 2 from

%0 = mul i64 %x, i64 2

%1 = div i64 %0, i64 2

to

%0 = shl i64 %x, i64 1

%1 = shr i64 %0, i64 1

Which constant folding will reduce to just %x.

Re:Swift 5: start your engines on Wednesday August 09, 2017 @09:56PM (#14975653)
There are tons of amazingly-smart people working on Swift at Apple right now
Re:Swift 5: start your engines on Wednesday August 09, 2017 @09:53PM (#14975635)
-swift-version 3 really just turns on some different paths through the parser and type checker to allow previously-valid Swift 3 code to survive to code generation time.

They're both compatible

Re:We're joining Facebook on Tuesday July 25, 2017 @02:29PM (#14850531)
I have the strange feeling this will really only be used to enforce the copyrights of large music and movie industry corporations and will not be effective at protecting the IP of independent creators.
Re:GitHub Report Card on Wednesday January 04, 2017 @11:07PM (#13324645)
This should be much higher. Thanks!
Re:Fun with Swift on Monday January 04, 2016 @11:40AM (#10836544)
The author completely missed the point of named parameters. How am I supposed to know that the string argument of "make_window" is the title?
Re:Base65536 – Unicode's answer to Base64 on Sunday December 06, 2015 @01:28AM (#10684572)
Why did I just implement this in Swift? https://github.com/harlanhaskins/Base65536.swift
Re:FastMail: Shutting down our XMPP chat service on Monday November 16, 2015 @12:34AM (#10572796)
Apple uses XMPP internally as a way to securely communicate.

Doesn't really change much; just thought that'd be an interesting thing to throw out.

Re:The “Only” Coke Machine on the Internet (1998) on Tuesday September 08, 2015 @02:41PM (#10187472)
I'm a Computer Science House member -- Drink is still a staple of our organization! Where else can you get Jolt on campus?

Also we've since made an awesome web app and iOS app for dropping drinks.

Re:Should I use a Swift struct or a class? on Saturday July 04, 2015 @02:04PM (#9830968)
Surprisingly salient and cogent points for an article that's so hostile and willfully ignorant.

The author is correct about when to use both, and I'm glad he doesn't discount structs entirely like I've seen from some OOP strongholds.

"The way they write functional programs for decidedly non-functional problems is through a trick called a monad, which I will not explain and nobody understands anyway,"

Maybe you'd be less hostile if you actually took the time to learn about generic abstractions and how they can greatly simplify a codebase.

Hint: Optional is a monad, and you can use it as such.

Re:Why Android is a Better Platform for Startups than iOS on Saturday June 20, 2015 @11:45PM (#9752072)
>The move fast and break things approach

Sounds like something I want no part in.

Re:“Swift will be open source later this year” on Monday June 08, 2015 @10:39PM (#9683779)
LLVM has a GitHub mirror, too.

https://github.com/llvm-mirror/llvm

Re:Atomics in Objective-C on Tuesday May 05, 2015 @02:43PM (#9494167)
Why no mention of GCD here? GCD is very, very good at synchronizing access to shared resources.

The most Cocoa-compatible way of handling background execution of expensive procedures is always going to be best executed, quickest, using Grand Central Dispatch.

For example:

    @interface Foo ()
    @property (nonatomic) dispatch_queue_t backgroundQueue;
    @end
    
    @implementation Foo

    - (BOOL) veryExpensiveMethod:(id)arg completion:(void (^)())completion {
        dispatch_async(self.backgroundQueue, ^{
            if (_counter++ > N) {
                _counter--;
                return NO;
            }
            // Critical section
            _counter--;
            return YES;
            dispatch_async(dispatch_get_main_queue(), completion);
        };
That will ensure every call to -veryExpensiveMethod is run in sequence, and won't require waiting on your end.

These problems have been solved, better.

Re:Ways to save Apple (1997) on Thursday April 30, 2015 @11:38PM (#9469242)
>50. Give Steve Jobs as much authority as he wants in new product development.
Re:Swift 1.2 and Xcode 6.3 beta on Monday February 09, 2015 @04:14PM (#9023795)

    let x: String = {
       if 3 == 4 {
          return "Hello"
       } else {
          return "Goodbye"
       }
    }()
Although in this case, I'd just use ternary.

    let x = (3 == 4) ? "Hello" : "Goodbye"
Re:Show HN: Bond – A Swift binding framework on Friday January 30, 2015 @05:52PM (#8975019)
This looks really amazing. Probably the most simple implementation of FRP I've ever seen, nonetheless in Swift.
Re:Show HN: Swift vs. Objective-C Benchmarks on Sunday January 25, 2015 @07:32PM (#8944907)
Seems like performance always works in Swift's favor when the compiler is able to reason about the types (e.g. no AnyObject nonsense, banishing the objc dynamic behavior).

Interesting to see Generics performing so poorly, though.

Re:An easy to use iOS floating drawer view controller on Sunday January 18, 2015 @02:03AM (#8906929)
Please don't use hamburger menus on iOS. http://blog.manbolo.com/2014/06/30/apple-on-hamburger-menus

Older »