Caleb Josue Ruiz Torres.

Software Developer.

Ongoing stuff.

Shining in the light.

I know you know, Scala 3.3.0 LTS is ready to be downloaded and installed.

Did you know you can use such an expressive programming language to complete some training at Udacity? e.g. Design of Computer Programs taught by Mr. Peter Norvig himself!

That's right, take a look to the following screenshot I took two months ago.

Scala to Python translation depiction

Indeed, Udacity has enabled an assistant using LLM technology to help you in your learning journey. So even when the autograder accepts Python code, you can use Scala to design your solution and then have the AI assistant translate your code into Python so you can submit it for evaluation.

My request does even contain an incorrect English sentence, did you spot it?

Heads up! In production you'll likely want to use the safer version headOption instead of head.

Shining in the light is the first track in the album Walking into Clarksdale album by Page & Plant. Enjoy it!


Most likely you are aware of some websites like leetcode, to tackle some computer science problems. A famous data structure you'll find there is the Linked List. For simplicity it is presented as follows, using the Java programming language:

class ListNode {
    int val;
    ListNode next;
    ListNode() {}
    ListNode(int val) { this.val = val; }

From an API designer point of view, you'll want to enhance such definition by adding features so the users of your library have more expressive power at their fingertips. The first thing that one should want to provide is the ability to use the enhanced for statement given a Linked List. You achieve this by implementing the Iterable interface.

Can I provide my library users a way to transform a Linked List they have created by mapping a function to every element in the list? e.g. root.fmap(x -> x * 7); with root being the Linked List's head. While we can spend some time digging into Category Theory to grasp a formal definition for what a Functor is, instead we shall have a look at Haskell's Functor type class which basically says you have to provide an implementation for the following function fmap :: (a -> b) -> (f a -> f b) in order for your data definition to be considered a Functor.

In the previous post the idea that a Haskell class is like a Java interface was presented. For the purposes of our discussion, it turns out we need to come up with an interface for Functor defining a fmap function.

interface Functor {
    void fmap(IntUnaryOperator op);

Now, our Linked List can implement the aforementioned interface, so we can transform the elements within the list using the famous lambda expressions like the one presented above. If you are in a hurry, I am sharing with you a self-contained example. See you next time.

Edit: May 15, 2023. Somehow I felt the need to add this unrequested and more likely unnecesary clarification, and the thing is that by no means we are trying to exercise the Functional Programming paradigm in this example but only trying to borrow the Functor idea and land it to Java.

Happy Hacking!

Sorry, I couldn't resist the temptation to write about this topic, so here's my attempt to talk about Monads!

Let's consider what Mr. Simon Peyton Jones is saying in the following video, in that section the same explanation comes in two places:

  • Haskell class is like a Java interface
  • [Haskell class] It's more like an Object Oriented Interface

If you happen to know the Java programming language, you'd certainly remember the Comparable interface, which requires you to implement the compareTo method.

Now, while you can have a look at the source code for the Monad class. Let us rather focus in a some sort of simplified version presented in the book I am reading these days.

class Monad m where
  return :: a -> m a
  (>>=)  :: m a -> (a -> m b) -> m b

And just like that, if you want a data type to be a Monadic one, you'll just have to provide implementations for the two functions in the aforementioned code. And just like the Comparable API designers mention in the documentation that compareTo implementors must ensure total order property is present in the code, in that same way, Monads requires you to be sure some laws are present in your implementation.

What are these laws? And how can we go about implementing the functions in the Monad class? We are lucky, we are standing on the ground of more than thirty years of research produced by hard working computer scientists in this area. A good starting point however, is the Advanced Functional Programming training course taught by Professor Graham Hutton.

Let me finish this post, just like Mr. Erik Meijer ends his tutoring in his videos for the FP101x (Heavily recommended): Happy Hacking!

The end of programming?

This weekend I was watching "advent of Scala", a video posted by George Hotz, aka geohot; And if you are a Software developer, you certainly know we all consult books, forums, perform queries over search engines, to deliver the feature we are working on at any given point of time. Even consumated computer scientists like Erik Meijer accept that fact.

Now, if you pause the aforementioned video at [04:38] timestampt, you can actually see the suggestions ChatGPT offers to geohot after his query about how do one read a file in Scala. One of them being:


// Read the lines of a file
// as a list of strings

val lines: List[String] =

Which is cool, if you think about it. It turns out the suggested way of doing this, presented in the Effective Programming in Scala training, is actually as follows.

import scala.util.Try
import scala.util.Using

def readDateStrings(fileName: String): Try[Seq[String]] =
  Using(Source.fromFile(fileName)) {source =>

"Using ensures that the resources we use are eventually released, whether our program fails or succeeds" as the fellows at the Scala Center share with us. The second suggestion offered by the AI is StdIn.readFile, I shall mention I was unable to find any information related to that function in the latest Scala 3 API documentation, perhaps is unexisting. Yes, AI assistants will evolve and get better with time. These days, however, we are still in charge of writing beautiful code, so these machine learning models can be trained on those examples and perform better. And we can only do that by continuing investing time educating ourselves.

So, no, in my opinion it is not the end of programming, a conclusion I haven't realized based solely on the above discussion. But it is now clear to me that people building products using only classical computer science models and techniques will be at disadvantage while competing with the computer itself, in the sense that the machines are in fact in charge of deriving the "business rules" based on the data we feed in.

Please don't dismay on all those "prophecies of doom". I really invite you to learn how to program in the classical sense, because it is fun, and it's a very rewarding intellectual endeavor, and there are other benefits that come along with it, just as learning some high school Mathematics (Even if you feel like you were left behind), and you've heard it first from Leslie Lamport, it's all about thinking. Our future societies will be grateful if we exercise our thinking today.

On having healthy lifestyle.

While reviewing some paperwork related to my job history in the past days, I found out I was 236 pounds (107 KG) back in June 2015. These days I am 280 pounds (127 KG). I've been gaining a lot of weight, specially in the last three years.

Today I am sharing with you this new goal. I am proposing myself to start losing some of that weight by means of taking walks and a healthy diet. What do you think? Am I up for the challenge?

Stay tunned for the results.

About this section.

Indeed, this section is planned to share with you the things I am currently focused. It will blossom in an entire blog but for now I am just presenting the layout of some goals I am actively working for the time being.

  • Obtaining the Oracle Certified Professional (OCP) targetted for Java Developers in the upcoming months.
  • Start a series of programming blog entries intended for people new to the field, it will be in Spanish.
  • Right now I am in the middle of the book "Programming in Haskell" by Graham Hutton. Since I am only read this material on Sundays I suppose this is becoming more like a year goal instead.
  • Of course I am not forgetting about continuing my journey with Blender 3D.