Ruby Ruby Mistakes

blacktulip · 2013年01月17日 · 最后由 skandhas 回复于 2013年01月17日 · 2212 次阅读

https://gist.github.com/c8188956cd66c38feb1f

Ruby Mistakes

  • Using blocks for looping and callbacks
    • break/next/return semantics in blocks extremely bizzare
    • And they have different behavior in procs vs. lambdas
  • Why on earth does defined? return a string?
  • throw/catch. Why!
  • Inline rescue, no ability to specify what exception (and by extension, "catch anything" behavior common in community)
  • Mutable objects have a hash method and can go in Hashes. Why!!!
  • Extremely complex grammar, makes barrier to entry for implementation much higher
  • Special case of flip-flop and regexp in an if statement (only if it appears syntactically though!)
  • Setting $= to something truthy causes all string operations to become case-insensitive. This and other magic globals from perl are mind blowing.
  • Keywords that silently override methods by the same name (defined?, on Rubinius block_given?)
  • f {}. Tell me what the parsing of that is.
  • proc, lambda, block, method, unbound method, functions. None of which have a clear relationship. set_trace_func exists, even though you can't pass functions around.
  • Bizzare magic:: def f Proc.new end f { |x| 3 } How does Proc.new know where the block came from?
  • Ruby's module system makes namespacing optional (and off by default).
  • Regexp with named matches decompose into local variables. Dear lord why.
  • Encoding system is beyond broken
  • Scopes: constants, class vars, instance vars, methods, locals. wtf.
  • Constants aren't constant. Truth in naming.
  • Thread locals are really fiber locals.
  • You can change the encoding of a string. Just jesus christ wow.

这就是 Ruby 啊

目測作者是用 python 的。。 呃。。 貌似還是 django 開發團隊

很浓的酸味 ......

需要 登录 后方可回复, 如果你还没有账号请 注册新账号