D
Daniel Spiewak
codecommit.com · Personal blog · on HN since 2007
Daniel Spiewak writes about Scala, functional programming, type inference, parser combinators, and operational transformation.
What HN saysHN commenters recommend his Scala for Java Refugees series, and his operational transformation and Hindley-Milner articles as clear explanations.
70HN people shared it
32linked it in comments
46stories submitted
675story points
7 years agolast shared
2007people per year2026
Most-shared posts
- 1Operational Transformation (algorithm behind Wave, Google Docs)17 people · 142 points · first shared 2010 · 21 comments on HN
- 2Monads Are Not Metaphors (2010)5 people · 101 points · first shared 2010 · 45 comments on HN
- 3What is Hindley-Milner and why is it cool? (2008)4 people · 213 points · first shared 2008 · 46 comments on HN
- 4Scala for Java Refugees4 people · 3 points · first shared 2009 · discussion on HN
- 5The Joy of Concatenative Languages (Part 2)3 people · 15 points · first shared 2008 · 3 comments on HN
- 6Odersky on Scala's type inference3 people · 8 points · first shared 2010 · 3 comments on HN
- 7The Magic Behind Parser Combinators3 people · 4 points · first shared 2009 · discussion on HN
- 8Is Scala Not “Functional Enough”?3 people · 3 points · first shared 2008 · discussion on HN
- 9Software Transactional Memory in Scala (2008)2 people · 17 points · first shared 2008 · 10 comments on HN
- 10The Joy of Concatenative Languages2 people · 5 points · first shared 2008 · discussion on HN
- 11XMLBuilder: A Ruby DSL Case Study2 people · 3 points · first shared 2008 · discussion on HN
- 12The “Option” Pattern - Scala vs C++/Java2 people · 2 points · first shared 2008 · discussion on HN
- 13Persistent(immutable) Vectors in Scala2 people · 1 points · first shared 2008 · discussion on HN
- 14Scala for java refugees part 62 people · first shared 2009
- 15Monads Are Not Metaphors1 people · 96 points · first shared 2010 · 39 comments on HN
What HN people wrote when they linked it
amix · 2014-04-30
I can recommend this article that explains OT really well: http://www.codecommit.com/blog/java/understanding-and-applying-operati…
advinture · 2012-10-01
If you're coming from Java, I recommend the Scala for Java Refugees[1] series of blog posts. If you're interested more in the functional side, there is a course by Odersky on Coursera right now.
I haven't found any Scala IDEs stable or enjoyable yet. I've been using [insert favorite editor] with sbt[2].
[1] http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees
[2] https://github.com/harrah/xsbt/wiki
zbailey · 2011-10-03
I love Heroku's little "language and community" section of these articles when they add a new supported platform. For example, the link to the explanation of Scala's Hindley-Milner type inference method (http://www.codecommit.com/blog/scala/what-is-hindley-milner-and-why-is… definitely taught me something new about the internals of Scala, and in general a new topic in Computer Science.
Congrats on shipping yet another supported platform!
rubyrescue · 2010-09-03
wow, just googled that. here's a great summary of Operational Transforms. http://www.codecommit.com/blog/java/understanding-and-applying-operati…
whakojacko · 2010-05-19
a book-free way to do it would be to start with reading an introduction such as: http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees (not really entertaining, but good content)
Once you are done with that, read articles on the fantastic Daily Scala blog: http://daily-scala.blogspot.com/ . There are LOTS of useful little morsels in there.
For a beginner asking questions, stackoverflow is IMO the place to go, the people on the mailing lists can sometimes be a bit hostile towards newbies.
calambrac · 2009-04-08
I love how Scala solves this problem (or rather, provides the same functionality while avoiding the problem altogether):
http://louisbotterill.blogspot.com/2009/02/scala-implicit-conversions.…
http://www.codecommit.com/blog/scala/scala-for-java-refugees-part-6
Edit - more links, more detail:
http://technically.us/code/x/the-awesomeness-of-scala-is-implicit
http://scala.sygneca.com/code/simplifying-jdbc
jahfer · 2019-05-07
A number of years back, I wrote an OT implementation in Clojure/ClojureScript as a hobby project [1] and learned a lot along the way. I even extracting out the core client/server implementations to their own package [2].
It's an incredibly fun topic, and one that's also really challenging. It also gave me first-hand experience with fuzz-testing where I could simulate all kinds of concurrent-edit conflicts and ensure both clients came out with the same end-result. While the end client/server implementations are working, it was a lot more effort than I anticipated building a full-fledged editor on top. I was too stubborn at the time to attempt to integrate with existing RTEs though, so the most notable part of the project was the core lib, not the end product.
For those interested in implementing it for themselves, I can't recommend this piece [3] by @djspiewak enough.
[1] https://github.com/jahfer/ot
[2] https://github.com/jahfer/othello
[3] http://www.codecommit.com/blog/java/understanding-and-applying-operati…
pjasiun · 2017-10-19
6 months is a very optimistic scenario ;) A guy responsible for OT in Google Wave wrote once that he spent 5 years on it and it still does not work well in all cases. After 3 years of struggling to get it right, we know what he meant.
Anyway, I believe that you can find a good entry point to OT here: http://www.codecommit.com/blog/java/understanding-and-applying-operati… It gives a nice overview of the problem – in a human-readable language – but it’s only the beginning of the journey.
The original OT implementation has been designed for linear documents – texts. It does not fit very well with tree structure – you don’t want elements (tags) to intersect after resolving collision. It also does not fit undo where the order matters.
For sure, operational transformation is not a closed subject, which you can just learn. It is an open problem with many cases still unsolved. If you are looking for a good topic for a thesis, I would recommend it :)
exikyut · 2017-10-19
> 6 months is a very optimistic scenario ;)
Oh.
> A guy responsible for OT in Google Wave wrote once that he spent 5 years on it and it still does not work well in all cases. After 3 years of struggling to get it right, we know what he meant.
...Wow, I see.
(As an aside, I think it's really sad Wave's "cool" UI was never properly released.)
> Anyway, I believe that you can find a good entry point to OT here: http://www.codecommit.com/blog/java/understanding-and-applying-operati… It gives a nice overview of the problem – in a human-readable language – but it’s only the beginning of the journey.
I actually think this is one of the articles I found a while back. I agree that it's very thorough and in-depth, and, uh, I've managed to get slightly further into it before I started hitting PgDn repeatedly and my eyes glazed over than when I read this a few months ago! :)
> The original OT implementation has been designed for linear documents – texts. It does not fit very well with tree structure – you don’t want elements (tags) to intersect after resolving collision. It also does not fit undo where the order matters.
Ooooooooh yowch.
> For sure, operational transformation is not a closed subject, which you can just learn. It is an open problem with many cases still unsolved. If you are looking for a good topic for a thesis, I would recommend it :)
Hah!
When I was exploring OT a few months ago I also explored alternatives such as realtime…
currywurst · 2011-06-22
Coincidentally, today is the first day I'm seriously looking into Scala, and I think his points serve well to temper one's approach to language.
I think Scala is an admirable and ambitious effort to allow oo + func programming on the JVM. I also got the impression that the type system is "good enough" for most DRY efforts. But then, my background in this area is virtually non-existent.
Depending on what sources you learn from, you don't need to learn all the intimidating language features in the beginning itself. I am currently working through [1] - well written, but slightly outdated. [2] is where I got oriented initially.
It's also great that they do well to come within striking distance of Java in performance (this is not my impression of Clojure). Another super cool approach seems to be that of Mirah (no special runtime, Ruby-like syntax).
[1]: http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees
[2]: http://grahamhackingscala.blogspot.com/2010/12/guide-to-learning-scala…
cscotta · 2010-10-17
Hey Hugo,
I've somehow become a bit of a devil's advocate for Java lately. Thanks for pinging me - happy to offer a few thoughts.
I've not actually tried using Jersey/JAX, but it looks like a very clean setup for quickly writing low-latency JSON APIs. I'm impressed by the Getting Started example (here: https://jersey.dev.java.net/use/getting-started.html) and find the use of decorators to specify path, methods, and content types creative.
As for the rest, keep in mind that you don't have to use anything that you don't want to. I've done a fair amount of Java development and never actually used Hibernate, Maven, or JBoss. For the most part, the complexity that these tools can introduce, while great for many projects, kind of scares the crap out of me. Like you, I'd always go for the simplest workable solution available.
Jetty is a very nice, simple alternative to Tomcat/JBoss, though I find Tomcat to be rather nice myself. One thing I've come to love about Java deployment is that you're literally deploying just one file (a .jar or .war) rather than hundreds.
If you're looking for a nice, clean ORM, check out ActiveObjects by @djspiewak. Its design is based on the active record pattern, and it's very easy to get up and running with about any database as a backend. I used this on a large project ending a few months ago and had a great experience with it. Daniel's also available via Twitter and IRC and tends to be happy to offer an answer to a quick, informed question. …
CompuIves · 2018-03-26
Thank you very much! It was definitely one of the most fun features to build.
I started working on this on March 15th, and the past few days was about testing everything, preparing the release and squashing bugs. The advantage of this type of functionality is that there are tons of high quality papers and articles already written on the subject, especially this one helped me a lot: http://www.codecommit.com/blog/java/understanding-and-applying-operati… There were a lot of sleepless nights involved too.
I'm not sure about the VS Code and Atom teams, but I imagine that there are more constraints and there is more functionality to implement since they work with hundreds of potentially big files. I think those factors make it harder to implement this functionality than in the case of CodeSandbox.
doug1001 · 2017-12-10
well the top-level git data structure is pretty close to eg, Scala's Vector, which is an immutable container implemented as a tree with a high branching factor of 32. Modification to such a vector, rebound to a new variable, relies on structural sharing of the original (http://www.codecommit.com/blog/scala/implementing-persistent-vectors-i…
pmontra · 2017-06-29
Because they're not new. Check this XML DSL for Ruby, March 2008 http://www.codecommit.com/blog/ruby/xmlbuilder-a-ruby-dsl-case-study
What's happened here is that it's being done in a statically typed language which is harder than in a dynamically typed on. So, good job done.
sjansen · 2017-03-06
Since you've been deep diving into OT, you've probably already seen: http://www.codecommit.com/blog/java/understanding-and-applying-operati…
But just in case you haven't, it has a nice high level overview of how Google Wave implemented rich text on a tree using annotation boundaries.
lanna · 2016-09-22
I really liked Daniel Spiewak article about it: http://www.codecommit.com/blog/scala/bloom-filters-in-scala
tveita · 2016-08-17
Reminds me of the operational transformation used in Wave.
http://www.codecommit.com/blog/java/understanding-and-applying-operati…
I see they mention it in the paper, saying the difference is that Wave requires a central server to impose a total ordering of operations.
seanmcdirmid · 2014-07-22
Rich Hickey makes a similar argument:
http://www.codecommit.com/blog/scala/is-scala-not-functional-enough
RyanZAG · 2012-11-23
Scala was looking pretty nice till I got to this:
http://www.codecommit.com/blog/scala/scala-for-java-refugees-part-6
Not convinced on Scala being a good language to use for multi-person projects anymore. Same as with C++, you would have to heavily push code reviews and coding standards (disallow everything from that link?) in order to have even slightly maintainable code...
bnoland · 2012-02-20
When I did http://collabedit.com I used the approach outlined at: http://www.codecommit.com/blog/java/understanding-and-applying-operati… with an md5 hash for the "Operational Parentage" piece.
It was pretty tough to implement (for me at least). Especially when I got to using the "Bridger" and "Buffer" to transform.
Your approach seems much simpler. Do you retain the ability to "play back" the edits like etherpad did?
How big can a document get before you run into the precision issue you mentioned?
dantheman · 2012-01-10
Scala has the Option/Some type, IIRC based on Haskell's Maybe, where it's used as: Option(int), and then you check the return for None or Some(int). The compiler should catch when you forget to cover the None case.
Here's a good little tutorial: http://www.codecommit.com/blog/scala/the-option-pattern
nupark2 · 2011-12-16
Your concerns seem ill-founded given that these are solved problems. There are working implementations of low-barrier cross-language compatibility, today, for both the JVM and the CLR.
Here's one example; Rhino provides pretty seamless bridging from JavaScript to Java:
https://developer.mozilla.org/en/Scripting_Java
I've used it to run user-supplied JS inside the JVM.
PHP is pretty easy too:
http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp#JavaPHPintegrati…
Scala is even more lightweight here:
http://www.codecommit.com/blog/java/interop-between-java-and-scala
Bear in mind that these are all for the JVM, which wasn't even designed with the intention of being a general-purpose multi-language VM.
DanielRibeiro · 2011-11-15
F# seems to have a Hindley-Milner type system, as described some years ago also by Daniel Spiewak[1].
Which is a vast improvement over more mainstream type systems, while not as powerful as traditional logic type systems, such as those used in First order and Higher Order Logic.
However, I personally rely more on unit tests than on type systems to make sure the code is consistent. And when I do that, specially when I write the test before the code, I find the type system getting more in the way than helping me. Rich Hickey, Clojure's creator, compared[2] these to guard-rails.
[1] http://www.codecommit.com/blog/scala/what-is-hindley-milner-and-why-is…
[2] http://www.infoq.com/presentations/Simple-Made-Easy
Arrgh · 2011-04-08
A minor nitpick-nitpick: it's not so much that a JVM requirement prevents Scala from using H-M type inference, it's that H-M doesn't work very well with subtyping, which Scala supports for its own O-O reasons. This comment from Martin provides some context: http://www.codecommit.com/blog/scala/is-scala-not-functional-enough#co…
closure · 2010-12-31
Definitely. I really like Haskell's type inference, but have always been concerned about issues like those raised in: http://www.codecommit.com/blog/scala/universal-type-inference-is-a-bad…
jankassens · 2010-11-24
The core algorithm is called "Operational Transformation".
See http://www.codecommit.com/blog/java/understanding-and-applying-operati…
simonw · 2010-11-15
Scala's creator is on record as regretting the inclusion of XML literals in the syntax of the language:
http://www.codecommit.com/blog/scala/working-with-scalas-xml-support
pjscott · 2010-08-04
A while ago Google Docs even switched to using Etherpad-style operational transformation instead of diff-match-patch. Some pretty mind-bending technology here:
http://www.codecommit.com/blog/java/understanding-and-applying-operati…
bitsai · 2010-06-17
Daniel Spiewak has written a fair number of Scala articles, and I've found them to be quite helpful:
http://www.codecommit.com/blog/category/scala/page/10
mchadwick · 2009-10-18
http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-ja…
Above is an overview of how the Scala compiler attacks this exact problem. Long story short: It is able to grok just enough Java to build a basic AST and resolve circular dependencies the same way it handles one in pure Scala.
The article also hints that Groovy has similar capabilities.