bodhilogic

bodhilogic

Macros for Program Generation

I watched a video in the forum (which I can’t find now) about someone generating pretend OOP code for Elixir as a joke and jab at OOP.

That video got me thinking…

Is it possible to use macros to roughly translate an OOP, web-framework, PHP application into Elixir?

I’m not talking generating 100% correct and compile-able Elixir but rather, a library of macros to do most of the heavy lifting of the conversion, followed by whatever amount of manual code clean-up is necessary to get the Elixir code compile-able/runnable?

Failing that, has anyone ever tried to convert a large PHP web application into Elixir? What were the gotchyas and pain points?

Most Liked

dimitarvp

dimitarvp

The library should be this: OOP.

OOP in the BEAM VM (and thus also Elixir) is mostly made possible by tuple calls. Relevant and good discussion: Tuple Calls.

However, Erlang OTP 21.0 is released and, well:

“Tuple calls” have been removed from the run-time system.

Not sure if the OOP library is making use of those; there should be other ways but IMO the OTP 21 release signals that the Erlang maintainers are not focused on supporting such mechanisms of the BEAM and thus, indirectly, are not interested in emulating OOP. I am not informed about the exact reason though (most likely a technical and not a conceptual one I’d guess), just giving you some pointers if you want to research further.

Last Post!

bodhilogic

bodhilogic

Thanks for your answer.

I wasn’t looking to mimic OOP behavior in Elixir, but rather take PHP code that happened to be in a OOP paradigm and rewrite all of the PHP code (ignoring the mechanics that enables the OOP to work correctly) into Elixir code.

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
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
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
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 40082 209
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement