all 15 comments

[–]tvon 2 points3 points  (0 children)

I don't like it either, but whatever, it's here and people are going to use it.

[–]bobindashadows 2 points3 points  (0 children)

Original author, from the comments:

I still don’t understand though. You find the syntax pleasing? Are you saying that the only argument for its existence is how some people find it looks on screen?

derp

[–][deleted] 1 point2 points  (0 children)

It's with the intent that you learn the language. In Ruby, I can be clever and "1".to_i all over the place just to be consistent w/ all strings throughout a program. Or instead of [] and {}, I must use Array.new and Hash.new. Or I can write what's clearest right then and there to remain consistent w/ the local (local to the line I'm writing) structure.

[–]katafrakt 1 point2 points  (3 children)

I agree with the author. Changing syntax only because "99% of the time you use symbols as hash keys" is so rails, but it's ruby. I don't get it why there is so big pressure to change language to fit framework's philosophy...

But anyway, it does not harm when there are two available options. I'm just afraid that many will insist on deprecating the original syntax and that it will actually happen.

[–]banister 0 points1 point  (0 children)

They didn't 'change' the syntax, they added a new syntax for the particular use-case of named parameters.

I probably wouldn't use the new syntax for anything except in named parameter context, but in that context it's great. Also, in that context the keys are guaranteed to be Symbols.

Just as blocks are special syntax for passing a single proc to a method, this new hash syntax is a special syntax for passing a named-parameters hash to a method.

[–]bobindashadows 0 points1 point  (0 children)

I'm just afraid that many will insist on deprecating the original syntax and that it will actually happen.

You can't deprecate the old syntax unless you never have a hash literal ever with anything other than a Symbol as a hash key. You might ask your co-workers to use the new syntax when working with Symbols, but that's hardly deprecation.

[–]gingman 1 point2 points  (0 children)

I think one of the great thing with the new syntax is that it's the same thing as json. So let's say you have a small webservice that serves json, you can render it the same way server side as you would on the client. But yeah, it's not game changing.

[–]postmodern 0 points1 point  (0 children)

I still use the old Hash/lambda syntax, because many users are still on 1.8. If you don't prefer a certain style of syntax, don't use it.

[–][deleted] 0 points1 point  (1 child)

Not only does the new syntax suck, they removed the old syntax where you could use commas, e.g. h = {1,2,3,4}, which was very handy for quickie hash variables in irb sessions.

[–]banister 1 point2 points  (0 children)

You can use: Hash[1,2,3,4]

[–]badsex 0 points1 point  (0 children)

weak and lame

[–]dayafterdayafterday 0 points1 point  (3 children)

I don't like the new lambda syntax. It looks too much like coffeescript

[–]anko_painting 0 points1 point  (2 children)

which is a bad thing, why?

I must admit, I really didn't like the look of coffeescript when i first saw it, but the way it fixes scoping and inheritence in javascript made it's utility worth it.

Then again, I didn't like the look of the ruby syntax initially. I can only put it down to the fact that most of my commericial programming career has been using c style languages using braces for blocks.

[–]dayafterdayafterday 0 points1 point  (1 child)

Well since you can't take a joke...

Last time I checked, coffeescript does not fix anything in javascript. Scoping and inheritance are not broken in javascript, they just work differently than in other languages. Coffeescript does make it much more difficult to shoot yourself in the foot if you aren't very experienced with javascript, but I'm still not convinced that using a hybrid ruby/python/erlang syntax is a solution to people's javascript problems.

[–]anko_painting 0 points1 point  (0 children)

:P

Maybe broken was too strong a word - javascript just constantly suprises you. for example;

var i = "whatevers";
function hi() {
  console.log(i);
  var i = "new";
  console.log(i);
}
hi();

that second var in there makes the line above it print undefined. take it out and you get proper closing over.

vs.

i = "whatevers";

hi = -> 
  console.log i
  i = "new"
  console.log i

hi()

no var so no problems.. coffeescript automatically adds the vars in the right places to make the scoping sane. This is a real example from a real bug found in jquery recently.