bryanjos
Hi, I just published version 0.23.0 of Elixirscript.
https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md
Most of the changes are around JavaScript interop now that Elixirscript uses the Elixir compiler to compile and load files during compilation. This also means you can define macros in the same file now. Another bonus is that this release makes it a bit easier to share code between Elixir and Elixirscript.
That’s about it. Try it out and any feedback is always helpful.
Trending in Announcing
Hey everyone!
Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application.
This library uses Erlang esaml to provide
plug enabl...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
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
Hi all!
I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas.
You...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
This showed up on my feed.. anyone heard of it? Just hype?
Ox Alpha is a reasoning model designed for coding, sustained ag...
New
It’s not that it’s vocabulary is too advanced. It’s something worse.
I get lost trying to follow even a paragraph written by Claude. It’...
New
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
Introductory paragraph
I’ll be looking for a keen junior or someone that has a couple of years experience in the real world (so you’ve be...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 42 to 33- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
tme_317
Hmmm… maybe you would like using OCaml syntax instead of ReasonML syntax (both compiled to JS by Bucklescript) if you want a less verbose syntax. Although in that case not sure how you can use JSX. There is the bucklescript-tea project but instead of JSX it uses an Elm-style list-of-list representation of the DOM.
Maybe someone knowledgable over on the ReasonML Forums would know how you could use ReasonReact and JSX (which like you said is just calls to
React.createElement) with the less verbose OCaml syntax. It must be possible I’ve just not seen examples.I’m not as interested in the syntax but the excellent inferred typing (without using TS or Flow) is the big win for me. Biggest drawbacks is having to find (or write) bindings to random 3rd party JS libraries (if you need them) and the relatively small (but friendly) community. Anyway it might be close to what you are looking for.
English3000
Funny that you mention that. I literally came across Reason earlier today.
The thing is I’d argue Reason is a step down from JavaScript in terms of syntax.
In all, I’m really happy with React and JSX–I just miss the feeling I have when writing Elixir code, where every character is meaningful.
My issue with JavaScript’s at times slightly verbose syntax is it creates mental friction for me. Imagine reading a made up dialect of English that put “to” in front of all verbs and “a”, “an” or “the” in front of all nouns–
–It isn’t necessary and makes the sentence harder to read. I have to use effort to filter out these meaningless filler words in order to understand what I’ve written (or debug, for that matter).
English3000
That said, in all honesty, I would advocate for a redesign.
The concept to keep in mind is to think of JavaScript as a virtual machine for the browser. Then, ElixirScript should build on top of JavaScript in the way Elixir builds upon Erlang. This means that if I put JS in an EXJS file, the JS will work (interoperability). So ElixirScript is just the building block that converts Elixir to JavaScript. It shouldn’t have opinions.
Next, we use React as the structure for our JSX. React should be implemented as a behaviour. It should require a
@spec render(props :: map, state :: map | pid)function or macro that accepts ado:block with JSX. If implemented as a string, there is already the syntax to interpolate Elixir code. Then the string can be converted to JS, which can handle the parsing. It would be nice to have a JSX linter for.exfiles though.Beyond that, the
Reactbehaviour should allow for optional lifecycle methods (e.g.mount,unmount), a constructor (maybe call itinitto follow Elixir convention), and I’d argue for an optionaldatamethod, ideally modeled after Relay…Last, I would suggest a documentation revamp.
A great starting point for using plain ElixirScript would be a
socket.exin a Phoenix project. I’d love to see an example of this, or receive enough instruction from the documentation that I would know how to set this up for myself.And a final note: I really like your implementation of state inside of a process. I think this is really powerful because then the backend and frontend can now share the same state (SEE: “Functional Web Development with Elixir” re: stateful servers). Add in Mnesia (in-memory database) and your React/React Native app will be faster than anything out there.
Reviewing React’s implementation notes, I definitely think the role of ElixirScript should simply be to convert Elixir to JavaScript. Likewise, React.EX should simply convert to React components.
I think you’ve already built those parts. I just want to see them refactored to be closer to the React experience.
English3000
Googling, JSX has not yet come to Elixir… Anyone know off the top of one’s head about other languages that have implemented it?
I found this article. In a nutshell, JSX syntax is merely syntactic sugar for an AST of
React.createElementcalls.If you’ve seen the library
Shorthand, it allows one to create maps with JS-like behavior:m(item) => %{item: item}. For ElixirScript, you could simply have a functionjsx(type, props, children)that evaluates to the JS equivalent.bryanjos
ElixirScript works at a level where if you can do what you defined in standard Elixir, it’s work in ElixirScript. I’d be interested if anyone did what you prescribed. There was an ElixirScript issue open for almost a year about JSX but nothing really came about from it.
tme_317
I know this isn’t exactly what you are envisioning embedded directly into Elixir but have you looked at ReasonML with ReasonReact?
That’s what I am happily using to get JSX with elixir style “module”/component structure you are talking about (no explicit importing/exporting) and great type inference.
English3000
In the JSX article, there is a quote:
The analogy here is:
I.e. Yes, Elixir is more powerful than JS–that’s why we’re replacing it. But, I hope you’d agree that JSX is a better DSL for the frontend.
From an implementation standpoint, this may mean creating a JSX DSL for Elixir (like Phoenix’s Ecto is for SQL queries).
I.e. Keep React’s design patterns and JSX. Replace JavaScript’s syntax with Elixir’s.
Actually, you don’t even need to handroll the DSL. You can just have a special
rendermacro which accepts ado:block with JSX as its last argument.English3000
I wanted to offer some feedback:
I am glad you have been working on compiling Elixir to JS. But what I’d really like to see is a ReactJS-like experience on the frontend. What I mean by that is:
keep the modules structure of Elixir, where anything in the project can be accessed without needing to know the specific file path or explicitly export anything
keep the ability for Elixir syntax to be transpiled to JavaScript
I’ll elaborate on the third point.
My main beef with JavaScript is the syntax includes meaningless, “boilerplate” characters. Conversely, I really like JSX. While it’s already too late and doesn’t mean much coming from a stranger, I think you went in the wrong direction with a DSL different from JSX.
I wish I could write a file like this:
This would render the text
webon your computer orscreenon your phone.acrolink
Any usage examples / use cases mates?
tmbb
I haven’t looked at the source, but from the blog: