Posts

Ruby 3 Type profiling: Dynamic data type at run time in ruby

Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the ruby's some special concepts and I am sure you will get excited to make your hands dirty with those code, so why to wait let's get started... Ruby 3 introduces type profiling, a new tool that lets us examine how programmes behave at runtime and determine the types of objects there. By helping the Ruby interpreter to produce more effective code, this can help performance. Type profiling is an optional feature that can be turned on or off at runtime. This blog post will go through the new type profiling functionality in Ruby 3 and give a practical use for it. To enable type profiling, we need to pass the -v command-line option to the Ruby interpreter. Here's an example: In command A, we enable type profiling and the just-in-time (JIT) compiler, which can improve performance by compiling Ruby code into machine code at...

Rails 3 Ractor : a parallel execution feature of Ruby without thread-safety concerns

Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the ruby's some special concepts and I am sure you will get excited to make your hands dirty with those code, so why to wait let's get started... Ruby 3 introduces Ractors, commonly referred to as Ruby Actors, as a new concurrency feature. They enable us to execute several threads of code concurrently without having to share memory or state. As a result, concurrent and parallel programming is made simpler, which can enhance performance and scalability. It's necessary to grasp the fundamentals of concurrency and parallelism in programming before we delve into the specifics of Ractors. Concurrency is the capacity of a programme to manage many activities or execution threads concurrently. The term "parallelism" describes a program's capacity to run numerous processes or threads concurrently while utilising multiple processor...

Ruby 3 : New features

Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the ruby's some special concepts and I am sure you will get excited to make your hands dirty with those code, so why to wait let's get started... The most recent significant version of the Ruby programming language is Ruby 3. It has a number of interesting new features and advancements and was published on December 25, 2020. We will examine some of Ruby 3's updated features in this blog. -> Ractors Ruby 3 introduces Ractors, also referred to as Ruby Actors. They enable us to execute several threads of code concurrently without having to share memory or state. As a result, concurrent and parallel programming is made simpler, which can enhance performance and scalability. Ractors are simple to use and integrate with existing code because they are designed on top of the Thread API that already exists. -> Type Profiling Type ...

Ruby advance hash learning

Image
   Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the advance ruby's hash concept and I am sure you will get excited to make your hands dirty with those code, so why to wait let's get started... https://www.freepik.com/photos/pattern If you already read my previous post on  Ruby hash and its methods  then you can easily find out the key difference between this post and that post after completing the reading of this one. But if you didn't read or if you are not sure how ruby's hash works, then you can go to read the basics and then can easily understand this complex hash post. Till the time we may have seen the hash as in key, value pair and mostly key is in String or Symbol type. But it's not limited to this only, In ruby the key of the Hash can be a Data type, Array, A complex (nested) array or even the ruby's Kernel. Yes, you read correctly, But ...

Rails Helper complete guide

Image
 Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the Rails Helper method and its usage in the rails view and also its access in the terminal or controller. Even though we can access rails helper methods in the controller, but it is highly recommended not to use it, since it violets the rails architecture guideline. We will look how we can use existing rails helper methods, create custom rails helper and how to use it and also will look how to make use of rails helper defined outside the scope of ApplicationHelper. We will also explore some of the helpers provided by the Rails. Love photo created by rawpixel.com - www.freepik.com If you are not aware of what is rails helper, Well in the ROR, in the view we may write some conditions or operations but it will make the view more complex and hence make the view dirty, and not only that sometimes we may have to write same...

Ruby Self and its role

Image
 Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the ruby's self keyword and its usage. You may have come up with self while working on the existing code base, but not got the significance of it, then read this post to understand it in a simpler manner. Even if you are not a ruby developer then also this article will be helpful since self is used in almost many programming languages. Wait ruby's self is like above image only, it is representing the current object in the current context. Confused? 🤪, wait let me tell you with the example, Now lets decode above code to understand what is the self is, Firstly, we have a class Student with a constructor to initialise the instance variable score , and a method named : show_info  , Then we have created a instance of Student class, and stored the object into variable s1, Now lets decode specifically the :show_inf...

Ruby Hash and its methods

 Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the ruby's Hash and its methods available to simplify our development and make the code more smarter 😅 Ok then without wasting a time we start looking into Ruby's Hash. If you are new to the development then you can read below or if you are aware of what is hash then you can skip to next paragraph. Hash: Similar to array the Hash is a collection of objects but in the diffrent fashion. The hash store the items in the form of a key and its value. In short see below image, how lock can be access by the key assigned to it, similar to this only hash works. Enough theory let jump into it with some example, One important think to remember is Hash will always take unique key, It means one key cannot be considered again in the hash. Now i think you understood how hash works, now lets jump into some of the hash methods and how...

ROR Important tools & Gems to simplify the development

Image
Hi, This is  Shubham Mishra  a ROR, iOS, Python developer,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the Awesome tools to simplify your RoR application development process. Coders are also attempting to make into one the latest cutting edge technology and resources in their net development undertakings. Ruby on rails has always been one of the most common answers, though many of more than common quality ideas took the net development industry by weather with rain and thunder. Ruby on rails is a powerful, shaking, open-details programming language which takes care of to come with a rough writing language that helps reading and writing, producing the net telephone operations through a quick and good-price development stage. simple-making and doing work well are its principal chief places. Holding the code clean and structured when creating a wide Rails framework can be a grueling job for even the most exper...

Ruby's Gsub method usage

Hi, This is  Shubham Mishra  a ROR, iOS, Python developer,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the Awesome ways to use ruby's Gsub method. Now, lets first understand the term 'gsub' -> 'sub': Substitute,  'g': global Sounds a little odd, no problem lets go practically for better understanding. Lets say we have a string,  str = "Awesome season" What we want is to replace a word with another in ruby, say in our case it is replacing season with movie, now what we will do is, This is saying : Replace all the occurrences of the first word 'season' with the 'movie' Well other than just replacement task your gsub method can do a lot more stuffs, let's have a watch. Replace pattern with regular expression : So now lets learn to replace not only a single word but a sentences matching a regular expression, such as matching a phone number, email address etc The first option is ...

Currying: A Ruby approach

Image
Hi, This is  Shubham Mishra  from India,  this is the part of  Ruby on Rails  exploration journey.  In this post we will discuss about the ruby's one of the underworld approach: Currying (not 🥘 this one 😅). I thing it would be better to understand it first by diagrammatically. Let understand curry in ruby in a snap. Lets suppose we want to sum up 3 numbers [1,2,3], Normal Ruby approach : Normal Sum in RUBY Curried Sum: Curry in Ruby Simple, isn't it!,😉😉, Ok if you are not in a hurry then you should now go through the Code level reading to understand it even better. Practice it :  Curry in Ruby, Play here See the OutPut: #<Method: main.sum> Normal Sum: 6 Curried Sum 👇: #<Proc:0x000055c305dbb0f0 (lambda)> #<Proc:0x000055c305dbace0 (lambda)> 6 Now, understand each part: The sum() method is the normal ruby code, where (*) is splat operator, which takes more than one arguments. Then we have method(:sum)...