Talks

Lightning Talks - Day 3

wroc_love.rb 2015

00:00:14.080 Hi, I am Pavel Nemczuk and I want to show you some game light operations. It's not a solution to anything, but it is a tool that you could use to separate some logic. Why should you use it? You can have business logic in small operations that are light and simple. You can use it in pure Ruby, and from version 1.9 onwards, you can set up different actions on success or failure. You can also set up dependencies on this operation. That's simply all. But how does it work? You could have an operation like 'get news', and you could catch some errors. In the execution, you would have your business logic. When you create the operation, you define the dependencies, what happens on success or failure, and simply run this operation. That's it.
00:01:14.400 It's a different approach compared to simply wanting a successful or failure response. You can also utilize it with ActiveRecord or ActiveModel, and it works pretty well. You can build several operations and run them concurrently. The fun part is that you can chain operations, change reactions, and use recursion. It works quite well, and I'll show you how it works.
00:03:16.159 Okay, it’s a simple operation, and we want to ensure success. So, when anyone likes this game, it results in a failure. However, if we have some followers, it returns true; so, it's cool! We have an ActiveModel approach where you could have a person and run validations. It appears like this: if we do not provide any parameters, the validation fails.
00:04:51.680 Interestingly, when you have a chain reaction with recursion, it works nicely. For instance, when we have several servers providing the data, we might want to check them. Thank you.
00:05:47.520 So here’s the second part of the Crystal presentation. Here’s some code written in pure Ruby, as you can see. We can execute it with Ruby, but oh my, we can also run it with Crystal! This segment is about method overloading. We have the same method that accepts different arguments, so if we call this method with a string, number, or a block, a specific version of the method will be executed.
00:06:00.479 Next, I want to discuss attributes that I mentioned last time but didn't finish. The syntax is similar to CoffeeScript, where we can assign the value to an attribute in the constructor parameter. We no longer need to write lengthy code like we do in Ruby; we can set it all up succinctly. Regarding 'nil', if we do this in Ruby, we get a runtime exception for an undefined method for nil class. However, in Crystal, we catch similar errors at compile-time.
00:08:19.680 Now we can define the type of attribute that a variable, like an array or hash, will store. At the top, we define an array of strings. If we execute it, everything goes fine. But if we try to insert a number into this array, we get an error. Similarly, with hashes, if you define a hash mapping strings to booleans, everything works until you try to map a string to another string, resulting in an error.
00:09:02.640 We all know that in Ruby, we can map over elements, executing methods on each element. You can use concise notation like symbol-to-proc. If we execute it in Ruby, it works similarly in Crystal, though the syntax is a bit different. We use dot notation instead of symbols, allowing explicit execution of methods on particular elements. Now, let’s explore inheritance. When we run code to establish abstract inheritance, we may encounter errors if the abstract class isn't correctly defined. Using the abstract class resolves this issue.
00:10:55.680 I don't know how about you, but before the conference, I was mostly waiting for Lucas's talk about Lotus. Unfortunately, he didn't come, so I will try to replace him in five minutes. I've had my eye on Lotus since June 2014 when Luca wrote the first blog post. The team is doing a commendable job and advancing rapidly. You can follow Lotus on their GitHub channel or track their roadmap on Trello, which is quite impressive.
00:12:11.680 So, what is Lotus in brief? It’s a full stack framework aiming to be as modular as possible, allowing you to replace any part or remove it entirely if it's unnecessary. Let me show you some code. There's a simple Ruby object for the Lotus entity, providing basic attributes and initializer functionalities.
00:13:15.440 Lotus also implements the repository pattern. Here, we've got a mapper for the 'todos' table in the database, mapping attributes to the entity. This repository offers some basic operations, and you can define your controllers in Lotus, which focus on single actions, resembling use cases in existing Rails applications. Attributes exist under an 'expose' meaning only defined variables will be accessible. The routing system is similar to that in Rails. Lotus also employs strong parameters but, unfortunately, nested attributes are not yet supported.
00:15:50.880 Thank you very much! Now, I wanted to talk about something important. We often think of ourselves as our exceptions, so you shouldn't use exceptions for flow control as they are inherently slow. A few months ago, I checked this idea, but before deciding anything about performance, one should consider context. For instance, a single SQL query returning an integer is a good starting point.
00:16:56.560 Exceptions are indeed slower if they occur, but there’s no significant performance concern if an exception isn’t thrown. However, this becomes negligible if your code involves several SQL queries, which is typical for actual applications. In those cases, feel free to use exceptions and measure performance accordingly.
00:17:07.839 Now, testing your systems can be challenging. The easy way looks like typical web interactions involving browsers, front and back ends where tests are written and everything usually passes or fails cleanly. But things change if your application runs physically across different machines or infrastructures. For example, if you are a developer managing browsers across different systems, distributed testing becomes much more complex.
00:20:14.960 You want everything to be green during test execution. When a PR request is submitted, background processes manage the building and testing of your application to notify when it’s ready for merge. Working with physical systems, rollbacks may take a considerable amount of time, making it impractical. So, if you run applications on complex infrastructure, automation can break. Managing dependencies in continuous integration poses additional challenges.
00:21:51.840 The testing scenario from start to end could be quite tedious, often neglected in typical workflows. Most developers tend to run unit tests before anything else, where check passes instantly, but spinning up the entire infrastructure for testing takes much longer and could add significant delays.
00:23:59.040 Many languages and communities encourage developers to engage positively with open-source initiatives. I ask you to consider the community aspect of the tools and languages you choose for your projects. It's important to foster joy and collaboration in our work at every level, not just in our personal endeavors.
00:25:08.159 For instance, consider coding communities like those at Ruby conferences—welcoming and encouraging developers from various paths to share their knowledge and experiences. This sense of community contrasts with languages tied to corporate entities that may create a more insular or competitive atmosphere.
00:26:52.179 Now, in discussing future trends, the shift towards single-page applications must be highlighted since many developers are embracing this architecture. However, it comes with its complexities—two separate applications (one for the backend and one for the frontend) handling layers that may often feel cumbersome and repetitive. Features are typically developed across multiple layers, making the task tedious.
00:28:57.280 Proponents like Facebook and Netflix are pioneering efforts to streamline these processes with libraries like Relay and Falcor. Such technologies abstract away many operational layers, making it simpler to manage data flow in client applications, while GraphQL provides a unified query language, simplifying API interactions significantly.
00:31:38.320 Now, let's delve into Capture The Flag events—an engaging way for developers to test security skills through hands-on experiences with practical challenges. They allow legal hacking, where participants find hidden flags in purposely designed vulnerabilities while learning to appreciate different file formats and security threats at the same time.
00:32:53.000 These events enrich knowledge on various topics such as file manipulations, underlying principles that make activities like bypassing filters all possible. For those interested, platforms offer many challenges with diverse focus areas and varying complexities making it accessible to newcomers and seasoned developers.
00:34:18.000 Finally, let’s discuss Color Dodger, a non-profit initiative based in Ireland aimed at engaging children and adults alike in solving IT-related problems. The essence of the initiative lies in shared knowledge acquired through hands-on challenges, fostering creativity among attendees without the constraints often present in traditional learning environments.
00:35:39.360 The inspiring nature of these sessions showcases the eagerness of participants as they tackle varying complexities of problems. Observing young children grasp advanced concepts in programming or project management firsthand demonstrates the great potential of nurturing creativity without time constraints and the biases of conventional frameworks. So let's embrace learning from each other, ensuring that we approach technology with a sense of wonder and community.
00:40:03.960 And now, for the exciting part where we have prepared a list of candidates for prizes during this conference. We will run a unique check on our list of candidates to ensure fairness in our prize draw. If any individual has spoken multiple times, we will adjust accordingly. Each prizewinner will be selected randomly. Congratulations to everyone involved, and thank you for participating!