Rich_Morin

Rich_Morin

I’m curious whether anyone is using AI (really, LLM) assistance in coding Elixir (especially in Livebooks). If so, which chatbots (etc) seem to be working the best?

Showing Posts 1 to 10

CharlesIrvine

CharlesIrvine

I use ChatGPT quite a bit by asking - “How do I do this using Elixir?” The answers are usually pretty good. Here’s a question I just asked today along with the response:


My question:

Using Elixir, how do I check to see if two lists have the same members, regardless of the order?

ChatGPT said:

ChatGPT

In Elixir, you can check if two lists contain the same members, regardless of order, by sorting each list and comparing them. This approach works because sorting ensures both lists will have the same order if they contain the same elements.

Here’s a simple example:

def same_members?(list1, list2) do
  Enum.sort(list1) == Enum.sort(list2)
end

Example Usage

same_members?([1, 2, 3], [3, 2, 1]) # returns true
same_members?([1, 2, 3], [3, 2, 2]) # returns false

This approach works well for lists with unique elements. However, if you have large lists and performance is a concern, you might consider using a different approach that doesn’t require sorting, such as converting the lists to maps of element counts and comparing those.

You said:

Are you sure there isn’t a built in function that does this check?

ChatGPT said:

ChatGPT

You’re right; Elixir actually has a built-in function for this exact purpose: Enum.frequencies/1. By using it, you can create a frequency map for each list and then compare those maps directly, which is both efficient and concise.

Here’s how you can do it:

def same_members?(list1, list2) do
  Enum.frequencies(list1) == Enum.frequencies(list2)
end

Example Usage

same_members?([1, 2, 3], [3, 2, 1]) # returns true
same_members?([1, 2, 3], [3, 2, 2]) # returns false

Using Enum.frequencies/1 is beneficial because it directly compares the counts of each unique element in each list, which avoids sorting and is faster for large lists.

AndyL

AndyL

I just had Claude 3.5 Sonnet write a 50 line bash script. With Claude: 5 mins. Without Claude: 20-30 mins. For me, standalone scripts are a sweet spot for the LLMs.

sbuttgereit

sbuttgereit

A lot of discussion on the general point in this recent discussion: Current status of LLMs writing Elixir code

My initial comments from that thread: Current status of LLMs writing Elixir code - #5 by sbuttgereit

regex.sh

regex.sh

I use Claude and o1 for brainstorming mostly (almost never for code and syntax)
And Perplexity for asking syntax stuff (it provides references)
I’m waiting for good multi-agent system and open-source LLM to fine-tune some model on elixir and use it as programming assistant (similar to o1-mini)

Eiji

Eiji

Brilliant! If you know better then why using ChatGPT :joy:

Maybe for “old, good” language like a Bash. In Elixir LLMs have often no idea about types they use.

I use various models from time to time for this purposes, but only if I’m seriously stuck. I can’t trust LLMs after what I experienced in past. :+1:

What? Even if we don’t count writing message on chat then still chat bots are replying after few seconds … Simply bookmark Syntax reference @ Elixir’s documentation and use Ctrl+F (or equivalent on your OS). It should be much faster and you would avoid false results. I really understand that “AI” is good for research (especially if you forgot the naming), but using it for syntax sounds like a overcomplicating problems way too much.

If there would be model focused on Elixir then I would also be interested. Hopefully it would not make so terrible mistakes, see my post:

I’m against calling LLM an AI. It’s producing too stupid answers to call it intelligence at all. That’s said I’m not against LLMs at all. They could be really useful even in current state as long as they would be used properly. You have to be aware that the answers may be completely wrong, see:

So …

I really don’t recommend it. Using LLMs for Elixir regularly in current state would cause you more problems than solve. Prefer it for research and remember to be as descriptive as possible. You can also probably use it as a “smart” code snippet generator, but really nothing more than that.

AndyL

AndyL

Maybe for “old, good” language like a Bash . In Elixir LLMs have often no idea…

Yeah. Would it be possible to proactively train an LLM to be very proficient at Elixir? How would it be done?

CharlesIrvine

CharlesIrvine

I can see why you were confused. Not a good example.

On some occasions, when you ask how to do something, you do get back a very acceptable answer, but sometimes you don’t. In those cases, if you ask again, maybe with a little different wording, you might get back a better answer.

CharlesIrvine

CharlesIrvine

Good question. I think I saw that with an Azure OpenAI subscription, you can do this. It’s not free though.

Eiji

Eiji

I understand that, but:

  1. It’s your assistant and not inversely :smiley:
  2. It can’t be called “AI” then
  3. Nobody can lose a job because of such problematic tool
CharlesIrvine

CharlesIrvine

All true!

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 92995 915
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
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
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews