Last month I had the opportunity to participate in the conference called BRUG (Bialystok Ruby Users Group), which took place in SoftwareHut in Białystok.
I’m a person who started exploring IT world in the area of development in Ruby with framework RubyOnRails not long time ago but I want to share with my experience of participating in this event and provide a part of the topics that were raised.
Let’s take a beer, piece of pizza and talk about ruby!
HTTP 103 Early Hints
The first speaker was Seb Sito, who introduced the topic about HTTP 103 Early Hints.
At the beginning of presentation I didn’t expect what is hiding under this slogan, but with each word I realized that it could actually apply to me when I’m currently writing and operating app that maybe not require solution to resolve problem with delayed loading of content, but I’m sure with that I will be faced with a question “How can i prevent it?”
If we started to talk about loading time optimization, we should know that it concerns the moment when the user enter our website for the first time. Which behavior is like a traffic in London at rush hours, each element want to be on its place that fast as it possible.
How important performance is?
There are many situation in which the client gives up the services of our application.
For example, promotion on our website ends in a last minute and the link to this sale was passed over 100 times, a sad fact may turn out that 15% of users didn’t take advantage of the promotion because our website was loading too long and the simply left our store.
An equally unpleasant situation can be when a customer needs to find the fastest communication connection to settle a high-priority matter on the other side of the city and because of long loading page train was missed.
Better! Let’s think about opening a sale with a limited pool of tickets for o concert of a favorite artist, and in this case seconds are worth as a gold - these are the first simple examples in which it plays an important role time, and if we extend it we most often lose something.
Solution
There are many ways to improve performance.
We can start by dividing the download of content into sections. I mean to organize the download queue for the necessary content to function, i.e starting with HTML, going to dynamic links and assets.
The second way is to change the way our Homepage is written.
The basic languages that really work very well even on huge websites are often replaced with spells that make the user’s page look beautiful and even almost smell! But when thrown without any skill, they can make the use of our application uncomfortable by prolonged loading. In such situations, the principle of keeping the structure simple, which often turns out to be the lightest, is ignored. At this point, let me give a comparison what i heard to ReactJS - it happens that beginners start learning programming directly from this library of JavaScript, which makes them forget or even don’t know how many things can be replaced using simpler and lighter HTML
An interesting step is to consider whether our content must be loaded in full form for each user?
Maybe you can create a display of content after the action somewhere.
Simple examples:
- load dynamic links after/on hover action for a given element
-create a query only after reaching a certain page height, which is not visible without using scroll
For my part, I would like to add that it is also good to point out the Turbo tool, which is already available by default in Rails 7.0. It may well play an important role in addressing the question of heavy content
Is REGEX not enough problems?
The second raised topic at the September BRUG is “Is REGEX not enough problems?” presented by Rafał Camlet.
My experience with regular expressions is little, I usually met while validating the correctness of provided address e-mail. In those moments I noticed that this is quite complicated syntax that has to stand out from the standard syntax of written code.
Finding a way to extract records from the database after specifying the parameter value may stop us for a moment with question what tool is worth to use or will it be possible to do it with simple regular expression?
Values nested in ‘<>’ can be confusing when extracting them, the example show that REGEX can be quite simple and friendly :]
'czekolada <mleko> i inne rzeczy. :>'.match /<[^>]*>/
# <mleko>
m = 'czekolada <mleko> i inne rzeczy. :>'.match /<([^>])*>/
m[1] #mleko
Parslet
Rafał presented an interesting tool for parsing our documents, to which we can easily add regular expression to bring about specified values.
In the example below Rafał defined a methods in a class Parser inherited from Parslet to find out text with downcase letters a-z in specified tags < >
require 'parslet'
class Parser < Parslet::Parser
rule(:txt) { match('[a-z]').repeat }
rule(:tag) { str('<') >> txt.as(:result) >> str('>') }
rule(:pattern) { txt >> tag >> any.repeat }
root :pattern
end
result = Parser.new.parse("czekolada <mleko> i inne rzeczy.")
result[:result].to_s # mleko
The written code can run for a long time causing complications during application development, which can actually be replaced with shorted, more readable code that will be a simple to modify validator using REGEX
RubyMine shortcuts that make your job easier
The last raised topic was “RubyMine shortcuts that make your work easier” by Mateusz Białowąs.
RubyMine is a code editor that was created based on the use of the Ruby language and its RubyOnRails framework. I noticed that a very wide group of developers has experience in working with this tool and they recommend it very highly, supporting their arguments that lead to the improvement of work efficiency through convenience and time saving.
Mateusz also shared with us about steps of the first setup to make your work environment - the code editor - more open to you as a developer.
Competiton!
At the end of the September edition of BRUG was organized a competition! Participants who expressed their opinion about BRUG and presented topics had opportunity to join in draw for a product license from JetBrains… RubyMine!
With three spinning of the wheel ;]
I would like to say Thank You to the sponsors of the event, by them it is possible to gain so much valuable knowledge!
Sponsors:
Code&Pepper https://codeandpepper.com/
2n IT https://www.2n.pl/
KRUKO https://www.kruko.io/
SoftwareHut https://softwarehut.com/
Miłośnicy Ruby https://milosnicyruby.pl/