I love functional programming
I like functional programming and what it brings to the table, but this is pretty funny.
I like functional programming and what it brings to the table, but this is pretty funny.
This “Can someone explain to me the benefits of IO?” Reddit post makes for some interesting functional programming and referential transparency reading.
This image is from the book, Functional Programming for the Object-Oriented Programmer. It provides a good, basic definition of functional programming.
Dateline October 20, 2017: I’ve renamed my book about Scala and functional programming. The original name was, “Learning Functional Programming in Scala,” but I don’t think that sets the tone of the book quite right, so I renamed it to “Functional Programming, Simplified (Scala edition).”
You can preview and buy the book in two places:
Here’s the new “Rampaging Lambda” book cover:
Functional Programming, Simplified is currently an Amazon best-seller in the functional programming category.
Amazon shows that Functional Programming, Simplified is a #1 New Release in its category. That’s cool.
As a brief note this morning, I’d just like to offer a “thank you” to the people who have purchased my new book, Functional Programming, Simplified, as sales have certainly exceeded my expectations. I first offered the idea to the people at O’Reilly, and when they turned it down I was concerned that maybe they knew something I didn’t. But sales and feedback have all been very positive, so thank you for that.
When you look at Functional Programming, Simplified on a dolly, it’s not that big. ;)
The first seven chapters of my new book, Functional Programming, Simplified, are now available online. More coming soon.
As I wrote in Functional Programming, Simplified, functional programming can lead to happiness (and sanity). The quotes in this slide from Rúnar Bjarnason’s FP talk expand on what I wrote in my book. They keys are that pure functions are very simple, and you don’t have to constantly worry about the mutable state in your application.
I’ve been looking for a way to make Functional Programming, Simplified smaller, but haven’t yet found a way to do that while keeping all the essential information in it. But IMHO, it’s still a heck of a lot easier than reading all of these books on the right:
The next chapter of my new book, “Functional Programming, Simplied (Scala edition)” is now online. It’s titled, “Benefits of Functional Programming.”
When I was writing Functional Programming, Simplified (FPS), I looked for ways to make everything easier. Then I found this game. The idea is to learn chess moves in a small setting, so you can then take them to a full chess board. It’s one reason FPS ended up with 130 micro-lessons.
I haven’t read this yet, but here’s a link to an electronic version of a free book titled, The Science of Functional Programming. Who knows, it may one day have an impact on my book, Functional Programming, Simplified.
As a brief note today, here’s a Scala method that writes the strings in a list — more accurately, a Seq[String]
— to a file:
def writeFile(filename: String, lines: Seq[String]): Unit = {
val file = new File(filename)
val bw = new BufferedWriter(new FileWriter(file))
for (line <- lines) {
bw.write(line)
}
bw.close()
}
Sorry, not much free time these days, so without any discussion, here’s a simple Scala Try/Success/Failure example:
Based on my two books, Learn Scala 3 The Fast Way and Functional Programming, Simplified, here’s my video on Expression-Oriented Programming (EOP) in Scala:
Summary: This blog post shows one way to drop/filter the first matching element from a Scala sequence (Seq, List, Vector, Array, etc.). I don’t claim that the algorithm is efficient, but it does work.
While creating some Scala test code earlier today I had an immutable list of toppings for a pizza, and I got into a situation where I wanted to remove the first instance of a topping.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.4, “How to run a shell command from the Scala REPL.”
You want to be able to run a shell command from within the Scala REPL, such as listing the files in the current directory.
Run the command using the :sh
REPL command, then print the output. The following example shows how to run the Unix ls -al
command from within the REPL, and then show the results of the command:
As a brief note today, I started to create a little Scala/JavaFX WebSocket client based on the Java-WebSocket project. I initially created it to test my Play Framework WebSocket example. I had hoped to be able to easily get to the server response request headers, but atm I don’t see a way to do that.
That being said, this is what the Scala/JavaFX WebSocket client currently looks like:
And here’s its source code: