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

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54092 488
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement