Live data from Hacker News

What Color Is Your Function?

journal.stuffwithstuff.com

101–110 of 153 posts

Re: What Color Is Your Function?

#101
post #17

Earlier quoted context omitted.

I'm not sure if you're leading this or not, but to be clear... this is exactly a type system. (Edit: read your blog; it's clear you're leading it. Poe's Law is in effect sometimes here, sorry 'bout that!)

It's a good type system. Many programming languages don't support this kind of type information, notably C.

I'm always curious how far a sufficiently motivated masochist could go with C... I guess it's just C++ ;)

Re: What Color Is Your Function?

#102
post #60

A lot of commentors are mentioning that this is just a specific case of effect typing. Haskell and monads have been brought up as an example of effects typing, but I'd like to present another example that more closely resemble familiar static type systems. Nim[1], at least at one point (I'm looking at the current manual and can't find it documented), had support for tagging functions with a pragma and the compiler wo…

Also, what about Koka ? http://koka.codeplex.com/ and http://research.microsoft.com/en-us/projects/koka/ From the latter: > The Koka project tries to see if effect inference can be used on larger scale programming. The language is strict (as in ML), but seperates pure values from side effecting computations (as in Haskell). Through the effect types, there is also a strong connection to its denotational semantics, whe…

I just wanted to say that I've finally taken a look at Koka after hearing you mention in on HN many times. It's very nice! I appreciate how it provides most of the bang of effect types much more conveniently than one might expect with the explicit monadic structuring going on in Haskell.

Have you looked at Frank [0] by any chance? It has a very similar row-effect type (I guess these were both first explored in Eff?) but in a CBPV language which makes it clear how pure values are separated from effectful computation.

[0] http://homepages.inf.ed.ac.uk/slindley/papers/frankly-draft-...

Re: What Color Is Your Function?

#103
Tornado made async code slightly less painful by using yield and coroutines, but you still have to run blocking methods on thread pools using futures. They abstracted it really nicely and I can now write clean code if I need an occasional blocking library in my tornado code.

But after writing tons of Go over the past 2-3 years, going back to async code, even with the tornado sugar, just feels like driving a manual car after getting used to automatic. It's just redundant. I've seen better, I've written way cleaner code and got better concurrency. Promises, futures, yielded generators - they are all syntactic hacks. The only language I've used that really addresses this properly is Go (disclaimer: I haven't written any Erlang).

Re: What Color Is Your Function?

#104
post #101

Earlier quoted context omitted.

It's a good type system. Many programming languages don't support this kind of type information, notably C.

I'm always curious how far a sufficiently motivated masochist could go with C... I guess it's just C++ ;)

You can write very safe code by using structs (even 1-element structs) for everything. But there's no generics system and very little in the way of safe tools for making one; writing a safe "generics runtime" and macros to use it puts you halfway to writing a new language.

Re: What Color Is Your Function?

#105

Tornado made async code slightly less painful by using yield and coroutines, but you still have to run blocking methods on thread pools using futures. They abstracted it really nicely and I can now write clean code if I need an occasional blocking library in my tornado code. But after writing tons of Go over the past 2-3 years, going back to async code, even with the tornado sugar, just feels like driving a manual ca…

downvoted for this? really?

Re: What Color Is Your Function?

#106
post #104
post #101

Earlier quoted context omitted.

I'm always curious how far a sufficiently motivated masochist could go with C... I guess it's just C++ ;)

You can write very safe code by using structs (even 1-element structs) for everything. But there's no generics system and very little in the way of safe tools for making one; writing a safe "generics runtime" and macros to use it puts you halfway to writing a new language.

>structs (even 1-element structs) for everything.

Are there any large C projects written in this style?

Re: What Color Is Your Function?

#108
post #104

Earlier quoted context omitted.

You can write very safe code by using structs (even 1-element structs) for everything. But there's no generics system and very little in the way of safe tools for making one; writing a safe "generics runtime" and macros to use it puts you halfway to writing a new language.

>structs (even 1-element structs) for everything. Are there any large C projects written in this style?

All I'm aware of is a friend's private project of around 20KLOC.

Re: What Color Is Your Function?

#110
post #96
post #54

So I've been writing javascript full time for a couple years at this point, client, server, and open source, and what I have adopted is coercing everything into promises, which I suppose would be the author's way of saying making everything red. If you have something that is not async mixed in with something that's async, you can still add it to the promise chain and it will resolve right away. If you have a library…

This is great for one's own projects, but if creating something for more than one's immediate project (i.e. libraries), it forces everyone else to adopt the same style. Maybe those other projects are also using other libraries that don't use promises, so now there is a problem. Do you wrap the other library in promises too, if that is even a viable option for you? Colorness is a problem for the whole ecosystem too.

Promise is the best thing an async library method could return because it's always trivial to convert into anything you want (callback, stream, async/await, yield whatever you want) because it's the only thing that's standardized. However, nobody gets the callback contract (https://gist.github.com/CrabDude/10907185) right. Even node core gets the callback contract wrong in different ways in its different APIs.

In practice however most library callback apis resemble the callback contract enough so that one-line promise-wrapping of the entire library is possible.

Post reply on HN