Creative Coding
Ruby as Science, Art & Craft
Summarized using AI

Ruby as Science, Art & Craft

by Davy Stevenson

In her talk titled "Ruby as Science, Art & Craft," presented at the Ruby on Ales 2014 conference, Davy Stevenson explores the multifaceted nature of programming, arguing that it lies at the intersection of science, art, and craft. With a background in GIS software development at Esri, she encourages attendees to reflect on how these aspects of programming can enhance their skills and insights, regardless of their formal training in computer science. The key points discussed in her presentation include:

  • Diversity in Programming Backgrounds: Stevenson notes that many developers are self-taught or come from related fields, highlighting the strength of this diversity compared to more traditional engineering disciplines.
  • Computer Science Fundamentals: Emphasizing the varied structure of computer science departments, she shares that students may graduate without practical coding experience, focusing instead on theoretical aspects such as algorithm study and Big O notation.
  • Algorithm Analysis: Stevenson breaks down different complexity classes of algorithms, illustrating their performance using examples like the convex hull problem, which plays a crucial role in various fields including computer graphics and GIS.
  • Programming as Art: She posits that Ruby’s expressiveness allows code to be viewed as an artistic medium. Just as artists use a palette to create, programmers can develop their unique styles within Ruby, which reflects their individual expression.
  • Collaboration in Coding: Highlighting coding as a social activity, Stevenson points out that effective collaboration and shared coding styles foster innovation and creativity, contrasting the individuality required in personal coding styles.
  • The Journey of Mastery: Stevenson compares learning programming to mastering a craft, suggesting that continuous learning and adaptation are crucial. She uses her experience in knitting to metaphorically illustrate how mastery evolves through practice and exposure to new techniques.
  • Beauty in Code: The concept of 'beautiful code' is examined, suggesting it goes beyond aesthetic appeal to involve clarity and constructive design that facilitates usability for other programmers.
  • Embracing Diversity: Stevenson emphasizes the importance of diverse problem-solving approaches within programming communities, advocating for inclusion and empathy that can strengthen the programming ecosystem.

In conclusion, the talk reaffirms that programming is a blend of scientific rigor, artistic expression, and crafted skill. Stevenson encourages developers to explore different perspectives and cultivate a collaborative spirit that elevates the programming community as a whole, ultimately leading to improved outcomes and innovative solutions.

00:00:13.219 Thank you. Davy Stevenson has a Twitter account for both of her cats. Their names are Kamatikun and Topistany Whiston. I find this very impressive; I only have one Twitter account for my cat. Davy's going to be talking to us about Ruby as science, art, and craft, which is perfect because every time I'm programming, I feel like I'm gluing macaroni on a piece of paper. I hope I'll be able to learn something from this.
00:00:22.140 Everyone, please welcome Davy.
00:00:59.239 My name is Davy Stevenson, and my Twitter handle is up there. The goal of this talk is for everyone to walk away with something new to think about, whether or not they consider themselves a computer scientist, whether they think of programming as an artistic medium, or whether they see programming as their craft.
00:01:06.659 I work at Esri in the Portland R&D Center. Esri is the premier producer of GIS software, and they were kind enough to sponsor this conference because I love Ruby on Ales so much. Thank you very much to Esri for allowing me to be here. I also want to acknowledge the rest of our Ruby team, Ken and Jen, who are back there. I work on the GeoTrigger service, a product that Esri makes to help mobile developers add geofencing easily and accurately into their apps. However, I won’t be discussing that today, so if you want to learn more, feel free to ask me later.
00:01:58.020 For those of us who have a degree indicating that we have formally studied the discipline of our careers, that degree most likely says computer science. This is one of the newer scientific fields. The structure of the computer science department can vary drastically between different colleges and universities. Computer science originated from mathematics, yet the mathematics involved lacks the physical properties that govern the functions of computers.
00:02:18.299 Computer science departments encourage study in other fields, such as physics or electrical engineering. Some programs continue the tradition of having lab classes, while others can be predominantly theoretical. As a result, it is entirely possible for students to graduate with a computer science degree without actually having written any code.
00:02:51.299 So, if students aren't actually learning code in computer science classes, what exactly are they learning? One of the fundamental classes for any computer science major is the study of algorithms. Studying algorithms abstractly means separating implementation details from the underlying properties of the problems we aim to solve.
00:03:03.240 Algorithms are analyzed by their overall complexity, known as Big O notation, which helps us determine how well an algorithm scales. An algorithm is often fast on a small set of 10 elements, but what happens if you have a set of a thousand or ten million? Here's a graph showing how the runtime of an algorithm increases with the number of elements for various major Big O complexity designations. When analyzing an algorithm with Big O notation, we only care about the highest order factor, ignoring any constants or lower order terms.
00:03:57.959 For example, O(log n) algorithms grow very slowly. You can hardly see that the bottom blue line is even increasing at all, which generally indicates that the algorithm is running on a sorted data set. This is significant, which is why caching and pre-sorting are so important. O(n) algorithms require an analysis of every single element in the set, and the vast majority of the best search algorithms operate at this complexity. This is crucial for developing efficient login algorithms needed for data analysis.
00:05:03.000 Next, we have O(n^2) algorithms, known as quadratic, which represents polynomial complexity. The growth of these algorithms starts to become significant with increasing elements. O(2^n) algorithms are exponential and require a small data set or processing via background tasks. An example of this is the classic traveling salesman problem, which is an exponential algorithm.
00:06:08.400 Now we get to the real challenges, O(n!) factorial algorithms. Implementing any algorithm that is factorial in nature can lead to significant problems very quickly as your data set scales. If you're curious to know more, there are resources available, like the Big O cheat sheet website, which covers various space and time complexities for many common algorithms.
00:06:31.620 Another entertaining resource is Algorithmics, a dance troupe that creatively portrays common sorting algorithms through various dances, including the Hungarian Dance. Highly entertaining and worth watching!
00:06:51.900 So, what is an algorithm exactly? It is a set of instructions designed to solve a particular problem. A problem might have many algorithms that describe correct solutions and many more that provide adequate solutions. As an example, let's discuss the convex hull, which describes the envelope of a given set of points. The easiest heuristic for visualizing this is to think of wrapping a string around the set of points.
00:07:13.900 This is a simplified example, but it illustrates that the points the string touches define the convex hull. It's essential to mathematically prove that all vertices creating the polygon that defines the convex hull consist entirely of points from the set. Convex hull calculations are useful in several fields, including computer graphics for advanced bounding box calculations, pattern recognition, image processing, and GIS.
00:07:40.560 Calculating the convex hull allows for other important tasks, such as finding the centroid or center of gravity or performing intersections with other polygons. The brute force algorithm used to solve the convex hull problem involves iterating through every possible pair of points. This can be quite complex even for small data sets, and it highlights a simple fact: all points on one side of a line define the convex hull. A line that is not part of the convex hull will have points on both sides, which helps when determining convexity.
00:09:03.900 The O(n^2) designation comes from the necessity to go through each pair of points and determining whether other points are all on one side of the line, making it a nested loop structure. However, we can improve this process significantly. A simpler and more efficient algorithm called the Gift Wrapping algorithm, or Jarvis March, begins by finding a point on the convex hull. By iterating through all points and calculating their polar angles, we can repeat the process around the points until the hull is complete.
00:10:00.000 The O(n * h) complexity arises from calculating polar angles and subsequently processing each point on the hull. In the worst-case scenario, if every point is part of the hull, this would turn into an O(n^2) algorithm, showing a substantial improvement over the brute force approach. In cases where the number of points on the hull is expected to be large, we can apply more complex algorithms like Graham's scan, which operates in O(n log n).
00:10:49.620 Numerous other algorithms have emerged over the last 30 years that provide various solutions to the convex hull problem with O(n log h) efficiency. The most suitable algorithm for any given task will depend on the characteristics of the data set and the associated costs of implementation and maintenance.
00:11:21.480 In programming, we strive for efficiency and adaptability, constantly seeking to enhance existing algorithms and apply them to new problems. Whether or not you view yourself as a scientist, the code you write can contribute significantly to expanding our collective understanding.
00:11:46.620 Ruby has gained admiration within its community for its beauty and expressiveness. This sentiment reflects our artistic nature—we view code as our medium. The flexibility and power of Ruby allow us to appreciate the beauty of code as we do with paintings. The structure, skill, and artistry involved create an impressive harmony as we step back and see all the parts working together.
00:12:13.440 If Ruby is our artistic medium, then our syntax choices represent our palette. Our programming style becomes our distinct trait, and within the Ruby community, we have various styles, from minimalism to more decorated code with extensive quantifiers to clarify intentions.
00:12:33.960 While Ruby is an object-oriented language, it allows for functional approaches as well. Our styles can reflect our individuality, much like how art exists in various forms. Neuroscientists have found that the same pathways in our brains light up when we appreciate beautiful paintings or moving music, reflecting the beauty found in mathematicians’ equations.
00:13:07.380 Consider Euler's identity, often regarded as the most beautiful mathematical equation. It encapsulates the fundamental mathematical principles while connecting various essential numbers. I suspect that if neuroscientists observed computer scientists viewing elegant code, they'd observe similar pathways lighting up.
00:13:32.940 Unlike many artistic endeavors, coding is inherently a social activity. We collaborate with teams, and our software largely relies on libraries and frameworks created by a broad community. As artists, we must understand how our style impacts our collaboration, recognizing that a unified coding style facilitates cohesion, just as a singular style weighs down artistic creations.
00:14:06.900 While a single style may promote uniformity, it would render our creative processes monotonous. Embracing diverse problem-solving approaches, developing various algorithms, and encouraging creativity allow us to flourish. We should wholly embrace differences that contribute to our uniqueness and inspire experimentation within our community.
00:14:55.800 We shouldn’t fall into the trap of equating complexity with a lack of simplicity. Complex problems often demand intricate solutions, yet we should break them into simpler parts whenever possible. In both art and code, simplicity is vital; we celebrate the DRY principle (Don't Repeat Yourself) and the Single Responsibility Principle, organizing code into libraries and frameworks to promote straightforwardness.
00:16:00.900 Becoming a master craftsman takes years of practice and skill. The concept of apprenticeship allows progression through various levels of mastery. We are craftspeople or artisans, and understanding the multifaceted nature of programming can open our minds to the diverse skills essential for coding.
00:16:41.820 As a knitter, I've developed a range of knitting skills over the years, enjoying the mastery of various techniques. However, every time I learn a new technique, it's like starting fresh. My experience aids my understanding, but many skills don’t seamlessly apply to new methods. This journey of continual learning and growth reflects the essence of both knitting and programming.
00:17:04.920 Coding can appear deceptively simple at first glance, similar to knitting. Yet, as you delve deeper, you realize the complexities, just as variances in casting on methods surface when starting to knit. Exploring changes and adaptations leads to creating wonderful things, whether in knitting or programming.
00:18:14.200 When mastering various algorithms, we transition from simply following patterns to becoming creators. At some point, you may feel confined by conventions and desire to explore how the pieces work beyond just following a set pattern. Each new algorithm leads us to question methods and enhance our creations.
00:19:12.360 Sometimes, knitting may not solve a certain problem, just as programming tools may not always fit. As a knitter, I may not prefer crochet, but when it serves as the right solution, I embrace it. When it comes to crafting complex items like sweaters, knowing when to use other techniques can significantly enhance the outcome.
00:20:17.160 Crafts can be professional or a hobby. Programmers often blend work with personal interests, creating engaging projects that foster joy. This intersection between professional and personal creation enriches the programming community, where the act of creation is meant to improve lives.
00:20:50.740 I conducted an experiment requesting the internet for examples of beautiful code without defining what ‘beautiful’ meant. The purpose was to encourage diverse interpretations. I received a mix of serious and whimsical responses, demonstrating that beauty can manifest in myriad ways. Some examples encompassed widely recognized projects, while others highlighted individual coding styles.
00:21:30.240 Beautiful code is not only about aesthetics; it's about constructive APIs that simplify complex technologies. Cleanly structured code improves usability, ultimately benefiting other programmers as they navigate through more complex processes. Collaborative and well-organized coding leads to beautiful environments where all contributors can shine.
00:22:28.500 The beauty of coding lies in the intricate balance of teamwork and technical prowess. In programming, beauty prevails when we can build off each other’s collective knowledge. Programs that thrive are the result of both shared vision and diligent effort among their creators, celebrating the beauty of collaboration.
00:23:08.520 As programming represents progression in the scientific realm, we continuously strive to expand our collective understanding. We must embrace divergent thinking in problem-solving, exploring multiple avenues and collating the best solutions to foster growth in the scientific field.
00:23:48.180 If programming is considered art, there are numerous correct ways to approach it. Embracing this diversity enriches our community and fosters a welcoming environment for development. As a craft, the tools we opt for can shape outcomes, emphasizing the importance of choosing the right method for the task at hand.
00:24:39.000 As we engage in code writing, our focus should extend beyond the technical to the interpersonal. Enhancing our community demands an empathetic approach. Encouraging new entrants and sustaining their development strengthens our ecosystem.
00:25:17.000 There’s immense satisfaction in mentoring someone who later contributes a precious solution that you needed, creating an invaluable connection within the programming landscape. Technology isn't a zero-sum game, encouraging collaboration to chart a progressive future.
00:25:51.840 Thank you very much for your time and attention today. I also extend my gratitude to the organizers for putting on such a fantastic conference and to my colleagues for providing the wonderful visuals in this presentation.
00:26:12.240 Lastly, thank you to Esri Portland for their ongoing support. It's been a pleasure sharing insights and experiences with each of you today.
Explore all talks recorded at Ruby on Ales 2014
+3