Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Thinh Tran
Thinh Tran

Posted on

     

[ Introduction to Ruby ] The Programming Language Designed for Humanity by Japanese Snr.

So, someone on Earth has told you to learn coding?

There are a numerous doorways to get started with the code. But, you know, there's always some special choices which are preferred by lucky people. And one of those is Ruby - the programming language is designed for humanity by Japanese souls.

For anyone who is starting to learn the code, the most important aspect of the starter tools is always about friendliness. And by the word "friendliness", what really I means is "human readability". The closer the language is to our nature tongue, the easier it is for us to engage in learning to express the logical thinking in the code.

Hello, Ruby!

And the first program that people ever wrote in any programming language is "Hello, World!". Just a seamless transient from our nature speaking language to a computer's one: "Hello, Ruby!"

~/Desktop/main.rb

main = Proc.new {   puts "Hello, Ruby!"}main.call
Enter fullscreen modeExit fullscreen mode

Does that make a sense? Just like the progress to do any task in our daily life, here we've given the computer aProc(edure) - a series of the steps needed to do to cause a result that we wished.

It may end up with a change happened on the level of a Graphical User Interface application at some point on our learning progress. But, for the start time, it happens with a mere sign of a subtle message which isput on our Command Line Interface window.

Installing Ruby

Feeling eager to run your very first program written in Ruby? Here's the link where you can download the installer for Ruby Runtime Tools:Downloads Ruby Installer for Windows.

If you're a Linux user then you can search and install it from the default repository. Just a single command in the Terminal, I guess. Some thing likesudo apt install ruby should work for a Ubuntu user, orsudo dnf install ruby for a Fedora fellow.

Got it installed? Then we can just run our very first program:

CMD|Terminal.io

cd Desktopruby main.rb
Enter fullscreen modeExit fullscreen mode

Image description

Hello, fellows coders!

Noticed the point wecall our very firstprocedure? That's the place where we can make our very first program a little more flexible. What if we can just bind a name or a kind of friendly word at that place and then the result just happens according to the object of the greeting phrase?

main.rb

main = Proc.new { |name|   puts "Hello, " + name + "!"}main.call "fellow coders"
Enter fullscreen modeExit fullscreen mode

CMD|Terminal.io

clearruby main.rbHello, fellow coders!
Enter fullscreen modeExit fullscreen mode

Is that just a simple shiny tweak? We've added an input|name| and use it in the greeting phrase to inject the to-be-bound value at the place when we call theprocedure. And by the time you've got familiar with some only Command Line basics that we ever need. It's good to move on and just learn more stuff only of the language Ruby itself.

See you in the next chapter:[ Boxes of Ruby ]

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

A beggar, a learner, a prayer, a devotee of Mahayana Buddhism...
  • Location
    Hanoi
  • Education
    Hanoi
  • Work
    Freelancer
  • Joined

More fromThinh Tran

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp