Live data from Hacker News

What do you call this in Ruby?

github.com

51–60 of 69 posts

Re: What do you call this in Ruby?

#51
post #6

This sums up what I dislike most about Scala (which is an even worse offender in this regard). A rule of thumb: if a 10-year-old wouldn't be able to intuitively read the operator, use words.

People say that. But it's totally misguided IME. You're talking about scalaz.

Normal Scala code has fewer symbols than Ruby aside from function lifting (the underscore).

In fact, you've got Generics (square braces), curly braces for blocks, fatty arrows for call-by-name, functions parameters and pattern matching. Parens for methods and tuples. Underscore for function lifting. cons (double or triple colon). Stab by arrows as an optional shorthand infix notation for creating Pairs AKA Tuple2.

Every once in a blue moon you might see :+ to mean add a single item.

You can write a whole heckuva lot of Scala and never use much more than that. If you're facing symbolic overload then you should probably reevaluate the libraries you're using.

The only ones I use frequently that add anything else are spray-routing/akka-http's Route.~ to concatinate routes and json4s's JObject.~ to concatinate two objects together.

Yes there's a world of libraries that add a lot more, but they're entirely optional. You aren't a bad programmer if you do or do not use scalaz. (At least I don't consider myself a bad one, and I don't.)

Scala itself doesn't actually extend all that far beyond c#. The FUD around symbols in Scala is just that. You add cons, the occasional stabby arrow and the underscore and you've got the extent of Scala's additions you'll find in your average library.

I just do not get how people walk away with this impression. Especially Rubyists where ivars, cvars, pipe characters, two different HashMap styles etc is in everyday code.

IME Scala developers in-training don't actually have much trouble with this stuff. What they have trouble with is pattern-matching structure and function composition.

But Ruby can't do either.

In fact, other than the ability to invent more complex DSLs with more symbols I'm not actually sure that there's anything Ruby does better. Or more consistently.

Re: What do you call this in Ruby?

#52
post #20
post #12

A select few operators (out of hundreds) for a single Haskell library: https://github.com/ekmett/lens/wiki/Operators (For full disclosure, the lens library is infamous for this.)

You are perfectly fine importing the module Control.Lens.Combinators[0], which has the full functionality of lens except the operators. There's nothing you can do with operators but can't do with normal functions named with words. [0]: http://ekmett.github.io/lens/src/Control-Lens-Combinators.ht...

Oh, definitely. Haskell approach to operators and overloading is exactly the Right Way: operators are weirdly syntaxed function, and you can add your own. No need to make bit-shifting do IO.

Re: What do you call this in Ruby?

#53

Meanwhile: Mathematica 10.0 for Mac OS X x86 (64-bit) Copyright 1988-2014 Wolfram Research, Inc. In[1]:= FullForm[x->y*z^w] Out[1]//FullForm= Rule[x, Times[y, Power[z, w]]] In[2]:= x\[UnionPlus]y\[RightTee]z Out[2]= x ⊎ y ⊢ z There's no reason your programming language shouldn't be able to tell you what these things are called in English without an external reference.

Some operators are so abstract that they don't really have a good name.

Eg if you are talking about groups in general, how do you pronounce the group operation ∘? At uni, we usually just called it Kringel.

Re: What do you call this in Ruby?

#55
post #46

Earlier quoted context omitted.

For those wondering, here's the request: https://github.com/JuanitoFatas/what-do-you-call-this-in-rub... Here's the response: Hi Christian, thanks for the Pull Request! But I think this is not appropriate rubygems/rubygems#124. :bow:

Can someone explain to me, why this is not appropriate?

Sperm comes from ejaculate. Ejaculation is a bodily function. Bodily function is likely not going to be proper in a professional environment.

Re: What do you call this in Ruby?

#56
post #32
post #8

Earlier quoted context omitted.

Written words are symbols as well. What should we do when we don't understand words?

We Google them, which is an impossible task for non-alphabetic symbols. :P

I wonder at what point people started to expect that search engines can instantly provide all the answers to everything worth knowing. The correct place to find a word you don't know is a dictionary. The correct place to find a symbol in code that you don't know is the definition in the source code (or language reference if it's baked in), or simply ask someone who knows.

Re: What do you call this in Ruby?

#57
post #8

Earlier quoted context omitted.

Written words are symbols as well. What should we do when we don't understand words?

Slippery slope argument. I like the Litmus test that a ten year old should be able to read them, which means that +, *, / and - are fine but =~> and other nonsense should be banned.

Most people who write software are not children. I certainly hold my doctor, accountant, mechanic, etc to a higher standard. Why should we expect software developers to be no better than children?

Re: What do you call this in Ruby?

#58
post #46

Earlier quoted context omitted.

Can someone explain to me, why this is not appropriate?

Sperm comes from ejaculate. Ejaculation is a bodily function. Bodily function is likely not going to be proper in a professional environment.

Really? What about sleep/wake?

Re: What do you call this in Ruby?

#59

Earlier quoted context omitted.

Slippery slope argument. I like the Litmus test that a ten year old should be able to read them, which means that +, *, / and - are fine but =~> and other nonsense should be banned.

Most people who write software are not children. I certainly hold my doctor, accountant, mechanic, etc to a higher standard. Why should we expect software developers to be no better than children?

We're specifically talking about operators and finding a way to determine if they are universally known.

If the wording bothers you, replace it with "We should only accept symbolic operators that are taught up to sixth grade".

Re: What do you call this in Ruby?

#60

Earlier quoted context omitted.

Most people who write software are not children. I certainly hold my doctor, accountant, mechanic, etc to a higher standard. Why should we expect software developers to be no better than children?

We're specifically talking about operators and finding a way to determine if they are universally known. If the wording bothers you, replace it with "We should only accept symbolic operators that are taught up to sixth grade".

Also prohibited: == (children learn =), &&, ||, |, ^, %, ++, --, != (children learn ≠), ~, >.

& is maybe allowed. Sixth graders don't know about bitwise operations, but they know & means "and". That's stretching things a bit, though.

Is [] allowed for indexing? When I learned about arrays in sixth grade... No, wait, I didn't learn about arrays in sixth grade. For that matter, I didn't learn about functions using (): those are only for grouping expressions. Functions are just like, "sin 90". Also, since I didn't learn about code at sixth grade, I obviously didn't learn about using {} to delimit code blocks; , was only used in prose, not in mathematics.

Having said that, it's unclear why programming languages should be limited to operators that we can guarantee "sixth grade" students (whatever that happens to mean in your part of the world) will have heard of.

What actual benefit could it bring, other than (maybe) making it easier for somebody who hasn't learned a language to guess the meaning of a piece of code in that language? Is that benefit worth making code twice as long and rendering half the keyboard useless?

    main() {
      printf("hello, world\n");
    }
Should, I assume be:

    the main procedure is:
      the message is "hello, world" plus a new line;
      display the message;
      stop.
Anything else will be too confusing for the many sixth graders currently working professionally as programmers.
Post reply on HN