dbsimmons64

dbsimmons64

What is (and isn't) converted from Elixir to Javascript?

Hi All

Just started looking at Hologram and think it has huge potential. Is there a list of what does, and doesn’t work when converting from Elixir to JavaScript. I was looking to validate that a form field was a valid number and had the following

elixir

case Integer.parse(params.event.value) do

      {int, _} -> int

      :error -> :error

end:


```

When running the code I get the following error in the console:

runtime.entry.js:364 Uncaught HologramBoxedError: (FunctionClauseError) no function clause matching in Integer.count_digits/2

The following arguments were given to Integer.count_digits/2:

    # 1
    "1"

    # 2
    10


I’m assuming this is because Integer.parse doesn’t yet convert to JavaScript. Of course I could be completely wrong and this is a silly error on my part.

cheers

Most Liked

bartblast

bartblast

Creator of Hologram

Hey @dbsimmons64,

Elixir functions are transpiled automatically to JavaScript by Hologram. However, at the very bottom layer, they use Erlang functions which need to be ported by hand to JavaScript. The detailed process is described here: Hologram Elixir -> JS compilation - #6 by bartblast

If some Erlang function isn’t yet ported, an error with details about the missing function is displayed in the browser console. However, that’s not what you encountered here.

The error you’re seeing with Integer.count_digits/2 was due to problems with bitstring segments handling in the client-side implementation. However, even after fixing that initial bitstring handling issue, you would have eventually encountered errors about missing Erlang function ports that Integer.parse/2 depends on. So there were actually two layers of problems: first the bitstring patterns handling, and then missing Erlang functions underneath.

Good news:

I’ve just released v0.6.3 that fixes the client-side support of Integer.parse/2. Both the bitstring handling issues and the missing Erlang function dependencies have been resolved, so your code should work now after updating.

Current project stage:

At this stage of the project, if something doesn’t work it’s usually a small thing and I typically fix it within 24 hours - just like with your issue!

Going forward:

I completely agree - we need more transparency about which Erlang functions are missing. I’ve been thinking recently about creating some initiative to help me port the rest of the functions. The process is actually quite simple, especially with the help of AI tools (it’s a perfect use case for them), but it’s time-consuming for me as I’m juggling many other aspects of the project like new features, core functionality, etc.

If you’re interested in helping with Hologram development, porting these Erlang functions would be the perfect way to contribute! Each function is relatively straightforward to implement, and I’m happy to review pull requests and provide guidance.

dbsimmons64

dbsimmons64

Thanks so much @bartblast for the detailed explanaition. I’ll take a look at the link you’ve provided to see if I can better understand the process (if so I’d love to help out). Cheers.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
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
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
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
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

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
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
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement