Lambdas in Spark: now you're talking!

Published: 2015-05-11
In a previous article, I tried to figure out what the hell lambdas could be good for in Java. Short version: nice, but not compelling (mostly because of my silly example).

But lo and behold, ye of little faith. The Good (?) Lord of Functional Programming has inspired another much better example in me.

Take a look at this simple Spark program. Nothing fancy, just building key/value pairs from a text file :

In the pre-lambda world, you would build key/value pairs like this:
  "WTF?!" I hear you say and yes, I'd have to agree. This is pretty hard to read and definitely not Java at its finest.

Here's the lamba version:

Do you see the light now? Oh c'mon, just a little bit? ;)

Till next time, keep codin'.

About the Author

Julien Simon is the Chief Evangelist at Arcee AI , specializing in Small Language Models and enterprise AI solutions. Recognized as the #1 AI Evangelist globally by AI Magazine in 2021, he brings over 30 years of technology leadership experience to his role.

With 650+ speaking engagements worldwide and 350+ technical blog posts, Julien is a leading voice in practical AI implementation, cost-effective AI solutions, and the democratization of artificial intelligence. His expertise spans open-source AI, Small Language Models, enterprise AI strategy, and edge computing optimization.

Previously serving as Principal Evangelist at Amazon Web Services and Chief Evangelist at Hugging Face, Julien has helped thousands of organizations implement AI solutions that deliver real business value. He is the author of "Learn Amazon SageMaker," the first book ever published on AWS's flagship machine learning service.

Julien's mission is to make AI accessible, understandable, and controllable for enterprises through transparent, open-weights models that organizations can deploy, customize, and trust.