?

Log in

No account? Create an account
 
 
11 April 2016 @ 08:25 pm
Abusing Functional Programming in Scala  
My favorite Scala evangelist is trying to reinvent the wheel in caching.

He enjoys playing with monads and fancy terms like side-effects, but forgets about software development basics -- clearly defining real-world problem that he is trying to solve:
---
Dennis: Do you mean you do not support a scenario when multiple users are requesting your web app ~simultaneously?
ivan_gandhi: I do not condone sharing code with effects between threads.
---

It is not clear whether his code is supposed to work in multi-thread environment (like serving incoming web requests from multiple users) or in single-thread (like outgoing requests from a single thread service).
It is not clear whether he wants to reuse cache between parallel threads or not.
The end result -- code without purpose. Such purposeless code is impossible to meaningfully evaluate.
On the other hand such approach gives a lot of room for inventing Cartesian product of input source and time segments.

My takeaway from it is that Scala inspires excessive FP games and therefore distracts developers from solving real-life problems.
 
 
 
No hugging no learningormuz on April 12th, 2016 01:51 am (UTC)
та ну, он же говорит
actor style, message passing, все дела.

то есть, точно никаких shared данных не будет.
Dennis Gorelikdennisgorelik on April 12th, 2016 02:07 am (UTC)
Где именно говорит?

И как из actor style и message passing следует отсутствие multi-threading?

Edited at 2016-04-12 02:08 am (UTC)
No hugging no learningormuz on April 12th, 2016 02:20 am (UTC)
"as a service"
из актор стайл, следует что общих данных с другими тредами нет, а вовсе не отстутствие мульти-поточности. (ровно как и присутствие мульти-поточности тоже не следует, как знать - может этот кеш-сервис будет единственным потоком на этой машине.


Dennis Gorelikdennisgorelik on April 12th, 2016 03:36 am (UTC)
Что такое "актор стайл" и как из "as a service" следует отсутствие общих данных с другими тредами?

Типичный сервис вполне подразумевает работу с общими данными в параллельных запросах к сервису.

Edited at 2016-04-12 06:44 am (UTC)
(no subject) - ormuz on April 12th, 2016 10:29 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 10:39 am (UTC) (Expand)
(no subject) - ormuz on April 12th, 2016 11:01 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 11:19 am (UTC) (Expand)
(no subject) - develop7 on April 12th, 2016 01:08 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 10:28 pm (UTC) (Expand)
(no subject) - develop7 on April 13th, 2016 09:13 am (UTC) (Expand)
(no subject) - dennisgorelik on April 13th, 2016 09:23 am (UTC) (Expand)
(no subject) - develop7 on April 13th, 2016 12:28 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 13th, 2016 06:57 pm (UTC) (Expand)
(no subject) - develop7 on April 13th, 2016 08:09 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 13th, 2016 09:40 pm (UTC) (Expand)
(no subject) - sab123 on April 12th, 2016 05:38 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 10:32 pm (UTC) (Expand)
(no subject) - sab123 on April 13th, 2016 01:58 am (UTC) (Expand)
Dennis Gorelikdennisgorelik on April 12th, 2016 03:37 am (UTC)
> может этот кеш-сервис будет единственным потоком на этой машине

В этом случае у параллельных тредов могут быть общие данные, потому что они читают из одного и того же кэша.
(no subject) - ormuz on April 12th, 2016 10:33 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 10:48 am (UTC) (Expand)
(no subject) - ormuz on April 12th, 2016 10:56 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 11:34 am (UTC) (Expand)
СБsab123 on April 12th, 2016 05:35 pm (UTC)
Будет. Message passing делает все то же самое, но гораздо сложнее. Примеры читать здесь: http://web.newsguy.com/sab123/tpopp/06odata.txt , последний раздел "Queues as the sole synchronization mechanism"
Dennis Gorelikdennisgorelik on April 13th, 2016 12:08 am (UTC)
How long did it take you to write this book?

Did you use any writers/editors to fix English language?

What was your main goal in writing it?
СБsab123 on April 13th, 2016 02:07 am (UTC)
About a year's worth of spare time including editing :-) Something like 300 work hours probably.

This is pretty much the first draft before any noticeable editing. I've edited it (myself) and improved the readability for the printed edition.

The goal was to make money. Which didn't really work directly but worked in a roundabout way: the bragging rights help at job interviews and helped me to add more money annually to my salary than I hoped to make from the book's lifetime. The downside is that it doesn't scale easily: I think writing a second book won't help to make any more money.

Well, spreading the experience and knowledge was the secondary goal :-)
(no subject) - dennisgorelik on April 13th, 2016 05:35 am (UTC) (Expand)
(no subject) - sab123 on April 13th, 2016 09:20 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 13th, 2016 09:42 pm (UTC) (Expand)
No hugging no learningormuz on April 13th, 2016 03:26 am (UTC)
Вы, конечно, книгу написали, и я не особый фанат актёров,
но пример у вас немного безумный, типа я вам локи и на актёрах изображу, если нужно.
кроме того, совершенно ненужное противопоставление тредов и актёров, как-будто есть выбор - всунуть скоуп лок, или страдать с очередями/дисруптором.
(no subject) - sab123 on April 13th, 2016 09:19 pm (UTC) (Expand)
(no subject) - ormuz on April 14th, 2016 02:47 am (UTC) (Expand)
(no subject) - sab123 on April 14th, 2016 09:43 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 14th, 2016 10:00 pm (UTC) (Expand)
(no subject) - sab123 on April 14th, 2016 10:09 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 14th, 2016 10:20 pm (UTC) (Expand)
(no subject) - sab123 on April 15th, 2016 08:46 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 15th, 2016 09:13 pm (UTC) (Expand)
(no subject) - sab123 on April 15th, 2016 11:24 pm (UTC) (Expand)
(no subject) - dennisgorelik on April 16th, 2016 12:03 am (UTC) (Expand)
(no subject) - sab123 on April 18th, 2016 11:21 pm (UTC) (Expand)
(no subject) - sab123 on April 14th, 2016 09:50 pm (UTC) (Expand)
(no subject) - ormuz on April 17th, 2016 03:20 pm (UTC) (Expand)
(no subject) - sab123 on April 18th, 2016 11:23 pm (UTC) (Expand)
rezkiy on April 12th, 2016 02:03 am (UTC)
cache invalidation is one of two hardest problems in computer science.
Dennis Gorelikdennisgorelik on April 12th, 2016 02:05 am (UTC)
That does not mean we have to do cache invalidation even more complex than it already is.
rezkiy on April 12th, 2016 02:15 am (UTC)
What he has exposes another hard problem in computer science: naming things.
(no subject) - dennisgorelik on April 12th, 2016 03:41 am (UTC) (Expand)
(no subject) - rezkiy on April 12th, 2016 05:59 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 06:11 am (UTC) (Expand)
(no subject) - rezkiy on April 12th, 2016 06:19 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 06:41 am (UTC) (Expand)
(no subject) - rezkiy on April 12th, 2016 07:09 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 07:26 am (UTC) (Expand)
(no subject) - rezkiy on April 12th, 2016 07:29 am (UTC) (Expand)
(no subject) - dennisgorelik on April 12th, 2016 07:35 am (UTC) (Expand)
(no subject) - rezkiy on April 12th, 2016 08:36 am (UTC) (Expand)
журнал закрытjuan_gandhi on April 12th, 2016 02:31 am (UTC)
It may be time for you to learn something new.
Dennis Gorelikdennisgorelik on April 12th, 2016 03:59 am (UTC)
What specifically are you suggesting to learn?
журнал закрытjuan_gandhi on April 12th, 2016 10:38 am (UTC)
Nothing. You have to find it yourself.