Better HN
topnewbestaskshowjobs
Log inSign up

randomstudent

122 karma · joined Jun 27, 2017 (9y ago) · 46 submissions

Submissions

comment 9y ago · link · parent

> At least for my operation it looked very much like I would really need to become a BEAM vm expert to make sure things ran smoothly

From someone with zero experience in building concurrent systems: isn't this true for every sufficiently complex system? If your system is complex enough, then no general framework will help much, right?

comment 9y ago · link · parent

> "for" needs to be implemented as a special form as it emits some optimizations that are only available at the Core Erlang level.

That's interesting. I wonder if a future Elixir version could have a way of defining macros which sould emit these optimizations. Is this a likely direction for future developments?

> "with" needs to be implemented as a special form as it has different lexical properties than a bunch of nested cases.

Could you expand on this a little? What are those different lexical properties?

comment 9y ago · link · parent

Yes.

Superficially, `do ... end` blocks look like English, because they are English words. On the other hand, they don't really correspond to any real grammar construct of the English language. They live in the the uncanny valley where you try to read it like English, but you can't actually read it as such. For some reason, the use of keywords like `def`, `defmodule` or `defmacro` doesn't bother me as much. Maybe because they are not block delimiters?

In my opinion, braces, delimiters or parenthesis create less visual noise than endless cascades of `end` keywords:

    def f(x) do
      ...        
          end
        end
      end
    end
There are other block keywords besides `end`, which serve no purpose other than simplify some keyword list arguments at the cost of higher complexity.

In general there is too much syntax sugar for things that don't really benefit from it.

Parenthesis in function calls are optional in some places but not others, which creates some unnecessary confusion.

The syntax for anonymous functions is

    fn arg -> do ... end
The `end` keyword is strange and I keep forgetting it (that's more a problem with me than the syntax, I know).

The language is subtly whitespace sensitive in some places, while being mostly whitespace insensitive.

Macros can't take a variable number of arguments, which leads to the proliferation of Special Forms (it's a kind of macros that is treated as special by the compiler) which could perfectly be macros if it weren't for this limitation.

For a situation where this causes problems and requires some extra weirdness in what should be a simple DSL, look at this Github issue in the new testing library scheduled for inclusion in the standard library: https://github.com/whatyouhide/stream_data/issues/21

comment 9y ago · link · parent

It's just Nginx + Phoenix on a rented Linode server. It's in beta, so I don't care much about security beyond the basics...

EDIT: I could drop Nginx and use "raw" cowboy (the webserver behind phoenix), but Nginx makes it easier to setup TLS certificates and I'm lazy enough to keep it around just because of that...

comment 9y ago · link · parent

What do Promises/Futures/Async/etc. have to do with monads? Are monads a good abstraction to model those things?

comment 9y ago · link · parent

It's not very hard to deploy. Just use the proper tools to compile and build a release (on a VM emulating the same architecture as your server), rsync the resulting files into the server and strat the app.

Getting hot code reload to work is harder, but for a "normal" basic deployment it's just this. App restarts take less than one second of downtime for my app, and that's a cost I'm willing to pay.

You shouldn't do this by hand of course. Write an Ansible playbook or something else that does this for you

comment 9y ago · link · parent

I'm not qualified to answer that, as I haven't used Drab, but you can ask on the proper topic at the elixir forum: https://elixirforum.com/t/drab-phoenix-library-for-server-si...

comment 9y ago · link · parent

The author doesn't talk a lot about preemptive scheduling, which is probably the best thing about the Erlang virtual machine. This video explains what preemptive scheduling is and why it is extremely useful: https://www.youtube.com/watch?v=5SbWapbXhKo

First, the speaker creates an application endpoint that runs into an infinite loop on invalid input. Then, he shows how that doesn't block the rest of the requests. Using native BEAM (EDIT: BEAM = EVM = Erlang Virtual Machine) tools, he looks for the misbehaving process (the one running the infinite loop), prints some debug information and kills it. It's pretty impressive.

Another great (and lighter) resource, is "Erlang the Movie" (https://www.youtube.com/watch?v=xrIjfIjssLE). It shows the power of concurrency through independent processes, the default debug tools, and the power of hot code reloading. Don't miss the twist at the end.

comment 9y ago · link · parent

Erlang has its own HTTP(s) servers, like cowboy (https://github.com/ninenines/cowboy) so it doesn't need Nginx and the like. Those servers simply take the place of Nginx. There is nothing special about Nginx that you can't copy in other languages, like Erlang.

The main web framework for elixir, Phoenix, is just something that bundles cowboy (the webserver) with some utilities on top of it. No need for Nginx.

I do use Nginx in my side projects in front of my Elixir web app, but that's because of some conveniences Nginx brings (having Nginx is probably making my requests a little slower).

comment 9y ago · link · parent

Elixir and Phoenix exceeded all my expectations. I thought about what I wanted to build, read the docs and built it. Done.

When I was still using python, I spent days (weeks?) reading about the problems, looking for design patterns that might work for my use case, and finaly quit in frustration.

comment 9y ago · link · parent

You can look into drab, an elixir server-side DOM manipulation library: https://github.com/grych/drab. I've never used it, but many people in the Elixir community think it holds a lot of potential.

comment 9y ago · link · parent

The syntax is bad (just like ruby), and there are some annoying limitations with macros, but the semantics are very good, and the ability to keep thousands (or hundreds of thousands, or even millions if you know what you're doing) of stateful connections to clients is very useful in practice.

comment 9y ago · link · parent

> the same crowd that argues that building additional highway capacity won't accomplish anything because it'll just get filled with more cars

It will allow more people to commute into the city, which is the goal, right?

> seems to think that additional housing capacity won't similarly be filled up immediately.

And more people will be able to live there... Isn't that the goal?

comment 9y ago · link · parent

The Spanish and Portuguese empires have much to be ashamed of too... Whether you should personally be ashamed for that is up to you.

comment 9y ago · link · parent

> from driving all the way to the Western shores of Spain.

I don't think it was luck. It was probably the lack of cars ;)

comment 9y ago · link · parent

This article is very weak... They cherry pick a single metric (overdose-related deaths) and use that to prove Portugal's policy is the best thing ever.

Other metrics that are relevant: Has drug use increased or decreased? What about the burden of disease associated with drug use? Also, even more importantly: What has happended to deaths in other countries over time?

12