If anybody is interested in F#, look for a nearby meetup group to join. The SF F# group is pretty active and Mathias Brandewinder's hacker dojos are absolutely awesome!
Perhaps you aren't? Unlike struct packing, the knapsack problem has a fixed upper limit. There's no limit on number of struct fields, and indeed, every solution consists of all of them.
I'm not saying it's exactly the knapsack problem, but it's quite related. Ordering from largest to smallest does not yield the optimal solution - period.
The article says throughout that sorting the fields in order of decreasing alignment requirement (i.e., size) minimizes slop. The proof for this is pretty straightforward. The article also discusses why you might not do this (e.g., structures might try to match layout of memory mapped devices).
Rudeness is a choice you make, by the way. You can change your behavior.
This is better described as a 'publish-subscribe pattern using web sockets'. To be brutally honest (take this as constructive criticism), the addition of the HTTP endpoint isn't very interesting either. Implementing all this takes perhaps less than 100 lines of code.
We fixed the XSS issue. Having said that, this site is just to demonstrate that you can use any standard web socket client (including the one in your browser); normally you would build the XSS mitigation into the client app if necessary.
What scenario do you have in mind for a "pub-sub pattern using WS"?
It might not be the scenario we were shooting for. The HTTP endpoint was an important requirement. We needed a way to receive HTTP POST calls in an app which wasn't accessible from the web (i.e. no incoming HTTP, but we could make an outbound WS call). Something like Runscope's Passageway (https://www.runscope.com/docs/passageway) would have been our first choice, but it wasn't easy to bake it into the app itself.
Fastmail was once owned by Opera but bought itself to be independent again. I reckon they wouldn't be interested in being owned by another corporation, especially Yahoo.
We talked about this in the office a few weeks ago. The conclusion that we came to is that we're pretty happy with our current situation so any buyout would have to have a fairly enormous amount of cash attached :)
I disagree that it maps most directly to the problem statement. You're performing a common factor computation in your mind, which may be more difficult given numbers other than 3 and 5. In my opinion, pattern matching offers the most direct solution and comes with an abundance of compiler optimizations. Here's an example in Rust...
for i in range(1i, 101) {
match (i % 3, i % 5) {
(0, 0) => println!("Fizzbuzz"),
(0, _) => println!("Fizz"),
(_, 0) => println!("Buzz"),
_ => println!("{}", i),
}
}
> I disagree that it maps most directly to the problem statement. You're performing a common factor computation in your mind, which may be more difficult given numbers other than 3 and 5.
Well, sure, explicitly calling out i % 15 rather than (i % 3) && (i % 5) or the equivalent has that problem.
> In my opinion, pattern matching offers the most direct solution and comes with an abundance of compiler optimizations.
Pattern matching is not available in many languages, but, sure, where its available, its a great choice. Note that this still has a distinct case for the case where both % 3 and % 5 are true, rather than just testing those cases independently and sequentially and concatenating, so I think it falls into the general class of solutions I was describing.
The solution in Haskell is quite clean, I believe.
fizzBuzz n
| n `mod` 15 == 0 = "FizzBuzz"
| n `mod` 3 == 0 = "Fizz"
| n `mod` 5 == 0 = "Buzz"
| otherwise = show n
main = mapM_ (print . fizzBuzz) [1..100]
I agree with you about generalizing pattern matching for less simple cases. Your example brought to mind view patterns, about which Oliver O'Charles had a nice writeup recently [1]. Nifty little extension.
let buzzer number =
match number with
| i when i % 3 = 0 && i % 5 = 0 -> "FizzBuzz"
| i when i % 3 = 0 -> "Fizz"
| i when i % 5 = 0 -> "Buzz"
| i -> (sprintf "%i" i)
for i = 1 to 100 do
printfn "%s" (buzzer i)
I'm an F# developer, but still decided to not use F# to build an android app. Dealing with the UI libraries like support.v4 was just too painful from a functional perspective. If you don't need any object oriented dependencies, then it's smooth sailing.
I've only heard that in context of A: missing tooling, B: Microsoft, in their quest to make customers feel C# is still the real language and F#'s just some science toy. I've used F# for a Web UI via WebSharper and it was lovely. It's just a poor reflection on the state of UI kits if they don't work with F#.
Interesting that one of those presenters is named Howard Payne. Along with Payne being an elevator company, Howard Payne is the name of the antagonist in 'Speed', who hacks an elevator...
[0] http://www.meetup.com/sfsharp/