viktorklang / blog

Letters from Klang
230 stars 21 forks source link

The Feedback Issue #3

Open viktorklang opened 8 years ago

viktorklang commented 8 years ago

Dear reader,

this is where you can make general comments on the blog, provide feedback and :sparkle: :+1:'s :sparkle:.

Keep things civil, but I already knew you were going to do that anyway.

carstenlenz commented 8 years ago

I really appreciate it. Very straightforward. It's like the VIM of blogs.

carstenlenz commented 8 years ago

... oh :+1:

soc commented 8 years ago

Wouldn't it make sense to add these blog posts to scala-lang.org/blog?

britter commented 8 years ago

:+1: for the blog. Really nice posts so far. I like, that you're keeping the posts short.

One suggestion: If you're planning to do a full fledged blog here, is may be worth looking into jekyll. It's pretty easy to publish a blog as GitHub page this way. In fact I've done it myself.

gervaisb commented 8 years ago

:+1: Short articles. I can read them immediately, they don't wait in my #toread backlog. Sometimes hard for a Scala beginner like me but the mental gym is always fois. Thanks

kjozsa commented 8 years ago

good stuff. Show off https://github.com/viktorklang/blog/commits/master.atom for those who'd want to follow in an rss reader.

viktorklang commented 8 years ago

@kjozsa :-) yes, that's a good one, I have that as a link in the README.md but I should really put that into every single post.

viktorklang commented 8 years ago

@gervaisb Thanks! That's exactly what I'm trying to do, I read tons and tons of blogposts so I'm trying to write posts that I'd like/enjoy to read too—respecting the readers' time :)

rkuhn commented 8 years ago

Great format, I like it! It would be awesome to have commenting built in—and github happens to offer this feature: if every blog post were a pull request then discussions would easily be possible even on individual paragraphs.

viktorklang commented 8 years ago

@rkuhn Now that's a terrific idea. I'll experiment with that for the next post!

megri commented 8 years ago

Having had a taste of scalaz.concurrent.Task, I kinda wish that Futures would allow delayed execution (as in don't spawn a new one every time I map over one) in a similar manner.

(In fact, separating the concepts of defining an [not necessarily] asynchronous operation and running one is powerful.)

Am I being unreasonable?

viktorklang commented 8 years ago

@britter Thanks for the suggestion, I'm trying to see if I can stick to vanilla GH features for as long as possible. That makes it possible for me to have the same workflow I do for any coding :)

viktorklang commented 8 years ago

@megri Yes. Very unreasonable. ;-) Jokes aside, scalaz.concurrent.Task is an interesting construct, and it would be nice to have something like that in the stdlib. One unanswered question is whether transducers would be enough.

britter commented 8 years ago

@viktorklang in fact your workflow would stay absolutely the same, but the result would look much better. This is, because GitHub pages support jekyll natively. So you just set up the jekyll project in your repo, activate gh-pages and GitHub will automatically export your blog as gh-page. You would still simply wite your posts in markdown syntax, but it would look like a real website.

More information can be found in the GitHub documentation and the jekyll documentation.

HTH!

jozic commented 8 years ago

this looks like an awesome idea! no need to host, no need to setup, just write plain md files i think it's very readable as is, and you don't need to read jekyll docs as a bonus :)

anicolaspp commented 8 years ago

Now I like Scala Future, @viktorklang, a lot has changed since How C# beats Scala in async programming

viktorklang commented 8 years ago

@anicolaspp Thanks! I'm really glad you like them now :)

viktorklang commented 8 years ago

@jozic :) I wholeheartedly agree!

viktorklang commented 8 years ago

@britter Great points! I'll sleep on it and see if I want to take the Jekyll plunge one more time. :)

dwalend commented 8 years ago

I notice you sometime show the types, but comment them out:

val someFuture: Future[String] = …
val lifted/*: Future[Try[String]]*/ = someFuture.transform(Try(_))

Why use a comment? Why not just declare the type?

viktorklang commented 8 years ago

@dwalend That's a great question and I hope I have a somewhat good answer:

I tend to want to emphasize when type annotations are not needed, since sometimes you need to be explicit in order to guide the type inferencer.

dwalend commented 8 years ago

Thanks. That makes some sense, but I worry that innocents might cut and paste the code, then the comment rots toward being misleading. (In my own code I put type annotations whenever I spend more than a few seconds pondering it, and for all but the most obvious types in example code. I don't think I'll ever get your level of sophisticated readers.)

dwalend commented 8 years ago

This means that global will have at most scala.concurrent.context.maxThreads + scala.concurrent.context.maxExtraThreads concurrent Threads.

Would "at most scala.concurrent.context.maxThreads" (and not more) be better? Will people find scala.concurrent.context.maxExtraThreads? Will they be astonished when it matters?

viktorklang commented 8 years ago

@dwalend I was considering writing a post on "Configuring the global ExecutionContext", do you think that'd be interesting?

dwalend commented 8 years ago

Definitely. Also, if you write something that reads as strangely as "...maxExtraThreads" , revisit the config code. (Maybe even "maxIOBlockedThreads" would be better. API control would be better than properties.)

viktorklang commented 8 years ago

@dwalend Where would you put said API control? :-)

dwalend commented 8 years ago

ExecutionContext.global I suppose.

The harder question - what could turning the knobs actually do?

viktorklang commented 8 years ago

@dwalend Sure, but where would it be invoked? And what if multiple things tried to change it? :)

dwalend commented 8 years ago

Classic awful mutable globally accessible state. They'd fight it out. Last in wins. And changes to the ExecutionContext.global doddle behind, trying to keep up. It'd be like one of those horrible control problems modelled by undergrads using Simulink.

It would stink, but it might be better than nothing. Then again, exposing anything beyond System.getProperty() it might brick you out of future innovations.

viktorklang commented 8 years ago

@dwalend Something like that, yes ^^

Lasering commented 8 years ago

Future.firstCompletedOf could have an implementation with varargs. Because Future.firstCompletedOf(f1, f2, f3) is simpler to read than Future.firstCompletedOf(Seq(f1, f2, f3)).

Sorry if this is the wrong place to make this suggestion.

viktorklang commented 8 years ago

Hi @Lasering, sadly @varargs in Scala are possibly mutable Sequences (scala.collection.Seq) and cannot be safely used for things that pass across threads.

raymondtay commented 8 years ago

👍 nice blog. Improving the symmetry of the APIs in Futures in Scala 2.12 is good, definitely helps. Looking forward to using the new swanky ACPS style.

Was wondering if the new thread names might be too long? W.r.t debugging live systems in a data centre with a 21" monitor for someone with poor eyesight.

viktorklang commented 8 years ago

@raygit Thanks! :)

Regarding the thread names, I'm open for improvements, so feel free to suggest alternatives!

shishkin commented 8 years ago

@viktorklang, thanks for the series! Will Future in Scala 2.12 eliminate the need to reimplement Futures in frameworks like this http://twitter.github.io/finagle/guide/Futures.html#futures?

viktorklang commented 8 years ago

Hi @shishkin,

Future in Scala 2.12 won't mitigate the reasons listed (especially not that last one ;)).

Futures in Finagle "conflate" the notion of a value, and the notion of a Task/Operation (which would be cancellable etc). In the future (no pun intended) the Scala Standard Library might feature a Task-representation, which would in that case be cancellable. (The problem with cancellation on the JVM is that it needs to be cooperative, and the problem of sticking that feature unto Future would make Future not read-only).

Does that help? :)

shishkin commented 8 years ago

Thanks, perfect answer.

muntis commented 7 years ago

Part 9 has compilation error that's bugging me acps(r.transform(result => Success(result :: list)), tail) should be acps(r.transform(result => Success(result) :: list), tail)

betandr commented 7 years ago

'future.flatten' is a great feature, thanks!

viktorklang commented 7 years ago

@betandr Thank you, i'm glad it's getting used! (It was getting harder and hard justifying flatMap(identity)) :)

tarsa commented 7 years ago

Hi Viktor,

I have thought a few hours about promise linking and that complicated mechanism looks unnecessary for me. I've managed to fix the memory leak problem with a simple change - extracted creation of closure to another method. My post about that is here: https://groups.google.com/forum/#!topic/scala-internals/RtsPUliPNQA and the project with demonstration is here: https://github.com/tarsa/FuturesFix

What do you think about that? From my experiments it works. Without promise linking logic (but with that small fix) the source code of Futures and Promises would look much simpler and easier to follow.

viktorklang commented 7 years ago

Hi @tarsa!

I've replied to your email :-)

Lasering commented 6 years ago

Hi @viktorklang

In Scala 2.13.0-M4 varargs are now immutable Seqs

https://github.com/scala/collection-strawman/wiki/FAQ

scala.Seq[+A] is now scala.collection.immutable.Seq[A] (this also affects varargs methods).

So Future.firstCompletedOf could be overloaded with a varargs alternative.