Tag Info

Hot answers tagged

50

Major Differences: Both Scala and F# combine OO-imperative programming and functional programming into one language. Their approach towards unification of paradigms is vastly different though. Scala tries to fuse the two paradigms into one (we call it object-functional paradigm), whereas F# provides the two paradigms side by side. For example, algebraic ...


33

This has nothing to do with functional programming - you can find this kind of situation in context of any other programming language - developers who love the advanced constructs of "their" language so much that they ignore any common sense about readability and keeping things simple. I have encountered such a situation in C, C++, Perl, Java, C#, Basic, and ...


31

The question is confusing, as C and C++ are languages, while JVM is a virtual machine and .Net is a platform. Scala could be implemented in C or C++, and it could generate machine code instead of bytecode for a virtual machine. Answering the question that was asked: Scala was not implemented in C or C++ because Scala, the language in which it is actually ...


28

There's one thing that you can do concisely and efficiently in Java that you can't in Scala: enumerations. For everything else, even for constructs that are slow in Scala's library, you can get efficient versions working in Scala. So, for the most part, you don't need to add Java to your code. Even for code that uses enumeration in Java, there's often a ...


28

Memory management is utterly relevant since it governs how fast something appears even if that something has a great deal of memory. The best and most canonical example are AAA-title games like Call of Duty or Bioshock. These are effectively real-time applications that require massive amounts of control in terms of optimization and usage. It's not the usage ...


25

IMHO from somebody programming in Java for the last 7 years and being my strongest language, I find Scala quite alien and am having a hard time getting used to it. Xtend feels more like Java and was able to write a simple application with it much quicker. Granted I didn't give myself enough time with Scala, but I certainly understand why some may be turned ...


24

The real brick was the memory allocation - at worst, Java allocated a whopping 52x more memory than C, and 25x more than C++. Do you understand the numbers you base your question upon? How much memory was allocated? What were the programs doing? When there's a big disparity between those Java and C programs, it's mostly the default JVM memory ...


23

All programming is related to mathematics. Indeed many universities still place their computer science programs under the purview of the mathematics department. As for learning functional programming, you do not need to have a strong base in mathematics to learn it. I've learnt three different functional languages now to reasonable proficiency (Haskell, ...


22

There is an easy, but boilerplate heavy way to seal classes in Java. You put a private constructor in the base class then make subclasses inner classes of it. public abstract class List<A> { // private constructor is uncallable by any sublclasses except inner classes private List() { } public static final class Nil<A> extends ...


21

I can advise Programming in Scala because it's from the creator of the Scala language: Martin Odersky. He describes most of the features of Scala very detailedly and explains, why he chose this feature instead of an other one. Therefore, the reader gets a deep insight into Scala. The book is fantastic. It is one of the best programming books I've ever ...


21

What Odersky says is (Slide 11, http://www.slideshare.net/rawwell/scalaliftoff2009pdf): "Scala is deep where other languages are broad." This means, scalable is meant in terms of flexibility and expressiveness. You can create your own control structures. E.g. the actors frameworks is a library, but it looks like it uses language features. This means ...


21

Now, I don't know much about Clojure and little about Scala, but I'll give it a shot. First off, we need to differentiate between tail-CALLs and tail-RECURSION. Tail recursion is indeed rather easy to transform into a loop. With tail calls, it's much harder to impossible in the general case. You need to know what is being called, but with polymorphism ...


21

In Scala, the * is a valid identifier. One could write: val * = "trollin'" println(*) With the result being: trollin' One could write a class named * as such: class * { def test():String = { "trollin'" } } So with that being the case, when I have a class * in the package us.hexcoder and I write: import us.hexcoder.* You would be saying ...


20

According to the Benchmarks Game for a single core, 32 bit system, Scala is at a median 80% as fast as Java. The performance is approximately the same for a Quad Core x64 computer. Even memory usage and code density are very similar in most cases. I would say based on these (rather unscientific) analyses that you are correct in asserting that Scala adds some ...


20

Here are a few reasons, which might be more or less compelling for you, depending on your own preferences: Do not simply discount it for being "syntactic sugar". While you may say that something is just syntactic sugar, it is after all the sugar that sweetens your life - as a programmer just as well as a coffee or tea drinker. Singletons - every Scala ...


19

REPL - I was using scala at work for a long time before I really started to use the REPL regularly. It can be useful for checking little things (like: how will a very large BigDecimal format itself using toString?) But I've started using it much, much more since I started using scalaz and functional-programming, because it allows for quick playing around ...


19

While it is true that Scala has been used in the wild at the Guardian and at Twitter, there is one fundamental concern. Much of Java's popularity comes from the fact that it is relatively easy to read and maintain. Scala has an problem here as it can be written in many different styles. OO style vs functional style is the obvious split here, but it gets ...


19

Disclaimer: I'm not a Scala guru. Scala does two things extremely well which Java (currently) does not. Solve functional problems At the most basic level, Scala has fully fledged closures with collections support. This means you no longer have to write boiler plate code such as (shamelessly ripped off a DZone post) public List<Item> bought(User ...


19

According the Great Benchmarks Game, ATS is faster than the rest with Haskell, Scala, and one of the variants of Common Lisp in a rough tie for speed close behind that. After that Ocaml and F# are in roughly the same speed category with Racket and Clojure lagging behind... However, almost none of this means anything at all really. It's all a question of ...


19

Subtyping and inheritance are two different things! Nothing doesn't extend everything, it's a subtype, it only extends Any. The specification[§3.5.2] has a special case governing the subtyping-relationship of Nothing: §3.5.2 Conformance [...] For every value type T , scala.Nothing <: T <:scala.Any For every type constructor T (with ...


18

Well, I think Scala is too complex. It feels like C++ in that it has a myriad of different ways of doing things. Some would call this "richness", "expressiveness" or "power", but your mileage may vary. In many real world projects you would have to artificially limit what language features you're going to use and what not, so that all developers involved ...


18

One of the big hurdles languages face when being introduced to the world at large is library availability. The traditional response to this has been to provide a C-based FFI (foreign function interface) to permit you access to C-based libraries. This is not ideal for a variety of reasons, chief among them: There's a lot of different ways that libraries ...


18

Short Answer: There is a simple solution to your problem. Just install the virtual-machine with Linux (Ubuntu) - it is free. I am also a mainly .NET developer who loves to experiment different things, or try variety of frameworks and/or development tools. The main thing here is not to mess your main development environment. Thus, installing everything in a ...


18

So from a neutral point of view, which syntax is simpler and readable? Those are two very different questions. Simpler means "composed of fewer parts". Clojure's syntax has fewer rules, ergo it is objectively simpler than Scala's. Readability, however, is subjective. It mainly comes down to familiarity. For example, I find ECMAScript, C#, Java, D, Go, ...


17

I don't think Groovy is going to disappear, it is a self sustained entity now. Grails framework is built around Groovy language, which it is a good reason to stay alive. Groovy got its killer application. I'm not saying Grails is the only vital Groovy project, Gradle is also pretty good. GORM is really handy. Gant is a nice improvement over Ant. Not ...


16

I've been programming Scala for more than one year now, so I'll try to set myself back a year to answer this question. Scala code is more concise than Java code (no setter or getter, a lot of the type information can be inferred) The built-in support for XML literal is very appealing. Java library compatibility and interoperability is great The support ...


16

What you are really asking about here is how to do Polymorphism in functional languages, i.e. how to create functions that behave differently based on their arguments. Note the first argument to a function is typically equivalent to the "object" in OOP, but in functional languages you usually want to separate functions from data, so the "object" is likely ...


16

As with all things, it's a trade-off. If you are building an application that is going to run on a single user desktop and can reasonably be expected to control a large fraction of the RAM on that machine, it may be worth it to sacrifice memory usage for implementation speed. If you're targeting that same machine but you're building a small utility that is ...


16

I'll expand my comment a bit. The List[T] data structure, from scala.collection.immutable is optimized to work the way an immutable list in a more purely functional programming language works. It has very fast prepend times, and it is assumed that you will be working on the head for almost all of your access. Immutable lists get to have very fast prepend ...


15

Probably the easiest way is to first use Scala only for testing. In this case, you might even not have to tell your boss :-) If he asks, tell him "that's just my private test case, it's so much easier and faster to use Scala for it". Once you (and your organization) has enough experience with Scala you can start using it for the 'real' code.



Only top voted, non community-wiki answers of a minimum length are eligible