lud

lud

Status vs State

Hi,

I hope this is not too silly as a subject but I need your input, specially from native english speakers.

If you look at gen_fsm, you will see that the State is generally a short term, like open or close, while the term Data contains, well, the data of the FSM.
In a GenServer, the term state can be short but will often contain more than that, generally multiple maps, monitors, caches, etc. Since my beginnings in Erlang, I used to call state the representation of the data carried along in some process or group of functions.

Then there is the word status. In french, we have statut, which is a literal transaltion, and can be used to describe a single word representing a person status, like the facebook status “single” or “engaged” (don’t know the real english terms for facebook).

I am working with Java developers who use status to represent the full state of an entity, a system, etc. whereas state is generally implemented with a Java enum, like ONLINE, OFFLINE, etc. We extensively use both words and I am sometimes confused when I have to name things.

From my research it seems that they are right, and that state should be a short term like in gen_fsm, and status should be the more complex data structure.

So I would like the opinion of Erlang/Elixir developers because in those languages the state word is also used extensively to represent data structures.

Thanks!

Most Liked

John-Goff

John-Goff

This one is really up in the air in my opinion, I could see arguments made in either direction. My gut instinct as a native English speaker is to say that the state would be a more complex representation and status would be a shorter, more ephemeral bit of data. I’m also biased by my experiences though, so I’m probably more naturally inclined to the elixir/erlang way of doing things.

dimitarvp

dimitarvp

As a non-native English speaker, I had the same impression. Status is stuff like “order has been paid”, or “message delivery failed”, or “rent is past due” etc. It’s often just one small piece of data, bound to one object.

State on the other hand feels much more like a bigger thing that’s being kept somewhere persistently. You can say that your building’s utility payments is state (usually kept on paper by one person). Also your taxes are state. An Ecto.Changeset is a state that you pass around and maybe modify and pass the new version to another function. A database is state. :ets cache is a state. Redis / Kafka queues are state.

ityonemo

ityonemo

Also to pdimitar’s comment I would also say that by convention, status is not only “short” but also usually taken from a finite and enumerated set of options

Last Post!

derek-zhou

derek-zhou

I am no native English speaker, but I’ll give my 2 cents anyway.

Status sounds like an abstraction, something that will last for a while, eg: IRC status, marital status.

State when used in this sense feels like much more short term, ephemeral, eg: state of mind.

Where Next?

Popular in Discussions Top

AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
owaisqayum
I have a sample string sentence = "Hello, world ... 123 *** ^%&*())^% %%:>" From this string, I want to only keep the integers, ...
New
shishini
I think this twitter post and youtube video didn’t get as much attention as I hoped I am still new to Elixir, so can’t really judge ...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement