HNHacker News
TopNewBestAskShowJobs

pka

1,132 karma · joined January 2, 2012

submissionscomments
pka··on Coq 8.6 is out
Is the database and/or specification open source? A formal verification of a distributed system sounds very interesting.
pka··on Why Functional Programming Matters (1984) [pdf]
You don't need unsafePerformIO for any of these.

> Anything that needs rewriting a memory address without losing time by allocation and garbage collection.

ST gives you mutable references. Or just use IO.

pka··on Why Functional Programming Matters (1984) [pdf]
> There are plenty of tricks you can not write on pure monads

This made me curious, could you list some?

pka··on Why Functional Programming Matters (1984) [pdf]
> This means we can exploit any efficiency trick an imperative program can do, including low-level stuff. The seasoned FP programmer will then proceed to encapsulate the efficiency trick in a abstract module such that the rest of the program doesn't have to worry about it.

You can do that in a pure language as well (i.e. ST monad.) Purity shouldn't be given up lightly.

pka··on Jid – Drill down JSON data incrementally
Shameless, but related plug [0] - an interactive JSON log viewer.

[0] https://github.com/pkamenarsky/sherlock

pka··on Let’s Stop Bashing C
I can't see how this can be a good thing.

If C is that bad at managing complexity (and complexity doesn't only arise from bad design choices, some problems are inherently complex) then it should be used as rarely as possible, period.

It's not about idealism, it's about ill-placed, almost comical elitism ("C is a low-level-hacker language and only real programmers use it" while a 3rd grader could understand pointer arithmetic) to the point of rather spending 5 days writing bug-ridden code in C instead of 5 minutes in whatever else, just because it's the right way.

It's ridiculous.

pka··on Let’s Stop Bashing C
You're making a great point against C, yet somehow you are not realizing it.
pka··on Let’s Stop Bashing C
So you're saying C is a great language until you have to parse XML.

... exactly.

pka··on Let’s Stop Bashing C
Until the logic is complex enough and you screw it up. Then you write over '\0' in some string and have a root exploit. Congratulations!

float *float_ptr; float_ptr += 1;

is no more confusing than

float float_ptr[...]; float_ptr[1];

pka··on Let’s Stop Bashing C
At first I thought that was sarcasm... but it's unfortunately not.

> no more overflows, no more pointer screwups, no more forgetting to free the memory, because you'll know exactly what will happen in the chip and the memory when that code compiles

To whoever wrote this: are you ready to share the code of a sufficiently complex program in C (or assembler, why not) you wrote and pay $100 for every "pointer screwup", buffer overflow, memory leak and generally every bug people find, which could have been prevented by a strong type system or borrow checking and other such complicated features?

pka··on Standardized Ladder of Functional Programming [pdf]
If your language is not purely functional it is imperative. There is really no conceptual difference between Clojure and Python, except for syntax/macros and that Clojure has immutable data structures in clojure.core.

You could use mutable arrays in Clojure the same way you could use immutable arrays in Python (yet nobody is calling Python a functional language.)

Still, I agree that functional mostly means "language with closures and immutable data" in the mainstream, but in the context of this post I'd say it's not that hard to guess that the authors meant purely functional.

pka··on Standardized Ladder of Functional Programming [pdf]
> But the point is that nobody's putting 'S-expression syntax languages' in a Lisp-centric list of essential functional programming skills.

They should've probably said "FP-only" (i.e. pure) languages to exclude imperative languages that merely support functional programming constructs, like Clojure, Erlang, etc.

I agree, many of the concepts that are useful in pure languages (i.e. monads) are not that practical in imperative/impure or dynamic languages (at the cost of reduced ability to reason about your program.)

> And if the list is comprised of Haskell-centric jargon for more generic notions, that's obviously grounds for criticism.

It's the other way around - the items on this list are the more generic concepts [0]. Less expressive languages lack the (practical) ability to reason about those concepts generically, hence the need for more specialized constructs, like i.e. streams, transducers, etc.

[0] https://en.wikipedia.org/wiki/Coinduction#Codata

pka··on Standardized Ladder of Functional Programming [pdf]
The fact that it's meaningless to you doesn't mean it doesn't have any meaning :)

Your "hideously complicated type theory" is many peoples' "hideously horrible paren-based syntax" - i.e. Lisp. So, how many people don't learn Lisp only because of its syntax? I'd say a lot.

Many of the concepts make sense when having an explicit type system, so if you want types you may want to learn them.

Others I suspect you are already using, even if you don't know them by name. Have you ever used streams? Congratulations, this is what codata is.

pka··on Show HN: Storing your bookmarks under revision control
I made something similar [0] for Pentadactyl [1], a vim-like extension for Firefox.

By pressing Cmd-D the user is prompted to enter a tag, and after that a .webloc (essentialy a link) file is created in a subfolder determined by the tag name.

The location to store the files in can be configured (i.e. some Dropbox folder, so that bookmarks are automatically shared).

This has the advantage that it's:

* instantly searchable using the same search interface like everything else (Spotlight)

* forwards compatible - no need to import/export bookmarks when switching browsers

* distributed - bookmarks are instantly and automatically distributed (Dropbox)

* automatically backed up forever (Dropbox)

I'm not using Firefox right now, so the extension might be out of date. Maybe time to port it to Chrome/Safari :)

[0] https://github.com/pkamenarsky/fbookmark

[1] https://addons.mozilla.org/en-US/firefox/addon/pentadactyl

pka··on Mastering Time-to-Market with Haskell
I agree, stack traces are a good thing.

For the time being, make a helper function:

ixWithString :: String -> Int -> Array a -> a

check the bounds inside and error out with a custom message when the index is outside the array bounds.

pka··on Mastering Time-to-Market with Haskell
I am not following Elm closely and may be wrong, but I'd be surprised. The creator (Evan) is really picky about having unsafe features in the language.

It's even impossible to upload a package to the official repository containing JavaScript code without prior approval, because the native code may crash!

pka··on Mastering Time-to-Market with Haskell
I.e. look at how PureScript does it [0]. Haskell could do the same.

[0] https://pursuit.purescript.org/packages/purescript-arrays/3....

pka··on Mastering Time-to-Market with Haskell
Because of types, basically. You can construct the core data structures of your program and the types of the functions operating on those data structures without having to actually implement said functions. When the types fit together, i.e. your program is logically consistent, you can start filling in the actual code.

This is much faster than writing a large chunk of code, playing around in the REPL thinking everything is ok, only to realize one week later that you didn't think through some core aspect of your design and then having to refactor a sizeable piece of your codebase.

> The last message I get was something like "Array.Array: Index out of bounds". Program crashed. No idea where the error originated.

It is an unfortunate historical artefact that there are still partial functions (i.e. functions that may crash) in the Haskell base libraries. It is generally advised to avoid such functions, but this is not very clearly communicated to newcomers to Haskell.

For example, Elm, a language largely inspired by Haskell, doesn't have partial functions. This is why it prides itself in "not having any runtime errors in production" (excluding things like compiler bugs or unsafe JavaScript libraries, of course).

pka··on Mastering Time-to-Market with Haskell
Back then I would have loved to do it because of the exact reasons you mention (i.e. it would have been a perfect case study of the same project implemented in two different languages), but unfortunately I wasn't at liberty to disclose specifics.

All I could do is collect metrics like lines of code and intentionally vague experience reports from former colleagues who are still there, but I guess that's hardly gonna convince anybody.

pka··on Mastering Time-to-Market with Haskell
> That is precisely the job of responsible management: to stop technical teams from using expensive technologies, that are not only unproven, but hardly have any actual anecdotal information at all. The precise difference between management and developers is that management sees the bigger picture.

In most cases management isn't qualified to make technical decisions. Managers rarely see the bigger picture.

I've worked on a Haskell project that worked, never crashed, was lightning fast and was meeting deadlines for new features without a problem. Then higher management decided to throw away probably around 7-10 man-years and rewrite the whole thing in Java, quite literally "just because Java". We even had a consultant from FP complete come over to take a look at our codebase and talk in front of management about the advantages of a mature codebase in Haskell. Management didn't even come.

Abandoning Haskell, in my case, had absolutely nothing to do with its technical merits and everything to do with incompetent management. When I left one year after they started rewriting the project in Java (I was staying to help maintain the Haskell code while the transition was happening) everything was buggy as hell, slow and unmaintainable. Not to mention that half the Java guys they hired had already left again.

pka··on Mastering Time-to-Market with Haskell
> Initially, you're spending a lot of time prototyping, fumbling around trying to find the right abstractions. Here Haskell mostly gets in the way

The opposite is true: here Haskell helps to find the right data structures/abstractions incredibly fast. The ability to quickly construct and reconstruct a high-level skeleton of your program without actually having to implement anything makes prototyping much easier and faster than in comparable dynamic languages.

> But then you hit a wall. Laziness makes for brutal debugging.

Laziness can sometimes surprise you in bad ways, but it's not like it's impossible to debug.

> Singly linked lists actually suck.

Just replace them with the right data structure then? Even for big codebases and fundamental program abstractions that's a 15min job, because of types.

> Performance optimization is a black art.

I agree. But then again - you don't have to write everything in Haskell. Writing the critical 1% in C, testing the shit out of it and calling it from Haskell is absolutely fine.

pka··on Why the MacBook Pro Is Limited to 16GB of RAM
Photoshop on Linux?
pka··on Do you really want a single-page application framework?
This is insane.

Even keeping two different views in sync in different parts of an application without a framework is so much work it's not worth the effort, let alone building a whole SPA.

But to each their own.

pka··on TDD Doesn't Work
Having a good type system would be a good start :)
pka··on Elm from a Business Perspective
I agree the blog post wasn't professional, but there was none of that tone where it mattered, the Github issue.

I can see where his frustration stems from though, getting a response like "I don't want to unless you show me a use case" when clearly presented with a use case after spending weeks trying out someone's language can be infuriating. As I said, not very professional, but understandable imo.

pka··on Elm from a Business Perspective
> And yet plenty of programmers somehow manage to ship perfectly good solutions to everyday problems without "generic programming" capabilities as you define them.

This is definitely true. The firmware on your phone is probably written in assembler.

> Instead of sitting on such a high horse the more constructive approach is to outline the shortcomings, implement the solution, and contribute it upstream.

You complain about sitting on high horses while the author did exactly that and got a high-horse response from Evan.

> Comparing a language that programmers use every day to ship working solutions to another one that has considerably smaller mindshare and community

Are you talking about PureScript? Judging by GitHub popularity I'd say both languages are about equal in that regard, but who knows.

pka··on Elm from a Business Perspective
Instead of abstractly arguing over "writing generic code", here are some concrete examples I came up with when running down a random Haskell file:

* Thing.map :: (a -> b) -> Thing a -> Thing b instead of deriving Functor (or Applicative, Monad, Generic, ...)

* showThing :: Thing -> String, readThing :: String -> Maybe Thing instead of deriving Show/Read

* decodeThing :: Json.Value -> Maybe Thing, encodeThing :: Thing -> Json.Value instead of deriving From/ToJSON

* lenses definitions instead of makeLenses ''Type

* things like

    update (Event childEvent) model -> let (m, fx) = Child.update childEvent model.child in ({ model | child = m }, Fx.map Event fx)
instead of using lenses

* append :: (a -> a -> a) -> (b -> b -> b) -> (a, b) -> (a, b) -> (a, b) instead of reusing the Monoid instance on tuples

* toDyn :: (a -> TypeName) -> a -> Dynamic, fromDyn :: (a -> TypeName) -> Dynamic -> Maybe a instead of deriving Typeable

* things like type StateLogger st = { log :: [st], current :: st } and then writing StateLogger.map, StateLogger.return, StateLogger.andThen, StateLogger.modify, StateLogger.tell instead of just type StateLogger = WriterT [st] (State st) and getting all of that for free... not only that, but now you can use lenses for manipulating a deeply nested state as well, because guess what, Control.Lens.Zoom is written generically

And those are just the possible, but cumbersome things. There's stuff that's impossible to do:

* free monad custom DSLs

* GADT datatypes for typesafe request/response communication

* existential quantification in ADTs

Now this is very down-to-earth get-things-done Haskell code. All these things are there because they make the code simpler, easier to understand and eliminate repetition.

pka··on Elm is Wrong
It's only because Elm is basic Haskell minus a lot of stuff. So basically if you know Haskell you already know Elm (so you need the 15 minutes to get up to speed wrt ports and subscriptions or whatever), but at the same time miss the stuff that has been left out that you take for granted, hence the failed attempt of the author to get some of that back.
pka··on Elm is Wrong
You seem to miss the point.

Elm is particularly easy to pick up for people coming from Haskell. Maybe not in 15 seconds, but 15 minutes is a totally reasonable estimate.

The author can without doubt write a large project in Elm. His complaints were about missing the conveniences of abstraction Haskell-like languages provide, and he is more than qualified to talk about it.

Decomposing records into tuples of comparables has probably crossed his mind :)

pka··on Elm is Wrong
PureScript!
← PreviousPage 6 of 13Next →