sashaafm

sashaafm

I’d like to know what are your opinion between building a Web App using embedded Elixir/Phoenix (.eex files), where the data is being passed with the render function to the template, like so:

<%= if @var do %>
  It is obviously true
<% else %>
  This will never appear
<% end %>

vs. separating the frontend (with Javascript and AngularJS maybe) from the backend, using Phoenix to serve a RESTful API:

$http({method: 'GET', url: '/some/phoenix/api/resource'})

What are the advantages and situations where each one is better suited? Are there any use cases where they should be mixed? (particularly does Phoenix mix well with Angular?)

For a simple information system, I think embedded is more than enough but for more modular, better structured and to allow frontend and backend developers to work concurrently the latter is better. Also, separating makes the backend development easier since you just have to build on the :api pipeline instead of both :browser and :api pipelines.

The main disadvantage (for me at least) when separating the frontend from the backend is to have to use a lot of Javascript which I personally hate and find difficult.

Showing Posts 1 to 10

OvermindDL1

OvermindDL1

Well using embedded it is significantly easier to internationalize if that is important for your project first of all.

Personally I would go with embedded regardless unless I want/need a single-page-app, in which case phoenix would just be an API endpoint.

zimt28

zimt28

I’m currently rebuilding an SPA app, which I had built in Meteor using Phoenix. Rendering things on the server again, like I’ve done “in the past” makes things so easy again! Also, comparing the two, the SPA solution didn’t feel or responds faster. There are some places where I need JS, but I will just use Vue.js or so where is makes sense.

Just because everyone builds SPAs now doesn’t mean it’s always the best solution!

andre1sk

andre1sk

It highly depends on your particular application.

sotojuan

sotojuan

Depends on your app but for the most part you can do a good ol’ server rendered app—it’s much easier too.

StefanHoutzager

StefanHoutzager

Internationalization can be done by creating a json serverside with screendefinitions: language dependent labels, errormessages etc. which can be used to render the ui clientside. Can be done via a phoenix channel also. But I like to have a ui that does not know about the other layers so that I could switch the backend when needed. And I did not care to learn a bit of js.

OvermindDL1

OvermindDL1

Yeah that is basically what I’d done, just a map of default strings to internationalized strings for the currently logged in user, defaulting to using the existing string if not in the map. Just feels like a hack.

StefanHoutzager

StefanHoutzager

To me .eex and the likes in other languages always felt like a hack. At the start of <% I begin to cringe. :slight_smile:

sotojuan

sotojuan

And React’s JSX/Angular’s HTML doesn’t? It’s just a template and in Phoenix’ case it’s a function that gets called and replaces tags with data.

I’m having trouble figuring out why it is a hack. Care to explain further? I’m interested.

StefanHoutzager

StefanHoutzager

I explained it before in this thread (wherein you also wrote so the explanation might be already familiar)):

Michal Kunikowski has made remarks in this thread that could interest you also.

sotojuan

sotojuan

I guess for me separating Elixir and “HTML” is not so much separation of concerns rather than separation of technologies. I still think server side REST MVC solves 90% of business’ needs, but I’m old fashioned :smiley:

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews