If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby (learning and language comparisons)
Re: Ruby (learning and language comparisons)
tektoog wrote:What is it going to be to migrate to FS4?
I haven't used it a huge amount yet - I've only been an alpha-tester for a little while. But my impression so far is that back-compatibility is extremely good considering what a huge job it is to add 64-bit. And primitives haven't been neglected, either - for example, the range of stream primitives for using double-precision is way more comprehensive than it used to be, and there are some very useful debugging tools.
Of course, the chief developer is now MyCo - and I think this has made, and will continue to make, a huge difference. FS now has a main developer who was a long-time forum regular, is hugely into audio DSP, and who has actively sought out an alpha-testing team that's a broad selection of the userbase. For far too long, most of the coding was the job of people who never even visited the forums at all, and they never really seemed guided by what users were really wanting.
Things are looking up, I would say.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Ruby (learning and language comparisons)
Many good points made above guys!
My only programming experience was Sinclair Basic, Zilog Z80 machine code and a brief flirtation with Visual Basic (which I thought was good).
So, as has been said above, the big thing to "get" is Object Oriented Programming. It took ages for me to understand the general concept (and tulamide a lot of patience). So often I read something like “The great thing about Ruby is that everything is an object” without any further explanation or even comment. Well to me that meant absolutely nothing, like saying “Everything in the world is actually a mestabule”.
Cheers
Spogg
My only programming experience was Sinclair Basic, Zilog Z80 machine code and a brief flirtation with Visual Basic (which I thought was good).
So, as has been said above, the big thing to "get" is Object Oriented Programming. It took ages for me to understand the general concept (and tulamide a lot of patience). So often I read something like “The great thing about Ruby is that everything is an object” without any further explanation or even comment. Well to me that meant absolutely nothing, like saying “Everything in the world is actually a mestabule”.
Cheers
Spogg
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: Ruby (learning and language comparisons)
---
Last edited by tulamide on Sat Mar 07, 2020 11:46 am, edited 1 time in total.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby (learning and language comparisons)
Spogg wrote:So often I read something like “The great thing about Ruby is that everything is an object” without any further explanation or even comment.
In the past I tried hard to explain the concept with a series of tutorials over at FlowstoneGURU. But it is a problem to put it in simplest words. I usually tend to give real life examples, but then the reader has to be able to transfer that image onto actual Ruby programming. And if I explain the classes in Ruby themselves, people are missing a relation to something they know.
Maybe a comparison between old-school programming and object-oriented programming will work better?
Here's the picture: You are a programmer employed to write an application that lists all animals of a zoo, with all their aspects, like order or family. Before oop, you would have done something like that:
animal_names = ["lion", "brown bear", "boar", "wild goat"]
animal_class = ["mammal", "mammal", "mammal", "mammal"]
animal_order = ["carnivore", "omnivore", "omnivore", "herbivore"]
animal_family = ["felidae", "ursidae", "suidae", "bovidae"]
animal_species = ["panthera", "ursus", "sus", "capra"]
You now have 4 fixed arrays, and the user of your application might type in a name, then you go through all arrays until you find a match, store the index of the match and list all other arrays' content under that specific index. For example:
input: lion
lion: mammal, carnivore, felidae, panthera
This works, as long as all arrays have the same structure (everything that belongs to the lion needs to be stored under index 0, etc.). It can get more complicated though. Say, the user input is "mammal". Your program code needs to find 4 mammals with all of their properties now. You probably need to install a buffer to store the findings until everything is found, and some kind of system to identify, which ones you already found. And it becomes very uncomfortable, if the zoo gets a second lion.
OOP can make this a lot more easier. I won't go into inheritance (just a bit) and mixins (not at all). But just the most simple aspect of oop already helps you a lot: Creating an object ("class" is a synonym for object) that combines all its properties!
- Code: Select all
class Animal
attr_accessor :species, :family, :order, :class, :isit
end
class Lion < Animal
alias_method :is_carnivore?, :isit
def initialize
self.species = "panthera"
self.family = "felidae"
self.order = "carnivore"
self.class = "mammal"
self.isit = true
end
end
george = Lion.new
george.is_carnivore?
You now have a lion object, that you instantiate with "Lion.new". So, no matter how many lions the zoo will get, you are prepared. Searching also gets a lot easier now, as you just ask all the objects, if they have a specific property. (This example is not complete, it is just a quick showcase)
We successfully switched to object orientation (here the lion). We added everything that defines a lion into one closed group - the object or class. I just carefully touched inheritance, as a lion surely is an animal. So I made a base class of animals, which all other animals will derive from. In this class I've put everything that all animals share. Here they all share the properties themselves (in Ruby known as attributes), but not the content of them. But when I create a Lion instance, it inherits all properties from the base class Animal, and can fill them in with its own specific data.
I'm pretty sure, this attempt will again not be understood - but hey, I tried
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:33 am, edited 6 times in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
Your on-going toxic language really annoys me. It hinders me to address the content of your post.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:33 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
Well, my contribution wasn't for discussion, but for explaining the basics of object oriented programming. The example purposely used a base class to show one form of inheritance and alias_method was used to show how one variable can have different meanings, dependent on the class it is used in. Etc.
The point is, my 90 minutes writing the post were spent to explain the concept to someone who never came in touch with it. Not to present the best, fastest or easiest way. And yes, Ruby also supports structs, but that's not a specific oop concept.
The point is, my 90 minutes writing the post were spent to explain the concept to someone who never came in touch with it. Not to present the best, fastest or easiest way. And yes, Ruby also supports structs, but that's not a specific oop concept.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:33 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Ruby (learning and language comparisons)
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 10:34 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Who is online
Users browsing this forum: No registered users and 83 guests