100 Days of Rust : Day 4

Started with (optional) assignment at the end of “Programming Concept” chapter : Convert temperature between Celsius and Fahreinheit. 1 Since the algorithm itself is not part of the learning the language, I asked Google Bard about the formula. It was nice working on some code after a while (Aside from work, I mean) Once again, I realized that compiler is very helpful 😍 I started simple. Breaking down functionality into smaller functions.

Continue Reading »

100 Days of Rust : Day 3

Today I finished Functions and Control Flow etc. While these are not new “concepts” for me, one always learns something new when learning a new language. Two things I learnt: I liked the fact that rust does not evaluate anything other than boolean as truthy like both python and ruby loop can have labels, and can be used with break and continue to indicate where should the execution continue

100 Days of Rust : Day 2

Today I started with Data Types While most of it is intuitive, it is useful to go over the documentation. e.g. For tuple, I had expected that to access specific index, syntax would be mytuple[0]. mytuple.0 was not I had expected. I also tried to print the tuple. In the process, I learnt about pretty printing only from the compiler errors. The compiler errors are so descriptive 😍 Here is the code in case you are interested

Continue Reading »

100 Days of Rust : Day 1

Today I finished the Number guessing game During the early part of the code, my mind started thinking “How will comparing string input from the user, work with a number? 🤔” (💪 of having gone through such issues numerous times over the years) Of course, it was explained later. I was a bit disappointed that the code paniced upon entering non-number 😞 especially after the expect clause. Turns out that is expected behaviour.

Continue Reading »

100 Days of Rust : Day 0

In this new year, I have decided to learn rust All my recent experience has been in dynamic languages (90% python, 10% ruby) But I started my software development career in C, and did that for probably 10 years. So I’m not new to compiled languages.1 But things have changed a lot (for the better) in these years. Additionally, rust is getting a lot of attention from bigwigs like MS.

Continue Reading »

Ameba: Rubocop for Crystal Language

Ameba seems like quite mature linter for Crystal language. As I start my first real world code in Crystal language, the real tools are very useful. (Side note: I didn’t write any non-real-world crystal code. I’m not sure it helps. REPL sessions are not code. they don’t count) It automatically uses built-in formatter in the --fix mode. There is also awesome emacs integration as well. Check ameba.el

Crystal Language: C Like Performance, Ruby Like Syntax

I’ve been intrigued by Crystal Programming language for some time. I’ve been programming in Ruby for almost an year now (Mostly Rails, which I can’t say I like - too much magic) TBH, speed of interpreted language has not been an issue (I worked in python for quite some time before Ruby) but Crystal also comes with statically inferred types. Since it is a compiled language - bunch of errors maybe caught at compile time, rather than at run-time.

Continue Reading »

Bang Methods in Ruby (and Rails)

Today I learned about Bang methods in Ruby. Methods ending with ! are potentially dangerous, because they update the object they operate on. ➜ irb --sample-book-mode >> name = "sample_string" => "sample_string" >> name.reverse => "gnirts_elpmas" >> name => "sample_string" >> name.reverse! => "gnirts_elpmas" >> name => "gnirts_elpmas" As we can see above, reverse! modified name itself. Most times (?) we don’t want that. But sometimes we do. Knowing that !

Continue Reading »

Read The Docs Carefully

Continuing with my Ruby language learning journey, I wanted to use it for more than Hello world. So I decided to try python’s request equivalent. Since I didn’t know where to begin, I just searched for requests on RubyGems Turns out Gem by the exact name exists and with description Because Requests for Python is awesome 🤗 But it isn’t updated in close to 5 years now. I also wanted to use something native (i.

Continue Reading »

Ruby Debugger

While there are multiple ways to use Ruby debugger, for my first Ruby script (?) I found starting the script via rdbg to be the easiest. Like rdbg myscript.rb Debugger has all the basic command I have used elsewhere. n for next pp for pretty print q for quit For subsequent times, using require 'debug' followed by binding.break may be better. This README has all the details.