Do you have any alternative or ‘better’ names for things in programming?

Have you ever come across a word or phrase about something and thought “hang on, this other word better describes that!”?

If so this thread’s for you!

Simply give us the name/term/meaning/etc …and maybe prepare yourself for a little resistance :lol:

Does idea for this thread came from Python master/slave debate? ;D

4 Likes

I keep wanting to write about how there are two kinds of objects.

Facts and Actors

These are both modelled by objects in the OOP world and I think there are things from the OOP world that can be applied to writing elixir/erlang programs but only if you recognise this difference.

A fact is immutable and an Actor changes over time.

4 Likes

Wouldn’t facts be “value objects” and actors be “entities” in DDD vernacular? https://enterprisecraftsmanship.com/2016/01/11/entity-vs-value-object-the-ultimate-list-of-differences/

1 Like

More or less. Though I dislike that “value objects” still includes the word “object”. That’s been lost to overuse.
Rich hickey talks about facts that are true for ever so I use that term

3 Likes

Nope :lol: I was thinking more along the lines of things like Map :101:

1 Like

As in “maps” a “key value” to a “value”.

Is this because Ruby calls it a Hash? (Seemingly focusing more on how something is accomplished - rather than why it exists in the first place).

Python calls it a Dictionary (implying “looking things up”).

ES2015 introduced Map - which is always in danger of being ignored because people use Objects as makeshift maps.

4 Likes

It’s in danger of being ignored because of inconvenient syntax :wink:

1 Like

I feel put_assoc/4 in Ecto gives the wrong impression. In my opinion, It reads like you are adding one or more associations and not working with an entire collection. Something along the lines of set_assoc/4 when working with all (ie. deleting existing associations) and put_assoc/4 when adding one or more in addition to the existing associations would be cool.

4 Likes

I was thinking of the Map function :slight_smile:

In many programming languages, map is the name of a higher-order function that applies a given function to each element of a functor, e.g. a list, returning a list of results in the same order. It is often called apply-to-all when considered in functional form.

I know it has roots in mathematics, but still, to me it doesn’t really feel right. Would Enum.all or Enum.apply (or apply_all) feel more natural?

Well, it would probably be confused with Enum.all?/2

I’m not sure about that one, as we already have Kernel.apply, which takes a list as the last argument, therefore Enum.apply could be thought of as a argument switch to Kernel.apply, similar how some String and Regex functions correlate to each other.

If at all, lets take this one, but still I do prefer map

1 Like

That did cross my mind too :lol:

Good point :slight_smile:

That’s probably my fave too. Btw, I am not suggesting it is changed in Elixir - it’s just something I remember thinking was odd when I first learned about it (in Ruby)… and wondered if anyone else had wondered similarly about other things :smiley:

I do like it when languages feel natural though - in the sense that you think something might do what you want, and it does. I think that makes learning the language a lot easier.

So this is not immediately an answer to your question, but very much related: I have been thinking in the past about naming things in general, and I actually think that it might be helpful to create some kind of Thesaurus of what things are commonly called in computer code, with both an ‘etymology’ (how it came to be) as well as a ‘reasoning’ (why it still is used, and when you should one alternative over another).

Take words like ‘wrapper’, or ‘widget’, or ‘divider’, or ‘handler’, or when to use ‘library’ vs 'package, or ‘scheduler’ vs ‘periodic tasks’. When to use ‘reader’ as name for something, and when to use ‘scanner’ instead.

7 Likes

That’s a great (fun!) idea Qqwy!

Perhaps it could be done in conjunction with the glossary we are thinking of introducing?

https://elixirforum.com/t/do-you-think-we-need-a-glossary-section/12988

1 Like

Ruby -> Gems
Crystal -> Shards
Elixir -> Hex packages Drops
:grinning:

8 Likes

Maybe you weren’t introduced to the notion that in y = f(x) f simply “maps” values of x to values of y. So when you have a bunch of x values, map uses f to produce the bunch of corresponding y values while maintaining the “shape” of the bunch (typically a list but it doesn’t have to be).

2 Likes

I don’t think so, because they don’t capture the essence that map creates a list of the results

1 Like

Well, since this seems like a thread that invites throwing a bomb and running away…

RECURSE IS NOT A WORD

When you have a recurrence of a function on the stack, that function has recurred. Recursion is to recur.

So get off my lawn you damn kids!

5 Likes

Please don’t :joy:

1 Like

Can we extend this slightly to complain about names in specific packages or modules in the standard library?

  • AssertValue should become Approve, and assert_raise val should become approve val and after the value was approved by the user it should automatically change to approved val == expected.

  • GenServer shoud become GenericServer. Gen reminds me of a generator somehow.

  • I don’t like the name Agent, but I don’t really have anything better to suggest… Honestly I’m not sure I like agents that much.

  • The name ExUnit assumes we’re using unit tests. But it’s also usefull for all kinds of tests, like property tests, integration tests, etc.

3 Likes