News for hackers. Stuff that matters.
Re:Mint, a new HTTP library for Elixir by gamache on Monday February 25, 2019 @06:21PM (#19250454)
Fantastic! Congrats on the release, Eric and Andrea!

For Elixir devs who want a higher-level interface to Mint, check out Mojito: https://hexdocs.pm/mojito/Mojito.html https://github.com/appcues/mojito

It builds on Mint to offer one-off requests, connection pooling, and a generally friendlier interface than playing telephone with a TCP socket. :) Play around and let me know how it goes!

Re:Mint, a new HTTP library for Elixir by ramchip on Monday February 25, 2019 @04:19PM (#19249546)
I like that Mint keeps dependencies to a minimum. I wanted to use the Gun client in the past, but couldn’t because Gun and Cowboy would depend on different versions of Cowlib (this is less of a problem now that Cowboy 2 is well supported in Phoenix). Instead I used HTTPoison, but the way it wraps Hackney makes it a bit annoying to understand and debug, and the pooling can cause problem.

Mint looks lower level, but with a clean, well-documented API which should be a great building block in the future. Congrats Eric and Andrea!

Re:Mint, a new HTTP library for Elixir by skrebbel on Monday February 25, 2019 @01:23PM (#19247982)
It took me a while to figure out whether this is an HTTP client library or a server library. Turns out it is the former. Nice! I like that it's in-process. I wish more Elixir libraries would default to such a design.

(EDIT: I had accidentally written "latter" instead of "former" above, causing a bunch of people to correct me, thanks for that)

Re:Mint, a new HTTP library for Elixir by derefr on Monday February 25, 2019 @01:50PM (#19248230)
I've noticed that the distinction between server and client is much less apparent in HTTP2 libraries than it was in HTTP1 libraries. It doesn't seem like Mint follows this philosophy, but many HTTP2 libraries (even ones that also support HTTP1) are both server and client libraries.

Presumably this is because HTTP2 is sort of two protocol layers stuck together—a session layer and an application layer—and at the session layer, HTTP2 just has identical "peers" rather than any concept of client/server. (Theoretically either side of an HTTP2 connection could open a session to the other side and send a message! It's just the semantics of the HTTP-mimicking application layer that stop this. If you read the RFC, all the session stuff—frames et al—are specified in terms of "peers", and it's only when the spec starts talking about HTTP request-response that we see "clients" and "servers" mentioned.)

Since implementing the session layer is most of the work of implementing an HTTP2 client/server, and the session layer is just about "peers", once you've implemented it for a client (or server), you can reuse it to implement a server (or client) mostly "for free."

Re:Mint, a new HTTP library for Elixir by thibaut_barrere on Monday February 25, 2019 @01:29PM (#19248045)
It's a "new HTTP client" (tweet from one of the authors -> https://twitter.com/whatyouhide/status/1100082898986774528).
Re:Mint, a new HTTP library for Elixir by hartator on Monday February 25, 2019 @01:38PM (#19248109)
The example is confusing, but it's actually an HTTP client.
Re:Mint, a new HTTP library for Elixir by davidw on Monday February 25, 2019 @03:54PM (#19249364)
In the Erlang world... it's always yet another client.
Re:Mint, a new HTTP library for Elixir by msie on Monday February 25, 2019 @02:27PM (#19248567)
So, it's the former (client library).
Re:Mint, a new HTTP library for Elixir by eternal_virgin on Monday February 25, 2019 @01:45PM (#19248181)
While I have qualms about the name since this is like the 20th Mint I've heard of now, I'm incredibly excited as to what this has to offer. The control over the underlying process is key to creating beautifully asynchronous applications, and it gives me a lot of node-got vibes in terms of how easy it is to use.

And thank god, HTTPS support built in... it never ceases to amaze me why some HTTP libs don't have TLS as a given.

Re:Mint, a new HTTP library for Elixir by ams6110 on Monday February 25, 2019 @01:57PM (#19248295)
> it never ceases to amaze me why some HTTP libs don't have TLS as a given

Separation of concerns. TLS termination is something that can be done separately, and at scale you want to separate it anyway.

Re:Mint, a new HTTP library for Elixir by carlosdp on Monday February 25, 2019 @03:53PM (#19249354)
For a server, sure, but for a client?
Re:Mint, a new HTTP library for Elixir by ams6110 on Monday February 25, 2019 @08:23PM (#19251234)
Admittedly, I missed that. I thought this was a server lib.
Re:Mint, a new HTTP library for Elixir by dharmab on Monday February 25, 2019 @02:14PM (#19248447)
TLS is a layer 4 protocol feature which can be used for other libraries such as database clients. Most languages split the TLS implementation to more easily reuse that code.
Re:Mint, a new HTTP library for Elixir by supernintendo on Monday February 25, 2019 @03:56PM (#19249375)
At least the naming is distinct within the Elixir ecosystem. It has always bothered me how close HTTPoison and HTTPotion are to one another.
Re:Mint, a new HTTP library for Elixir by dnautics on Monday February 25, 2019 @04:46PM (#19249770)
not to mention that the dominant JSON parser used to be called Poison.
Re:Mint, a new HTTP library for Elixir by mrdoops on Monday February 25, 2019 @06:45PM (#19250609)
I'm liking the trend of designing runtime-behaviour agnostic libraries in Elixir. We get such powerful runtime capabilities with OTP, but indulged in the wrong context our cool OTP processes can be imposing assumptions onto our users.

I'd like to see some kind of generic HTTP contract or REST-API client builder library next so we can have swappable HTTP adapters (e.g. Mint/Hackney). I don't want to depend on a library like HTTPoison or Tesla directly when making a client, instead just generic Request/Response structs or protocols. That way an internal project can use a single HTTP adapter across all REST integrations rather than whatever the library author chose to use.

Re:Mint, a new HTTP library for Elixir by Dirlewanger on Monday February 25, 2019 @01:51PM (#19248245)
What does Mint provide over, say, HTTPoison? Still can't quite grok what it's offers.
Re:Mint, a new HTTP library for Elixir by supernintendo on Monday February 25, 2019 @04:25PM (#19249594)
Requests made with HTTPoison are passed to the library’s own connection pool whereas requests made with Mint are handled in the same process. While HTTPoison is great for most use cases, Mint is a promising solution for anyone who has specific control flow requirements.

I’m interested in this for some of the uglier API integrations I maintain where an ordered chain of requests must be made with no guarantee of delivery and responses that involve a considerable amount of in-memory processing (large XML bodies to be exact). Having control over my process architecture is preferable to leaving it up to the HTTP library’s connection pool in these cases.

Re:Mint, a new HTTP library for Elixir by 0xADEADBEE on Tuesday February 26, 2019 @01:58AM (#19252502)
Thank you so much for a concise answer to the exact question I had.
Re:Mint, a new HTTP library for Elixir by whatyouhide on Monday February 25, 2019 @01:59PM (#19248319)
The main thing is a processless architecture that lets you easily build architectures that are fine-tailored for your use case. You might build a process that holds many connection structs, or a use the connections directly in say a GenStage producer/consumer, or things like those. The idea is that you now have the building blocks to build whatever fits your thing :)
Re:Mint, a new HTTP library for Elixir by kt315_ on Monday February 25, 2019 @02:05PM (#19248368)
What is the advantage over Gun? (https://ninenines.eu/docs/en/gun/1.3/manual/)
Re:Mint, a new HTTP library for Elixir by whatyouhide on Monday February 25, 2019 @02:09PM (#19248401)
Re:Mint, a new HTTP library for Elixir by kt315_ on Monday February 25, 2019 @02:15PM (#19248463)
I think Gun has very similar philosophy, e.g. it is connection oriented and does not impose pooling and such.
Re:Mint, a new HTTP library for Elixir by ericmj on Monday February 25, 2019 @02:59PM (#19248851)
Gun starts a process for each connection. The main idea for Mint was to not do this so that users can choose their own process structure.
Re:Mint, a new HTTP library for Elixir by kt315_ on Monday February 25, 2019 @07:29PM (#19250917)
With Gun it is also possible to create a specialized process structure albeit with more heavyweight processes behind each connection. Mint provides lightweight (possibly more efficient?) abstraction to achieve similar results. Thanks Eric and Andrea!
Re:Mint, a new HTTP library for Elixir by etxm on Tuesday February 26, 2019 @12:40AM (#19252244)
I wish a solid HTTP client and JSON library was a part of the std lib. I feel like all of my apps have HTTPotion, HTTPoison, Poison, and Jason as dependencies.
Re:Mint, a new HTTP library for Elixir by sysashi on Monday February 25, 2019 @03:06PM (#19248903)
this library was renamed from xhttp to mint and new name is much more refreshing :)

I'm excited to try out this library (or something built on top of it)! In my day to day work I use hackney, it's an awesome lib, but sometimes I struggle with documentation.

Re:Mint, a new HTTP library for Elixir by KhoomeiK on Monday February 25, 2019 @01:50PM (#19248231)
A lightweight serverside Elixir framework like this is exactly what I was looking for earlier this week. Phoenix is really clunky in my opinion and pretty foreign (Ruby/Rails-like) coming from a lightweight Flask/Express/Go background.
Re:Mint, a new HTTP library for Elixir by whatyouhide on Monday February 25, 2019 @01:57PM (#19248293)
Ouch, this is not a server library but a client! We updated the title of the blog post since it wasn't clear, not sure if we can update it here as well :\ Sorry for the confusion!
Re:Mint, a new HTTP library for Elixir by brightball on Monday February 25, 2019 @01:58PM (#19248311)
Phoenix is just some additional libraries around Plug. The reason it’s so popular is that there’s almost no performance hit compared to using raw plug unlike a lot of other frameworks.
Re:Mint, a new HTTP library for Elixir by josevalim on Monday February 25, 2019 @02:34PM (#19248631)
If you prefer something more low level, then you can look at libraries like Plug, Maru, Raxx and others.
Re:Mint, a new HTTP library for Elixir by conradfr on Monday February 25, 2019 @02:25PM (#19248551)
Re:Mint, a new HTTP library for Elixir by mmartinson on Monday February 25, 2019 @02:53PM (#19248800)
I'd recommend using plug + cowboy for your web layer and if you prefer to do away with some of the more prescriptive parts of phoenix.
Re:Mint, a new HTTP library for Elixir by darkmarmot on Monday February 25, 2019 @07:01PM (#19250719)
Maybe we should package it together as PlugBoy?
Re:Mint, a new HTTP library for Elixir by dnautics on Monday February 25, 2019 @05:03PM (#19249902)
looking at the library, one of the exciting things (for me) is the existence of stream_request_body. AFAICT there isn't an obvious way to do this in any of the other libraries.
Re:Mint, a new HTTP library for Elixir by alexgaribay on Monday February 25, 2019 @01:59PM (#19248313)
Admins: Can we get the title updated to the actual article's page title to avoid some confusion?

"Mint, a new HTTP client for Elixir"

Re:Mint, a new HTTP library for Elixir by chooseaname on Monday February 25, 2019 @01:40PM (#19248135)
Is it me or are we running out of names for things?
Re:Mint, a new HTTP library for Elixir by anoncake on Monday February 25, 2019 @03:51PM (#19249340)
No, some people just like confusing others instead of using sane and unique names like e26160a5-70c5-476a-b701-95871a79ad48.
Re:Mint, a new HTTP library for Elixir by smacktoward on Monday February 25, 2019 @01:57PM (#19248292)
Nonsense, there's still plenty of available names out there.

In unrelated news, be sure to check out my new project Asbhrjfuugwxcgxedzkyhbwf!

Re:Mint, a new HTTP library for Elixir by bryanrasmussen on Monday February 25, 2019 @03:13PM (#19248984)
Why would you name your project after my password!?
Re:Mint, a new HTTP library for Elixir by smacktoward on Monday February 25, 2019 @03:31PM (#19249152)
"I've got the same combination on my luggage!" https://www.youtube.com/watch?v=_JNGI1dI-e8
Re:Mint, a new HTTP library for Elixir by tomcam on Monday February 25, 2019 @03:57PM (#19249387)
They’ve already announced a change to CockroachHTTP
Re:Mint, a new HTTP library for Elixir by whatyouhide on Monday February 25, 2019 @01:49PM (#19248225)
Ahah, yes we are :)
Re:Mint, a new HTTP library for Elixir by ProAm on Monday February 25, 2019 @01:29PM (#19248040)
People are the worst at naming products. Why call it Mint when there is already an insanely popular Mint.com financial software. It makes Googling/searching for product relevancy near impossible. It's like try to search for Firefox on Android vs Firefox on a desktop information.
Re:Mint, a new HTTP library for Elixir by ryeguy on Monday February 25, 2019 @01:34PM (#19248084)
No it doesn't. All you have to do is search <language> <package> and you get relevant results. Look through your library list, it's pretty common for the names to only make sense in context.
Re:Mint, a new HTTP library for Elixir by dnautics on Monday February 25, 2019 @04:50PM (#19249798)
actually, if you need it fast, you can just duckduckgo "mint !hexpm"
Re:Mint, a new HTTP library for Elixir by elcritch on Monday February 25, 2019 @10:29PM (#19251775)
That’s handy!
Re:Mint, a new HTTP library for Elixir by dnautics on Monday February 25, 2019 @10:54PM (#19251857)
Yes sorry I should have also mentioned that it only really saves time if you have ddg as your default searchbar engine!
Re:Mint, a new HTTP library for Elixir by loceng on Monday February 25, 2019 @01:31PM (#19248064)
It's in the context of Elixir, so search for "mint elixir" and I'm sure it'll be quite discoverable - or searching for "mint" on an Elixir contextualized site.
Re:Mint, a new HTTP library for Elixir by Qwertystop on Monday February 25, 2019 @02:07PM (#19248390)
"mint elixir", unsurprisingly, mostly turns up beverages and mint-flavored medicinal things.
Re:Mint, a new HTTP library for Elixir by loceng on Monday February 25, 2019 @02:11PM (#19248419)
What search engine did you use?

On Google, the first two results for me on "mint elixir":

Mint, a new HTTP library for Elixir - Elixir https://elixir-lang.org/blog/2019/02/25/mint-a-new-http-libr... 42 mins ago - Mint is a new low-level HTTP library that aims to provide a small and functional core that others can build on top.

GitHub - ericmj/mint: Functional HTTP client for Elixir with support for ... https://github.com/ericmj/mint Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2 - ericmj/mint.

Re:Mint, a new HTTP library for Elixir by bryanrasmussen on Monday February 25, 2019 @03:17PM (#19249020)
For me opening up Microsoft Edge which I never use for anything not testing related and hence Google does not know me on that browser and does not guess I want programming stuff Mint Elixir came up #5.
Re:Mint, a new HTTP library for Elixir by dx87 on Monday February 25, 2019 @03:06PM (#19248906)
For me on Google, "mint elixir" has the GitHub repo as the first result, then a bunch of links for "How to install Elixir on Linux Mint". DDG gives a software company called "Elixir Mint" as the first result, followed by links to drink recipes, and the GitHub repo is down near the bottom.
Re:Mint, a new HTTP library for Elixir by chooseaname on Monday February 25, 2019 @01:42PM (#19248155)
Not to mention Linux Mint.
Re:Mint, a new HTTP library for Elixir by wryun on Tuesday February 26, 2019 @04:59AM (#19253141)
At least it's definitely not TOS.