News for hackers. Stuff that matters.
Re:Phoenix 1.0 by lpsz on Friday August 28, 2015 @03:17PM (#10137347)
If you were choosing today, would you recommend choosing Elixir over Go for web/back-end development? Would you say Go is more suited for high-performance command-line tools, and Elixir for long-term running stuff?

I'm an indie developer building such a back-end (social networking/chat space), have full choice of language. Started using Go earlier this year and mostly happy with it.

Should I switch to Elixir in my next iteration? Would it make me more productive, or save me from various deployment hurdles in long-term?

(Please don't take this as one of those mostly aimless "Hey, is Ruby or Python better?" type of questions. I hate those myself. I'm going to be investing thousands of hours into Go at this point. Hoping for some serious pro-vs-con discussion, hoping people who have architected something big in either language could chime in -- such is the major plus of asking on HN.)

I tried Googling, and the best/most recent I found was this thread. [1]

[1] https://www.reddit.com/r/elixir/comments/3c8yfz/how_does_go_...

Re:Phoenix 1.0 by tbrooks on Friday August 28, 2015 @03:44PM (#10137473)
I don't know enough about the internals of the languages to speak on that, but here's what has influenced my decision on choosing Elixir:

Community: smart people (who I respect) in the Ruby community are getting really excited about (and choosing) Elixir. People like José Valim, Dave Thomas, Bruce Tate, Chris McCord, etc.

BEAM and OTP: The Erlang VM and OTP have been battle-tested at Ericsson. It's known for having 9 9's of reliability and scaled WhatsApp to millions of simultaneous connections.

HEX: like Rubygems was for Ruby, Elixir/Erlang has a budding package management system via Hex. Hopefully this becomes the canonical source for libraries.

Phoenix: Rails popularized Ruby and became the framework of choice for quickly and pragmatically developing CRUD apps. Phoenix has Rails-like conventions in building an Elixir app and has built in support for websockets. This framework is built for today's technology.

Syntax: Coming from Ruby, the Elixir syntax is approachable and understandable. It's easy to jump into without having much prior knowledge.

Kinda subjective, but those are reasons why I'm excited and choosing Elixir to build future projects upon.

Re:Phoenix 1.0 by nathan_long on Friday August 28, 2015 @05:04PM (#10137832)
One thing that attracts me to Elixir is what it doesn't have to do. Go had to start from 0, Clojure had to build FP on top of Java. If they work at all, it's a success.

By contrast, if Elixir just works, it's useless. Its functionality comes almost entirely from Erlang. Therefore its whole reason to exist is to make using that power more pleasant.

That's why, for example, Jose Valim has said "if you see a bad error message in Elixir, which makes you confused and does not help you solve the problem, pls open a bug report." https://twitter.com/josevalim/status/621933537009246208

Re:Phoenix 1.0 by davelnewton on Friday August 28, 2015 @05:18PM (#10137887)
Clojure built FP on the JVM, not Java. Elixir introduces language features onto BEAM. I guess I don't see the comparison making sense here.

Elixir's functionality comes from BEAM and the language, not Erlang.

Re:Phoenix 1.0 by strmpnk on Friday August 28, 2015 @06:49PM (#10138234)
Elixir actually compiles to the Erlang AST and thus is leveraging Erlang much more than it might seem.
Re:Phoenix 1.0 by davelnewton on Saturday August 29, 2015 @12:34AM (#10139078)
I see; I thought it compiled to BEAM code directly. I'd wonder then if there's anything representable in the Erlang AST that can't be represented by Erlang itself; it doesn't look like it so far.
Re:Phoenix 1.0 by klibertp on Saturday August 29, 2015 @08:43AM (#10139803)
There's not - see docs for parse transforms. Erlang is homoiconic in the sense that it's parse tree is its own valid data-structure literal. This is also true for Elixir. The difference is the `quote` and `unquote` macros and a simpler parse tree format in Elixir, which makes meta-programming much easier than in Erlang from what I understand.
Re:Phoenix 1.0 by nox_ on Saturday August 29, 2015 @10:37AM (#10140092)
I have rarely read things that were that much wrong. Just because the code can be represented as a data structure, or just because the compiler is written in its own language, that doesn't make a language homoiconic.
Re:Phoenix 1.0 by flackjap on Sunday August 30, 2015 @07:42AM (#10143045)
I concur -> In computer programming, homoiconicity (from the Greek words homo meaning the same and icon meaning representation) is a property of some programming languages in which the program structure is similar to its syntax, and therefore the program's internal representation can be inferred by reading the text's layout. Wiki
Re:Phoenix 1.0 by klibertp on Sunday August 30, 2015 @10:37AM (#10143424)
Every language's syntax internal representation can be inferred by reading it's text layout. It's what parsers do and people can, too.

How "similar" internal representation needs to be to its textual version to be homoiconic is subjective.

In Erlang an expression:

    2+3.
yields this AST:

    {op,1,'+',{integer,1,2},{integer,1,3}}
You can strip line and type annotations (you could also easily add them to the Prolog example below), which will get you:

    {'+', 2, 3}
If you scroll down the Wiki page you cite, you'll see an example in Prolog, where this:

    X is 2*5
yields AST of this shape:

    is(_, *(2, 5))
The important similarity here is that all elements of ASTs are still first class objects in the language. You can manipulate them in their raw form with the same functions you'd use for manipulating any other data. In other words, once you have an AST, you don't need to evaluate it, it's enough to just read it.

This is not true for Python. An expression:

    2+3
yields:

    Expression(body=BinOp(left=Num(n=2), op=Add(), right=Num(n=3)))
An AST here cannot be manipulated in its raw form here. To manipulate it - the representation itself - you'd have to parse it again or evaluate it to use special methods on AST objects.

So this is the practical definition of homoiconicity I came up with. You are of course free to disagree. I'm stressing "practical" here, because what I'm interested in is how easy it is to manipulate the AST to write macros. Homoiconicity for the sake of homoiconicity is of no interest to me.

PS. BTW, maybe I should base my argument on Lisp instead of Prolog. If you read the Wikipedia page carefully you'll see the part on Lisp says the same thing I do above.

Re:Phoenix 1.0 by davelnewton on Monday August 31, 2015 @01:11AM (#10145552)
Homoiconicity specifically means that the primary representation of the language is a datatype in the language itself; Erlang isn't that.

I don't find it particularly subjective, it's just what it means. According to what you're saying any language that can be parsed and manipulated by the language is homoiconic, since the AST can be represented by types available in the language, no?

Re:Phoenix 1.0 by klibertp on Monday August 31, 2015 @04:50PM (#10149007)
> Homoiconicity specifically means that the primary representation of the language is a datatype in the language itself; Erlang isn't that.

Literal datatype.

And please, prove it to me that "Erlang isn't that". My examples above indicate quite clearly that yes, it is.

> I don't find it particularly subjective,

I was referring to the word "similar" which appeared in the definition of homoiconicity given by flackjap.

> since the AST can be represented by types available in the language, no?

Yes, if the datatypes used in AST representation have literal forms in the language. No otherwise.

Re:Phoenix 1.0 by davelnewton on Wednesday September 02, 2015 @03:15PM (#10161359)
You claim any language that can represent its AST using that language's literal datatypes is homoiconic?! No. I can represent an AST in array literals in essentially any language, and quite a few using object/hash notation. That alone does not make a language homoiconic. See, for example, the lengthy thread here: http://c2.com/cgi/wiki?HomoiconicExampleInJava
Re:Phoenix 1.0 by klibertp on Thursday September 03, 2015 @05:26AM (#10163978)
There's another constraint, as seen in the definition of homoiconicity from Wikipedia. I'll paste it once again:

> In computer programming, homoiconicity [...] is a property of some programming languages in which the program structure is similar to its syntax, and therefore the program's internal representation can be inferred by reading the text's layout. If a language is homoiconic, it means that the language text has the same structure as its abstract syntax tree (i.e. the AST and the syntax are isomorphic). This allows all code in the language to be accessed and transformed as data, using the same representation.

As I noted, a similarity is subjective, but I never claimed that it's not needed as a criterion. So, what I claim is that homoiconicity happens when the AST representation consists of only literal datatypes of the language AND the AST structure is "similar" to the original code.

That's it. And also:

> I can represent an AST in array literals in essentially any language

I doubt it, but that's irrelevant. Had you done it you'd essentially reimplement the language of your choice and then we're not talking about that language in general anymore, but about your implementation. What you say here is that "every language can be made homoiconic given appropriate AST implementation". And that's probably true, although I suspect it gets too hard to do in practice for more complex syntaxes.

May I ask where are you getting your strong convictions about homoiconicity from? If you read the Wiki page you'll notice the use of less than precise words, like "similar" or "Languages which are considered homoiconic include" and so on. The concept itself is not as clear-cut as you seem to believe and it's mostly defined by examples.

Also, you still didn't provide a convincing argument that Erlang is not homoiconic; you only claimed that "it isn't" and moved on.

EDIT: as an example of how subjective homoiconicity is take a look at Julia. Listed on the wikipedia as homoiconic, here are the details: http://docs.julialang.org/en/latest/manual/metaprogramming/ - if Julia is homoiconic, then Erlang and Elixir are too. And Haxe, and Dylan. Are they? I don't know, I'm not going to argue about this. As I said, homoiconicity is only interesting as a way of simplifying macro creation; any more discussion is honestly useless to me.

Re:Phoenix 1.0 by aaron-lebo on Friday August 28, 2015 @03:27PM (#10137403)
Elixir, in my experience, is a much more productive and powerful language. If you are a one-man-show I'd pick Elixir any day.

Here I am pimping my own stuff but I wrote a related article on this:

http://lebo.io/2015/06/22/the-unix-philosophy-and-elixir-as-...

Re:Phoenix 1.0 by lpsz on Friday August 28, 2015 @04:17PM (#10137625)
Thanks, I actually read!

"The Go devs have since stated that they were surprised to see that a lot of Go converts were from dynamic languages like Python and not C or C++. Go still makes sense for a lot of apps ... somewhere, however, that has been extrapolated to the idea that Go is a good language for writing web apps."

I think this is the crux of the question. And heck, it's very easy to spin up a web server in Go, and so many intro examples focus on that.

Re:Phoenix 1.0 by MCRed on Saturday August 29, 2015 @02:32AM (#10139289)
And elixir/erlang are great for writing custom servers handling custom protocols.... but you're better off just dropping in Cowboy and working at a higher level.

Go is really compelling in producing a single-binary application... but for web apps, I think Elixir wins because it's working at a much higher level, and thus you're more productive.

Re:Phoenix 1.0 by otis_inf on Saturday August 29, 2015 @02:39PM (#10140939)
That was a great read, thanks for sharing!
Re:Phoenix 1.0 by stock_toaster on Friday August 28, 2015 @04:17PM (#10137627)
One thing I really like about Go is that the output is a binary. This significantly reduces some types of infrastructure complexity (deploy, CI, etc).

After a long stint as a python dev, I find myself seemingly almost subconsciously avoiding languages that require a ceremonial dance and some type of sacrifice to get all the various bits (dependencies, etc) in just the right place before the app will start up properly.

Re:Phoenix 1.0 by rubiquity on Friday August 28, 2015 @04:22PM (#10137644)
Elixir is easier to deploy than Python/Ruby. Since Elixir compiles down to bytecode all you need installed on a server is the BEAM (the name of Erlang's virtual machine). It's not as simple as a binary but is still a significant improvement over git-based deployments.
Re:Phoenix 1.0 by nailer on Friday August 28, 2015 @04:35PM (#10137702)
Wouldn't you have to pull the elixir source and then compile the bytecode on the boxes you're deploying onto?

Forgive me if I've missed something. I'm just getting excited about elixir at this stage.

Re:Phoenix 1.0 by jake_morrison on Friday August 28, 2015 @09:55PM (#10138706)
We deploy using Erlang "releases", which bundle the Erlang vm along with your application and it's dependencies into a tarball with a script to run the application. You don't need to install Erlang on the target system, just unpack and run.

We use "mix release" to build the tarball, scp to the server and unpack, then run using an upstart unit which runs "exec su -s /bin/sh -c 'exec "$0" "$@"' myuser -- /path/to/deploy/directory/bin/myapp foreground"

It's pretty painless. We are automating with Fabric now, but will likely be switching to Ansible soon.

Re:Phoenix 1.0 by rubiquity on Friday August 28, 2015 @04:45PM (#10137758)
There's releases where you can build a tarball[0] or RPM[1] that includes your application byte code plus the BEAM. Here's how you can go about building, testing and deploying a release in the context of Phoenix specifically: http://www.phoenixframework.org/v0.13.1/docs/advanced-deploy...

Optionally, you could cross compile locally or compile on a build server and have the other nodes pull from there, same as you would do in Go.

0 - https://github.com/bitwalker/exrm

1 - https://github.com/smpallen99/exrm-rpm

Re:Phoenix 1.0 by simoncion on Sunday August 30, 2015 @11:33AM (#10143558)
AFAIK, bytecode compiled on one Erlang system runs on any other. Bytecode is stored in .beam files, and -AIUI- .beam files are always forward compatible.

However, I'm not sure if bytecode compiled with an Erlang version >=17.0 will run on earlier versions of Erlang if it makes use of maps. (Maps are a new type that was introduced in Erlang 17.0.) I should really test this.

Re:Phoenix 1.0 by lpsz on Friday August 28, 2015 @04:21PM (#10137642)
Yes, and the standard Go workspace layout (and therefore not even needing a makefile) is great.
Re:Phoenix 1.0 by namelezz on Friday August 28, 2015 @04:29PM (#10137682)
You are probably more productive in Elixir at the early stage of development. However, I personally think Go would be better for long-term development because it is statically typed.

You can read more about pros and cons of statically and dynamically type languages [1]

[1] http://programmers.stackexchange.com/questions/122205/what-i...

Re:Phoenix 1.0 by josevalim on Friday August 28, 2015 @04:54PM (#10137790)
The presence of a type system definitely improves maintainability, however it is only one of many factors. Being C and Haskell both statically typed, are they equally suitable for long term development?

For example, Elixir is a more "strict" dynamic language than your usual Python/Ruby/Javascript. Data is immutable. There is no monkey patching. Most state changes happen explicitly via process communication. The macro system is compile-time which means nothing will pull the carpet under your feet at runtime.

Also long-term productivity is about actually maintaining your system in production. And Elixir leverages 3 decades of experience on that, using a runtime designed to build systems that self-heal and are fault-tolerant (I slightly explore this here: http://blog.plataformatec.com.br/2015/06/elixir-in-times-of-...).

I don't want to give a yes or a no answer, I would just like to point out the line is much blurrier than that. It doesn't matter which type system you use, your code is going to have bugs or unexpected situations will arise, specially when we are talking about network. So knowing that your system system can heal itself is quite comforting.

Those are two complementary aspects. It is one of the reasons I would love to see a statically typed language succeed in the Erlang VM.

Re:Phoenix 1.0 by niklasni1 on Friday August 28, 2015 @05:23PM (#10137918)
> The presence of a type system definitely improves maintainability, however it is only one of many factors. Being C and Haskell both statically typed, are they equally suitable for long term development?

They're both statically typed, but the type systems obviously aren't equal. I would argue that stricter types are in fact one of the main things that helps me be more productive in languages with MLish type systems compared to C which lacks e.g. generics and proper sum types.

That said, I find Elixir very interesting for the exact reasons you said.

Re:Phoenix 1.0 by Scarbutt on Friday August 28, 2015 @08:43PM (#10138544)
They're both statically typed, but the type systems obviously aren't equal.

That was his point.

Re:Phoenix 1.0 by niklasni1 on Saturday August 29, 2015 @04:55AM (#10139466)
I suppose the main difference is the presence of algebraic data types. But does that even make sense without static typing?
Re:Phoenix 1.0 by namelezz on Friday August 28, 2015 @06:10PM (#10138113)
Thank you for sharing. Hopefully, learning Elixir will be a great experience for me.
Re:Phoenix 1.0 by rubiquity on Friday August 28, 2015 @05:15PM (#10137877)
I've used both Go and Elixir so here's my thoughts:

Elixir/Erlang aren't your typical dynamic language. Elixir is compiled and has pattern matching. I catch a ton of bugs at compile time in Elixir that I would never catch in Ruby/Python/JS until runtime. Examples of these are misspelled variables/bindings/function names and pattern match that will never actually match. Those are really, really common time wasters all taken care of at compile time.

Now what types of errors in Go really hurt you? Race conditions at runtime. I have to be way more careful about that to where it was costing me a lot of time in very concurrent programs. Eventually you develop a paranoia. Go has better tooling to help with this now, but concurrency and a language that prefers pointers just doesn't mix well. In Elixir I don't worry about this because everything is immutable. Now that GOMAXPROCS defaults to NumCPU I think a lot of programs that looked race condition-free probably aren't.

As far as runtime goes, Elixir and Go are at the same mercy but Elixir has much better debubbing capabilities than Go thanks to Erlang.

If you want something that gets you closer to static types and you have the discipline to keep up with running it and maintaining your type annotations, there's always dialyzer.[0].

Re:Phoenix 1.0 by bpicolo on Friday August 28, 2015 @10:12PM (#10138753)
You can handle misspelled variables/bindings/function names in Ruby/Python/JS by linting. That's a class of errors that's easy to avoid anywhere with a good text editor.
Re:Phoenix 1.0 by 15155 on Saturday August 29, 2015 @12:55PM (#10140610)
Due to the extremely dynamic nature of Ruby, I'm not aware of any linter that can catch misspellings when interacting with class or instance variables, dynamically-defined methods, etc.

It's an entirely different level of statically-verifiable correctness.

Re:Phoenix 1.0 by bpicolo on Saturday August 29, 2015 @08:16PM (#10141814)
I know of class/instance variables working for py linters. Dynamically-defined methods, no, but those are hard to reason about even for humans so it's best to avoid them entirely.
Re:Phoenix 1.0 by lobster_johnson on Sunday August 30, 2015 @03:50PM (#10144298)
Pattern matching will only get you so far without static analysis, though?

For example, if I have a function that returns {foo}, and I change it to return {foo, bar}, then a pattern match on its return value that does {Foo} -> ... will fail at runtime, and the compiler won't pick it up, right?

In a statically type language (such as Go), changing the number (or type) of return values will result in compilation errors until all callers have been updated.

Re:Phoenix 1.0 by bbatha on Friday August 28, 2015 @05:42PM (#10138012)
Elixir can be optionally typed with the Dialyzer which will bring you to about the same level of static typing as go (if not more because the dialyzer allows for generics).
Re:Phoenix 1.0 by flackjap on Sunday August 30, 2015 @07:54AM (#10143071)
With compile time checking that is already there + Dialyzer, you basically have the whole 'code correctness' side of static typing? Right?
Re:Phoenix 1.0 by davelnewton on Friday August 28, 2015 @05:19PM (#10137893)
I've heard this argument before. For a long time, actually. But the kinds of errors I have are only rarely related to type issues, and those are almost always caught very early. YMMV, that's just been my experience.
Re:Phoenix 1.0 by niklasni1 on Friday August 28, 2015 @06:10PM (#10138112)
Having worked with Scala a lot recently, I've found that the ability to turn logic issues into type issues is an incredible gain for my productivity. OCaml programmer Yaron Minsky summed it up nicely with the advice that you should "make illegal states unrepresentable". He gives a good example of modelling a network connection in [0].

Another example is instead of shuffling a bunch of bare UUID objects around (or strings, for that matter) in a system where lots of different things have a UUID, I can make a simple reference type for the IDs of different entities. This way, calling a function that takes the UUID of one type of entity with that of another can be a type error that's caught by the compiler instead of a logic error that's caught by a unit test. This is cumbersome at best to do in Java or C, and obviously impossible in Python or Ruby, but in ML-inspired languages it's simply the most natural way to work.

[0] https://vimeo.com/14313378

Re:Phoenix 1.0 by davelnewton on Saturday August 29, 2015 @12:24AM (#10139051)
I wouldn't classify those as "type problems" but rather "using types to solve problems". I have no issue with the claim that great type systems make some... ahem... types of problems go away, although it's often trading one type of complexity for another. My issue is with the claim that "long term development is intrinsically better with static typing".
Re:Phoenix 1.0 by fghfghgfhfg on Saturday August 29, 2015 @01:18AM (#10139158)
The type system, at least more powerful ones, encode a lot of intention and more importantly, enforce it.

It might add some additional complexity in the first writing of the code, but in return you eliminate whole classes of problems forever. It's not just the initial writing that benefits (at some cost, admittedly), but all future changes won't have those problems either. In the case the types themselves need to change to account for expanded functionality or whatever, you again pay some cost in complexity, but in return every place the new type would cause problems you get a nice error.

The other thing to keep in mind is that whether or not these type are codified in the language they're there conceptually. Just because you have to write them down doesn't necessarily add complexity but is more like forced documentation that can be used to eliminate who classes of problems. It's difficult to see how this wouldn't intrinsically be better than so-called dynamic typing.

Re:Phoenix 1.0 by Havvy on Saturday August 29, 2015 @10:53AM (#10140161)
If you're talking about a good type system, sure. The type system in Go is frankly terrible at describing the kinds of invariants and reuse we care about.

I'd dare say that diaylizer (Elixir's optional but easy to use type system) would lead to more maintainable code than Go's forced type system in the long run.

Re:Phoenix 1.0 by davelnewton on Saturday August 29, 2015 @05:34PM (#10141415)
That more or less sums up my view on Go in a nutshell.
Re:Phoenix 1.0 by jeremyjh on Saturday August 29, 2015 @09:37AM (#10139927)
A type problem is any problem that types can solve for you. People who are exposed to very limited type systems consider the range of type problems to be limited. Still it is true that most of these problems are solved quickly and caught with unit tests - no one thinks that simple type problems are the source of your production bugs. A good type system is mostly a productivity play for me; I develop a little faster and I refactor MUCH more quickly and with less effort.
Re:Phoenix 1.0 by davelnewton on Saturday August 29, 2015 @05:33PM (#10141413)
I'm pretty familiar with actually-good type systems, and as I've attempted to say, they do eliminate certain classes of problems. They just don't happen to be the types of problems I struggle with or find major productivity-burners. YMMV.

Orthogonal to all this is that I'm underwhelmed by Go's type system :/ If I was going to shoot for a language whose type system really helped me (in the ways I need/want help) it wouldn't be Go. It's pretty slick for some things (aesthetics aside) though.

Re:Phoenix 1.0 by cgag on Friday August 28, 2015 @11:49PM (#10138994)
If you haven't used a good type system (which has at least algebraic data types and pattern matching), it's hard to realize how many of those bugs might actually be type issues.
Re:Phoenix 1.0 by davelnewton on Saturday August 29, 2015 @12:27AM (#10139058)
I'm not claiming that good type systems aren't useful, I'm claiming that the statement "Go is better for long-term development because it's statically typed" is more like FUD than actionable information.

I also agree that good type systems can reduce some forms of complexity (while often introducing another, but that's a different discussion).

Re:Phoenix 1.0 by encoderer on Friday August 28, 2015 @03:43PM (#10137468)
All of our servers and daemons at Cronitor have been built using Python. I know you're asking just about these two languages but i would consider a language with a bigger library and user base. It takes discipline with language features but we've had a lot of success writing stateless daemons that are under heavy load 24/7. It's been far easier to think from a fan-out pov vs worrying about every clock cycle wasted by, for example, the garbage collector.
Re:Phoenix 1.0 by bjourne on Friday August 28, 2015 @09:16PM (#10138606)
My advice would be to find out for yourself and don't believe the hype:

> Would you say Go is more suited for high-performance command-line tools, and Elixir for long-term running stuff?

Like Go isn't very high performance. See for yourself: http://benchmarksgame.alioth.debian.org/ (I know, lies, damn lies and benchmarks, but it's the best we got!). Elixir is it good for marathons because it's based on Erlang and Ericsson claims six nines uptime? Just use the tech you find is most FUN to work with because it's better to have fun programming than being bored.

Re:Phoenix 1.0 by jtwebman on Friday August 28, 2015 @09:44PM (#10138671)
Also it depends on the system you are building. Elixir and Erlang scale great and send messages even between servers fast! So if you need to scale it is great. Go I am sure is faster performance wiz but Elixir/Erlang will stay running longer and be easier to reason about as the system gets bigger. Go will be easier to find devs then Elixir/Erlang will be harder. So there are trade offs.

In the end you could use both, use the right tool for the job.

Re:Phoenix 1.0 by walterstucco on Friday August 28, 2015 @08:21PM (#10138501)
No, I won't! I would advice you to learn them both instead, they are on such opposite sides, than knowing both will expand your knowledge in a very fulfilling way.
Re:Phoenix 1.0 by happywolf on Saturday August 29, 2015 @12:22PM (#10140495)
Nice insight. Learning more languages, especially those that seem to be different, could widen one's perspectives, and able to avoid the issue of learning only hammer and treat all problems as nails.
Re:Phoenix 1.0 by kamac on Friday August 28, 2015 @03:24PM (#10137381)
Out of curiosity, which libs/frameworks are you using in Go? (that are web related)
Re:Phoenix 1.0 by lpsz on Friday August 28, 2015 @03:29PM (#10137410)
Hmm, still in the exploratory-hacking phase. Rewrote various parts of what Gorilla provides for learning purposes, plan to switch to Gorilla.

Using "lib/pq" (Postgres) for the db.

Also: need to cache some computed data in memory, and reload using a REPL or other means, haven't figured out the most "batteries included" way to do so yet.

Also: need to figure out the most production-friendly way to redeploy code (sounds like Erlang/Elixir can do really well in this regard.)

Re:Phoenix 1.0 by rubiquity on Friday August 28, 2015 @04:27PM (#10137666)
> Also: need to cache some computed data in memory, and reload using a REPL or other means, haven't figured out the most "batteries included" way to do so yet.

Elixir does nicely here, too. For caching, ets[0] tables are very easy to setup. For reload, you can use IEx to connect to a remote node and do whatever you need to do.

0 - http://www.erlang.org/doc/man/ets.html

Re:Phoenix 1.0 by elithrar on Friday August 28, 2015 @07:40PM (#10138370)
> Hmm, still in the exploratory-hacking phase. Rewrote various parts of what Gorilla provides for learning purposes, plan to switch to Gorilla.

Good pick. The gorilla toolkit is definitely flexible. I typically use a mix of gorilla (context, csrf, schema) and Goji (routing, middleware chaining).

My 'hard and fast rule' is that everything needs to implement the http.Handler interface if I'm going to use it, so I don't get abandoned with a bunch of custom libraries that I need to refactor away from.

> Also: need to figure out the most production-friendly way to redeploy code (sounds like Erlang/Elixir can do really well in this regard.)

Most typically use the system's init daemon, and/or Supervisor/Circus/monit. I'm partial to Supervisor on that front for the cross-platform compat.

Re:Phoenix 1.0 by kamac on Friday August 28, 2015 @03:36PM (#10137439)
Relating to redeploying code, did you give https://github.com/codegangsta/gin a look?

Also, any particular reason to not use a web framework such as gin-gonic for routing and templating? It simplifies some things down for me.

Re:Phoenix 1.0 by lpsz on Friday August 28, 2015 @03:46PM (#10137485)
Re: gin, thanks for the tip. I feel like this one makes more sense in development than in production, would like to avoid side effects (first HTTP request restarts the server), also an extra proxy layer.

Re: web framework. Absolutely, no intention to reinvent the wheel. Just informative to rewrite various pieces in the initial stages to get a better grasp on the language/patterns.

Re:Phoenix 1.0 by kamac on Friday August 28, 2015 @03:58PM (#10137542)
About gin, you're right, I think. But what else to use in case the app crashes? A simple shell script to restart the executable whenever it crashes (even though it shouldn't)? :) And what about hot code reloads? You'd have to stop the app for a second there, and replace the executable yourself. You'd also probably interrupt whatever the app was doing at the time, which could turn out pretty bad.
Re:Phoenix 1.0 by lpsz on Friday August 28, 2015 @04:01PM (#10137557)
I use upstart to respawn if crashes, but there's definitely more than one way to solve this one :) Hot code reloads is the more interesting issue.