Live data from Hacker News

How I fell in love with Erlang

boragonul.com

251–260 of 263 posts

Re: How I fell in love with Erlang

#251

Earlier quoted context omitted.

> just as long as you don't run out of call stack And with tail-call you don't even need to worry about that :)

Of course, that assumes that you write your functions so that they can be converted into iteration! Did you know that some C/C++ compilers will do tail-call -er- optimization? I learned this quite a while ago, so I'd expect every major C/C++ compiler to do it by now, but I was pretty impressed at the time.

> Of course, that assumes that you write your functions so that they can be converted into iteration!

I was indeed assuming this, however due to my lack of compiler knowledge, not explicitly writing your functions--at least in the classic way--doesn't necessarily mean you Erlang functions won't be optimized. See section 2.3 [0]

Though again, I don't know shit about compilers and while I can imagine what callER optimized calls could look like, I would need some examples!

[0] https://www.erlang.org/docs/19/efficiency_guide/myths

Re: How I fell in love with Erlang

#252
post #100

Earlier quoted context omitted.

Lets count the number of comercial sucesful released games that don't use mutability or object orientation.... I can't find any.

> Lets count the number of comercial sucesful released games that don't use mutability or object orientation.... > > I can't find any. They use it, but the best tend to minimize mutability. And as for object orientation- merely 'having classes' is not the same thing.

Unreal, Unity, Godot, Source, virtually every game engine is object oriented.

Re: How I fell in love with Erlang

#253
post #100

Earlier quoted context omitted.

Lets count the number of comercial sucesful released games that don't use mutability or object orientation.... I can't find any.

> Lets count the number of comercial sucesful released games that don't use mutability or object orientation.... 1) I suspect game engines that Carmack designed towards the end of his career are built in a largely-functional style. He's on record [0] as thinking that writing code in a functional style is generally a good thing to do. 2) Running on the BEAM doesn't mean that you give up mutability. In my experience wi…

How many games in Erlang have been released?

Re: How I fell in love with Erlang

#254

Earlier quoted context omitted.

Of course, that assumes that you write your functions so that they can be converted into iteration! Did you know that some C/C++ compilers will do tail-call -er- optimization? I learned this quite a while ago, so I'd expect every major C/C++ compiler to do it by now, but I was pretty impressed at the time.

> Of course, that assumes that you write your functions so that they can be converted into iteration! I was indeed assuming this, however due to my lack of compiler knowledge, not explicitly writing your functions--at least in the classic way--doesn't necessarily mean you Erlang functions won't be optimized. See section 2.3 [0] Though again, I don't know shit about compilers and while I can imagine what callER optimi…

> ...while I can imagine what callER optimized calls could look like...

What do you mean by "callER" optimized calls? That's a term I think I'm quite unfamiliar with.

> Though again, I don't know shit about compilers...

Oh, I also know fuckall about compilers. I'm just a bumbler who has muddled through a moderately-successful programming "career".

IME, on the topic of recursive functions, the big difference between Erlang and -say- a C++ program compiled with GCC is that the latter has a specific (but surely configurable somehow) call stack size limit which terminates the program if you exceed it. Whereas Erlang's limit seems to be "Well, how much RAM do you have, and how much space do I need to store away the arguments for each call?".

When I mentioned that some C/C++ compilers do tail-call optimization, what I intended to say was that they converted the recursive call into something more like iteration. I'm pretty sure that historically [0] the only way you could do this optimization is if the very last thing a function did was to call itself... doing anything after that call meant that the conversion to iteration was not possible. I have no idea if things have gotten quite a lot fancier in the years since I made this discovery and now.

If Erlang had a call stack whose size was limited by something other than the available RAM in the system, then whether or not your functions were written tail-recursive [1] would be quite a lot important, I think.

[0] And maybe it's still the case today? Refer back to my near-zero knowledge of compilers.

[1] I hope I don't forget that term again. It's much more succinct than my jumble about "tail-call optimization"

Re: How I fell in love with Erlang

#255
post #253

Earlier quoted context omitted.

> Lets count the number of comercial sucesful released games that don't use mutability or object orientation.... 1) I suspect game engines that Carmack designed towards the end of his career are built in a largely-functional style. He's on record [0] as thinking that writing code in a functional style is generally a good thing to do. 2) Running on the BEAM doesn't mean that you give up mutability. In my experience wi…

How many games in Erlang have been released?

Oddly enough, you can write in a functional style in most any programming language. It's true!

And (as a fun fact) did you know that Crash Bandicoot, Jax and Daxter, and many other Naughty Dog games were written in Lisp? I expect that more video games sold at retail back in the day were -whether entirely or just in part- written with weird languages and runtimes than we would expect.

But, to answer your question: I don't pay much attention to who's doing what in video games, so I don't know for sure. Folks often talk about using Erlang for video game servers, but not so often about video game frontends.

I do know that Erlang's said to be a pretty bad fit for -say- 3D video games that require high raw performance. Sections 1.3 and 1.4 of the Erlang FAQ [0][1] provide a decent idea of the sort of things for which it is and is not a good fit. Particularly relevant would be these excerpts:

  What sort of applications is Erlang particularly suitable for?
  Distributed, reliable, soft real-time concurrent systems.
  ...

  What sort of problems is Erlang not particularly suitable for? 
  ...
  The most common class of 'less suitable' problems is characterised by performance being a prime requirement *and* constant-factors having a large effect on performance. Typical examples are image processing, signal processing, sorting large volumes of data and low-level protocol termination.
  ...
  Most (all?) large systems developed using Erlang make heavy use of C for low-level code, leaving Erlang to manage the parts which tend to be complex in other languages, like controlling systems spread across several machines and implementing complex protocol logic. 
But you should really read those sections of the FAQ for yourself (while remembering that they were written like twenty years ago).

Also relevant is this excerpt from Learn You Some Erlang's introduction chapter in the "Don't drink too much Kool-Aid" section, written in ~2010: [2]

   Erlang is no silver bullet and will be particularly bad at things like image and signal processing, operating system device drivers, etc. and will shine at things like large software for server use (i.e.: queues, map-reduce), doing some lifting coupled with other languages, higher-level protocol implementation, etc. Areas in the middle will depend on you. You should not necessarily wall yourself in server software with Erlang: there have been cases of people doing unexpected and surprising things. One example is IANO, a robot created by the UNICT team, which uses Erlang for its artificial intelligence and won the silver medal at the 2009 eurobot competition. Another example is Wings 3D, an open source 3D modeler (but not a renderer) written in Erlang and thus cross-platform.
Having said that, I play a lot of video games. Based on what I've seen, I expect that most indie video games these days could easily eat the constant factor introduced by using Erlang for coordination.

Having said that, with the existence of Unity and Unreal Engine, along with the documentation and assets built for both, why would you?

[0] https://www.erlang.org/faq/introduction#idm27>

[1] Those FAQ sections have remained largely unchanged for something like twenty years. Computers have gotten much faster (and the Erlang VM and compiler have gotten much better) over that time, making the "constant factors" introduced by Erlang smaller than they once were.

[2] https://learnyousomeerlang.com/introduction#kool-aid>

Re: How I fell in love with Erlang

#256
post #155

Earlier quoted context omitted.

That's absolutely terrible and hilarious at the same time.

Same guy as 'MongoDB is web scale'. I wish they'd done more videos; they're hilarious.

How on earth did I miss this for 12 years? Thanks, the MongoDB video is one of my favorites ever and now I can add this to the lore

Re: How I fell in love with Erlang

#258
post #253

Earlier quoted context omitted.

How many games in Erlang have been released?

Oddly enough, you can write in a functional style in most any programming language. It's true! And (as a fun fact) did you know that Crash Bandicoot, Jax and Daxter, and many other Naughty Dog games were written in Lisp? I expect that more video games sold at retail back in the day were -whether entirely or just in part- written with weird languages and runtimes than we would expect. But, to answer your question: I d…

It was not written in LISP, but a LISP dialect, called GOOL.

Wich means:

GAME ORIENTED OBJECT LANGUAJE....

The example you gave about how functional laguages can make comercial videogames... has objects at the core of its design.

Re: How I fell in love with Erlang

#259
post #120
post #100

Earlier quoted context omitted.

Lets count the number of comercial sucesful released games that don't use mutability or object orientation.... I can't find any.

Meh, I remember hearing that no one would release a commercially successful game in a managed language with a GC 15 years ago. Time flies. Most things are said to be impossible until someone tries to do it anyway.

15 years ago the xbox 360 store was already full of games made in c#.

If 15 years ago you said games can't run on managed laguages you knew nothing about videogame development.

Re: How I fell in love with Erlang

#260
post #258

Earlier quoted context omitted.

Oddly enough, you can write in a functional style in most any programming language. It's true! And (as a fun fact) did you know that Crash Bandicoot, Jax and Daxter, and many other Naughty Dog games were written in Lisp? I expect that more video games sold at retail back in the day were -whether entirely or just in part- written with weird languages and runtimes than we would expect. But, to answer your question: I d…

It was not written in LISP, but a LISP dialect, called GOOL. Wich means: GAME ORIENTED OBJECT LANGUAJE.... The example you gave about how functional laguages can make comercial videogames... has objects at the core of its design.

> The example you gave about how functional laguages can make comercial videogames...

No. As I said:

> I expect that more video games sold at retail back in the day were -whether entirely or just in part- written with weird languages and runtimes than we would expect.

Post reply on HN