HNHacker News
TopNewBestAskShowJobs

pka

1,132 karma · joined January 2, 2012

submissionscomments
pka··on Composable multi-threaded parallelism in Julia
For completeness' sake, Haskell has had this for over a decade :) A SO thread that gives a nice overview [0], the paper [1], the library [2]. Here's how a parallel fib looks like:

  fib :: Int -> Int
  fib n
    | n <= 1    = 1
    | otherwise = x ‘par‘ (y ‘pseq‘ x + y + 1)
    where
      x = fib (n-1)
      y = fib (n-2)
[0] https://stackoverflow.com/questions/958449/what-is-a-spark-i...

[1] http://simonmar.github.io/bib/papers/strategies.pdf

[2] http://hackage.haskell.org/package/parallel-3.2.2.0/docs/Con...

pka··on For the Love of Pipes
The things you listed may form a monad, but your list/iterator transformation doesn't use monadic composition.

> list.select { |x| x.foo > 10 }.map { |x| x.bar }

Where's `bind` or `join` in that example?

pka··on OOP vs. Functional Programming (2014)
> OO is not about state

OO is very much about state, and that's the fundamental difference between non-FP languages and FP.

    a1 = object.f(b);
    a2 = object.f(b);
If a1 != a2 or f performs any side effects at all you've got state. Doesn't matter if it's "private" or "hidden". Your functions are not referentially transparent.

It also doesn't matter if your language implements OO in terms of message passing (Smalltalk, Erlang) or method calling (Java, C#, ...).

pka··on Fear, trust and JavaScript: When types and functional programming fail
You try to parse the received data into a predefined data type, if this fails you are forced by the type system to handle the failure scenario, if it parses correctly you now have a 100% valid data structure you can work with in the rest of your codebase, no defensive checks necessary.
pka··on Fear, trust and JavaScript: When types and functional programming fail
Did you read the whole thing? This is exactly the point the author is trying to make. Look, you both arrive at the same conclusion even:

> Or you change the game and just use PureScript. Or ReasonML, or Elm, or even ClojureScript.

> If you want to see actual dynamic typing and how it can shine, use ClojureScript. If you want to see actual static typing and how it can kick ass, use PureScript.

pka··on Why Arc Isn't Especially Object-Oriented (2002)
Two obvious differences off the top of my head:

1. Overriden methods have access to the internal state of the parent class, which is almost universally a bad idea.

2. Since functions are values, you can freely mix and match different view configurations without having to create a subclass for every permutation.

pka··on Why Arc Isn't Especially Object-Oriented (2002)
> OOP is good for domains that naturally give rise to a clearcut inheritance structure, such as stateful GUI frameworks

React begs to differ.

> or ontologies that directly mirror real-world objects.

Such as?

pka··on Why Arc Isn't Especially Object-Oriented (2002)
Use higher order functions to customise behaviour. I.e. your hypothetical NSTableView would look like this:

    nsTableView ::
      { renderCell :: a -> NSView   -- this is the function that renders a cell given an `a`
      , header     :: NSView
      , footer     :: NSView
      }
      -> [a]
      -> NSTableView a
I.e. pass in a function that renders a cell for a given `a`, a header and a footer NSView and whatever else, a list of `a`s and get back a NSTableView which displays that list of `a`s.

React calls this pattern higher order components iirc.

pka··on Decision Tables
Most, if not all, functional languages support pattern matching: Haskell, OCaml, Clojure, Erlang/Elixir, Purescript, Idris, Elm, etc.
pka··on OOP Is Dead, Long Live OOP
> Do you think the tool you use to achieve a task doesn’t matter?

I think many people do think that, with a twist; specifically, when presented with a higher level language they'd argue "it's just a tool", while a lower level language would be "the wrong tool for the job".

I.e, for a hypothetical Ruby programmer, Haskell = "just a tool", C = "the wrong tool".

pka··on We can no longer leave online security to the market
I'm not sure you could cover up a data breach that easily. Those data dumps are going to be sold on the black market eventually, and I speculate that in many cases government agencies will be able to identify unannounced breaches.

Slap a 10x (or even 100x) fine on companies whose data breaches are discovered independently and covering stuff up won't look like such a good idea anymore.

pka··on Niels Bohr’s Argument for the Irreducibility of Biology to Physics (1994)
> Nothing can explain "everything".

I'm not saying I argue for the opposite, but that is very definitive statement in need of a very strong argument to be taken seriously.

> What does that even mean?

Things that we don't even know how to talk about yet, like consciousness.

Even if consciousness is just an emergent phenomenon, this still doesn't explain the subjective experience of consciousness. Subjective experience might be irreducible, but it might not. We don't know yet.

From what I understand, you're claiming that we can't explain higher levels of emergence in terms of lower levels. But that's not true, and your example of hardware/software is the prime example of that. We can explain or model every level of abstraction perfectly in terms of the preceding, lower level of abstraction, until we get to the quantum mechanical properties of the substrate your software is running on.

Whether it's practical to talk about the rules of chess in terms of QM is another matter - it's not - but I'd maybe argue that's because we're not intelligent enough to hold enough information at once in our brains, not because of some inherent impossibility of doing so.

pka··on Upgrading GitHub from Rails 3.2 to 5.2
> I think this comes down to low ceremony vs high ceremony

One of the most cited qualities of languages like Haskell are their "refactorability" - i.e. one can routinely rip out the guts of a 100KLOC codebase and replace fundamental data structures and functionality in order to implement new features in a couple of hours, no problem whatsoever.

In Rails, I'd do everything in my power to not touch any "important" code if I can get away with it, because no matter how good the test suite, it's still a test suite. It shows the existence of bugs, it doesn't prove their absence. Many people claim that's not a problem in practice, but I personally tend to avoid more fundamental code changes in dynamic codebases precisely because of that fact.

To drive that point home, I'd trust a Haskell codebase without a test suite more than a Rails codebase with an average to good test suite.

Also, it seems to me that "moving fast" is directly at odds with the topic at hand, upgrading Rails. If Rails allowed one to move fast, then surely upgrading Rails shouldn't take a year and a half, even in a big codebase?

> Spec driven design seems to offer some of the benefits of static typing with the flexibility of dynamism.

Definitely, though it's not a replacement for types. Also, the probably more important thing here is that Clojure is functional, making a whole class of bugs stemming from mutability and OOP impossible.

If you're planning to go down the Clojure/spec route, you might want to check out Ghostwheel [0], a lightweight DSL which seems to be gaining a lot of traction lately.

[0] https://github.com/gnl/ghostwheel

pka··on Niels Bohr’s Argument for the Irreducibility of Biology to Physics (1994)
I don't think that's a very controversial point of view. Emergent behavior is all around us - ant colonies, neural networks, and yes, biological organisms.

Whether emergence can explain everything is another matter though, and I think that's where "irreducibility" might come into play.

pka··on Upgrading GitHub from Rails 3.2 to 5.2
> I was part of a SaaS startup using Java Spring

You may accuse me of shifting the goalposts, but do notice I said modern above. I'm not up-to-date with Java anymore, but iirc Play [0] would be worth checking out.

> This is a problem you want to have because you have skin in the game.

I'm saying that this is a problem you don't have to have at all.

> Back to you - you didn't address my question - if you were to launch a product idea, what static stack would you pick?

In the context of SPAs, I'd choose some of the Purescript React libraries and some generic Haskell REST/Websocket server, like Warp/Servant (this is a stack I've used in production).

For a standard web app, I'd go with Yesod [0], which is a somewhat Rails-like framework, but it fully leverages the advantages of static types, i.e. it turns things like dead links, trying to inject user input into a DB query without escaping it first, invalid queries (i.e. querying a person by product id), and many more into compile-time type errors.

> I'm not saying you're categorically wrong, but you haven't presented any science to support your dismissive tone.

Still, to claim that the context of the current thread at least doesn't suggest that Rails is a maintenance nightmare would be disingenuous at best.

> Pick the right tool for the job.

That's what we're discussing here, right? I can't see when Rails would ever be the "right tool" for anything (except for the one use case I alluded to above) but that's obviously subjective, rendering that phrase utterly meaningless.

[0] https://www.playframework.com

[1] https://www.yesodweb.com

pka··on Upgrading GitHub from Rails 3.2 to 5.2
> A year and a half of how much effort?

> The project originally began with 1 full-time engineer and a small army of volunteers. We grew that team to 4 full-time engineers plus the volunteers.

They had four full-time people working on upgrading Rails at some point!

pka··on Upgrading GitHub from Rails 3.2 to 5.2
If you're talking about CRUD boilerplate apps, literally any modern web framework in a static language.

Again, even if "rapid prototyping" was a thing in Rails (i.e. rapid as opposed to what?) you start paying back the price tenfold once your project becomes moderately complex, test coverage or not.

So if your question is specifically "What's a good stack for a blog I'll never touch again or maintain with X and Y integration, tomorrow", then ok, cool, Rails.

pka··on Upgrading GitHub from Rails 3.2 to 5.2
It is a massive failure, and it would be solved by static types.

I could take a big, unmaintained 10 years old Haskell codebase and upgrade it to the newest compiler and libraries in a couple of days, at most (and it would most likely work on the first try after it compiles).

pka··on Upgrading GitHub from Rails 3.2 to 5.2
> that is more productive than Rails

So, spending a year and a half on a major version upgrade of your web framework is "productive" how exactly?

I mean, whatever time you think you've saved by using Rails during the initial prototyping phase (and I don't think even that's true), you'll more than pay for in maintenance costs.

pka··on David Patterson Says It’s Time for New Computer Architectures and Languages
This is already possible to a degree within existing type systems - here’s a small experiment tracking execution time of list comprehensions on the type level in Purescript [0].

[0] https://twitter.com/pkamenarsky/status/961666713900249088?s=...

pka··on Why I never finish my Haskell programs
Doubting your competence is not a personal attack/ad hominem, so don’t try to twist my words.
pka··on Clojure is cool
I agree, but it’s the best you can get if for some reason you’re stuck with Clojure.
pka··on Clojure is cool
For Clojure, check out Ghostwheel [1] - a lightweight DSL for writing specs.

If you want proper static typing though, ReasonML might be a good choice. Static, compiles to js and native, super easy to learn, and there’s an experimental Lisp frontend with Clojure-like syntax if you can’t live without paredit.

[1] https://github.com/gnl/ghostwheel

pka··on Why I never finish my Haskell programs
> And this is the most hilarious aspect of Haskell community. You assume that the only reason people might not like the approach is due to their sheer ignorance of the wonders of the type system.

No, I don’t, and when I happen upon somebody who is competent in Haskell and still prefers Clojure/Erlang/whatever then genuinely interesting conversations tend to happen.

This is not the case here though.

pka··on Why I never finish my Haskell programs
> I'm also not sure what you're judging my competence in it on exactly as you've likely never seen a single line of code that I've written in it.

And I don’t need to. I (and anyone proficient in Haskell, really) can infer your competence with somewhat reasonable confidence based on your comments, like this one.

People who’ve just read LYAH are able to contribute to production codebases already, no problem, but they still may not have even understood basic concepts, such as functors or monads (this is firsthand experience from work), let alone monad transformers, arrows or lenses - which I consider to be a good thing. Based on your comments (and not only this thread here), this is where I’d place you in terms of competency, but of course you are more than welcome to correct me.

pka··on Why I never finish my Haskell programs
> You've already conceded that your solution is not appropriate for production

I’ve done no such thing.

> You can't even acknowledge that your preferred approach to dealing with side effects has any drawbacks to it.

It does, probably not the drawbacks you think of though (“conceptual overhead of types”?).

Generally, you seem to be awfully incompetent in a language you claim to have used for a year. That’s not a bad thing, but you don’t present your arguments with a big fat disclaimer stating that. If you did, I think there would be much less tension in these kind of discussions.

pka··on Why I never finish my Haskell programs
> However, my experience is that if you question the effectiveness of static typing, or ask for evidence in support of the claimed benefits you'll get a very hostile reaction.

That's an interesting thing to say, seeing how representative figures of (specifically) the Clojure community get really defensive really quickly once somebody questions the effectiveness of dynamic typing - which I specifically didn't do.

> He outright dismisses that any valid alternatives are possible

I was merely dismissing your incorrect claim about logging in Haskell. And yes, not taking advantage of the type system when you are already programming in a language with a type system amounts to #yoloing it, in my opinion. Doing the same in other languages is fine, since you don't have another option really.

pka··on Why I never finish my Haskell programs
Well yeah, because a logging statement in production can fail (i.e. network connection drops). The type system forces you to deal with that fact instead of letting you write code that e.g. brings down your server unexpectedly because of some random log call.

Many would consider that a feature, but if you want to #yolo it anyway, like in most other languages, just use trace in prod and call it a day.

pka··on Why I never finish my Haskell programs
http://hackage.haskell.org/package/base-4.11.1.0/docs/Debug-...

For future reference, this isn’t a good argument for trolling Haskellers.

pka··on The Machine That Builds Itself: The Strengths of the Lisp Languages (2016)
> Reading and understanding the Idris proof is actually more work than understanding the untyped Python version, therefore it's actually harder to say whether it's correct or not in a semantic sense.

That was your original, nonsensical, point (emphasis mine).

> My point is that tests and runtime contracts provide sufficient guarantees in practice.

That's your revised point (which I don't care much about discussing), after moving the goalposts sufficiently.

← PreviousPage 2 of 13Next →