5 ms·
I fell in love with Erlang. I always prefer languages where the syntax is very simple because you don't need to know that much when reading the code. In fact,
by linkdd 5y ago
I fell in love with Erlang. I always prefer languages where the syntax is very simple because you don't need to know that much when reading the code.
In fact, Erlang was so simple I was able to read it before I even knew what it was. I learned it by digging into the RabbitMQ source code.
Pattern matching with function branching and case really changed the way I develop in every language. Just have a linear instruction flow, no more multiple returns, no more if/else, just read the code and when you're at the end of the function, you know what it returns.
Then, I fell in love with Elixir. The only language where macros aren't just C's #define to replace text. You're working directly with the AST, and that's just obvious to me now it should be done like that. Mix is also a game changer for the Erlang/Elixir ecosystem, it's so easy to build/release/deploy with Mix. I remember having some difficulties getting erlang.mk or rebar to work correctly, but with Mix it was instantly working. Also config/runtime.exs, I love you.
The OTP framework let's you structure your code the same way you conceptualize it in your head: "I have this part that talks to this part, and they need to know what this part is doing" translates to "I have a module that send messages to this GenServer, and they both monitor this process".
I can't understand why those languages aren't more known/hyped/adopted/... It's a shame.
- thewakalix 5y ago> The only language where macros aren't just C's #define to replace text. You're working directly with the AST It's hardly the only such language. In my experience, Haskell, Rust, Common Lisp, and Scheme all have macros that operate by syntax trees rather than text substitution, and I have no doubt that there are several more that I'm not aware of.
- davidkunz 5y agoI add: Nim, Crystal
- adenozine 5y agoI add Io(defunct), Self, Smalltalk, Tcl...
- auxym 5y agoEh, Tcl's metaprogramming, as far as I remember, is highly text based. EIAS.
- jjnoakes 5y agoIt's mostly based on manipulating lists. Scoping is a bit odd, but if you squint, the fact that unevaluated lists are passed into functions where they can be manipulated (by normal tcl list functions) and then evaluated in the caller's scope (or in other scopes), coupled with the fact that built in syntax (if, proc, for, etc) is the same as user-defined function call syntax, gives you more metaprogramming power than you might expect.
- adenozine 5y agoTrue, mostly. As the other commenter noted, function calls can be squeezed through some rather macro-looking holes if you just push hard enough. Don't get me wrong, Tcl metaprogramming is awful and gross and I don't recommend it, I was just being the stereotypical nitpick HN commenter for that moment since it CAN be done.
- leephillips 5y agoJulia is another.
- gpderetta 5y agoIn fact, which language except C and derivatives has macros that are inky simple token replacement?
- linkdd 5y agoAFAIR, Haskell do have metaprogramming but not with macros, I remember reading this[0] a few months ago. Maybe I misread the article? For Rust, I've seen more usage of `macro_rules!` than the other one (so much I did not even know it existed). And it looks a lot like C's #define. But yeah, my bad, I've been a bit too presumptuous when saying Elixir was the only one. [0] - https://chrisdone.com/posts/haskell-doesnt-have-macros/
- pjmlp 5y agoAdding Java and .NET languages, which do it via attributes/annotations, compiler plugins, and T4 templates and code generators. Circle compiler for C++, and D as well.
- ipnon 5y agoI will give you an answer. The average system won't encounter the drawbacks of not using this model until they have the good problems of too much success and too many users. At that point you can throw warm bodies into cold chairs and mostly solve the problem. To conclude, Node and Python are good enough, and VC bucks will iron out the kinks. That being said, having learned Elixir, I struggle to imagine using anything else for a greenfield web application. However, I have some curiosity about programming languages and was willing to take a leap of faith based on a few enthusiastic HN posts. Not everyone is like this. Let me add that you, yes you reading this post, should read Elixir or Erlang if you haven't yet!
- brightball 5y agoI’m the same way. After getting into Elixir virtually everything else just feels like a bad decision for a new application.
- waynesonfire 5y agoTotally, and in like every dimension.
- jmnicolas 5y agoWhy? Convince me!
- LandR 5y agoAny lisp will give you macros like you describe. If say lisp macros are more powerful and simpler too.
- pessimizer 5y ago> In fact, Erlang was so simple I was able to read it before I even knew what it was. I learned it by digging into the RabbitMQ source code. No matter what language I'm programming (including elixir), my pseudocode in design documents is always written in a pidgin erlang. It's simple, direct, discourages side-effects and encourages composability. Its building blocks (and syntax) also make it easy to describe abstract data types and schemas.