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 Responses

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

Where Next?

Popular in Discussions Top

pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
sergio
There’s a new TIOBE index report that came out that shows Elixir is still not in the top 50 used languages. It also goes on to call Elix...
New
Qqwy
I would like to spark a discussion about the static access operator: .. For whom does not know: it is used in Elixir to access fields of...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New

Other popular topics Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
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 47930 226
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement