Top products from r/scala
We found 36 product mentions on r/scala. We ranked the 26 resulting products by number of redditors who mentioned them. Here are the top 20.
1. Programming in Scala: A Comprehensive Step-by-Step Guide, 2nd Edition
Sentiment score: 3
Number of reviews: 5
Used Book in Good Condition
2. Programming in Scala: Updated for Scala 2.12
Sentiment score: 2
Number of reviews: 4
CBL Distribution
4. Programming Scala: Scalability = Functional Programming + Objects
Sentiment score: 2
Number of reviews: 3
O Reilly Media
6. Programming in Scala: A Comprehensive Step-by-step Guide
Sentiment score: 1
Number of reviews: 2
Used Book in Good Condition
7. ML for the Working Programmer, 2nd Edition
Sentiment score: 1
Number of reviews: 1
8. The Ray Tracer Challenge: A Test-Driven Guide to Your First 3D Renderer (Pragmatic Bookshelf)
Sentiment score: 1
Number of reviews: 1
9. Testing in Scala
Sentiment score: 0
Number of reviews: 1
Used Book in Good Condition
10. Beginning Scala
Sentiment score: 1
Number of reviews: 1
Used Book in Good Condition
11. Hiring The Best Knowledge Workers, Techies & Nerds: The Secrets & Science Of Hiring Technical People
Sentiment score: 1
Number of reviews: 1
Used Book in Good Condition
12. Working Effectively with Legacy Code
Sentiment score: 1
Number of reviews: 1
Prentice Hall
14. Java SE8 for the Really Impatient: A Short Course on the Basics (Java Series)
Sentiment score: 0
Number of reviews: 1
Used Book in Good Condition
15. Scala for the Impatient
Sentiment score: 1
Number of reviews: 1
Addison-Wesley Professional
16. Fuzzing: Brute Force Vulnerability Discovery
Sentiment score: -1
Number of reviews: 1
17. Domain-Driven Design: Tackling Complexity in the Heart of Software
Sentiment score: 0
Number of reviews: 1
18. Code Reading: The Open Source Perspective (v. 1)
Sentiment score: 0
Number of reviews: 1
> The best that has been presented so far is an example using a random number generator that was interesting, but so conceptually removed from real life code that I don't know what to do with it.
But you asked for a simple real-world example. That's a simple real-world example. Feel free to replace the random number generator with, say, reading from a
File
, or accepting an HTTP request on a socket, or whatever.>So it uses a thread...yes, I understand that threads are a scarce resource, but so are RAM and compute cycles.
Again, the difference is that we can specify threads' lifecycles programmatically. We can't with CPU cycles or memory. (Well, kind of: see scala-offheap for an alternative approach to memory management).
> The scalaz crowd doesn't have any problem blowing through all of the RAM on my machine...
I don't know what you mean by this. scalaz's just a library. How much memory are you using with it?
> ...so why do threads get the special "algebraic" treatment?
We're doing a lot of server-side stuff at scale, so it's helpful to be able to be very explicit about when and where we use threads, and in particular to be able to refactor our code at will without worrying, e.g. about introducing starvation etc. funnel, our distributed monitoring system, is a good example of a system that benefits from
Task
etc.>What is so special about the use of a different thread to compute 1 + 1 that makes it hard to reason about?
It's not hard to reason about in isolation. It's that it may be fine in one place in your program and cause, e.g. thread starvation (depending on what
ExecutionContext
is implicitly in scope) elsewhere in your program. I mean, probably not with "1 + 1," but with people really doing stuff like wrapping JDBC calls withFuture
in, say, a web app that's supposed to scale, it's a real problem.> I was hoping for a meaningful explanation of the concept that you find so powerful, and you didn't explain what anything meant, you linked to 250 pages of academic brain teasers using language that only computer scientists would bother with.
So pick just one link. The "academic brain teasers" are the actual explanation, and are meaningful. When we talk about "functional programming," we mean "ensuring software functions and math functions are the same thing." I mean, they are anyway; it's just that the math inherent in functions that mutate variables, throw exceptions, etc. really is incomprehensible. So we try to keep things simple. But simple does not mean "familiar," necessarily.
So when I say "algebraic identities," I just mean, to steal one of /u/tpolecat's examples:
val x = Task.delay(r.nextInt)
for {
a <- x
b <- x
} yield (a, b)
and
for {
a <- Task.delay(r.nextInt)
b <- Task.delay(r.nextInt)
} yield (a, b)
are "equal," i.e. they have the same value, and equally or more importantly, the "state of the world" (the RNG
r
, in this case) is the same both ways. It's really the latter point Tim Perrett is driving at with his tweet.> If I have to be a PhD computer scientist to find any sort of usefulness for the distinction between Future and Task, then you can count me as unimpressed.
You don't; it's just that the ground-level explanations of what it means for pieces of code to "have the same value" or what is and is not a "side-effect" etc. are mathematical, and if you put a bit of effort into understanding them, they apply to all code. That's their real strength. Then you can make informed tool choices, pro or con.
> Frankly, this whole conversation makes me glad that the scalaz crowd decided to fork the compiler and go their own way.
We use scalaz with good ol' scalac like 99% of all scalaz users.
> Please take all this bullshit with it.
Your hostility just makes you sound extremely insecure. I'm a mostly self-taught programmer, too (had freshman year of university, flunked out). I've written a lot more imperative/OO code than anything else, and had never used scalaz before starting my current job. What I came to understand and appreciate is how much easier programming is when functions are referentially transparent (like the example above) and total (don't throw exceptions, dump core, loop infinitely... i.e. return a result).
So I'm sorry if the terminology is off-putting. I think, though, that if you work through Functional Programming in Scala, you'll find it's easier than it seems (with a bit of experience), and the benefits to your confidence in your code will be nearly immeasurable.
I'm not sure I'm quite over the gap yet but what's brought me this far is probably unhealthy levels of enthusiasm coupled with trial-and-error.
Truth be told it took a while, but we started out on different terms. I started learning Scala the same week I started learning C-sharp for a new employment some 3.5 years ago. Digging into the now a bit dated second edition of Programming in Scala was for me a timely decision as my hobby helped me in my professional work.
Scala and modern C-sharp have some similarities in that they use high level abstractions to process collections. Things like map, flatMap, filter (Select, SelectMany and Where in C#) are commonplace and the times I reach for foreach, let alone a lowly for-loop, are easily counted.
There are some details that differ in how collections are handled: .NET has them lazy by default and everything end up an IEnumerable<OfSomeType> whereas Scala is mostly eager. Both variants have pros and cons but I must say I prefer .NET here, it feels like the "more functional" way of doing things and also interestingly enough the way Java 8 has decided to do it. A lot of people like to argue about this, which is a good thing as it means we'll see development in both aspects.
Anyway, the message that I am trying to convey is that you need to know how it works, and why it works, before you can understand why it's slow. That Scala runs on the JVM by default doesn't mean its constructs are equal, no matter how similar they may seem. Scala's for-comprehensions, for example, are not analogous to a vanilla Java
for
or even foreach. Rather, they are literally a way of expressingflatMap
,map
andfilter
in a more linear fashion. They are functional and carry an overheadI'll agree with both the enthusiasts and the pessimists and say that Scala gives you more than enough rope to shoot you in your foot. Maybe unfortunately so as we are much more likely to screw up spectacularly while transitioning from one language to a seemingly similar language, as we are a couple of years down the road.
To round off, getting over the gap is as much about taking in as it is about letting go. It is an investment in spare time: a worthwhile investment in my experience.
Finally a few tips:
Sorry for the rant!
addendum: Yes! I feel I am more productive in Scala compared to both Java and C#, even for bigger projects. The ability to try ideas and flesh out code is much faster once you get used to how the type inference works (and doesn't work in some instances)
Programming in Scala, co-written by Scala's creator, is the most detailed and authoritative book on the language. Highly recommended.
I also bought Pollak's Beginning Scala. It's a much slimmer book that tries - and, in my opinion, succeeds - to be a crash course in Scala's best features.
It's important to note that Scala 2.8 final is expected soon (2.8 beta pre-release is already available), so you might wish to wait for updated editions of Scala books. Scala 2.8 brings some important improvements and breaks the backward compatibility in some minor ways.
What else is there? git history, hopefully clean w/consistent branch/merges and commit messages, server logs w/devop notes (esp. heap, maxInline, GC etc params) annotated stacktrace or profiler runs, breakpoints/debug strategy, db schema, net logs, design docs yadda yadda. Not knowing anything else, i would read thru repo's recent and early history, run unit tests, profile/load test it and see how failure prone the server(s) are
You could start with an old repo that has the basic functionality you're interested in, hopefully it's a lot less LoC.
You could read Fowler or Feathers which i remember being good: http://www.amazon.com/Refactoring-Improving-Design-Existing-Code/dp/0201485672/
http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052/
I've read the first edition of this book Programming Scala and found it to be an excellent way to learn Scala.
I really like scala to build parallel and distributed applications, specially if I get to use Akka.
But many other people like it to build web applications, big data processing, data mining, etc.
Just find some task you would like to automate or a small project you have on the back burner and give a go implementing it with Scala.
For Scala-the-language I think Odersky's book Programming in Scala is a great intro. I found it extremely readable. One hurdle you might expect coming from JS based on my (limited) experience with JS is due to traditionally object-oriented concepts like inheritance or traditionally functional-programming concepts like closures have meanings and behavior in JS that are not quite the same as in most other languages despite the same terminology, and Scala is built around mixing OO and FP. So be prepared to relearn what some basic concepts mean in the context of a statically-typed mixed-paradigm language.
For Scala-the-ecosystem I'd say start with the basic tools in the sidebar: IntelliJ + Scala plugin and SBT. They'll at least get you building and running some Scala code. I'd take finding libraries for what you need on a case-by-case basis, e.g. waiting until you actually need JSON serialization to before evaluating the various JSON libraries.
If you want to learn Scala, the best reference book is Odersky's: http://smile.amazon.com/dp/0981531644
Dean Wampler's book is very good and more accessible:
http://shop.oreilly.com/product/0636920033073.do
Finally, if you want the full on FP experience, then you probably want:
https://www.manning.com/books/functional-programming-in-scala
If you're looking for a functional programming library on top of Scala (which is not at all the same thing as Scala the language), there are a number of options available, but they are constantly shifting -- last I heard, cats and shapeless are being actively worked on.
The Ray Tracer challenge: https://github.com/jamesmcm/raytracer_challenge_scala
Looks pretty cool so far
I need to fix some things where I hacked around using self types, but overall I've really enjoyed writing it in Scala and building it up step by step.
US beginner here
In general jobs are better in big cities than in rural areas. Look in places like Paris, Berlin, etc. In addition, keep in mind that a lot of companies don't know how to hire Scala developers. They list insane amounts of Java experience as a prerequisite thinking that a Scala developers is a glorified Java developer when in fact it's different. That being said, the good ones will actually care if you know functional programming. Start with the basics - core language
https://github.com/aashack/programming_in_scala_2nd/blob/master/Programming%20in%20Scala%2C%202nd%20edition%20(Artima%2C%202011%2C%200981531644)(1).pdf
Functional Programming
https://www.amazon.com/Functional-Programming-Scala-Paul-Chiusano/dp/1617290653/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1467346928&amp;sr=1-1&amp;keywords=functional+programming+in+Scala
From then people tend to go either toward big data (Spark, Scala wrapper for Hadoop) or toward web dev (Akka, Play). Big data pays more, lol. If you're getting a masters degree, the big data tests don't actually need you to know much Scala - just be able to solve simple programming puzzles. If you need to do ground up backend infrastructure with a team (like with actual design patterns and scalaz and what not), actually getting a job is hell because all the senior devs take up the jobs and if you want them you have them you impress the hell out of your interviewer (at least I had to) and also your interviewer has to be open minded (if they say something like "5+ years Java for Scala position", you're screwed). Java jobs are easier to find, and you don't have to travel to big cities, but they pay less.
From the sidebar:
Free Books, Tutorials and Guides:
Non-free Books:
Advanced!:
If you are a sophomore in college, I would start by watching Martin Odersky on Coursera, reading Programming in Scala (pdf) or Programming Scala.
I also have a tutorial series, but it isn't as good (everything is unedited live recording of me and my IDE).
Scala is a REALLY, REALLY hard language. Like if you only know object oriented programming and not functional programming, it could take you about as much time as learning C++. Scala is not for the impatient.
If you really want a project, find some code you wrote in Java and translate it into Scala. It could be a homework assignment. Ask your teachers if they would let you turn in homework assignments in Scala instead of Java. Say that Scala is like Java 2.0 and that functional programming is related to your math background and by allowing you to do homework in Scala you will be augmenting your CS skills.
'Programming in Scala' is a good book I'd recommend (http://www.amazon.co.uk/Programming-Scala-Martin-Odersky/dp/0981531644)
I second this. Great course to get you started. This book is also amazing (main author is the father of Scala himself, the same man that did the coursea course - M. Odersky).
I read the one from Martin Odersky: http://www.amazon.co.uk/Programming-Scala-Comprehensive-Step-Step/dp/0981531601/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1269246979&amp;sr=8-1
and the one from Dean Wampler.
The Wampler one is shorter and a bit more critical of Scala, but in my opinion the Odersky one is better for starters.
Here's an old book about OS with Java example, perhaps you can reuse it and convert it to scala :)
https://www.amazon.com/Operating-System-Concepts-Abraham-Silberschatz/dp/047050949X
I feel like Functional Programming in Scala is the obvious answer here.
Breaking away from the Rails (or in my case Django & SQLAlchemy) mindset of the model is both the business model and the persistence model can be hard to do.
However, why not this? -- This might not be good scala, I mostly tool around in it, you'd probably want status as a private attribute:
abstract class TaskStatus()
case class TaskCompleted() extends TaskStatus()
case class TaskPending() extends TaskStatus()
class Task(var status: TaskStatus) {
def isCompleted: Boolean = status match {
case TaskCompleted() => true
case => false
}
def markCompleted(): Unit = status = TaskCompleted()
}
Then Task is a regular object with no ties to a repository or service.
new Task(TaskCompleted()).isCompleted // true
new Task(TaskPending()).isCompleted // false
val t = new Task(TaskPending())
t.isCompleted // false
t.markCompleted()
t.isCompleted // true
This makes Task an entity it has business logic and state that persists from session to session (this other state is probably a title, who its assigned to, and an ID as a persistence allowance, but I've omitted these for brevity).
You can then stuff these tasks into a data store (pick your poison on how you do that) and reconstitute them from that data store -- essentially that's what a repository is: take in some entities, shove them into a data store; take in a query, pull some entities out of the data store.
With that in mind, your
TaskService.isTaskCompleted
can be a simple wrapper around a repository query that pulls that one task out and doesTask#isCompleted
on it (note you'll want to guard against unfound Tasks):class TaskService(val repo: TaskRepo) {
def isTaskComplete(id: Int) {
repo.findId(id).isComplete
}
}
Expanding this out to your TaskAssignments, your task now holds a reference to many TaskAssignments that probably have an
isCompleted
on them as well. In that case,Task#isCompleted
can end up just being `tasks.forAll(.isCompleted).<br /> <br /> Still no reference to a repository. The trick here is that
Taskis now an aggregate. When you ask the repository "Will you find me task 12345?" It not only pulls the literal
Task` out of the data store, but also all the parts of the Task as well. So you get the Task and the TaskAssignment objects.You might want to check out Domain Driven Design which helped cement these sorts of ideas in my head.
If you're having problems with terms like this, please read a basic book on functional programming, like Bird.
Was it The High Cost of AnyVal subclasses... by any chance? The same topic is also covered in Scala High Performance Programming, which I happened to read after the article.
Here you go
http://www.amazon.com/Testing-Scala-Daniel-Hinojosa/dp/1449315119/ref=sr_1_1?ie=UTF8&amp;qid=1464995693&amp;sr=8-1&amp;keywords=scala+testing
I learned from Programming in Scala and Akka in Action. They're not really tutorials, but they explain a lot of the rationale.
By the way, the 3rd edition has been out for quite some time now.
We've experienced the same problem. Probably my biggest regret in choosing Scala. I don't know if there is any easy answer. Basically, I studied the generated bytecode until I got a good feel for how various constructs were getting compiled.
The performant subset ... looks like Java. While loops, explicit primitive types, no type parameters (or specialization), and no Scala collections. But be wary of specialization, it definitely interacts badly with other language features and lead to incorrectly generated bytecode. See:
https://axel22.github.io/2013/11/03/specialization-quirks.html
(Quirks, ha!)
I haven't read it yet, but Chapter 3 of High Performance Scala Programming discusses various language features and the corresponding bytecode:
https://www.amazon.com/Scala-Performance-Programming-Vincent-Theron/dp/178646604X
Java 8 for the impatient -> https://www.amazon.com/Java-SE8-Really-Impatient-Course/dp/0321927761
Fuzzing is subclass of negative testing. It usually involves sending malformed or unexpected inputs at an interface (socket, file parser, etc). It's one of the techniques bad guys use to find buffer overruns and other exploitable defects in software. My favorite book on the subject is this one:
http://www.amazon.com/Fuzzing-Brute-Force-Vulnerability-Discovery/dp/0321446119