Li Haoyi
lihaoyi.com · Personal blog · on HN since 2013
Li Haoyi, a Scala developer, writes about Scala style, build tools, testing, functional programming, and tools like Ammonite.
What HN saysCommenters praise his Scala posts and book as clear for experienced developers, and cite his post on what's wrong with SBT.
141HN people shared it
73linked it in comments
206stories submitted
3.8Kstory points
8 months agolast shared
2013people per year2026
Most-shared posts
- 1Strategic Scala Style: Principle of Least Power16 people · 192 points · first shared 2016 · 64 comments on HN
- 2What's Functional Programming All About?14 people · 530 points · first shared 2017 · 153 comments on HN
- 3What's wrong with the default build tool for Scala14 people · 125 points · first shared 2017 · 85 comments on HN
- 4What's Next for Scala9 people · 316 points · first shared 2020 · 195 comments on HN
- 5Ammonite: Scala Scripting8 people · 105 points · first shared 2016 · 32 comments on HN
- 6Homepage8 people · first shared 2017
- 7Principles of Automated Testing7 people · 122 points · first shared 2017 · 8 comments on HN
- 8Ammonite: concise, type-safe file-ops in Scala7 people · 6 points · first shared 2015 · discussion on HN
- 9Benchmarking Scala Collections7 people · 5 points · first shared 2016 · discussion on HN
- 10Intro to Mill7 people · 3 points · first shared 2018 · 1 comments on HN
- 11How to conduct a good programming interview6 people · 270 points · first shared 2017 · 182 comments on HN
- 12Build your own Command Line with ANSI escape codes (2016)6 people · 92 points · first shared 2016 · 13 comments on HN
- 13New e-book: Hands-on Scala.js6 people · 26 points · first shared 2014 · 1 comments on HN
- 14From First Principles: Why Scala?5 people · 317 points · first shared 2021 · 329 comments on HN
- 15From first principles: Why I bet on Scala.js5 people · 107 points · first shared 2016 · 87 comments on HN
What HN people wrote when they linked it
valenterry · 2024-10-25
Yeah, that's true. Scala 2 allowed a lot of weird things and sometimes even nudged people into the direction of overengineering and writing cryptic code. I'm not surprised a lot of people were burned.
Basically, you needed a good and experienced developer from the start of a project for it to be a nice code base.
> I'm very fluent in Scala 2, but I will avoid Scala if I can, mostly to stay away from purely functional programmers.
There is the whole [Li Haoyi](http://www.lihaoyi.com/) ecosystem in Scala that is much more python-like, but nicely designed, statically typed and using immutable datastructures by default. I think it's the best you can get nowadays if you want to have immutable datastructures on the JVM. Any other option I've ever tried was way worse.
If you are fine with Java's stdlib then I guess Kotlin is the better choice.
> Does it prevent me from using a non-thread-safe object in multiple threads?
I would answer the question with yes, but maybe in a different way than you might expect. Scala prevents problems/bugs from using a non-thread-safe object in multiple threads by simply having immutability by default. Rust cannot do that (due to performance) so it has to have another way (the borrow checker). I would argue that the Scala way is better if you don't need the performance / memory-efficiency of rust and can live with garbage collection. That reduces the domains that you can use Scala for, but in exchange the code will be simpler compared to Rust…
philipkglass · 2021-12-10
I will toot the author's horn for him. He has a fine series of Scala posts on his blog [1] and his book Hands-On Scala Programming [2] is a great introduction to building real applications with Scala so that any experienced developer can understand and extend them.
I work at a small company that has been using Scala for 7 years. Some of the prior employees enjoyed playing with advanced language features and writing libraries for the most general possible case even when that made it hard to understand how they were used for the 2 actual cases we needed to handle. Akka, Cats, and Shapeless were all over the place.
Those earlier employees have churned off to other places and I have successively simplified the code they wrote that is still useful, while encouraging the use of no more language power than necessary in new development. Hands-On Scala Programming is the book I give new hires as a language introduction that shows the sort of style to be preferred. It's much more like super-powered Python than like Haskell.
I have written C, Fortran, JavaScript, Python, and Scala for money. When I started on Scala I had never written Java nor used any JVM language. I have come to really appreciate the rich ecosystem of JVM libraries, the instrumentation and profiling tools I get, and many aspects of the Scala language and standard library. I love Scala's collections and miss their power and ease when I'm writing Python. (Which I still do for certain scripting tasks and for…
AlexITC · 2021-01-21
First I would ask, what's your motivation?
- If you are just looking for a better Java, Kotlin is likely the way.
- If you are looking for a better language that leverages the JVM ecosystem, then, Scala might be the way.
It also depends about what kinds of projects do you want to work with, Scala is a no-go for Android if you are just learning, on the other hand, if you plan to work in distributed systems, Scala is great for that.
The biggest advantage I see on Kotlin right now is the Multiplatform side, we are taking advantage from it to write a library once, that can be consumed by Android, iOS, and our backend services built with Scala (we even want it for the JavaScript side but it isn't as mature as Scala.js).
On the Scala side, it has a very nice ecosystem, with powerful tools that usually get ported to other languages, for example, its the first language where I see good tools for:
- Compile time checked SQL queries.
- Documentation tools that actually compile your code examples to make sure it is correct (even arrow-ank on Kotlin was inspired by tut from Scala).
- Generating JavaScript code that actually works.
While Scala may have had not-so-good tooling years ago, right now is pretty good.
People usually complain about over-complex code, which can be true, but, you can find bad code in any language, on Scala you can choose a path, whether to be pure-FP or pure when practical, and there is great tooling for any side, I personally try to be practical and…
xolve · 2025-12-07
The bug reports linked on softwaremill and scala GitHub's are precise and surprisingly small fixes! It does show Scala's power in expressiveness.
Scala is a great language and I really prefer its typesafe and easy way to write powerful programs: https://www.lihaoyi.com/post/comlihaoyiScalaExecutablePseudocodethatsE… Its a great Python replacement, especially if your project is not tied to ML libraries where Python is defacto, like JS on web.
lmm · 2024-11-05
I love the idea/design of Nix and hope that one day someone will reimplement it in a way that one can reasonably understand/debug. Language is part of the problem but I think it's more of a https://www.lihaoyi.com/post/SowhatswrongwithSBT.html style problem where the execution model involves too much at runtime.
ackfoobar · 2024-10-25
> whole [Li Haoyi](http://www.lihaoyi.com/) ecosystem in Scala
He has very good taste. I wish more Scala people are like him.
> simply having immutability by default
Not everything is a pure data structure. I called a gRPC streaming callback with multiple threads in Scala (got garbled result in the receiver). You can say this is the fault of using the Java API, but the more Scala solution (fs2) involves serializing the access under the hood which is not cheap.
Recalling that my contention is with "all the goodies of Rust".
>> named destructuring
> Unless we are talking about two different things, yes it does.
I guess we are. I complained about this quite some time ago: https://news.ycombinator.com/item?id=31399737
kaba0 · 2024-09-21
Gradle and Bazel are absolutely general purpose build tools that are very widely used in industry.
As a smaller contender, my personal favorite is the Mill build tool (written in Scala), that is basically what a build tool should be, it’s as close to a theoretical perfect as possible. I really advise reading the blog post by its author Li Haoyi: https://www.lihaoyi.com/post/SoWhatsSoSpecialAboutTheMillScalaBuildToo…
lihaoyi · 2024-09-03
My own blog http://www.lihaoyi.com/ is also built using the Mill build tool. Incremental builds, parallelosm, watch-and-rebuild, etc are all things that static sites need as much as builds tools do; except you're compiling markdown to html instead of java to classfilrz or whatever. Cool to see others taking the same approach
MrPowers · 2021-12-10
> Scala offers you many design choices that work well in skilled hands
I agree that Scala works well in some skilled hands (see Li's libs), but the people that write the most terrible Scala programs actually know a lot about Scala. Scala has a unique way of encouraging genius programmers to write crazy code. People that know little Scala can just use it as a "better Python" language and actually write amazing Scala code.
I agree that Scala codebases that follow the Principle of Least Power can be amazing: https://www.lihaoyi.com/post/StrategicScalaStylePrincipleofLeastPower.…
Scala programmers generally frown on programmers that want to use it as a better Python and I think it should be the opposite.
nikitaga · 2021-02-27
I do find it interesting. I can't speak for Singapore's rules of succession, but I will nitpick however that Li Haoyi does not maintain the Scala.js compiler, that would be Sebastien and Tobias. He is nevertheless an exceptional, foundation-building creator in the Scala.js ecosystem, and has been at it from the start.
https://github.com/com-lihaoyi
https://github.com/lihaoyi?tab=repositories
https://www.lihaoyi.com/
vopi · 2021-01-20
SS: Just saw this article for the first time. I think it's interesting how the PM of Singapore apparently is (loosely) a hobbyist programmer.
Interestingly his son, Li Haoyi[0], is a well known Scala developer. From the article, "My children are in IT, two of them—both graduated from MIT. One of them browsed a book and said, 'Here, read this.'" It was a textbook on the Haskell programming language, Lee recounted. "One day that will be my retirement reading."
[0] https://www.lihaoyi.com/
joshlemer · 2021-01-06
Haoyi Li did a great piece on it: https://www.lihaoyi.com/post/SowhatswrongwithSBT.html
truelaurel · 2020-04-19
great action to make scala more accessible to developers. this should be a concrete answer to https://www.lihaoyi.com/post/TheDeathofHypeWhatsNextforScala.html
mwcampbell · 2018-12-09
I find compilation of statically typed languages to JS, as in Scala.js, worthwhile in principle, for the reasons that Haoyi argued so well in a blog post a while back [1]. But there's one major reason I would be reluctant to use Scala.js: runtime footprint. 45 KB gzipped (the number given on scala-js.org) is pretty heavy. Is that an inevitable trade-off for the power of Scala, or is there still more work that can be done to bring that down?
[1]: http://www.lihaoyi.com/post/FromfirstprinciplesWhyIbetonScalajs.html
pacala · 2018-04-20
> If scala team were to disavow sbt, that'd be the single best thing they could possibly do for the ecosystem.
Seconded. Between http://www.lihaoyi.com/mill/ and https://bazel.build/, there are plenty of alternatives.
paulddraper · 2018-04-07
I recommend reading the developers post http://www.lihaoyi.com/post/SowhatswrongwithSBT.html which is a balanced overview of sbt shortcomings.
stcredzero · 2017-08-31
Data flow, and FP, are about explicitly passing all the required dependencies into any step in the process, and getting back all the results
I always knew there was some relationship between FP and dataflow. There is something profound here. However, I'm not so sure that current FP languages are capturing this something in the best possible way. To me this:
http://www.lihaoyi.com/post/BasicFunctionalProgramming/CodeGraph.png
Somehow seems far inferior to this:
http://www.lihaoyi.com/post/BasicFunctionalProgramming/DiagramGraph.pn…
Cyph0n · 2017-04-18
Scala has an excellent REPL too. I often use it to test Java libraries without having to setup a full project. There is also the excellent 3rd-party REPL called Ammonite[1], which is maintained by Li Haoyi[2]. Not only is it a REPL, but it also provides a full-blown scripting interface in Scala!
[1]: http://www.lihaoyi.com/Ammonite/#Ammonite-REPL
[2]: https://github.com/lihaoyi
chickenbane · 2016-04-21
If you're into Scala, Haoyi Li has a great video about his (similary) Ammonite project
https://www.youtube.com/watch?v=dP5tkmWAhjg
http://www.lihaoyi.com/Ammonite/
acemarke · 2016-04-05
Usually I'm doing one of two things:
* Trying to completely learn how an application works
* Trying to figure out a specific issue or bit of behavior.
For case #1, you generally look for an entry point and spread out from there. For case #2, you're mostly concerned with a specific chunk of code, probably related to an error message you're interested in, so you do some quick searching or digging to jump straight down to the relevant spot.
This article is a great example of that sort of behavior and thought process: http://www.lihaoyi.com/post/DivingIntoOtherPeoplesCode.html
jinst8gmi · 2016-03-11
Well written Scala code is fantastic to work with, but it does take some practice and judgement to write well structured readable code. If you're having trouble reading your own code days later perhaps consider the way you're using the language. I'd strongly recommend reading http://www.lihaoyi.com/post/StrategicScalaStylePrincipleofLeastPower.h… if you're have trouble reading your own code.
still_grokking · 2023-01-05
> I like Rust's pragmatism.
Me too.
But Scala is also a very pragmatic language. If you want something academic go for Haskell.
> Allow limited operator overload.
Nitpick: Scala does not have any operators. So it doesn't have operator overloading at all.
Scala simulates operators by infix method syntax.
Instead of writing `1.+(2)` you can just write `1 + 2`. But the later is the same method call as the first one!
> Eschew HKT for a simpler abstractions.
AFAIK HKTs are more or less "just postponed" in Rust, AFAIK.
People would like to add them of course. The discussion goes on forever by now. Some small insight (there is much more when you look for it):
https://github.com/rust-lang/rfcs/issues/324
https://internals.rust-lang.org/t/higher-kinded-types-the-difference-b…
> Don't go in the deep end with type power, nor too much in opposite direction and avoid any complicated feature.
While having a full ML style type system with afine types on top, and quite some other type level mechanics up to singleton types?
Sure sure, no power in here. :-)
> The more powerful feature the more abusable it is, and Scala loves the power at all cost.
Everything is "abusable". This is not an argument.
But that Scala loves power at all cost is simply not true. The contrary is.
Just to cite one of the most influential post in Scala land of all times:
https://www.lihaoyi.com/post/StrategicScalaStylePrincipleofLeastPower.…
This, and the…
eternalban · 2022-06-03
> Rust really is a great programming language that solves a lot of other problems other languages don't. It does so by introducing a pretty clever paradigm.
Were you around when Scala was the end all be all of programming shiny things?
"Early on, Scala rode a wave of hype that frankly surprised even me: hype around pushing syntactic boundaries, hype around reactive architectures, hype around functional programming, hype around the Apache Spark project. Much of that hype has since died down, and there was a period of backlash and negativity both within the Scala community and outside of it. Since then, even the backlash has faded, and what is left is a reasonable, boring language steadily advancing and providing a great platform for general software engineering."
source: https://www.lihaoyi.com/post/TheDeathofHypeWhatsNextforScala.html
Not every concern needs to be solved at source level. My brief crit of both Scala and Rust is that they do not take a modular approach and instead have opted for a 'comprehensive' approach that necessarily entails (arguably) unreasonable levels of complexity at syntactic and semantic layers of source code.
ezst · 2022-03-16
> when properly designed (especially, avoiding the feeping creaturitis of something like Scala)
What I find interesting here is that Scala has the reputation of being a complex language, while its syntax and grammar are among the simplest and most straightforward there is: https://images.app.goo.gl/K1NTGUP4G9T6wfY48
I believe that this is what "scalable" means in the eyes of its creator: it offers very powerful abstractions to be adequate for mundane tasks (e.g. file-level scripting) up to complex systems and problem spaces.
Yes, as a consequence, people have created libraries and codebases with Scala that are inadequately complex and abstract for the problem at hand, but that's not something one should blame on the language but on the project/company culture. Same is true for any language: C++ templates can be abused in ludicrous ways, some of Java's design patterns make you wish inheritance would be forbidden, python's module imports potentially overwriting globals and other footguns.
No language can be dumbed-down so much that the resulting codebase becomes immune to some amount of "abstraction management", not go, not even python. Once this is understood and accepted, it becomes obvious that it's not worthy to castrate a language on the basis of "simplicity", because eventually this complexity will be warranted at a point in the future or for some aspect of the project.
I think the go designers did the right thing here, I don't think this will bring dramatic changes…
sideeffffect · 2022-02-08
> awkward currying
Personally, even though I haven't really thought it through deeply, I feel like Scala would be better if everything were curried.
> Subtyping also has many complex consequences
But also substantial benefits!
> There is limited type inference
I wish Scala would improve in this regard. Maybe paradoxically, inference works better with code tuned for subtyping and variance.
> tail call optimisation
This will be fundamentally solved by Project Loom. At least on the JVM (there's also Scala on JS and on LLVM).
> F# has units of measure
I dearly miss those. Type Providers even more so.
> OCaml has polymorphic variants
Could be nice in Scala. Or maybe not, can't tell now. And there's always the risk of too many features, which makes a language worse, not better.
> It was not designed as a functional programming language first and foremost
This is misleading at best. It was designed to show that the distinction between OOP and FP is arbitrary, not fundamental. In other words, Scala erases the distinction, it's fully OOP and fully FP. Scala has higher order functions, ADTs, pattern matching, a module system, like SML/OCaml. But it uses keywords `class` and calls it's instances "object" like Java. And it's interoperable with Java. But theoretically there's no fundamental distinction.
More languages are becoming more and more like Scala, btw.
https://www.lihaoyi.com/post/FromFirstPrinciplesWhyScala.html
And the concept of a programming language paradigm…
SimonPStevens · 2017-10-14
Brief telephone screen, mainly to confirm the role is a match to their expectations. We tell them about the role, and give them the chance to opt out if the role doesn't fit their requirements.
Then an in person interview. The usual discussion about work history and experience.
We do a technical piece. This consists of a spec, a laptop with appropriate tools/compilers installed and about half an hour to implement it. Followed by time afterwards to discuss their implementation, what else they would do that they didn't have time for, choices they made, etc. We are around to answer questions, but leave them in peace if not. We allow full access to internet resources as you would expect in the real world. The specs are usually fairly contrived, they have to be to fit in the time aloted, but we try to make them something that any decent programmer would be able to implement even if they have never see the concepts before. Where the best stand out is in their follow up discussion afterwards.
This blog post has been quite influential in our process - http://www.lihaoyi.com/post/HowtoconductagoodProgrammingInterview.html
asa400 · 2015-08-17
Li Haoyi just gave a talk at Scala by the Bay entitled "Beyond Bash", which details the shell scripting environment he's been working on that is hosted in a reimplementation of the Scala REPL, called Ammonite.
Slides for the talk: http://tinyurl.com/beyondbash
Docs: http://lihaoyi.github.io/Ammonite/
I wasn't at the talk, but I downloaded it and have been playing around with it. It's really fun!
The path operations are all typed (ie, you can't combine relative and absolute paths in stupid ways), you get all of Scala to operate on files and the filesystem (if you know Scala, this is pretty huge), and it has a handy pipelining syntax that is effectively an extension of the shell `|` operator we all know and love: http://lihaoyi.github.io/Ammonite/#Extensions
There are other niceties built in as well, like syntax highlighting and pretty printing, that gave me the impression that the author really cares about the UX of the software. It's not all academic/pure, in fact it appears to be the kind of pragmatic, practical thing that I wish Scala was known for. I highly recommend giving it a shot, especially if you already know Scala. I definitely will be giving it some time in the coming weeks.
ATMLOTTOBEER · 2025-02-19
It defines a DSL for your build that looks roughly like Scala code. But… it’s not! And there is a confusing “resolution” system for build tasks/settings. It’s also slow as shit. See https://www.lihaoyi.com/post/SowhatswrongwithSBT.html for a comprehensive takedown. If you’re interested in just playing around with scala I would use
https://scala-cli.virtuslab.org
Or for larger projects, the thing the author of the linked article is plugging (mill).
ldite · 2024-09-12
SBT is awful. I've never used Gradle, but if SBT is saner then I'm worried. This blogpost is a bit old, but still on-target: https://www.lihaoyi.com/post/SowhatswrongwithSBT.html
svieira · 2024-09-09
Anyone who is interested in pattern matching and the visitor pattern (and the benefits of various encodings of state and behavior) who hasn't seen them should check out:
* Li Haoyi's Zero-Overhead Tree Processing with the Visitor Pattern (https://www.lihaoyi.com/post/ZeroOverheadTreeProcessingwiththeVisitorP…
* Noel Welsh's Uniting Church and State: FP and OO Together (https://noelwelsh.com/posts/uniting-church-and-state/ or https://www.youtube.com/watch?v=IO5MD62dQbI is you like video)
* Bruno C. d. S. Oliveira and William R. Cook's Extensibility for the Masses Practical Extensibility with Object Algebras (https://www.cs.utexas.edu/~wcook/Drafts/2012/ecoop2012.pdf)