Any tips on coming from PHP?

If you mean Zeal then I tried that in the past and this is nowhere near Dash (unfortunately).

Not ware of Zeal. What I have tried in the past on Linux was indeed Dash or am I getting confused :thinking:

Now it seems for Mac only. From the link above :slight_smile:

1 Like

I’m late to the party, but I just want to add that when you look at PHP and Elixir from a distance and squint your eyes, there’s a lot of similarities in the execution model. People like to point and laugh at PHP but in many ways it’s just Phoenix/Plug done 20 years earlier.

Notably, PHP is stateless between requests (except if you use it in uncommon ways, eg ReactPHP). Every HTTP request starts a PHP thread, runs your code, returns a response, and exits. Every PHP request cycle is isolated, if you want to keep state to use between requests, you need to put it elsewhere (eg a database, some text files, a caching lib, somewhere).

Per the Rich Hickey definition of immutability, you could say that PHP is a purely functional programming language on the HTTP level, ie it uses only the data in an HTTP request to produce a response. Sure, you can mutate variables. But that’s all local, internal, isolated. There’s no state, except in external services.

Now, this is totally the same as what Phoenix does with HTTP requests, except not in a thread but in a lighter-weight Erlang process. The biggest difference you’ll notice is that it’s easier to store some state in the same BEAM application (but, like with PHP, not in the request process).

Eg where in PHP you might need to store data in a database or in a session, in Elixir you can spin up your own, self-programmed processes to keep track of state that you can use between various requests, or to kick off some background processing. These are the GenServers and friends that Elixir people love to rave about. In other words, Elixir lets you do everything PHP would let you do (except for loops and extract $$var), but it also lets you keep state right inside your application and run stuff in the background.

Often you won’t need to do that. Eg for typical CRUD apps, you’ll follow a pattern that resembles PHP extremely much. Get a request (phoenix / php will spin up a process / thread), do some DB requests, produce a response (phoenix / php will kill the process / thread). And if you want, you can do all kinds of background processing, caching (eg with ETS or Cachex), realtime websocket-y stuff as well. But even then, your HTTP request handling will not deviate from what you’re used to in PHP. Only all the other stuff is different. You might not need any of that other stuff when you begin.

So Elixir is really just PHP with more curlies, fewer dollar signs and semicolons, a little bit less locally mutable state and a little bit more globally mutable state.

2 Likes

And there is a PHP implementation in Erlang,

1 Like