Live data from Hacker News

Learn You Some Erlang for Great Good (2013)

learnyousomeerlang.com

21–28 of 28 posts

Re: Learn You Some Erlang for Great Good (2013)

#21

Earlier quoted context omitted.

I’m not sure there is a huge advantage at the beginning, perhaps even a disadvantage because of the ease of use of Elixir. As you get more advanced you start using Erlang here and there to access things not in Elixir. For example, Elixir only has lists not arrays, so if you need a good indexed data structure you end up using some Erlang. Also once you start getting into Mnesia etc, Erlang is the way. All this said, s…

I guess this depends on what you mean by "end up using some Erlang". If you mean that you end up calling certain library functions and such which are written in Erlang from Elixir.... well, yes, and you need to by design. But I'd argue calling a function written in Erlang or from Erlang's standard libraries isn't the same as having to write Erlang code. I use Erlang's ETS, its in-memory key-value store, quite a lot f…

> You are correct that Elixir doesn't have arrays and only lists... but that's also true of Erlang.

Erlang has the array module, which IIRC uses lists of tuples internally to simulate arrays. I assume that's what they are referring to.

Re: Learn You Some Erlang for Great Good (2013)

#22

Earlier quoted context omitted.

Oh boy. One of the things I have been doing to test if an LLM is 'there yet' by my standards is if it can spit out solutions in elixir without hallucinating packages that don't exist to get the job done. Since I haven't tested since chatgpt 4 came out I dunno where it's at for that but always felt like a decent litmus test.

I find that Claude 3.5 does a very admirable job. I only rarely see incorrect code and more frequently see recommendations for older libraries or obsolete versions of real libraries as compared to hallucinated libraries. I've been playing with Claude 3.7 thinking and, perhaps unsurprisingly, I find it overthinks the problem or tries to do far more than I really want it to for any prompt. I expect that I'm just using…

In any LLM it helps to use simple tricks to give it a few extra prompts like 'No blabbling' and 'Keep your code example simple and to the point without adding anything exrta' still but there's all sorts of research on optimization for getting better results from just how you frame your interaction with it in different and more exacting and concise wording:

https://github.com/jxzhangjhu/Awesome-LLM-Prompt-Optimizatio...

Really a lot of stuff you'd find in any university/college English course for academic writing style for getting your point across clearly applies as well:

https://alum.mit.edu/succinct-writing-guide

https://owl.purdue.edu/owl/general_writing/academic_writing/...

https://writingcenter.unc.edu/tips-and-tools/conciseness-han...

Personally though I've been avoiding its use in code and keeping it to where it shines. I've said this over and over. It's so good for writing drivel like copy and product descriptions and instagram posts and SEO-able text content. Stuff that people have been used to sounding kinda fake for decades if not over a century by now, that I have no heart to write myself but I can now literally just tell a robot to "increase engagement" and it shows in $$$.

Where I've found limits in what it can generate with code is with complex concurrency stuff that you really need to have knowledge about yourself to be able to prove isn't going to crash. The kind of stuff that you might pick up Elixr or Go for, specifically, I have always found it hits serious problems generating that kind of stuff. You need serious engineers who know stuff like TLA+, coq, spin etc to get that right if you're making systems that peoples lives or finances might depend on. I worry there's a lot of generated code being put out there in production which is not taking these things into consideration and people are just like 'wow it compiles, ship it'

Re: Learn You Some Erlang for Great Good (2013)

#23
I have used Erlang when elixir still had to emerge. Today, I am using Elixir, with Phoenix LiveView and OTP Genserver, Supervisor and ETS.

I would start with Elixir, if only because of its newbie friendly community. The Erlang community is reflected in the 'erlang in anger' book.

But if you need to deploy on a small platform, say 32 bit 100MBytes, Erlang is the way to go.

Re: Learn You Some Erlang for Great Good (2013)

#24

I have used Erlang when elixir still had to emerge. Today, I am using Elixir, with Phoenix LiveView and OTP Genserver, Supervisor and ETS. I would start with Elixir, if only because of its newbie friendly community. The Erlang community is reflected in the 'erlang in anger' book. But if you need to deploy on a small platform, say 32 bit 100MBytes, Erlang is the way to go.

Please know that both languages share a lot (the BEAM). Either will do to get to know the technology.

You can decompile bytecode to erlang .

Re: Learn You Some Erlang for Great Good (2013)

#25
post #21

Earlier quoted context omitted.

I guess this depends on what you mean by "end up using some Erlang". If you mean that you end up calling certain library functions and such which are written in Erlang from Elixir.... well, yes, and you need to by design. But I'd argue calling a function written in Erlang or from Erlang's standard libraries isn't the same as having to write Erlang code. I use Erlang's ETS, its in-memory key-value store, quite a lot f…

> You are correct that Elixir doesn't have arrays and only lists... but that's also true of Erlang. Erlang has the array module, which IIRC uses lists of tuples internally to simulate arrays. I assume that's what they are referring to.

Interesting. I didn't know about that module. But just like I asserted earlier... I don't need to write in Erlang to use that module:

  $ iex
  Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:20:20] [ds:20:20:10] [async-threads:1] [jit:ns]
  Interactive Elixir (1.18.1) - press Ctrl+C to exit (type h() ENTER for help)
  iex(1)> my_array = :array.new()
  {:array, 0, 10, :undefined, 10}
  iex(2)> my_array = :array.set(0, "test 1", my_array)
  {:array, 1, 10, :undefined,
   {"test 1", :undefined, :undefined, :undefined, :undefined, :undefined,
    :undefined, :undefined, :undefined, :undefined}}
  iex(3)> my_array = :array.set(1, "test 2", my_array)
  {:array, 2, 10, :undefined,
   {"test 1", "test 2", :undefined, :undefined, :undefined, :undefined,
    :undefined, :undefined, :undefined, :undefined}}
  iex(4)> my_array = :array.set(2, {:a_test, :test_tuple}, my_array)
  {:array, 3, 10, :undefined,
   {"test 1", "test 2", {:a_test, :test_tuple}, :undefined, :undefined,
    :undefined, :undefined, :undefined, :undefined, :undefined}}
  iex(5)> my_array = :array.set(3, %{test_field: "test map"}, my_array)
  {:array, 4, 10, :undefined,
   {"test 1", "test 2", {:a_test, :test_tuple}, %{test_field: "test map"},
    :undefined, :undefined, :undefined, :undefined, :undefined, :undefined}}
  iex(6)>
That is using the Erlang array module directly from the Elixir REPL, including such fancy features as rebinding on the single variable name `my_array`.

The Erlang docs say this about the underlying data type: "A functional, extendible array. The representation is not documented and is subject to change without notice. Notice that arrays cannot be directly compared for equality."

Based on my REPL test, at least when the element count is small, it looks like they're using tuples; specifically a tuple nested inside another tuple where the outer tuple is defining the array metadata.

I think the reason I've not used the Erlang module is that the Elixir Enum module (https://hexdocs.pm/elixir/Enum.html) is sufficient for the cases where I'd want some sort of indexed data structure. Typically though if I'm indexed I'm really after some sort of associative array and maps are sufficient for that case.

Re: Learn You Some Erlang for Great Good (2013)

#27
post #9
post #5

For those familiar with BEAM-based languages, are there any advantages to choosing Erlang over Elixir when starting a new project?

I've used both heavily and I'd have to say no. You are in general better off with Elixir, with easy access to all Erlang and Elixir libraries, all BEAM functionality, a better package manager and build tool, and a more modern feeling / easier to learn programming language. Also starting to see a progressive type system and just a much faster developing ecosystem in general. I think by now there's also more open sourc…

It's still a good idea to look at an Erlang book like this one. Kind of like natural languages, it's handy to be able to read Erlang even if you don't or can't write it. There's a lot of older literature, Erlang, pre-Elixir, that is worthy of study.

Re: Learn You Some Erlang for Great Good (2013)

#28
post #5

For those familiar with BEAM-based languages, are there any advantages to choosing Erlang over Elixir when starting a new project?

There are moments in which you will need to know Erlang to debug issues on an Elixir application.

Granted that for many Elixir devs, knowing (and learning) Erlang happens during such debugging efforts.
Post reply on HN