HNHacker News
TopNewBestAskShowJobs

alipang

1,057 karma · joined February 21, 2012

submissionscomments
alipang··on Event Modeling
It's funny how server-side and client-side architecture moves almost entirely hand-in-hand. Going by how we talk about things you'd think these'd be entirely different.

- The Model-view-controller architecture was moved to the server-side by ROR and its descendants.

- The javascript eventing model that was suitable for non-blocking UIs being moved server-side via Node.js.

- Now we're now also aligning around event/command-driven models for "state-management" (Redux, event-sourcing/CQRS).

- Event-streams like Rx.js being briefly hyped, but not gaining too much adoption (?) both for GUIs and servers.

It's nice to see that general programming principles are still applicable across domains.

alipang··on Gitlab More Than Doubles Valuation to $2.75B Ahead of Planned 2020 IPO
My company is currently considering switching away from GitLab CI/CD as well as we've found no way to increase the number of available minutes (2000 on our tier I believe, doesn't last very long) without upgrading many tiers before we can even scale it at all. Can I ask what plan you're on? I'm assuming since your company wants to pinch pennies you're also fairly small?
alipang··on Elegant Error Handling with the JavaScript “Either” Monad
I think you may like Monads for exactly the reasons you described though, I wouldn't focus too much on this particular sentence.

Monads for error handling are very similar to exceptions - they let you write your code in terms of only the happy path, but letting each step fail the entire computation if something unintended happens (with a relevant error). They also have some advantages if you like to be explicit about the "dark path".

1) In traditional imperative programming you have to make a choice between errors as exceptions (implicit) and errors as return values (explicit) - monads let you do both at the same time in a sense --- whether you get implicit or explicit behaviour depends on how you "glue" computations together.

2) Monads are more explicit about when a dark path exists in the sense that they will have a different type signature and often different syntax (at least in haskell/c#/scala and other languages that support explicit monad-based notation)

I'm not a huge fan of Monads for error handling in languages like Javascript without explicit support for them though, mostly as they just don't read very well.

alipang··on From Design Patterns to Category Theory (2017)
I've written a few blogs posts somewhat related to this at https://philipnilsson.github.io/Badness10k/, though it depends on the reader's level on whether they're a any good as an introduction.
alipang··on A New Way of Voting That Makes Zealotry Expensive
This seems to be the obvious problem. If I only care about X, and you only about Y, we could vote individually (100 tokens -> 10 votes for X, 100 tokens -> 10 votes for Y), or we could collude and make that vote (2 * 50 tokens -> 2 * 7 votes X, 2 * 50 tokens -> 2 * 7 votes Y).
alipang··on Thinkpad X210
Depending on what you want, a gaming box like https://www.gigabyte.com/Graphics-Card/GV-N1070IXEB-8GD#kf might do the trick. There's a lot of great laptops like the XPS13 that won't do gaming, but can do so with an external box.
alipang··on Declarative Programming: Is It a Real Thing? (2015)
Instead of talking about declarative programming we should talk about denotational programming - writing programs that map to a consistent mental model.

The fact that something is declarative doesn't mean that it's understandable. Webpack for instance is a piece of technology I consistently struggle to understand and predict the behaviour of, even though it's declarative. (Not intended to shit on webpack's developers / maintainers in anyway.)

alipang··on If monads are the solution, what is the problem?
Most monads I'm aware of have an operational interpretation.

The `Maybe` (or `Option`) monad, for instance, has the single effect

  fail :: Maybe a
  fail = Nothing
as soon as `fail` is "evaluated". Evaluation here is in the monadic sense - and is not related to the evaluation strategy of the host language.

List monads have a non-determinism operational interpretation. The `State`, `Writer` and `Continuation` monads obviously do as well.

You could say the `Reader` monad has the single effect

  ask :: Reader e e
but thinking about this operationally is certainly not that helpful as this returns a single constant value from the environemnt.

The same thing goes for `Free` which is essentially a data structure for the abstract syntax of Monads. However in some sense even for this part of you understanding of free monads is likely based in providing a natural transformation to an interpretation in another monad (i.e. `iterM`)

alipang··on If monads are the solution, what is the problem?
An introduction was posted here recently - which may be good, depending on how comfortable you are with logic in general.

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.673...

alipang··on If monads are the solution, what is the problem?
There is a point to it though - continuations, for instance, have monadic structure - but at the cost of introducing a strict evaluation order. There is other work related to the linear logic that does what Monads do - provide an abstract syntax - but working better with laziness, so it's not exactly wrong to give Monads an operational perspective.

There are many perspectives one can use to understand Monads. The operational one is valid - and useful for many beginners. Of course, it's not the only way to look at them, as you point out.

alipang··on If monads are the solution, what is the problem?
Here's a tutorial with a focus on more practical applications that doesn't try to go too deep into the semantics of monads, but rather tries to build intuition on a syntactic/language level - which I think is generally more helpful for beginners.

https://philipnilsson.github.io/Badness10k/escaping-hell-wit...

alipang··on Escaping Hell with Monads (2017)
The point is not that any one example is better than the other, rather it's that the same syntax can be used to uniformly solve multiple different problems (partiality, async, "non-determinism", and state-passing).
alipang··on What are covariance and contravariance?
If you ever want function types you will always need both co- and contravariance as pointed out in OP's articles.

Using covariance as a default is also not sound. Many things are "invariant", meaning neither co- or contravariant. This is already a sensible default. (It is however possible to automatically derive either property in some cases)

alipang··on Category Theory, Syntactically (2016)
I'd say there is not much point to Category Theory if we where to restrict ourselves to a single category. For instance Monoids are categories (with a single object) that is not the category of functions. Another set are the Kleisli Categories[1] that are equivalent to monads.

You mention Applicative Functors, which form another (different) category where arrows from a to b are on the form `f (a -> b)` and composition and identity laws of these arrows are equivalent to the applicative laws.

[1] https://en.wikipedia.org/wiki/Kleisli_category

alipang··on Two's complement – You beauty
https://en.wikipedia.org/wiki/Method_of_complements
alipang··on Algebraic Patterns – Monoid Morphism
My aim is for this series to be such a resource :) http://philipnilsson.github.io/Badness10k/

If you feel it's still too opaque, feel free to let me know anything specific and I will try to amend the articles with further explanation.

Categories/Functors/Monads will appear in the series in the future, as these arise as generalizations of topics discussed so far.

alipang··on Algebraic Patterns – Monoid Morphism
Your solution still assumes we can break down the problem according to the fundamental theorem of arithmetic, which is a monoid homomorphism. You simply have added more insight into the problem than I.

The goal of the article is show there's a consistent structural framework of problem solving underneath. I mention briefly that you can improve the solution along your lines.

The idea that let's us prove your algorithm above correct using this theory is that monoid morphisms compose (they form a functor category), and that equivalence relations that respect monoid composition induces monoid morphisms to the quotient classes.

Then we just define the equivalnce relation where two numbers are equal if they have the same number of fives in their prime factorization. The composite monoid morphism yields your algorithm.

I didn't want to overcomplicate the article with this, but I did mention it (it's in the hard-to-parse paragraph at the end of the section)

alipang··on Algebraic patterns – Semigroup
Comparators are not composed by ordinary function composition, but by pointwise composition in the domain. If you can read Haskell

    instance Monoid a => Monoid (b -> a) where
       f <> g = \x -> f x <> g x
Here they type a is the set `{ EQ, LESS, GREATER }` which is in turn composed in a left-biased way with `EQ` as an identity.

If you have two comparators, `lastNameComparator` and `firstNameComparator` and compose them into a comparator that compares first by firstName, then by lastName, surely that is a closed operation. It is also associative, and comparators do have an identity, so, yes they are also monoids.

alipang··on The Power of PCRE Regular Expressions (2012)
I've never understood the software engineering community's desire to call PCREs regular expressions simply because it has similar syntax to "formal" regular expressions.

There is good reason to distinguish the two, since they have completely different characteristics. PCREs may use an unbounded amount of extra memory, and may use exponential time. "Formal" regular expressions take linear time and memory, and can match only the regular languages. They operate completely differently (a regular automation vs. a stack based pattern matcher).

Regular expressions can NOT match HTML, PCREs CAN. Conflating the two is not helpful.

alipang··on The Arbitrary Logo
This page uses close to 100% of one of my CPU cores. (Ubuntu/Chrome), not sure if it's because of the logo.
alipang··on An Introduction to Reactive Programming
Here's an introduction to Bacon.js, implementing a game with eventstreams, if anyone is interested in more.

http://philipnilsson.github.io/badness/

alipang··on Asynchronous JavaScript at Netflix
Reactive (event) streams are a generalization of promises in a sense, from a single value to a stream of multiple ones. Both are monads.

Streams are to promises what lists are to maybes (options).

alipang··on AdBlock Plus’s effect on Firefox’s memory usage
Anyone knows if this also affects Chrome? I have Chrome saying Adblock is using 126MB of memory, but if there are giant stylesheets injected elsewhere that might no be reported fully in the Chrome task manager.
alipang··on The TeX tuneup of 2014 [pdf]
BADNESS 10000
alipang··on Comparing Haskell Web Frameworks
While I agree to some extent, I have to say the metaprogramming in Yesod does a good job at exposing solid information models for its abstractions, unlike, say reflection based metaprogramming in C# or Java. I find it pretty easy to bend it to my will, even if Yesod itself is quite opinionated.
alipang··on Why we left AngularJS
Yeah, Angular and Ember both have their own 'runtimes' essentially which is in stark contrast to knockout, which really is just a library, and there really is a fundamental difference.
alipang··on Make the Type System Do the Work
He claims it's to make wrong code look wrong. He uses the type system in order to prevent bugs, how is that abuse? Is the type system only there for performance in your opinion, or what's your angle?
alipang··on Ember.js is driving me crazy
Haskell: favor composition over configuration over convention.
alipang··on King.com, makers of Candy Crush Saga – Trademark Trolls with a Double Standard?
Except they're not going to go after Disney, only smaller companies without the cash to throw lawyers at problem.
alipang··on America's Dwindling Economic Freedom
If you're up for a longer read about Sweden's economic history, you can check out http://www.libertarianism.org/publications/essays/how-laisse....

There is of course some possible bias in this article that should be derivable from the domain name.

← PreviousPage 2 of 5Next →