Live data from Hacker News

How I fell in love with Erlang

boragonul.com

201–210 of 263 posts

Re: How I fell in love with Erlang

#201
post #107

Earlier quoted context omitted.

Mutation should be an advanced topic in programming teaching. Even in procedural languages. It should be seen as an optimization technique you only use when analysis has shown that to be the only way to solve a difficult bottleneck. Using mutation as a basic tool in programming was a mistake.

Yes, see SICP (Structure and Interpretation of Computer Programs).

I saw it. That’s how I know it.

Re: How I fell in love with Erlang

#202
post #18

I can totally relate to this. Programming in Erlang felt so natural compared to the knots I was twisting myself into writing C++. I was churning out C++ code, but wasn't having fun. Suddenly Erlang made it fun and programming became addictive.

> Suddenly Erlang made it fun and programming became addictive. I'm saying this with complete sincerity: WHAT IS IT THAT YOU PEOPLE SEE!? What is the fun? What are you addicted to? Typing and seeing the output? Solving a problem? I feel like I am missing out on some amazing life altering experience when I see people state that. The same thing I have with the article - what does it mean to love a programming language?

For me, strictly immutable and side-effect free programming was a forcing function* to make me really decompose problems into isolated parts. Only when I could do that could I truly say I understood the problem (and its distinct sub-problems) in full.

In that sense, Erlang isn’t really different from any other functional programming except that it also ships with a lot of actor / message passing concurrency dogma which solves a different and equally delightful set of problems (low-bug concurrency) at the same time.

So it’s a double hit of two great ideas in one paradigm.

*Oops, no pun intended.

Re: How I fell in love with Erlang

#203

Earlier quoted context omitted.

64 bit ints are a thing in JS for a while now

No, they aren't. You have to use BigInt, which will throw an error if you try to serialise it to JSON or combine it with ordinary numbers. If you happen to need to deserialise a 64-bit integer from JSON, which I sadly had to do, you need a custom parser to construct the BigInt from a raw string directly.

[deleted]

Re: How I fell in love with Erlang

#204

Earlier quoted context omitted.

Unfortunately very little is trivial for me. Personally I have found the real value of Erlang to be internally between trusted nodes of my own physical infrastructure as a high-level distributed "brain" or control plane for health monitoring, config distribution (env vars, static config files, etc), smart failover decisions etc. Keep the “outside view” (HTTP, SMTP, DNS) all standards-based OSI, internally mapped to d…

This stands to reason. If you need to bridge different languages together like in your case, they need to speak a common tongue. REST/GrahQL/gRPC solve this problem in different ways. There is no technical limitation keeping you from serving HTTP traffic from Erlang/Elixir, but from my own experience it isn't a pleasant experience. JavaScript or Python are dead simple, until you realise that 64-bit integers are not a…

> There is no technical limitation keeping you from serving HTTP traffic from Erlang/Elixir, but from my own experience it isn't a pleasant experience.

I would be interested in what was unpleasant? I've run inets httpd servers (which I did feel maybe exposed too much functionality), and yaws servers and yaws seems just fine. maybe yaws_api is a bit funky, too. I don't know the status of ACME integration, which I guess could make things unpleasant; when I was using it for work, we used a commercial CA, and my current personal work with it doesn't involve TLS, so I don't need a cert.

> you can probably even share Erlang's equivalent of file descriptors across servers (haven't tried, correct me if I'm wrong)

Ports are not network transparent. You can't directly send to a port from a different node. You could probably work with a remote Port with the rpc server, or some other service you write to proxy ports. You can pass ports over dist, and you can call erlang:node(Port) to find the origin node if you don't know it already, but you'd definitely need to write some sort of proxy if you want to receive from the port.

Re: How I fell in love with Erlang

#205
post #22

> X equals X plus one? That’s not math. That’s a lie. That's really interesting... My wife, who has no real mathematical background had the EXACT same reaction when I was trying to teach her some simple programming. I tried to explain that equals in that context was more of a storage operator than a statement that said line is true. She found it very frustrating and we gave up on the endeavor shortly thereafter. I've…

Tell her there are transparent subscripts on each use of =.

x(0) = 1

x(1) = x(0) + 1

There's no way to reference the subscripts. They're implicit and the language manages it for you. Ask her to think of the Kronecker delta function and it's definition.

Re: How I fell in love with Erlang

#206
post #125

Earlier quoted context omitted.

Thats interesting. In my case, elixir does take a longer time. Probably because i dont get used to or just use it not as frequent as other languange. Would you mind telling me your elxir program about? Is it a webapps or something similar?

One of the features I really like about the BEAM is that it solves the problem of organizing the topology of the applications I build. It's unlikely you're even close to doing this in other languages / frameworks. The supervisor tree is one of the killer-app features of BEAM. I hit the benefits of this ALL the time. I notice how it keeps getting solved over and over again in unique ways that are half-baked. In some w…

There are matured ways to do multi-service outside of BEAM. I get that it's extra work vs something built in, but this is only an issue at large scale, and you'd probably need to set that up anyway unless every service is Erlang/Elixir.

Re: How I fell in love with Erlang

#207
post #187
post #182

Earlier quoted context omitted.

Erlang's hot reload is a two-edged blade. (Yes yes, everything is a tradeoff but this is on another level.) Because it's possible to do hot code reloading, and since you can attach a REPL session into a running BEAM process, running 24/7 production Erlang systems - rather counterintuitively - can encourage somewhat questionable practices. It's too easy to hot-patch a live system during firefighting and then forget to…

You certainly can forget to push fixes to the source repo. But if you do that enough times, it's not hard to build tools to help you detect it. You can get enough information out of loaded modules to figure out if they match what's supposed to be there. I had thought there was a way to get the currently loaded object code for a module, but code:get_object_code/1 looks like it pulls from the filesystem. I would think…

You can run https://www.erlang.org/doc/apps/kernel/code.html#modified_mo... in some process and make it send notifications to your monitoring when anything stays modified for too long.

Re: How I fell in love with Erlang

#208

The only thing holding me back from Erlang is the lack of type checking. Convince me?

You might like https://gleam.run/ , another BEAM language but with type-checking. https://tour.gleam.run/basics/type-checking/

Gleam compiles to Erlang. So you can skip Erlang entirely but get all of the BEAM and ecosystem's benefits.

Gleam is very much worth checking out. It's syntax is very nice and natural feeling.

Re: How I fell in love with Erlang

#209

Took me a long time to figure out what gets lost with Erlang is: a) Ubiquity — everything understands HTTP. Erlang nodes only talk to Erlang (or a compatible runtime) b) Because there are no middleware standards (REST, GraphQL, OAuth, etc.), you must build or integrate your own abstractions c) Giving up infrastructure (reverse proxies, load balancers, CDNs), You handle distribution yourself or through OTP design d) I…

It's a Galapagos island full of stuff that evolved independently.

Concurrency is important, but if you are not familiar with concurrency primitives like mutexes, condition variables, barriers, semaphores, etc. and skipped directly to the actor model, that's a bit like you care a lot about concurrency while not caring at the same time.

Functional programming is great, but your CPU has registers and the way it works is closer to the imperative paradigm.

Re: How I fell in love with Erlang

#210
post #18

I can totally relate to this. Programming in Erlang felt so natural compared to the knots I was twisting myself into writing C++. I was churning out C++ code, but wasn't having fun. Suddenly Erlang made it fun and programming became addictive.

> Suddenly Erlang made it fun and programming became addictive. I'm saying this with complete sincerity: WHAT IS IT THAT YOU PEOPLE SEE!? What is the fun? What are you addicted to? Typing and seeing the output? Solving a problem? I feel like I am missing out on some amazing life altering experience when I see people state that. The same thing I have with the article - what does it mean to love a programming language?

Every coder has parts of programming they love, and parts they hate. Additionally, they have a mental model of what is risky, and what isn't. Languages, by their design, will make some things easier and some things harder, and so when people "love a language," they typically mean "it maps to what gives me dopamine."

A good example is mutable state: for a bunch of people, functional languages that enforce immutability has this calming effect, since you know your data isn't mutating where you can't see it. You've been burned by C++ code that's passing references as arguments, and you don't know if the list you received as an argument will be the same list after you've passed it as an argument to a different function. You don't know if you can futz with that list and not make a problem for someone somewhere else.

But for most people, they much prefer how "intuitive" it is to have mutable state, where they just change the thing in front of them to be what they need. This is especially true in the context of for loops vs. recursion: "why can't I just use a for loop and increment a counter!" A lot of Golang folks love that it explicitly rejects functional mapping primitives and "all you need is a for loop."

It's a very personal decision, and while IMO it doesn't really matter for the ultimate business success (usually companies fail because of something that's not tech-related in the least), it does shape _how_ it feels to work on a tech stack, and I'd argue, what kinds of technical problems you run into.

Post reply on HN