8 ms·
Explicit term inference with Scala 3
- natchy 6y agoAfter a couple weeks of dabbling between Scala and F# to migrate Python and Node.js codebases (at a scaling startup serving big enterprises) I ended up choosing F#. Scala is a beast and the package manager + build tools were giving me headaches. I’m optimistic about the current trajectory with Scala 3 and simplifying the language.
- klysm 6y agoI think F# is really underused - it fills a very similar spot in the trade off space and from what time I have read has excellent design.
- tremon 6y agoMy main beef with F# is the .net library -- none of it is written from a functional perspective, which means you're constantly mixing functional and object-oriented paradigms.
- theCodeStig 6y agoUnfortunately Scala suffers a similar story on the JVM with Java libraries.
- valenterry 6y agoIt misses type-classes and HKTs unfortunately. But the ML-like way of defining types and data is top notch. Even with Scala 3, F#'s way of defining types looks cleaner to me.
- lmm 6y ago> Scala is a beast and the package manager + build tools were giving me headaches. Ignore them and use maven. It's much better documented, consistent, and backwards-compatible. I struggle to understand why SBT ever gained any popularity, and it should certainly have never been recommended to newcomers.
- BossingAround 6y agoPersonally, I wouldn't recommend Maven to beginners. I would recommend beginners to learn Maven as it is one of the de-facto standards in JVM dependency management, but the documentation is highly confusing and the learning curve is very steep. Beginners will likely struggle with Maven concepts.
- lmm 6y agoI very much disagree; the only people I've known to have trouble with Maven are experienced developers who expected their build tool to work in a very specific way (i.e. that they would define a bunch of commands for it to execute and tell it what to do). For a beginner who comes to it with no preconceptions, maven is very easy: you fill in the parts your XML editor tells you to, list your dependencies, and then run one of their short list of phases for what you want to do: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#a-build-lifecycle-is-made-up-of-phases https://maven.apache.org/guides/introduction/introduction-to... . What could be simpler?
- JackFr 6y agoThe things I want to do, are they ‘goals’, ‘tasks’, ‘phases’ or ‘executions’? And do I manage my dependencies in ‘dependencies’ or ‘dependencyManagement’? And how is it that none of the ‘dependency’ goals can tell me the origin of the version - I have to use ‘help:effectivePom’? Maven is powerful and people forget how innovative it was. But it’s not easy.
- lmm 6y ago> The things I want to do, are they ‘goals’, ‘tasks’, ‘phases’ or ‘executions’? The page I linked to is pretty clear about which is which and what they do. > And do I manage my dependencies in ‘dependencies’ or ‘dependencyManagement’? You list your dependencies in dependencies, you manage them in dependencyManagement. But it's clear in the documentation, and if you're looking at a tutorial from 10 years ago then it'll still be accurate. There are confusing things in maven. But documentation and backward-compatibility go a long way, and I really think the fixed build lifecycle puts it head and shoulders above a lot of alternatives; the cost/benefit of each project having a slightly different set of build commands just doesn't stack up.
- liquid153 6y agoHas the scala hype train passed?
- alex_duf 6y agowhat makes you say that? (genuinely curious, but also I agree a little bit)
- barry27 6y agoYawn. Scala is awesome. So many whiney Clever People on here making vapid content-free barbs.
- MrPowers 6y agoYep, hype has peaked. Here's a great article on The Death of Hype: What's Next for Scala: https://www.lihaoyi.com/post/TheDeathofHypeWhatsNextforScala.html https://www.lihaoyi.com/post/TheDeathofHypeWhatsNextforScala...
- theCodeStig 6y agoHaoyi, is that you?
- xyzzy_plugh 6y agoThis is a nice write-up, it's beeb some time since I've written Scala and Scala 3 looks promising. Though, I am curious if there is anyone else who shares my mindset on Scala. In a corporate environment, I found it to be an extremely expressive and powerful language but that power comes at a grave price, which I'll try to summarize: - it's difficult to understand other people's code compared to other languages (e.g. Go) - it's so very implicit that you end up having to hold a lot of state in your head to understand what's going on. - the language is basically impossible to read effectively without IDE features. I usually enjoy reading most code bases, but Scala is downright painful to read in plaintext. You end up having to be a compiler.
- virgilp 6y ago> it's difficult to understand other people's code compared to other languages I think it depends a lot on the code. Scala 2 gives you a lot of guns to shoot yourself in the foot (see: implicit, as discussed here) - but you can also use it in its mostly-functional form, with immutable values, and then it can become very readable. Granted - I've always been using IntelliJ but I could read the scala code on Github too, just fine.
- lmm 6y agoIn a good Scala codebase you use the implicitness to put the business logic front-and-center and push secondary concerns into the background, but without making them completely invisible. The plaintext becomes something akin to the DSLs that people write in e.g. Ruby (using metaclasses and other such magic), but when you open it in an IDE (or compile it in your head) all those extra details become visible to you in a reliable way, rather than having to guess what a given piece of code actually does. IMO modern language designers should be making IDE-first languages - after all, most serious programmers do use IDEs (even if they build that IDE within Emacs or Vim). The problems with "visual languages" are that without a textual representation you can't meaningfully diff/merge/blame, not that using the GUI is an inherently bad idea. With Scala you get the best of both worlds: it's textual enough that version control works properly, but you have standard-ish way of folding, hovering etc. that mean that you can "zoom in" on the details of unfamiliar code but also "zoom out" to get a clear overview, in a way that few other languages manage.
- valenterry 6y agoA summary of what Scala is great for: - Safe and high performant concurrent programming. Scala is miles ahead of most other languages here and pretty much on par with the best ones (such as Haskell) - ETL / data transformations. Python is a big player here - but for stable and performant data pipelines, I strongly believe Scala is the better choice. For explorative things, python has the edge though. - Actor systems on the JVM. I believe that most "scalable" systems are over-engineered. A well configured postgres / elasticsearch and a machine with your application on good hardware goes _very_ far. But sometimes it's not enough and then Scala offers a great solution with Akka on the JVM. Erlang/Elixir with their runtime are probably even better, but Scala offers the better typesystem and one can stay in the JVM world if they want. - in-language custom DSLs. No seriously, Scala is the best language I know in terms of building typesafe, customizable DSLs within the language, making it almost look like another language. This is great if not so techy folks are to make changes to actual code in an easy way. The link in this post here shows some examples but it goes beyond. - Writing glue-code. Surprisingly, I think Scala is better than python and many other languages here, because of the sheer power of composability of the language and ways to connect pieces with each other in a typesafe manner. The reason for this lies mostly in the concept of implicits, which both enables great power and reusability but also makes the learning curve much steeper. This list might be a bit subjective and I don't know every language out there, but as the questions comes up almost everytime, I wanted to list the strengths of Scala in the areas where most other languages can't compete with it.
- jim-jim-jim 6y agoWell said. In some of my older comments I've shat on Scala (compared to Haskell) but after being forced to write Python for a day job, I've realized how good I had it with Scala. Luckily I'll be writing some again soon.
- threeseed 6y agoScala is incredible for web apps. I can write my React/JS front end [1] and highly concurrent, real-time scalable backend [2] using the same language, build tools etc. [1] http://slinky.dev http://slinky.dev [2] http://zio.dev http://zio.dev
- 6y ago
- AzzieElbab 6y agoCleanest way to extend functionality if ides are able to catch up and provide discoverability. Big win on syntax
- sabellito 6y ago> Avoiding repetition with contextual parameters This is the type of stuff that made me go away from Scala. Why implement a feature that optimises for code writing? How does my editor let me know that function receives that parameter without me going "???" and having to go into its definition? Implicit conversions fall into the same category, of making code pretty to look at, quick to write, and a nightmare to understand when you're new to a codebase. Shame, really. The good parts of Scala are wonderful.
- hocuspocus 6y ago> How does my editor let me know that function receives that parameter without me going "???" and having to go into its definition? IntelliJ has been able to do that for a while now. > Implicit conversions fall into the same category, of making code pretty to look at, quick to write, and a nightmare to understand when you're new to a codebase. Don't do it, and don't allow it in your codebase.
- sabellito 6y ago> IntelliJ has been able to do that for a while now. It has been 4 years since I did Scala everyday, back then it was hit or miss. Good to know things have improved. > Don't do it, and don't allow it in your codebase. I get your point, but that doesn't solve the issue if the community is down for using these features.
- hocuspocus 6y agoBoth JetBrains and the Scala center have invested in the tooling experience in the past 2-3 years, you should give it a try again! And I don't think I've encountered implicit conversions that often in the ecosystem.
- vvillena 6y agoThe community isn't very fond of implicit conversions. That's why you get warnings unless you enable a compiler flag, and why Scala 3 downgrades them from magic keyword definitions to avoidable stdlib types.