I am still using the old symbol hashes instead of the json hashes

sorry if i'm beating a dead horse with this topic but i really can't stand
the new json hashes in ruby.
the problem isn't the syntax (the syntax is great), it's just that it
breaks the consistency of the language to a degree i can't tolerate.
i picked up ruby 2 years ago (coming from PHP) and fell it love with it
because it was the only language that i found who actively promotes the
element of least surprises, which i whole heartedly love. PHP was going
through some major changes that i didn't really like at the time, mostly
their increasing infatuation with Java.
over the years as i get older and more experienced, i find that simplicity
is the biggest thing one should look for in a programming language. any
languages that aren't straightforward don't interest me anymore. but now
with ruby's new json hash syntax, it throws off the love i have about the
language. i continue to use and will always use the old rocket hash to make
my codes more consistent but i fear that i will create conflicts down the
line as more and more ruby devs turn to json hash 100%. i for one, think
the symbols should be presented as symbols (:), but in json hashes the
symbols don't necessary require (:), which bugs me a lot. i strive for
elegance and simplicity so as minute of an issue this is, it just irks the
heck out of me.

now, my question is, do you think it is okay for me to continue using the
rocket hash syntaxes and even evangelize about keeping it that way?

···

--
Kind Regards,
Jae

I feel with you in this regard. I also prefer the hash rockets in
hashes, with one exception: method calls.

    foo(arg1: "foo", arg2: "baz")

In these cases I think of the hash more like an argument list. And in
fact, since Ruby has added keyword arguments, they are. In all other
cases I prefer the hash rocket syntax for the same reasons you pointed
out.

    {:sym1 => "a", :sym2 => "b"}

There are other constructs in the language that I think are bad for
readability, the picky lambda for example. I fail to see a lambda
letter in “->”; that is an arrow to me and will always stay one. So I
continue to use the #lambda method instead, which is more readable to
me. The lambda calling syntax “.()” is a nightmare, it completely
defeats the meaning of parentheses. Together, things like this can be
done:

    x = ->{"foo"}
    puts x.()
    # => foo

Or even this:

    ->{puts("foo")}.()

And both are valid Ruby. But it does definitely not look like Ruby. It
looks like some functional programming language, and I don’t like that.
The Ruby programming language I imagine has a high value on
readability, and I therefore do not use such constructs, nor do I
recommend use of them.

Vale,
Marvin

···

Am Sat, 18 Jun 2016 23:15:06 -0700 schrieb Jae Lee <jaequery@gmail.com>:

now, my question is, do you think it is okay for me to continue using
the rocket hash syntaxes and even evangelize about keeping it that
way?

--
Blog: http://www.guelkerdev.de
PGP/GPG ID: F1D8799FBCC8BC4F

Hi,

No problem for using old hash-rocket syntax.

              matz.

···

In message "Re: i am still using the old symbol hashes instead of the json hashes" on Sat, 18 Jun 2016 23:15:06 -0700, Jae Lee <jaequery@gmail.com> writes:

sorry if i'm beating a dead horse with this topic but i really can't stand
the new json hashes in ruby.
the problem isn't the syntax (the syntax is great), it's just that it
breaks the consistency of the language to a degree i can't tolerate.
i picked up ruby 2 years ago (coming from PHP) and fell it love with it
because it was the only language that i found who actively promotes the
element of least surprises, which i whole heartedly love. PHP was going
through some major changes that i didn't really like at the time, mostly
their increasing infatuation with Java.
over the years as i get older and more experienced, i find that simplicity
is the biggest thing one should look for in a programming language. any
languages that aren't straightforward don't interest me anymore. but now
with ruby's new json hash syntax, it throws off the love i have about the
language. i continue to use and will always use the old rocket hash to make
my codes more consistent but i fear that i will create conflicts down the
line as more and more ruby devs turn to json hash 100%. i for one, think
the symbols should be presented as symbols (:), but in json hashes the
symbols don't necessary require (:), which bugs me a lot. i strive for
elegance and simplicity so as minute of an issue this is, it just irks the
heck out of me.

now, my question is, do you think it is okay for me to continue using the
rocket hash syntaxes and even evangelize about keeping it that way?

--
Kind Regards,
Jae

the new json hashes in ruby.

at this point, your confusion is clear.
the ruby doc only mention a new hash notation, it does not mention of
any "json hash".

..as more and more ruby devs turn to json hash 100%. i for one, think the
symbols should be presented as symbols (:), but in json hashes the symbols
don't necessary require (:), which bugs me a lot.

ditto

i strive for elegance and
simplicity so as minute of an issue this is, it just irks the heck out of
me.

the ruby doc is sometimes too simple, and may suffer lack. some basic
rules examples may be needed to provide clarity, eg, the ff should be
at least stated:

1) the new hash notation applies only to symbol keys [*]
2) the new hash notation requires that there should be no space
between the key and the colon (:slight_smile:
3) if the key name does not follow nor pass the identifier name rule,
one needs to quote it. or simply put, it must follow the rule for
creating a symbol

examples:
A. the ff example fails, dont do it:

{a : 123}

SyntaxError: unexpected ':', expecting =>
{a : 123}
    ^

{1: 123}

SyntaxError: unexpected ':', expecting =>
{1: 123}
   ^

{1_a: 123}

SyntaxError: unexpected tIDENTIFIER, expecting =>
{1_a: 123}

B. the ff passes. do these.

{a: 123}

=> {:a=>123}

{"1": 123}

=> {:"1"=>123}

{"1_a": 123}

=> {:"1_a"=>123}

{a_1: 123}

=> {:a_1=>123}

note that in the examples, ruby converts the notation to the clearer
rocket notation of the hash

now, my question is, do you think it is okay for me to continue using the
rocket hash syntaxes and even evangelize about keeping it that way?

sure : )

kind regards
--botp

[*] note, symbols in javascript is new. it was introduced in es6.

···

On Sun, Jun 19, 2016 at 2:15 PM, Jae Lee <jaequery@gmail.com> wrote:

I also prefer to use the hash-rocket syntax.
Nice to know it is not going away in the near future.

···

On Sun, Jun 19, 2016 at 2:56 PM, Yukihiro Matsumoto <matz@ruby.or.jp> wrote:

Hi,

No problem for using old hash-rocket syntax.

                                                        matz.

In message "Re: i am still using the old symbol hashes instead of the json > hashes" > on Sat, 18 Jun 2016 23:15:06 -0700, Jae Lee <jaequery@gmail.com> > writes:

>sorry if i'm beating a dead horse with this topic but i really can't stand
>the new json hashes in ruby.
>the problem isn't the syntax (the syntax is great), it's just that it
>breaks the consistency of the language to a degree i can't tolerate.
>i picked up ruby 2 years ago (coming from PHP) and fell it love with it
>because it was the only language that i found who actively promotes the
>element of least surprises, which i whole heartedly love. PHP was going
>through some major changes that i didn't really like at the time, mostly
>their increasing infatuation with Java.
>over the years as i get older and more experienced, i find that simplicity
>is the biggest thing one should look for in a programming language. any
>languages that aren't straightforward don't interest me anymore. but now
>with ruby's new json hash syntax, it throws off the love i have about the
>language. i continue to use and will always use the old rocket hash to
make
>my codes more consistent but i fear that i will create conflicts down the
>line as more and more ruby devs turn to json hash 100%. i for one, think
>the symbols should be presented as symbols (:), but in json hashes the
>symbols don't necessary require (:), which bugs me a lot. i strive for
>elegance and simplicity so as minute of an issue this is, it just irks the
>heck out of me.
>
>now, my question is, do you think it is okay for me to continue using the
>rocket hash syntaxes and even evangelize about keeping it that way?
>
>--
>Kind Regards,
>Jae

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

It’s less that the notation is converted, but that when serializing a hash for display in irb, the `Hash#inspect` method doesn’t have a special case for when the key is a symbol.

···

On 20 Jun 2016, at 3:46, botp wrote:

> {a: 123}
=> {:a=>123}

note that in the examples, ruby converts the notation to the clearer
rocket notation of the hash

Hi,

I also prefer to use the hash-rocket syntax.
Nice to know it is not going away in the near future.

Don't worry. I will never go away.

In addition, your feeling may come from syntax cognition.
In JavaScript, it uses ':' instead of hash-rocket (=>).

  ["a": 1, "b": 2]

In Ruby, ':' is used only for symbol keys,

  [a: 1, b: 2]

So symbol mark (:slight_smile: always comes with identifiers, in different order.

              matz.

···

In message "Re: i am still using the old symbol hashes instead of the json hashes" on Sun, 19 Jun 2016 18:29:32 +0100, Daniel Ferreira <danieldasilvaferreira@gmail.com> writes: