5 ms·
> Given a choice of languages, choose the least powerful language capable of solving your problem Then no one would ever use scala?
by spdionis 11y ago
> Given a choice of languages, choose the least powerful language capable of solving your problem
Then no one would ever use scala?
- lmm 11y agoScala allows you to restrict yourself to a much greater extent than many other languages. You could say use assembly for everything - there's nothing that assembly can't do, so in a sense assembly is more powerful than any other language. For me the reasons I use Scala rather than Java/Python/etc. are the same reasons I would use Java/Python/etc. rather than assembly. To write code with the same guarantees as the core of my system would be theoretically possible in a "simpler" language, but it would be incredibly verbose: it would take longer to write and be much harder to maintain (because you'd have to keep a lot more in your head to understand each piece of functionality). If I weakened the guarantees (i.e. didn't keep track of as many possible side effects) I'd have a higher defect rate, especially when refactoring. That's the small heart of a few projects, but I see a lot of merit in using the same language for your whole codebase: http://www.teamten.com/lawrence/writings/java-for-everything.html http://www.teamten.com/lawrence/writings/java-for-everything... . And Scala is actually a pretty nice language for one-off throwaway scripts where you don't care about tracking any effects or similar as well.
- TeMPOraL 11y ago> To write code with the same guarantees as the core of my system would be theoretically possible in a "simpler" language, but it would be incredibly verbose: it would take longer to write and be much harder to maintain (because you'd have to keep a lot more in your head to understand each piece of functionality). I could use the same reasoning to justify writing my code in Common Lisp instead. The thing about Turing-complete languages is that the only real dimmension of power is their expressiveness - i.e. how much boilerplate do you have to write to implement something (and therefore how much of that cruft other people have to deal with when trying to understand your code). I therefore find this principle as applied to programming languages to be illogical. It makes sense in non-Turing-complete languages though (configurations, DSLs) - because there by "least power" one means power in the computational sense. Accidentally making a language too powerful when it's not needed can lead to security issues.
- lmm 11y ago> I could use the same reasoning to justify writing my code in Common Lisp instead. Maybe you should then. I find it too hard to restrict my code in lisps: if I want a certain part of my code to be in a DSL-like constrained sublanguage, there's no standardized way to express that, only ad-hoc macros. > It makes sense in non-Turing-complete languages though (configurations, DSLs) - because there by "least power" one means power in the computational sense. I think non-Turing-complete general-purpose languages are possible. I'm very excited for Idris.
- lihaoyi 11y agoI was going to say Scala's secret weapon was in it's non-turing-complete typesystem. Unfortunately, Scala's typesystem is turing complete.
- TeMPOraL 11y ago> I find it too hard to restrict my code in lisps: if I want a certain part of my code to be in a DSL-like constrained sublanguage, there's no standardized way to express that, only ad-hoc macros. There is a standardized way - via "ad-hoc" macros. Except they're not really more "ad-hoc" than using classes and traits in Scala is "ad-hoc". Maybe 'aninhumer has a point - restricting the language is kind of the opposite goal of making it expressive/powerful. > I think non-Turing-complete general-purpose languages are possible. I'm very excited for Idris. Idris is not Turing-complete? :o. [0] - https://news.ycombinator.com/item?id=11470569 https://news.ycombinator.com/item?id=11470569
- aninhumer 11y ago>Maybe 'aninhumer has a point - restricting the language is kind of the opposite goal of making it expressive/powerful. My point was more that safety is a separate, important metric of language quality. It often conflicts with expressiveness, but not necessarily. See also SPJ's "Haskell is Useless" video: https://www.youtube.com/watch?v=iSmkqocn0oQ https://www.youtube.com/watch?v=iSmkqocn0oQ
- lmm 11y ago
- incepted 11y agoI guess the point of the person you're responding to is that following the article's advice, Kotlin would probably be a better choice than Scala in most cases. For example, Kotlin doesn't support higher kinded types so if your problem doesn't require highed kinded types, Kotlin would be a better fit than Scala since it's the "Least powerful language that will solve your problem". Which will probably lead to the controversial claim that "All programs need higher kinds" followed by the realization that the perceived power of a technology is extremely subjective.
- lmm 11y agoIt's not subjective, just disputed. There is a fact of the matter, and we will one day reach a consensus.