Use of Mixins and other stuff

My wife is doing some out of town work in the near future and I'm turning
to "Learning more Ruby" as a way to keep myself out of trouble. I'm looking
for advice on program/module/whatever structure and design as a way to push
my fairly meager skills up a notch.

I've been working on Rspec a little, and hope to get to Cucumber shortly.
Where I'm unsure of is how to best use Classes, Mixins, and Inheritance.
Current project code is:

A 'Character' will almost always have some 'Career', so you never really
create an instance of Character. All Career options have skills and names,
some have ranks. The skill lists and ranks differ by Career.

There's a Dice object that has various methods for random number
generation. Yet Dice could and should also be available for other programs,
so how do I decouple Dice?

That said, my Ruby environment is version 1.8.7. Please don't kill any
electrons telling me to upgrade, I can't change the environment. My
programming this project helps me learn for work projects, and work is Ruby
1.8.7.

Thanks!

Leam

···

--
Mind on a Mission <http://leamhall.blogspot.com/>

Hi Leam,

I've been working on Rspec a little, and hope to get to Cucumber shortly.
Where I'm unsure of is how to best use Classes, Mixins, and Inheritance.
Current project code is:

https://github.com/LeamHall/CT_Character_Generator

A character generator? Great! What system do you use? I don't recognize the
specific set of stats. (GURPS, perhaps?)

I've begun a similar project, albeit not entirely with Ruby, based on Anima:
Beyond Fantasy. What I found to be really helping/cool is to create a grammar
for dice rolls. That way, my little program correctly interpreted stuff like
"1d100+2d5+10". I used Treetop [1] for that.

I'd love to work more on RPG-related stuff, especially with a cool language
like Ruby. Character *name* generators and procedural map generation also
immediatly come to my mind. Ping me if you'd like to collaborate on any idea.

Cheers,
  Eric

[1] GitHub - cjheath/treetop: A Ruby-based parsing DSL based on parsing expression grammars.

···

On Monday 29 June 2015, 10:44:53, leam hall wrote:

My wife is doing some out of town work in the near future and I'm turning
to "Learning more Ruby" as a way to keep myself out of trouble.

:slight_smile:

I'm looking for advice on program/module/whatever structure and design as
a way to push my fairly meager skills up a notch.

Thanks for the interesting question!

I've been working on Rspec a little, and hope to get to Cucumber shortly.
Where I'm unsure of is how to best use Classes, Mixins, and Inheritance.
Current project code is:

https://github.com/LeamHall/CT_Character_Generator

Manipulating LOAD_PATH from every file just looks wrong. Don't you end up
with multiple identical entries that way? If, I would only do that in the
root file of the lib (chargen.rb if I am not mistaken). Generally I would
try to avoid it though. You could also use Module#autoload if you are
worried about load times / memory consumption.

A few random observations:

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L23
I would move this before the "begin" since you do not want to close the
connection if it cannot be opened in the first place. Maybe there is also a
block form of that method available.

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L32
I would *never* exit the process from within a library. Let the caller
handle the exception.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L11
This line is superfluous. I would also consider not using an option Hash
but rather local variables. The Hash is only good if you need to pass
around *all* options.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L30
There is a lot boilerplate. This should be doable much simpler. Here's what
I'd do:

0. Put stuff in a subdirectory "chargen".
1. Create a module that will be used as namespace for all character classes.
2. Set up autoload

module Chargen
  autoload 'Marine', 'chargen/marine'
  autoload 'Navy', 'chargen/navy'
end

3. Replace the whole case structure with

name = career.capitalize
character = Chargen.const_get(name).new
character.career = name

If you leave out step 2 you can still do

require "chargen/#{career}"
name = career.capitalize
character = Chargen.const_get(name).new
character.career = name

A 'Character' will almost always have some 'Career', so you never really

create an instance of Character. All Career options have skills and names,
some have ranks. The skill lists and ranks differ by Career.

There's a Dice object that has various methods for random number
generation. Yet Dice could and should also be available for other programs,
so how do I decouple Dice?

That said, my Ruby environment is version 1.8.7. Please don't kill any
electrons telling me to upgrade, I can't change the environment. My
programming this project helps me learn for work projects, and work is Ruby
1.8.7.

You should upg... SCNR :slight_smile: (At least I killed some electrons. Ha!)

Kind regards

robert

···

On Mon, Jun 29, 2015 at 4:44 PM, leam hall <leamhall@gmail.com> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can -
without end}
http://blog.rubybestpractices.com/

You already have "Dice" decoupled, because it lives in an object of its own,
as far as I can see.

There are two possiblilities to go further: One, you could decide that there
is no need for two dice objects because there is no "dice state" that could
separate them. I.e., dice1 == dice2 for all the lifetime of your application.
That would be what one expects from dice, anyways. In this case, make the Dice
class a singleton; you can then call Dice.instance.roll2 everywhere in your
code and still have just one Dice object. "Singleton" is a Ruby module.

You can even take that further and design "Dice" to be a module that you could
include with every class that needs dice rolls. While it is certainly shorter
to write "roll2" instead of Dice.instance.roll2, it would mean that any
Character object included the semantics of a dice roll, which is not what
you'd like to express.

As a counterexample, many IO objects include the Enumerable module. This is
correct, since IO::File can act like an enumerator much like Array can.
However, a Character cannot act like a Dice. Plus, Diceable sounds wrong,
which is probably a good indicator, too.

What comes to my mind is a full-featured Character and an NSC class that
features only the necessary attributes/methods for most common interactions. A
module could be "Attackable", adding #attack and #defend.

You can drive that further by making careers modules. Then, you'd have a
"BasicCharacter" object where you include FooCareer and Attackable, allowing
you to build character objects from building blocks.

HTH.

      --- Eric

···

On Monday 29 June 2015, 10:44:53, leam hall wrote:

There's a Dice object that has various methods for random number
generation. Yet Dice could and should also be available for other programs,
so how do I decouple Dice?

Hey Eric, this is Classic Traveller. While I can't say my code is
demonstration quality, look at lines 20-38 of lib/character.rb. It pulls
from a SQLite database in data/names.db. If your game uses non-human names,
I wrote a Vargr name generator in Go:

https://github.com/makhidkarun/vargr_names/

I find RPG stuff key to learning new languages. Work pays the bills but
does not inspire as much creativity.

Leam

···

On Mon, Jun 29, 2015 at 10:56 AM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

Hi Leam,

On Monday 29 June 2015, 10:44:53, leam hall wrote:
> I've been working on Rspec a little, and hope to get to Cucumber shortly.
> Where I'm unsure of is how to best use Classes, Mixins, and Inheritance.
> Current project code is:
>
> https://github.com/LeamHall/CT_Character_Generator

A character generator? Great! What system do you use? I don't recognize the
specific set of stats. (GURPS, perhaps?)

I've begun a similar project, albeit not entirely with Ruby, based on
Anima:
Beyond Fantasy. What I found to be really helping/cool is to create a
grammar
for dice rolls. That way, my little program correctly interpreted stuff
like
"1d100+2d5+10". I used Treetop [1] for that.

I'd love to work more on RPG-related stuff, especially with a cool language
like Ruby. Character *name* generators and procedural map generation also
immediatly come to my mind. Ping me if you'd like to collaborate on any
idea.

Cheers,
        Eric

[1] GitHub - cjheath/treetop: A Ruby-based parsing DSL based on parsing expression grammars.

--
Mind on a Mission <http://leamhall.blogspot.com/&gt;

> There's a Dice object that has various methods for random number
> generation. Yet Dice could and should also be available for other
programs,
> so how do I decouple Dice?

You already have "Dice" decoupled, because it lives in an object of its
own,
as far as I can see.

What if you and I collaborate on a Dice "thing" that can be used by my CT
Character Generator and your "A:BF" program? How do I get "Dice" as a
totally stand alone "thing".

For example CT uses 1d6, 2d6, and 1 or 2 d6 plus or minus something. Other
games might use a handful of d6 (Champions), or "Exploding d10" (7th Sea
Roll and Keep). It would be interesting to provide a Ruby based "thing"
that used high end Random Number Generation for rolls.

There are two possiblilities to go further: One, you could decide that
there
is no need for two dice objects because there is no "dice state" that could
separate them. I.e., dice1 == dice2 for all the lifetime of your
application.
That would be what one expects from dice, anyways. In this case, make the
Dice
class a singleton; you can then call Dice.instance.roll2 everywhere in your
code and still have just one Dice object. "Singleton" is a Ruby module.

Hmm...so Dice would be a Singleton, but cold provide lots of different
numbers based on being called again? I could do something like "Dice.2d6
and get something randomly different every time I called it?

What doesNSC stand for?

Thanks!

Leam

···

On Mon, Jun 29, 2015 at 11:22 AM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

On Monday 29 June 2015, 10:44:53, leam hall wrote:

--
Mind on a Mission <http://leamhall.blogspot.com/&gt;

Robert,

I read your reply.

My brain melted.

Will do some testing tonight to see if I can step up to the challenge.

Thanks!

Leam

···

On Mon, Jun 29, 2015 at 11:18 AM, Robert Klemme <shortcutter@googlemail.com> wrote:

On Mon, Jun 29, 2015 at 4:44 PM, leam hall <leamhall@gmail.com> wrote:

My wife is doing some out of town work in the near future and I'm turning
to "Learning more Ruby" as a way to keep myself out of trouble.

:slight_smile:

I'm looking for advice on program/module/whatever structure and design as
a way to push my fairly meager skills up a notch.

Thanks for the interesting question!

I've been working on Rspec a little, and hope to get to Cucumber shortly.
Where I'm unsure of is how to best use Classes, Mixins, and Inheritance.
Current project code is:

https://github.com/LeamHall/CT_Character_Generator

Manipulating LOAD_PATH from every file just looks wrong. Don't you end up
with multiple identical entries that way? If, I would only do that in the
root file of the lib (chargen.rb if I am not mistaken). Generally I would
try to avoid it though. You could also use Module#autoload if you are
worried about load times / memory consumption.

A few random observations:

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L23
I would move this before the "begin" since you do not want to close the
connection if it cannot be opened in the first place. Maybe there is also a
block form of that method available.

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L32
I would *never* exit the process from within a library. Let the caller
handle the exception.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L11
This line is superfluous. I would also consider not using an option Hash
but rather local variables. The Hash is only good if you need to pass
around *all* options.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L30
There is a lot boilerplate. This should be doable much simpler. Here's
what I'd do:

0. Put stuff in a subdirectory "chargen".
1. Create a module that will be used as namespace for all character
classes.
2. Set up autoload

module Chargen
  autoload 'Marine', 'chargen/marine'
  autoload 'Navy', 'chargen/navy'
end

3. Replace the whole case structure with

name = career.capitalize
character = Chargen.const_get(name).new
character.career = name

If you leave out step 2 you can still do

require "chargen/#{career}"
name = career.capitalize
character = Chargen.const_get(name).new
character.career = name

A 'Character' will almost always have some 'Career', so you never really

create an instance of Character. All Career options have skills and names,
some have ranks. The skill lists and ranks differ by Career.

There's a Dice object that has various methods for random number
generation. Yet Dice could and should also be available for other programs,
so how do I decouple Dice?

That said, my Ruby environment is version 1.8.7. Please don't kill any
electrons telling me to upgrade, I can't change the environment. My
programming this project helps me learn for work projects, and work is Ruby
1.8.7.

You should upg... SCNR :slight_smile: (At least I killed some electrons. Ha!)

Kind regards

robert

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can -
without end}
http://blog.rubybestpractices.com/

--
Mind on a Mission <http://leamhall.blogspot.com/&gt;

    I've been working on Rspec a little, and hope to get to Cucumber
    shortly. Where I'm unsure of is how to best use Classes, Mixins, and
    Inheritance. Current project code is:

    https://github.com/LeamHall/CT_Character_Generator

Manipulating LOAD_PATH from every file just looks wrong. Don't you end
up with multiple identical entries that way? If, I would only do that in
the root file of the lib (chargen.rb if I am not mistaken). Generally I
would try to avoid it though. You could also use Module#autoload if you
are worried about load times / memory consumption.

The program grew organically.

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L23
I would move this before the "begin" since you do not want to close the
connection if it cannot be opened in the first place. Maybe there is
also a block form of that method available.

I thought having it be in the "begin" would help catch any exceptions like "file not found" or permission errors.

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L32
I would *never* exit the process from within a library. Let the caller
handle the exception.

Hmm..understood. I need to figure out how to handle passed up exceptions.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L11
This line is superfluous. I would also consider not using an option Hash
but rather local variables. The Hash is only good if you need to pass
around *all* options.

Good point. Line 11 was in because I was trying to ensure the variable was blank. I'm still figuring OptionParser and pretty much copying code.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L30
There is a lot boilerplate. This should be doable much simpler. Here's
what I'd do:

Hmm...I like this. Let me work on understanding it more.

Leam

···

On 06/29/15 11:18, Robert Klemme wrote:

Robert,

I read your reply.

My brain melted.

Oh dear! That was not intended. If something is not clear please just ask.
(OTOH: that seems to be a surefire way to keep you "out of trouble". ;-))

Will do some testing tonight to see if I can step up to the challenge.

Good!

Thanks!

You're welcome

robert

···

On Mon, Jun 29, 2015 at 5:38 PM, leam hall <leamhall@gmail.com> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can -
without end}
http://blog.rubybestpractices.com/

Hi Leam,

What if you and I collaborate on a Dice "thing" that can be used by my CT
Character Generator and your "A:BF" program? How do I get "Dice" as a
totally stand alone "thing".

Sounds good, let's do that!

For example CT uses 1d6, 2d6, and 1 or 2 d6 plus or minus something. Other
games might use a handful of d6 (Champions), or "Exploding d10" (7th Sea
Roll and Keep). It would be interesting to provide a Ruby based "thing"
that used high end Random Number Generation for rolls.

Yep, plus some meta-programing so that "2d6+10" is actually a call! That would
be nice.

Hmm...so Dice would be a Singleton, but cold provide lots of different
numbers based on being called again? I could do something like "Dice.2d6
and get something randomly different every time I called it?

Yes, that would be the plan. Let me open a Github repo. Do you prefer a
specific license?

What doesNSC stand for?

Sorry, that should have been "NPC", i.e., non-player character. "NSC" is the
same but in German (Nichtspielercharacter).

Cheers,
  Eric

···

On Monday 29 June 2015, 11:36:08, leam hall wrote:

Robert,

Dealing with a bad cough, trying to get better at Ruby. Fun weekend.
I think most of your recommendations have been implemented.

I need to go work on Cucumber and Rspec. Some of my tests are passing and I'm too tired to figure out how.

Again, I appreciate your critique! It is making my code and skills improve.

Leam

···

On 06/29/15 11:18, Robert Klemme wrote:

On Mon, Jun 29, 2015 at 4:44 PM, leam hall <leamhall@gmail.com > <mailto:leamhall@gmail.com>> wrote:

    My wife is doing some out of town work in the near future and I'm
    turning to "Learning more Ruby" as a way to keep myself out of trouble.

:slight_smile:

    I'm looking for advice on program/module/whatever structure and
    design as a way to push my fairly meager skills up a notch.

Thanks for the interesting question!

    I've been working on Rspec a little, and hope to get to Cucumber
    shortly. Where I'm unsure of is how to best use Classes, Mixins, and
    Inheritance. Current project code is:

    https://github.com/LeamHall/CT_Character_Generator

Manipulating LOAD_PATH from every file just looks wrong. Don't you end
up with multiple identical entries that way? If, I would only do that in
the root file of the lib (chargen.rb if I am not mistaken). Generally I
would try to avoid it though. You could also use Module#autoload if you
are worried about load times / memory consumption.

A few random observations:

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L23
I would move this before the "begin" since you do not want to close the
connection if it cannot be opened in the first place. Maybe there is
also a block form of that method available.

https://github.com/LeamHall/CT_Character_Generator/blob/master/lib/character.rb#L32
I would *never* exit the process from within a library. Let the caller
handle the exception.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L11
This line is superfluous. I would also consider not using an option Hash
but rather local variables. The Hash is only good if you need to pass
around *all* options.

https://github.com/LeamHall/CT_Character_Generator/blob/master/chargen.rb#L30
There is a lot boilerplate. This should be doable much simpler. Here's
what I'd do:

0. Put stuff in a subdirectory "chargen".
1. Create a module that will be used as namespace for all character classes.
2. Set up autoload

module Chargen
   autoload 'Marine', 'chargen/marine'
   autoload 'Navy', 'chargen/navy'
end

3. Replace the whole case structure with

name = career.capitalize
character = Chargen.const_get(name).new
character.career = name

If you leave out step 2 you can still do

require "chargen/#{career}"
name = career.capitalize
character = Chargen.const_get(name).new
character.career = name

    A 'Character' will almost always have some 'Career', so you never
    really create an instance of Character. All Career options have
    skills and names, some have ranks. The skill lists and ranks differ
    by Career.

    There's a Dice object that has various methods for random number
    generation. Yet Dice could and should also be available for other
    programs, so how do I decouple Dice?

    That said, my Ruby environment is version 1.8.7. Please don't kill
    any electrons telling me to upgrade, I can't change the environment.
    My programming this project helps me learn for work projects, and
    work is Ruby 1.8.7.

You should upg... SCNR :slight_smile: (At least I killed some electrons. Ha!)

Kind regards

robert

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can -
without end}
http://blog.rubybestpractices.com/

Hi Eric/Learn,

You could always look at droll or dicebag or games_dice. Any of those might
give you a good forking point, as they all seem to have the generic dice
rolling down.

Best wishes,
Paul

···

On 30 June 2015 at 11:50, Eric MSP Veith <eveith@wwweb-library.net> wrote:

Hi Leam,

On Monday 29 June 2015, 11:36:08, leam hall wrote:
> What if you and I collaborate on a Dice "thing" that can be used by my CT
> Character Generator and your "A:BF" program? How do I get "Dice" as a
> totally stand alone "thing".

Sounds good, let's do that!

> For example CT uses 1d6, 2d6, and 1 or 2 d6 plus or minus something.
Other
> games might use a handful of d6 (Champions), or "Exploding d10" (7th Sea
> Roll and Keep). It would be interesting to provide a Ruby based "thing"
> that used high end Random Number Generation for rolls.

Yep, plus some meta-programing so that "2d6+10" is actually a call! That
would
be nice.

> Hmm...so Dice would be a Singleton, but cold provide lots of different
> numbers based on being called again? I could do something like "Dice.2d6
> and get something randomly different every time I called it?

Yes, that would be the plan. Let me open a Github repo. Do you prefer a
specific license?

> What doesNSC stand for?

Sorry, that should have been "NPC", i.e., non-player character. "NSC" is
the
same but in German (Nichtspielercharacter).

Cheers,
        Eric

--
Best wishes,
Paul McKibbin

m: +447990970862
l: +442032396225
s: blackratprime
b: http://blackrat.org/

Hi Leam!

Robert,

Dealing with a bad cough, trying to get better at Ruby. Fun weekend.

I'm glad you could get something positive out of the illness. Get well soon!

I think most of your recommendations have been implemented.

I see you use autoload. Great!

You have two files with the same name albeit different case. That can
create issues on some platforms and should generally be avoided. I'd just
stick with lowercase file names.

I need to go work on Cucumber and Rspec. Some of my tests are passing and
I'm too tired to figure out how.

Right, you should make them all fail. :wink:

Again, I appreciate your critique! It is making my code and skills improve.

You're welcome!

Kind regards

robert

···

On Sun, Jul 26, 2015 at 5:58 PM, Leam Hall <leamhall@gmail.com> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can -
without end}
http://blog.rubybestpractices.com/

Hi Paul,

···

On Tuesday 30 June 2015, 17:31:29, Paul McKibbin wrote:

Hi Eric/Learn,

You could always look at droll or dicebag or games_dice. Any of those might
give you a good forking point, as they all seem to have the generic dice
rolling down.

thanks for the hint about other projects!

It seems like Dice-Bag already uses a parser. The code looks good; I don't see
what could be missing here except for some rules.

Hum, perhaps we should plug Dice-Bag into a character generation framework...?

      --- Eric

Hi all!

I'm learning about 1 and a half year ago but I have a regular job not
related with codeing and can not dedicate all of my time studying. Still I
can not start to work as a web dev. or even webdesigner.

I have a few common questions and I hope someone will answer me.

Is Ruby useful for some jobs(projects) without rails? For which ones?

Some folks say that ruby is so easy - most easy language to learn. Ok it is
but what do you say about some concepts as blocks and yield? I learned not
a bit a html, css, jquery and js, rails and it seems that a JS is not so
tough as ruby in some concepts. What is your opinion?

One more question. How to improve my ruby skills when I already read a few
books \first was Learn to programming sec edition\. Some tutorials
(interactive) but I feel like I still can not do any program myself. This
confuse me. What to do?

thanks for your attention!

Boris

···

-------------------------------------
Mail.BG: Безплатен e-mail адрес. Най-добрите характеристики на българския пазар - 20 GB пощенска кутия, 1 GB прикрепен файл, безплатен POP3, мобилна версия, SMS известяване и други. http://mail.bg

Boris,

To answer several of your questions at once, yes I find Ruby a useful and fun language. The basics are not too difficult. I don't know a lot of the advanced stuff and do not do Rails at all.

What do you want to end up doing? If you want to do "server stuff", like advanced shell scripting with Ruby, cool. I can assure you it is very possible.

I have played role-playing games for many years. When I learn a new language I do game stuff with it. Maybe a random number generator. Then I build up to a basic character generator. Think about what you like and build toy programs to do something with that. Have fun!

If you can only do 15 minutes of programming a day, pick a large goal and break it down into very small bites. For a game character generator I do random numbers. Then print a series of them. Then print them with headers. Then print them doing something based off the number. Keep doing that for a few weeks and you can accomplish large goals. You might also look at Zed Shaw's "Programming Ruby the Hard Way".

I hope that helps. I find Ruby fun. I do not understand a lot of it but I can do stuff with what I know. You do not have to learn all the language before you begin to program. Code first, and learn as you go.

Leam

···

On 08/10/15 04:46, Boris wrote:

Hi all!

I'm learning about 1 and a half year ago but I have a regular job not
related with codeing and can not dedicate all of my time studying. Still
I can not start to work as a web dev. or even webdesigner.

Is Ruby useful for some jobs(projects) without rails? For which ones?

Yes indeed! Ruby came out in 1993 -- but Rails wasn't released until
2004. Meanwhile it had been used as a general scripting language, and
for all I know there may have been some other web frameworks for it
before Rails. Nowadays Ruby is also very popular in the DevOps field,
with tools like Chef and Puppet.

Some folks say that ruby is so easy - most easy language to learn. Ok it is
but what do you say about some concepts as blocks and yield?

All languages have some concepts that are more advanced than others.
*Using* methods that accept blocks is quite natural. When you do
something like:

  3.times do { puts "hello world" }

you are using a block (fed to Fixnum#times). No big deal; the main
gotcha is to remember that any variables defined within the block do
not carry their definitions over to the next iteration (if any).
*Writing* methods that accept blocks (using yield) is a more advanced
topic.

I learned not a
bit a html, css, jquery and js, rails and it seems that a JS is not so
tough as ruby in some concepts. What is your opinion?

The basics of the language itself, no problem. Any idiot can learn JS
just by copying from other people's web pages, and a look at the web
will show that millions of idiots have indeed done so.

But enough to do anything significant? You'll probably need to use
asynchronous techniques and therefore keep track of what is "this"
(the current object) at all times. That's not JS's fault, but it
doesn't really do much to make that easy, or remember the need. Some
of that can be alleviated by using CoffeeScript, though many people
find significant indentation weird too. :slight_smile: Then there's the
weirdness of prototypal inheritance, but if you're not already used to
the "normal" way, that might not be so bad.

Even aside from strange concepts (which are often deliberate or even
good; see Scala or Erlang for great examples), there are the gotchas.
All languages have gotchas. I've even put together a collection of a
couple dozen of Ruby's, at Ruby Gotchas - Google Slides . But JS has
much worse and less-avoidable gotchas. Here's just one easily visible
sample. Try this in your browser's JS console:

  [1,2,3,4,5,6,7,8,9,10].sort()

How often do *you* depend on an array of numbers being sorted
correctly, or other such simple operations that JS gets so terribly
wrong? Do you want to have to remember to adjust for this insanity
every time you do something so common and basic? See
Wat for more ways in which JS
often makes no sense at all. There are reasons why "JavaScript: The
Good Parts" is *so much* thinner, at a mere 176 pages, than
"JavaScript: The Definitive Guide", at 1096 pages. (And there are
reasons why I'm much more of a back-end dev than front-end.)

One more question.

Please start new discussions for new questions. It helps ensure that
the subject matches the Subject, if you get what I mean.

How to improve my ruby skills when I already read a few
books

Practice practice practice. Pick an idea and do it. Pick an open
source project and contribute. Check out Code Katas
(http://codekata.com/\) and do them (that's one of the main things I
did early on).

-Dave

···

On Mon, Aug 10, 2015 at 4:46 AM, Boris <sata@mail.bg> wrote:

--
Dave Aronson, consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.

I have seen this kind of questions asked over and over about (insert
language here).

I programmed (as a career) for almost 40 years. I did very little with
html. I did a lot of programming. Sometimes for the web (back end stuff,
not front end stuff).

Any general purpose language can be used for the web, usually with some
kind of web frameworks. But the language is built for and usually used for
anything but the web.

It all depends upon need. For instance, I built a mongo db database to keep
track of my movies and books. Ever gone to the store, and got a movie or
book, that when you got it home, you already had? I have many times, and I
got tired of it. So I wrote a databases for my movies and books, I add
books to it that I want to read (I sort by series and number of book in
that series - so I know which book I need next, and I list the movies I
have bought (> 500). I used ruby to add, delete, and modify my books and
movies. I used python (just another language, I could have used ruby, but
did that a long time ago), to webify the database, so when I go to the
store, I can see if I have it or not, or pick up the next book in the
series I am reading. Etc.

I have used ruby and python to program the raspberry pi. I used a $2 board
that takes signals to make a stepper motor work. I wrote it in python
first, then ruby to compare.

I like doing stuff, even in retirement.

So you ask, can I use (language) to do something besides the web? Of
course, you can! What do you want to do? Think about something you'd like
to automate, then do it.

Jerry

Jerry

···

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

*The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov

*I*
*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-
Anonymous

*If writing good code requires very little comments, then writing really
excellent code requires no comments at all!*- Ken Thompson

On Mon, Aug 10, 2015 at 7:05 AM, Dave Aronson < ruby-talk.list.2.TRex@codosaur.us> wrote:

On Mon, Aug 10, 2015 at 4:46 AM, Boris <sata@mail.bg> wrote:

> Is Ruby useful for some jobs(projects) without rails? For which ones?

Yes indeed! Ruby came out in 1993 -- but Rails wasn't released until
2004. Meanwhile it had been used as a general scripting language, and
for all I know there may have been some other web frameworks for it
before Rails. Nowadays Ruby is also very popular in the DevOps field,
with tools like Chef and Puppet.

> Some folks say that ruby is so easy - most easy language to learn. Ok it
is
> but what do you say about some concepts as blocks and yield?

All languages have some concepts that are more advanced than others.
*Using* methods that accept blocks is quite natural. When you do
something like:

  3.times do { puts "hello world" }

you are using a block (fed to Fixnum#times). No big deal; the main
gotcha is to remember that any variables defined within the block do
not carry their definitions over to the next iteration (if any).
*Writing* methods that accept blocks (using yield) is a more advanced
topic.

> I learned not a
> bit a html, css, jquery and js, rails and it seems that a JS is not so
> tough as ruby in some concepts. What is your opinion?

The basics of the language itself, no problem. Any idiot can learn JS
just by copying from other people's web pages, and a look at the web
will show that millions of idiots have indeed done so.

But enough to do anything significant? You'll probably need to use
asynchronous techniques and therefore keep track of what is "this"
(the current object) at all times. That's not JS's fault, but it
doesn't really do much to make that easy, or remember the need. Some
of that can be alleviated by using CoffeeScript, though many people
find significant indentation weird too. :slight_smile: Then there's the
weirdness of prototypal inheritance, but if you're not already used to
the "normal" way, that might not be so bad.

Even aside from strange concepts (which are often deliberate or even
good; see Scala or Erlang for great examples), there are the gotchas.
All languages have gotchas. I've even put together a collection of a
couple dozen of Ruby's, at http://bit.ly/RubyGotchas . But JS has
much worse and less-avoidable gotchas. Here's just one easily visible
sample. Try this in your browser's JS console:

  [1,2,3,4,5,6,7,8,9,10].sort()

How often do *you* depend on an array of numbers being sorted
correctly, or other such simple operations that JS gets so terribly
wrong? Do you want to have to remember to adjust for this insanity
every time you do something so common and basic? See
Wat for more ways in which JS
often makes no sense at all. There are reasons why "JavaScript: The
Good Parts" is *so much* thinner, at a mere 176 pages, than
"JavaScript: The Definitive Guide", at 1096 pages. (And there are
reasons why I'm much more of a back-end dev than front-end.)

> One more question.

Please start new discussions for new questions. It helps ensure that
the subject matches the Subject, if you get what I mean.

> How to improve my ruby skills when I already read a few
> books

Practice practice practice. Pick an idea and do it. Pick an open
source project and contribute. Check out Code Katas
(http://codekata.com/\) and do them (that's one of the main things I
did early on).

-Dave

--
Dave Aronson, consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.

I was in the same boat as you, job not related to coding and wanted to
learn Ruby on rails, but I had 3 kids and a mortgage...you get the gist.

It was hard for me to do on the side, so it wasn't till I was laid off
that(with the support of my wife) that I jumped careers and did a 12 week
fulltime intensive bootcamp in rails engineering..I do much better learning
with other people....this decision was the best of my career and resulted
in a very satisfying new job as a software engineer.

If you are having trouble doing it by yourself, find others to do it with
you.

Jeff

···

On Mon, Aug 10, 2015 at 7:59 AM, Jerry Davis <jdawgaz@gmail.com> wrote:

I have seen this kind of questions asked over and over about (insert
language here).

I programmed (as a career) for almost 40 years. I did very little with
html. I did a lot of programming. Sometimes for the web (back end stuff,
not front end stuff).

Any general purpose language can be used for the web, usually with some
kind of web frameworks. But the language is built for and usually used for
anything but the web.

It all depends upon need. For instance, I built a mongo db database to
keep track of my movies and books. Ever gone to the store, and got a movie
or book, that when you got it home, you already had? I have many times, and
I got tired of it. So I wrote a databases for my movies and books, I add
books to it that I want to read (I sort by series and number of book in
that series - so I know which book I need next, and I list the movies I
have bought (> 500). I used ruby to add, delete, and modify my books and
movies. I used python (just another language, I could have used ruby, but
did that a long time ago), to webify the database, so when I go to the
store, I can see if I have it or not, or pick up the next book in the
series I am reading. Etc.

I have used ruby and python to program the raspberry pi. I used a $2 board
that takes signals to make a stepper motor work. I wrote it in python
first, then ruby to compare.

I like doing stuff, even in retirement.

So you ask, can I use (language) to do something besides the web? Of
course, you can! What do you want to do? Think about something you'd like
to automate, then do it.

Jerry

Jerry

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

*The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov

*I*
*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-
Anonymous

*If writing good code requires very little comments, then writing really
excellent code requires no comments at all!*- Ken Thompson

On Mon, Aug 10, 2015 at 7:05 AM, Dave Aronson < > ruby-talk.list.2.TRex@codosaur.us> wrote:

On Mon, Aug 10, 2015 at 4:46 AM, Boris <sata@mail.bg> wrote:

> Is Ruby useful for some jobs(projects) without rails? For which ones?

Yes indeed! Ruby came out in 1993 -- but Rails wasn't released until
2004. Meanwhile it had been used as a general scripting language, and
for all I know there may have been some other web frameworks for it
before Rails. Nowadays Ruby is also very popular in the DevOps field,
with tools like Chef and Puppet.

> Some folks say that ruby is so easy - most easy language to learn. Ok
it is
> but what do you say about some concepts as blocks and yield?

All languages have some concepts that are more advanced than others.
*Using* methods that accept blocks is quite natural. When you do
something like:

  3.times do { puts "hello world" }

you are using a block (fed to Fixnum#times). No big deal; the main
gotcha is to remember that any variables defined within the block do
not carry their definitions over to the next iteration (if any).
*Writing* methods that accept blocks (using yield) is a more advanced
topic.

> I learned not a
> bit a html, css, jquery and js, rails and it seems that a JS is not so
> tough as ruby in some concepts. What is your opinion?

The basics of the language itself, no problem. Any idiot can learn JS
just by copying from other people's web pages, and a look at the web
will show that millions of idiots have indeed done so.

But enough to do anything significant? You'll probably need to use
asynchronous techniques and therefore keep track of what is "this"
(the current object) at all times. That's not JS's fault, but it
doesn't really do much to make that easy, or remember the need. Some
of that can be alleviated by using CoffeeScript, though many people
find significant indentation weird too. :slight_smile: Then there's the
weirdness of prototypal inheritance, but if you're not already used to
the "normal" way, that might not be so bad.

Even aside from strange concepts (which are often deliberate or even
good; see Scala or Erlang for great examples), there are the gotchas.
All languages have gotchas. I've even put together a collection of a
couple dozen of Ruby's, at http://bit.ly/RubyGotchas . But JS has
much worse and less-avoidable gotchas. Here's just one easily visible
sample. Try this in your browser's JS console:

  [1,2,3,4,5,6,7,8,9,10].sort()

How often do *you* depend on an array of numbers being sorted
correctly, or other such simple operations that JS gets so terribly
wrong? Do you want to have to remember to adjust for this insanity
every time you do something so common and basic? See
Wat for more ways in which JS
often makes no sense at all. There are reasons why "JavaScript: The
Good Parts" is *so much* thinner, at a mere 176 pages, than
"JavaScript: The Definitive Guide", at 1096 pages. (And there are
reasons why I'm much more of a back-end dev than front-end.)

> One more question.

Please start new discussions for new questions. It helps ensure that
the subject matches the Subject, if you get what I mean.

> How to improve my ruby skills when I already read a few
> books

Practice practice practice. Pick an idea and do it. Pick an open
source project and contribute. Check out Code Katas
(http://codekata.com/\) and do them (that's one of the main things I
did early on).

-Dave

--
Dave Aronson, consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.

Hey Boris,
Ruby is a very merciful language, most of the time there is more than just one way to do things. That can be really helpful. You don't have to use everything a language provides. You can start by writing procedural programs and later on move to a more object oriented style. For example for a long time I didn't really understand the concept of symbols in ruby and it was still possible for me to write programs.

A word of warning: Ruby is awesome if you want to write web applications and work with the web in general, but compared to other languages there aren't that much gems that deal with non web things. Sometimes you find a math library someone started or an unfinished JPEG library. But in general ruby is very web centric you can see that by the number of people who still think ruby and rails are the same thing. :grinning: Personally I would really appreciate it, if there were more non web projects in ruby, just like Python that has a wide variety of libraries that aren't related to the web at all. That's not a case against ruby, the language is completely capable of dealing with non web stuff, but you might end up writing a lot of the code you need yourself, where in other languages you could have used some else's well tested library.

So in the end it really depends on your project.

If you want I can show you some stuff, currently I have plenty of free time.

Greetings,
Tim

···

Hi all!

I'm learning about 1 and a half year ago but I have a regular job not related with codeing and can not dedicate all of my time studying. Still I can not start to work as a web dev. or even webdesigner.

I have a few common questions and I hope someone will answer me.

Is Ruby useful for some jobs(projects) without rails? For which ones?

Some folks say that ruby is so easy - most easy language to learn. Ok it is but what do you say about some concepts as blocks and yield? I learned not a bit a html, css, jquery and js, rails and it seems that a JS is not so tough as ruby in some concepts. What is your opinion?

One more question. How to improve my ruby skills when I already read a few books \first was Learn to programming sec edition\. Some tutorials (interactive) but I feel like I still can not do any program myself. This confuse me. What to do?

thanks for your attention!

Boris

-------------------------------------
Mail.BG: Безплатен e-mail адрес. Най-добрите характеристики на българския пазар - 20 GB пощенска кутия, 1 GB прикрепен файл, безплатен POP3, мобилна версия, SMS известяване и други.