Hacker News new | past | comments | ask | show | jobs | submit | nesarkvechnep's comments login

Another area where FreeBSD excels.

It’s good but has nothing on Phoenix LiveView. I love Common Lisp but for web, I can’t choose it over Elixir.

I agree, but this was about Lisp :) I hope it will get there though; I like CL more... The author of CLOG seems to be interested on how to improve it so.

Unpopular opinion but the BSDs are better OS for learning and hacking C. Super stable, amazing documentation, predictable, nice libraries included.


You obviously haven’t ran anything on the BEAM (Erlang’s VM).


Correct. Erlang also uses green threads?


Yes. And immutable data structures.

When data is immutable, it can be freely shared. Changes to the data essentially uses copy-on-write. And it only writes the delta change, since you don't need a deep copy due to immutability. Add that the garbage collectors of Haskell and Erlang are designed to work with a high allocation rate and have 0 cost for dead data, and this is much faster than what people think.

The way you implement a webserver in either Haskell or Erlang is rather trivial. Whenever there's an incoming request, you make a thread to handle it. So you don't have 1 webserver serving 10k requests. You have 10k webservers serving 1 request each. And since they are started from the same core data, they'll share that due to immutability. See also old-style Apache or PHP and fork().


Web servers handling lots of small requests are actually pretty easy to garbage collect to: you just delete all the data at the end of the request.

Either you have a specialised GC that works like this, or probably a good general generational GC can pick up on this pattern on its own.


Or you do as Erlang's BEAM VM: each thread has it's own memory area which is GC'ed individually. This means upon request termination, you just terminate the thread and the memory is reclaimed with no need for a GC.


In the abstract, this is very similar to spawning a unix process for every request, never free-ing any memory, and letting the memory allocation die with the process.


No reason. OC probably thinks that immutable data structures are always copied when being operated on.


Yes indeed, unless you use ropes or other specialised structures


Lists aren’t copied on prepend.

Tries (like scala’s Vector) or trie maps (the core map types of Scala, Clojure and probably Haskell?) aren’t copied on updates.

In fact, whether a data structure is an immutable or persistent data structure or merely an unmodifiable data structure (like Kotlin uses) is based on whether it requires full copies on most updates or not. In FP languages, immutable data structures aren’t “specialized” at all.


> whether a data structure is an immutable or persistent data structure or merely an unmodifiable data structure...

This hurt my brain. It seems that in some places (e.g. Java land) unmodifiable refers to something that you can't modify but could just be a wrapper around a structure that can be modified. In that case they use immutable to mean something that is nowhere modifiable.

I may be misrepresenting this idea, but I think the terminology is so poor that it deserves to be misunderstood.


Think about mutability in Java land this way:

  // Using mutability.
  // `increment` is void, and makes 2 bigger for everyone.
  increment(2); 

  // Typical Java "safety".
  // It's still void, but now it throws a RuntimeException
  // because the developers are saving you from making everyone's 2 bigger.
  increment(2);

  // Immutable
  // Returns 3
  increment(2);


Doesn't it depend on the data structure? Eg prepending to a list is actually cheaper with immutable data structures: you keep the original list and add a new head pointing to its head. Now you have two lists available in your program, but only one stored in memory. Yay!


Well luckily, Haskell is full of said "specialized structures."

containers and unordered-containers handle most of your needs and they only copy their trees' spines (O log n) on update.


Haskell also support eg arrays with O(1) in-place updates just fine.


Not really. You might want to look into “ Purely functional data structures” by Chris Okazaki.


Come to FreeBSD, we have just that - jails.


yup! FreeBSD jails are essentially what OP wants with chroot++.

I was pretty puzzled when Docker and LXC came around as this whole new thing believed to have "never been done before"; FreeBSD had supported a very similar concept for years before security groups were added in Linux.

Jails and ezjail were stellar to make mini no-overhead containers when running various services on a server. Being able to archive them and expand them on a new machine was also pretty cool (as long as the BSD version was the same.)


this whole new thing believed to have "never been done before";

Nobody with knowledge of sandboxing believed this, Virtuozzo and later OpenVZ had been on Linux for a long time after all. Virtuozzo was even from a similar time frame as FreeBSD jails (2000-ish).

The key innovation of Docker was to provide a standardized way to build, distribute, and run container images.


Virsh had worked for a long time before docker came around, but yeah… you essentially had to build your own Docker-like infrastructure that only you were using


Solaris Zones too. Absolute magic, many years before Docker and friends.



Of course not but it's JavaScript, why don't we pile more on top of the garbage mountain.


Not expert enough in pub/sub to tell whether these are sufficient, but perhaps these two functions could be folded into built-ins?


It’s subpar at the moment.


The OC is the type of person to tell you the problems of C are all skill issues.


Always have been (⌐■_■)


Because no one else cares to ask, are you running FreeBSD? I ask because you use ZFS.


Debian!


Damn, a stud! ZFS on Linux.


Ahaha :)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: