lyinsteve
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.
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.
They're both compatible
Building a Compiler in Swift with LLVM, Part 1 of 4: Introduction and the Lexer
Trill: A typed, LLVM-backed compiler, inspired by (and written in) Swift
Trill: A typed, LLVM-backed compiler, inspired by (and written in) Swift
Goto in Swift
Doesn't really change much; just thought that'd be an interesting thing to throw out.
Show HN: Implementing a Lispy Language in Haskell: Part 1
Also we've since made an awesome web app and iOS app for dropping drinks.
QuoteMaker – A Markov Chain Generator Generator
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.
Swift and Haskell: 'do' or Die
Sounds like something I want no part in.
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.
Computer Science House
Show HN: Click, use any watch band with Apple Watch
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"Apple just released some sample code for HomeKit
Interesting to see Generics performing so poorly, though.