Building Your Web Framework in Elixir with Adi Iyengar - EMx 222
Adi Iyengar is an Engineering Leader, Startup Advisor, Author, and Elixir Mix Podcast Host. He joins Allen to talk about his book, "Build Your Own Web Framework in Elixir". He begins by talking about the process of publishing a book, how he wrote his book and gives some tips to aspiring authors.
Show Notes
Adi Iyengar is an Engineering Leader, Startup Advisor, Author, and Elixir Mix Podcast Host. He joins Allen to talk about his book, "Build Your Own Web Framework in Elixir". He begins by talking about the process of publishing a book, how he wrote his book and gives some tips to aspiring authors.
Sponsors
Links
Socials
- LinkedIn: Adi Iyengar
- Twitter: aditya7iyengar
Transcript
Allen:
Hello, everybody. Welcome to another episode of Elixir Mix. I'm kind of solo hosting to a certain extent. We have a guest today who is one of the original hosts, not original, sorry, one of the hosts, usually, Adi Iyengar. Welcome, Adi. How are you?
Adi Iyengar:
Hey Alan, doing good. Thanks for having me
Allen:
Yeah,
Adi Iyengar:
as a guest.
Allen:
as a guest. Yeah, sorry, I'm a little bit out of it. It's been a crazy week. I've been trying to put together my home studio, so I may sound a little bit weird. And I don't know, maybe I'm running on E right now, because it's been a long day. But yeah, we thought we would bring you on, obviously, by we, I mean, you and I thought we would bring you on. It kind of sounds a little bit weird. Inception, to talk about your book that just got released, right?
Adi Iyengar:
Yeah. Yeah,
Allen:
So,
Adi Iyengar:
it was released
Allen:
mm-hmm.
Adi Iyengar:
last Friday.
Allen:
Did you guys have a big launch party or anything to celebrate her?
Adi Iyengar:
No man, I mean, first of all, I don't think there are launch parties for books, at least at this, that are launched at this scale, but even if there were, I know the first thing I did after the book launch was like, okay, I'm going to finally sleep for seven hours at night. So yeah, that's how I did my launch party sleep.
Allen:
Yeah, that sounds like a good party to me, even I want to go back to bed.
Adi Iyengar:
Ha ha.
Allen:
But yeah, I mean, that's a huge accomplishment. I mean, you've been writing this book. I mean, I think you've mentioned this book like so many times before. And now you're just coming out with it. Right. I mean, how long has the process been?
Adi Iyengar:
Yeah, so from start to finish, it's a little over two years. And there's different phases to it, right? Like I planned it, found a publisher, but realized like very early on that, you know, I'm gonna need a few tools, and I'll talk about it in detail, to help me write this book. So it was like more than just writing a book, it was writing tools sometimes, finding tools that'll help me write this book properly. But I think I was just very lucky to have publishers who were very flexible and put up with my pickiness in wanting to test every aspect of the book. And yeah, Pac were pretty awesome to work with.
Allen:
You test every aspect. Are you talking about building the mobile file or building the PDF or something? What do you mean by testing every single part of the book?
Adi Iyengar:
Yeah, yeah, let's get it. Let's get into it. I actually gave a talk about this at Code Beam in 2021. So, you know, when you're writing a book, especially a coding book, you insert code snippets in between text, right? It's not always feasible to insert the entirety of code snippets. Sometimes you insert, you know, part partial snippets, right? And there's a lot of copy and paste. And as you change code, which I'm sure you you can imagine you do as you're writing the book, it's prone to typos, errors. And I wanted the book to be something that people can copy and paste from. And I ask someone who reads a lot of code in books like yourself, Alan, it's like a pet peeve of mine that when I write copy and paste, it doesn't work. Either the code breaks, either the command line output is different for a different version of Elixir or whatever, or there's just typos. Or hey, sometimes the line numbers get copied along with the code, right? If they're copying stuff like that. So all of that. I wanted to write a book that at least minimizes those problems in an ideal world, eliminates those problems. So I did a lot of research and built this tool, which allows you to programmatically insert a code snippet from specific lines in between text. In that way, you can have a code snippet exist independently of your text. And you can test them. You can add CI as part of your repo, the books repo. And code is in a completely separate repository, a separate folder. And you can write tests for each code. Another thing I did was also make it like that for command line outputs. So instead of copying and pasting command line outputs, you would put, OK, here's the command that I'm going to run. The CI runs it for you. And if there's any get diff, CI breaks. That means the command and output changed. So I wanted a deterministic book, the final product, the final book that gets generated. And obviously, all of this gets piped to Pandoc to generate the final PDF and the Kindle version. But yeah, again, I'm happy to talk more about that. But I wanted to work with publishers, A, who would not put a lot of pressure on me to finish a book, which a couple of them did. They wanted me to finish the book in eight months. And so, and pack was very flexible with this. And I also, they were also very flexible with allowing me to spend three to four months building this tool to help me write the book in a efficient way, the way I wanted to write a book, right.
Allen:
Okay, I mean, that's interesting. So it sounds like, because there's basically two ways that books kind of get written in my understanding. It's like one way is that the publisher will approach you. Usually, it's like you're somebody in community, you have a following. So they're easy to sell a book because you have an audience already. And two is that they have, they have a book and they know going to find somebody who's at least kind of known. And then in willing to actually write the book, right? So, but I guess the other way too is that, which it sounds like what you had, which is that you had the idea to write the book and you're trying to find the right publishers. Is that the third way was probably what you had, right? ["The Third Way"]
Adi Iyengar:
Yeah, closer to the second one. Actually, the idea for the book has been there in my mind for a while, and a different publisher reached out to me in 2019 about writing a book. At that time, I think not many people had a lot of elixir experience, and I had just given a few talks and had a block, so they were like, okay, you want to write a book in elixir. But I was starting a company, I wasn't in the mindset to write a book at that time. But I think that definitely tease the idea that was a seed inside that was planted, right? Like, okay, you know, some, if a publisher reached out to me, maybe I can write a book. I was wrong. It's a lot of work. But but yeah, later on in 2020, early 2021, when I had this idea, and I can talk more about how the idea came later. And I already wrote a few, you know, chapters. rough chapters and I was like maybe it's time to look for a publisher and yeah, Pragmatic was the first people I went to obviously and it looked like they already had a few Phoenix books coming out at that time and they wanted me to either do a small version of the book, like a 90-pager, and so it doesn't compete with other big books, which makes sense, which is very fair. So I couldn't work with them but a couple of the publishers and I reached out pressure on me in terms of the time frame and PACT were the most... Dude, they didn't even complain about a single thing. They were... I can't believe how smooth this was. Like, I've heard stories of like, you know, publishers kind of breathing down all the authors' necks about like, hey, you know, putting pressure, right? I know Pragmatic doesn't do that, right? But I know what other publishers that do it. And it was great to see that PACT is another very... create publisher to write books for. If someone and anyone listening is thinking about writing their first book, definitely try to pragmatic, obviously. But if they're not available or if you want to try a different channel, we try to pack there. They're pretty awesome. And they have a lot of awesome books coming up about Elixir and Functional Program.
Allen:
Yeah, PECT, the thing about PECT is they have a lot of books. They don't really have much of a... I don't know, I guess there's a lot of publishers that don't really have much of a kind of focus, right? But
Adi Iyengar:
Right.
Allen:
it seems like the amount of books that they come out with is just insane.
Adi Iyengar:
Yeah, I think they're just a bigger publishing house, right? They're just huge. They have so many employees. They have kind of taken the route of hiring. I think it is more of a quantity over quality, for lack of a better word. Like it's more of that. Not to say that the quality isn't as good, but obviously if you're targeted towards a specific domain, like pragmaticist words, elixir, and some of the newer languages, we get genetic algorithms in elixir. You're not going to get any of the publisher publishing that book, and it's so awesome. that Pragmatic has the scope and the user base to publish a book like that. But yeah, Pat is trying to get into Elixir. That was the main reason to work with me. They already had two Elixir books before this, and they wanted to do an Elixir book that something like that doesn't exist in the community. And they wanted to kind of, for lack of a better word, take a risk and go publish a different book. They are trying to get into some of these new languages, Rust and Elixir specifically. They're really trying to get into and have like different options available for people.
Allen:
Yeah, I definitely heard that and I think they probably have the most amount of elixir books and then maybe followed up by I don't even know. I'm sorry, I'm talking about rust. They the most amount of rust books I've ever seen. And I think it's been followed quickly up by Manning.
Adi Iyengar:
Yep.
Allen:
And I think I can agree with you. I didn't want to say this, but you've already said it. I do think they go for quality quantity over quality. And like you said, not to say that some of the books are not like amazing. But there's just They they're not so selective over their authors as some other publishers, right?
Adi Iyengar:
Right, right. Yeah, I'm,
Allen:
But
Adi Iyengar:
sorry, go
Allen:
The
Adi Iyengar:
ahead.
Allen:
positive side about that one is like if you want a book about you know, how to use rust to Build I don't know something with Legos. They probably have five books about that
Adi Iyengar:
Right,
Allen:
Like, you know,
Adi Iyengar:
right.
Allen:
like they're very the very niche topics, which is quite interesting But that's then like the fun part is usually everybody has a niche problem to a certain extent So sometimes those can come in really big handy.
Adi Iyengar:
Yeah, yeah. And I think one of the great things that's packed is also, I think, just again, the quantity of technical reviewers to have at the disposal, right? Like, the kind of suggestions I got early on in the process was quite amazing. And I know that they've only recently developed this quantity of. technical reviewers, they have like created this entire like ecosystem, packed ecosystem where if you're a reviewer or a regular reader, you can like subscribe monthly and like get access to the entire, you know, selection of books and just read whatever you want for like 30 books a month or something. And I think they're trying to go for that kind of a model where, you know, they have this huge community and you know reviewers I mean, 15 people, 15 technical reviewers read my book. That's pretty awesome, right? And I got some really amazing feedback, especially early on, like how I can structure my chapters to make it more intuitive, because obviously I haven't think about this book for like a while, so the way I'm thinking is I'm gonna translate to how someone who hasn't thought about the book will read it, right? So I got a lot of very useful feedback, and I haven't spoken to like other... authors and even pragmatic, they didn't have nearly as much support and as much feedback and you know in terms of number of people reviewing the book and a number of people who read a lot who are reviewing your book right so they know how a good book is written. So yeah that's a huge advantage of working with Pak because if you're a first-time author like me I suck at writing. I'm a terrible writer. English is my... I guess it's kind of my first language right now, but I still hesitate in saying that. I'm not very comfortable writing anything in English. It takes me like 20 minutes to write a Gmail response. So yeah, having someone to act as guardrails around me to help me write this was really awesome.
Allen:
Yeah, I find it kind of interesting, like also, because as I've said before, I'm also kind of writing a book at the moment. I don't want to say too much because I jinx myself, but the what else is kind of interesting too is some of the editors, right? Because writing is writing. And so at least for me, my editor, like I looked them up and I was like, oh, this is my editor. And it was like a guy who wrote quite a few history books. So
Adi Iyengar:
Hmm.
Allen:
I'm like myself, can he really like help me? You know? But basically. I don't know, but like, is your, was any of your editors kind of like doing other things that you thought maybe they would be, you know, not so suitable or?
Adi Iyengar:
So, not me, but I know it was like that earlier for Pac too. And this is what I mentioned like in the last two to a half years, they revamped their tech writing. And they do like less tech writing too, like they have this like F.L. Furi Loop Studio, like music development book and stuff. They do have books like that too, but they have like really made sure they have technical editors and technical reviewers who not just like technical in terms of like overall engineering, like elixir people, functional people reviewing your book. if you're writing an extra book or rest people reviewing your rest book and right. That's that's the approach it took and I've seen it myself I'm gonna say the books in like last two three years equality has gotten pretty good. The ones that came out in last two years especially because they built that entire community of you know people who are incentivized to read a lot of books and like you know because they get free books and stuff like that so yeah I think. on top of the compensation obviously right on top of getting compensated they also get like access to free books so i think that model has really worked well for pack
Allen:
Okay, yeah, that's interesting. Well, I mean, the other thing too, like I said, writing is writing is also pretty good, but also I found out my editor is also like, I think I forgot if he's a tester or something, but he does actually work with software and he actually does that in a lot of time writing software documentation.
Adi Iyengar:
Nice.
Allen:
And not just, you know, like, okay, this function, but like actual like for customers, you know, so it's like, okay, this guy, he knows more than I thought, like let's see how it goes and so far it's been good. But in
Adi Iyengar:
That's
Allen:
the
Adi Iyengar:
awesome.
Allen:
end, you know, it's writing is writing. You got to make sure you have the right tone and all that kind of stuff. But
Adi Iyengar:
Yeah.
Allen:
going back to you, I mean, I don't know, for me, the hardest part was like starting, right? How did you actually manage to start something?
Adi Iyengar:
Yeah, so I think it might be different from other, I mean, everyone has their own story, right? So for me, and I'll talk about the book, right? So the book is about like building your own web framework and Elixir teaches you how to build something like Phoenix, like a smaller version, right? And this is something I kind of did very early on in my life. So I started off as like a Ruby and Elixir developer, Elixir, it was before Phoenix 1.0 came out, right? So... That allowed me to look at Elixir and Ruby on Rails differently because Rails is all this magic. And at that time, Elixir was not, right? Because we had to build a lot of things from ground up. So it forced me to look into Rails code. I would go and read Rails source code as a junior developer who had just learned Ruby. So how that helped me in my mentorship was whenever I would teach people about Rails or Elixir or Phoenix, I would. kind of break things down for them. I'd be like, hey, this is how the router works. If they have any questions, like, oh, why can't I put a pipeline inside a pipeline, write a router pipeline, right? Why can't I nest it? Oh, because it's written this way. And you can show it to them, build it for them. And it kind of took it to a little higher level where my wife was just shifting, switching her careers from a dental hygienist to a software developer in 2019. And she had a lot of, you know, She was doing Rails, right? And she had like very, she could not really find, it was very opaque for her. She could not really translate her understanding properly. I was like, come, let's just sit and try to build Rails, right? So three hours and we had like Rails down. And it was not the first time I did that. And I was like, oh wow, I've done this so many times in Elixir and Ruby. And every time I do it, two people I mentor, they really found very useful. So I wanna write a book about this whenever I get a chance. So this idea was there for a while. I had done this for a while. I'd given talks about it at meetups and conferences. So I had a very solid starting point. I knew where to start because I had built web servers before. Now, it wasn't as straightforward here because the web server understanding that I had having a computer science degree with web development as a minor, for lack of a better word, I knew a lot more about web servers than an average reader would, right? So, yes, that was one of the suggestions I got from early reviewers that, hey, first, talk about Cowboy as first chapter. That's a web server that's already built before using GentTCB to build a server in the second chapter. So, I think that's where the reviewers came in and helped a lot. Otherwise, I would have started off with a web server architecture and just build it instead of talking about a web server that's already there. How does certain design decisions have for me and stuff like that. So starting was easy in a way for me because I had a starting point, but it was modified by a very good feedback I got from technical reviews early on. Did that answer
Allen:
I thought
Adi Iyengar:
your question?
Allen:
you would know. Yeah. I was kind of curious. They like why not start with something like bandit It's kind of more new. They've been trying to be a little bit better. It's all elixir wouldn't have been make more sense
Adi Iyengar:
I think it was before Banner came out when I started writing the first
Allen:
Okay.
Adi Iyengar:
chapter. Yeah, or maybe it might have just came. I hadn't heard of it. It might just have come out and I know the whole conversation was going on for a while right about replacing cowboy and stuff like that or having an alternative. Yeah, so I mean, I was familiar with cowboy, I did not know how well. Any other episode was written and I knew how it worked. I had read about it. I had used it before Phoenix was a thing, right? So I was more confident about just using Kalba itself and talking about the different callbacks and patterns that Kalba uses.
Allen:
Yeah, but I mean Cowboy's also a beast too, right? It's been around for a long time, right? But it's also written in Erlang, so it's a little bit more difficult
Adi Iyengar:
Right.
Allen:
to read for people who are beginning. And speaking of beginning, right? Because I mean, I don't know, I feel I have a slightly different idea like then you do if you're saying like, this kind of book would be for a beginner. Like I guess if you already knew like basics of like how the web kind of works with servers, and it'd be interesting to see how that's implemented within cowboy elixir etc. But you're saying that you think this book is should be for beginners because to me, like I said, I think that's when a beginner starts, they're more interested in like getting something done. And then maybe like,
Adi Iyengar:
Right.
Allen:
well, how does this thing actually work?
Adi Iyengar:
Yeah, I would say, I don't want to say it's for intermediates only. And from the feedback I've gotten, it is more complicated than obviously programming Elixir or something like that. But I think a good way to tell, if you've read programming Elixir, if you've written a couple of Elixir apps, you've worked in Elixir for two or three months, then you're ready for this work. Obviously, if you have done Elixir for two years, kind of like taking a deep dive into Phoenix, you'll get a lot more out of this than someone who's only done it for three months, right? But yeah, I think it is mainly targeted towards those people who, you know, feel like they cannot contribute to open source for, you know, or Phoenix, like, because it's like beyond what beyond their abilities, which it's not. It's very simple. If I can do it, most people can do it. And just wanted to make it more accessible for people to feel more confident into feeling like they're a senior engineer who understands more details of how things work.
Allen:
Yeah, you got me. I might be cracking up this book a lot faster than I thought, because I'm actually kind of curious about how, you know, Phoenix works and how these kinds of things work. I mean, I do know that like basically it's built upon plug. So it was like, if you understand plug as the core, then it's probably just lots of fancy stuff on top of there. I mean, can I, can I say there, am I just oversimplifying
Adi Iyengar:
Yeah, totally.
Allen:
it?
Adi Iyengar:
Totally, totally. Phoenix is basically plug a few other components wrapped into many DSLs. That's all Phoenix is. So it is plug with, like, say, Cowboy or something, which, again, is they use Cowboy with a plug. They don't plug adapter for Cowboy. By the way, there isn't a behavior or documentation to write a plug adapter for a web server. So this book kind of. I want to say it's the only official documentation of how a plug adapter works. So I had to read through the code and understand that. But that's a different point. But yeah, you're right. Phoenix is a plug pipeline, even endpoint is a plug. And yeah, everything is wrapped into a DSL. And obviously, like ERB helpers and. Live View is not a plug. Like the Live View lifecycle is not a plug. But I think they interpret that as a plug. Like socket follows all the behaviors and implementation that Khan would. So yeah.
Allen:
Yeah, I do know that there's definitely some interesting and nice stuff that's added in from Phoenix. That obviously makes it easier to work with. So it'd be interesting to see how all this stuff kind of works. Like, I remember when I was able to use like EEX for a project. And I was like, Oh, how does it that they can like that they can have these files and then somehow they get compiled and it's like, wait a minute, this is actually built into Elixir itself. It's not a Phoenix
Adi Iyengar:
Right,
Allen:
thing. And I
Adi Iyengar:
right,
Allen:
was like,
Adi Iyengar:
right.
Allen:
this is easy. And now it's like, I feel like everything is not a mystery anymore. Once I did that, I was like, okay, actually, this is not too bad. Because
Adi Iyengar:
Yeah,
Allen:
if you think
Adi Iyengar:
yeah.
Allen:
about it, like, I don't know, like... I would say Chris and Jose, like not to bring them down or anything, but they were just Rails developers around the same time I was to a certain extent, maybe a little bit more advanced than me. But somehow they went off, like one guy did a programming language and one guy that took that programming language made a very great framework. But they're just normal people like us, right? It's amazing. And then if you look at it, you're like, this is actually not that difficult.
Adi Iyengar:
Yep, totally, totally. And I mean, the way Elixir does EEX is also so much better than the way Ruby does the ERB stuff. But yeah, I think that's a great place to start to cross that bridge of, I don't know, Phoenix Enlightenment, for lack of a better phrase. Right? EEX is awesome. Yeah, this book also has a chapter about EEX, In a smart engine, we actually write our own engine as well for the web framework we do. And again, that's also something I haven't seen been done anywhere else. How do you write your own X engine. It's something that Does not as much documentation for obviously because no one wants to do it. But yeah, you're right. That's one of the key components of Phoenix to
Allen:
It sounds like a book that can definitely show you all the core pieces and small bits. Yeah, so it's I never thought about like that. But yeah, that's quite interesting. And it's good like to market as saying, okay, this is definitely for intermediate. And I think that's good. Although I don't know if I'm necessarily intermediate, maybe I'm higher intermediate, but
Adi Iyengar:
Oh
Allen:
I'm
Adi Iyengar:
yeah,
Allen:
also very
Adi Iyengar:
I mean,
Allen:
curious
Adi Iyengar:
you're definitely
Allen:
about
Adi Iyengar:
senior.
Allen:
this.
Adi Iyengar:
You're definitely senior.
Allen:
Oh,
Adi Iyengar:
Because
Allen:
but I don't get senior pay. Why?
Adi Iyengar:
you don't live in a region that will give you senior pay. But
Allen:
Maybe.
Adi Iyengar:
yeah, but yeah, I mean, you're definitely senior, Alan. And I think this book, Intermediate, but in my life, when I've been mentoring people, the people who seek out books, right? The people who seek out mentors, For lack of, I mean, they're just amazing. Within two months or three months of doing Elixir, their understanding of how things work, their appetite for knowledge is so high, much higher than mine was. I think they can easily read this book as a junior Elixir engineer and get more out of it. So if you are someone who buys Elixir books, if you're someone who's getting into Elixir, who has already read programming Elixir, if you've read programming Elixir, have a couple of Elixir side projects, or Phoenix side projects as well, you can read this book understand everything. And that's another thing with this book. At the end of every chapter, there is a testing section. And for the people who are regular listeners of the podcast, it's probably not a surprise. But I wanted to make sure we test every component how it's working. Not just the components and the implementation itself, we also test the interface, how to test The earlier you learn this, I think the more you'll get out of the testing thing too, right? Like it will help you solidify the testing mindset.
Allen:
You don't worry that the sooner you get them into testing, the more they may not want to keep continuing with the book.
Adi Iyengar:
I mean, that's a risk I'm happy to take. Yeah, any excuses to promote testing, I will do it. I wanted to do TDD for the book, but I think that would have really turned off a lot of people, so I did not do TDD.
Allen:
We'd be happy to know this that like when I was creating my videos on YouTube, which I still plan to go back to I think I did mine TDD style like initially
Adi Iyengar:
Nice.
Allen:
I was doing very super easy and then I was like, you know what? I'm gonna do this the way I would actually do it. So I start with a test and then would make my changes, they would fail, make the changes make it pass and then like because I feel like so many tutorials and stuff they don't do this. Yet at the same time, I'm sure most of those people, at least some of them, do promote TDD or even testing in general. As long as you test, even if you make the change and then test, I think I'm okay with that. It's just the testing part I think is super important.
Adi Iyengar:
Yeah, it's so great to hear you say this, Alan.
Allen:
Yeah, I mean, like I said, I think that's because that's actually one of the questions I do have when I do follow tutorials. It's like, well, okay, I understand it. But how do I make sure that this is true? How do I test this? That's always one of my questions I have in my head. And then that's another googling session, I guess, spend hours on so it's good
Adi Iyengar:
Yeah.
Allen:
if people actually include that.
Adi Iyengar:
Nice.
Allen:
Like, I almost wish that the Phoenix book included tests sooner to a certain extent. But at least they have a section about it, which is important.
Adi Iyengar:
That's what I feel too. The book should have included testing.
Allen:
It
Adi Iyengar:
Chapter
Allen:
does include
Adi Iyengar:
two,
Allen:
testing, but not
Adi Iyengar:
yeah.
Allen:
in each chapter,
Adi Iyengar:
Not,
Allen:
which
Adi Iyengar:
chapter
Allen:
would have been
Adi Iyengar:
two,
Allen:
nice.
Adi Iyengar:
right, yep. Yep.
Allen:
Yeah, okay. I mean, I mean, so after you launch it, like, so because this is like a new age, right? Where basically, everything is digital. Like I was just watching this year documentary about GameStop and why GameStop kind of failed. It's because part of it was because, you know, video games, as you know, it went from physical copies to digital download.
Adi Iyengar:
Yeah.
Allen:
Right. So now that we're in another stage where, yeah, obviously behind you is a book. It looks like that is the book on the bookshelf or on the fireplace
Adi Iyengar:
That
Allen:
behind
Adi Iyengar:
is,
Allen:
you.
Adi Iyengar:
yes.
Allen:
I mean, there's just a couple. I mean, there's just a couple of those. But now what does it mean to actually launch a book? Does that mean that it's been on sale on Amazon or, you know, how do you actually say that the book is kind of done and it's been quote unquote launched?
Adi Iyengar:
I mean, when it's sent for printing, right, I guess it's still that. But yeah, I guess the Kindle version is available online. That's the one that's actually on sale right now. And yeah, I think it's like for like, I think it's five bucks cheaper than what it is usually. But yeah, I mean, honestly, the book has been done in my mind for a while. It's just the last bits of, you know, making sure. The format works for the publishers and stuff like that, but the Kindle book could have been launched, you know, three weeks before the actual publishing date. Surprisingly, though, a lot of people who bought the book bought the physical copy. I would say 60 65% of people or the physical copy. Some people did both, which is great, which our listeners are welcome to do. But yeah. It's good to see people are still buying the physical book, although I never buy physical books. I always buy the digital version. I don't have space
Allen:
Most concrete did I mean because you get a commission per copy sold right you get
Adi Iyengar:
Yeah.
Allen:
pennies or something like that. I'm kind of curious about this part. If somebody buys a bundle with both does that mean you get it's conscious two books sold or is that one book sold.
Adi Iyengar:
Two books sold.
Allen:
Two books OK.
Adi Iyengar:
Yeah. Also, by the way, I took a kind of a small cut in my, if you compare my book with other packed books, it's a little cheaper. And I wanted to keep it below $35, $40. I think it's going over $42 or something. So I took a little bit of cut on my share just to keep it a little cheaper than around the pragmatic cost, what pragmatic bookshelf books cost. The reason I say this is because if any of our listeners are, if it's still too expensive for them, like reach out to me, you know, some of you have already reached out by the way on through email that's expensive for you. And we can find a way to get a discount code or maybe even get a book too for free. There are ways to do that. So if anyone wants to read it, really wants to read it, especially students or junior engineers and are having a hard time buying it, reach out to me. My email should be in the show notes and I'll find a way to get to you.
Allen:
How nice you brought up in my mind, like, does this mean that we don't have a discount code for the show?
Adi Iyengar:
For the show right now we don't but I think by the time we will have the show notes the discount code will be ready. The
Allen:
OK.
Adi Iyengar:
publishers are working on one and I think it'll be like a 15% discount but like I said if we have students or engineers from like especially from like in different countries where your salaries are, everything is relative right so like reach out to me for this heart for you to buy and my goal writing this book isn't to make a cut. I mean, Alan, you know, right? Like, I mean, lifetime sales of the book will be like, you know, sixth of my salary, right? Of my yearly salary. It's not something that like really make a difference in my life. So my goal is for most people to read this book. So yeah, if people are having a hard time buying it, reach out to me and I'll find a way to get it to you.
Allen:
Yeah, basically unless you're Obama or somebody as popular as him,
Adi Iyengar:
Right.
Allen:
you're not going to be rich from a book. And
Adi Iyengar:
Definitely
Allen:
that at
Adi Iyengar:
not a coding book.
Allen:
least you look good though. Yeah, I've heard quite a few people like I heard some guy who got he wrote a book about Flutter and then he actually got hired to work and go because of the book on Flutter.
Adi Iyengar:
Oh wow.
Allen:
And it's and it sounds weird, right? But the reason is, and even he knew nothing about go. But I mean, basically, the guy was like, Listen, you wrote a book, it takes a lot of time, effort,
Adi Iyengar:
Yeah.
Allen:
and perseverance and everything else. That's a good quality to have. So would you like to, you know, come work? So speaking of that, has it opened any interesting doors now that your book is out and everybody's able to purchase a copy? Has there been anybody reaching out to you or anything came from it?
Adi Iyengar:
Yeah, I think nothing, no opportunities because of the book directly yet. What has been good is the, I have received so many emails and messages on LinkedIn. It's overwhelming. Actually. I was expecting maybe like, you know, 10, 15 messages, right. But I was not expecting over a hundred, 150 messages within a week of launch. And that has, it just shows you how excited our community is. It looks a community, right? Like the, the fact that. I mean, I'm not like any known person in the community, right? And the fact that people are buying, reading my book, and reaching out to give feedback, and all of that is overwhelmingly positive. It just shows how awesome Alexa Community is and how excited people are about all these interesting books coming out. There aren't many books like these, right? People are excited to read them and give feedback. Even like we tried to say, hey, it helped me a lot to understand how a router works. I always was very confused about how Phoenix Router works. Like I can't tell you how many people specifically mentioned that router part on the chapter eight, nine and 10, the metaprogramming part. So it's very rewarding, man. I think that is more, I think of any opportunities I could get that what the happiness and the satisfaction I got just in this like last five days. of all the emails that I've received, I think it can be matched. Unless someone offers me a million a year. But I'm not going to get that. But yeah, I think with Elixir Jobs, I don't think I'm going to do any better than the job I have right now. So I'm not really expecting this book to change my life in any way. Just give me the satisfaction of like, you know, that I've at least given back to the community a little bit.
Allen:
Okay, that makes sense. Yeah, maybe we can kind of go quickly kind of through, it doesn't be quickly actually, but kind of go over like the different chapters, right? So chapter one is all about, like you said, the kind of how cowboy works and actually kind of build a very simple cowboy, I'm guessing, right?
Adi Iyengar:
Yeah,
Allen:
That's
Adi Iyengar:
well,
Allen:
all
Adi Iyengar:
no,
Allen:
chapter one.
Adi Iyengar:
chapter one is it goes through Cowboy without even building it. It goes through how Cowboy works, its lifecycle, and builds an app using Cowboy so we can understand how a web server like Cowboy works. And then chapter two is building a web server from scratch using just GenTCP and just pretty much that, an INET module of our line.
Allen:
Okay. And what's following that then?
Adi Iyengar:
Yeah, so once you have a web server, you want to respond and dispatch. Say you got a web server, you need the ability to dispatch a request to a controller or a module, right? So routing. So next part covers routing with plug. So how can you use plug router to do some routing? Obviously, because I didn't talk about meta program until the very end. There's a lot of boilerplate as well, which I think it's good to get into. So like how you can work around the deficiencies of PlugRouter that it has when you're trying to write DSL to dynamically dispatch calls to different controllers based on configurations.
Allen:
So does this mean that by the time that we finish up the book, we'll be able to write it on Phoenix?
Adi Iyengar:
No, Phoenix is a lot more than this book. So one big example, this book doesn't cover Live View. I started writing this book when Live View was very new. And yeah, I could have added a chapter. It just would have been not one. It would have been two chapters. But yeah, this is also not a production level. Like the web server we built is not production level. We can't build Cowboy in one chapter. So if you want to host your website This the web framework we build in this book. It's called goldcrest by the way, which is by quick side segue to smaller bird not as big as a phoenix. It's a smaller Phoenix. So yeah, so if you want to build like a site project with that it should it should be able to do that regular rest should be right tests everything right but web sockets and Any kind of I don't know, HEEX, it doesn't have HEEX, right? HTML, compile time HTML syntax validation, it doesn't have that. So it doesn't have a lot of features that Phoenix has. Like it doesn't have the Phoenix HTML. Like all the helpers that Phoenix HTML comes with, right?
Allen:
Speaking of that, now you got me kind of curious. I tried to like because I have a bunch of templates with Phoenix HTML, and then I upgrade to 1.7 and then like it seemed like the changes that they want to do is that you shouldn't be using anymore like the Phoenix HTML stuff that they want you basically use all heaps and actual HTML.
Adi Iyengar:
Right, I think the HTML Phoenix HTML still used. It's it is used in the. I think it's called a components. Module that defines all the overrides that I think Phoenix HTML still imported over there. I'm not sure how you're using it in the templates, it might not be imported properly. I don't know, right, because you upgraded instead of regenerate. So I don't know if your web. ex file looks the way it should. But I do use Phoenix HTML 1.72. But good thing is components, I mean, that's a quick segue. 1.7 comes with components. You have models already there, already there. You don't have to re-implement those things. You can literally build a simple web application in a couple hours. Because it has all the components, forms, models, buttons. It even has the checkbox with the sliders, it has everything.
Allen:
Yeah, to be honest, I kind of like this style more because before it was a little bit confusing and like what are the things to add in?
Adi Iyengar:
Right,
Allen:
And
Adi Iyengar:
and this
Allen:
yeah.
Adi Iyengar:
also allows you to change it based on application.
Allen:
Yeah.
Adi Iyengar:
If Phoenix HTML, you could, there's weird ways you could, but this has, you have all the code right there that it's generated for you that it's editable.
Allen:
Yeah, and also it doesn't take too much time to actually rebuild those components in PhoenixHTML by yourself to a certain extent. So yeah, because they're not too difficult. Because what was tricky before is that you couldn't just insert strings into your templates. you had to wrap them with safe and everything like that if you want to build up your own stuff, or you have to use like
Adi Iyengar:
Right.
Allen:
that, the div functions, or there are functions, I think right or macros or something where you would be able to like nest them, like div
Adi Iyengar:
Right,
Allen:
do
Adi Iyengar:
I
Allen:
or
Adi Iyengar:
never
Allen:
something
Adi Iyengar:
used
Allen:
I
Adi Iyengar:
those.
Allen:
forgot what it was. Yeah, I did a couple of times. If they're not easy to use when you first start off and then after a while they're also easy to read. To
Adi Iyengar:
Because
Allen:
be honest,
Adi Iyengar:
it's like
Allen:
but
Adi Iyengar:
all ASTs, right? It's all the tuples. It's what they
Allen:
Yeah,
Adi Iyengar:
return.
Allen:
something
Adi Iyengar:
Yeah.
Allen:
like that. So
Adi Iyengar:
The
Allen:
yeah,
Adi Iyengar:
safe
Allen:
I mean,
Adi Iyengar:
and raw tuple.
Allen:
I do enjoy this a lot more. And actually, I was super against heaps at the beginning. I was like, this is stupid. I hate this. Because like, there's, it's just, it takes some time we used to. But then after I got used to it, I was like, all right, this is, I can do it. Like, I don't really love it. And then after I started making components, and this was when we have the, the compile time guarantees, which like
Adi Iyengar:
Yeah.
Allen:
you would declare what attributes, I was like, actually, this is kind of nice.
Adi Iyengar:
That is the best part about Higgs. Yeah, the
Allen:
Yeah,
Adi Iyengar:
compile time.
Allen:
and the slots. It took me some time to also write my minor on slots.
Adi Iyengar:
Yeah, well, I think that's where the Phoenix thing is going right and such a huge fan of the whole compile time guarantee with the new route the sigils as well right like the path the tilde P and tilde you right
Allen:
That
Adi Iyengar:
it.
Allen:
one too, I was quite a little bit against. I was like, come on, I like this, because then if I kept the name, I could change the route, right?
Adi Iyengar:
Yeah,
Allen:
But.
Adi Iyengar:
you could still define your helpers that point to the tilde P and tilde U, right? Like you could still do
Allen:
Yeah.
Adi Iyengar:
it that way, but it's just, that's where the guarantee comes, man. It's so awesome. And I think you can even add slashes as, so it looks for slashes, right? But if slashes aren't there, there are also warnings. So I think that, Again, it's pretty awesome that they have such a good compile time verification of HTML templates. I mean, no offense, but Ruby on Rails can't even dream of getting it. It's like so behind. It's so behind. I still help people with Ruby on Rails and things are so behind over there. Phoenix has already way surpassed Ruby on Rails and all these things.
Allen:
Or Ruby on Rails has their method missing that they use all the time. That's probably why
Adi Iyengar:
Oh
Allen:
they
Adi Iyengar:
man,
Allen:
cannot do it, right?
Adi Iyengar:
yeah, well, I mean, there's ways to explicitly break if method missing is getting called in certain things. But point is like, I think the community has not been driven in that direction. Like Chris McCord and Jose, everyone are aligned about the whole compile time checks, right? Like the more things you catch at compile time, the better. And Ruby doesn't have that option altogether.
Allen:
Ruby doesn't have that option. Yeah, yeah, that's true. That it is just kind of like interpreted
Adi Iyengar:
All right.
Allen:
on the fly to a certain extent. Yeah. Well, I mean, I don't want to bash it like that was like one of my bread and butter frameworks for a long time. But yeah,
Adi Iyengar:
Fray Ray.
Allen:
it does take time. You have to kind of what do you call that? You have to try something else and get into it, and then you start to see kind of like the beauty of it or the good parts of it. And there's always some things that you're going to miss. Like I do miss. so many helper functions that were in Rails that I wish I had. And then there's some that were ported over. You know, like, I don't know if you know what I'm talking about. Like there's like number to currency, right? That was built
Adi Iyengar:
I see.
Allen:
in. Yeah, there was
Adi Iyengar:
Yeah.
Allen:
just some nice helper stuff that were just like, oh, this is great.
Adi Iyengar:
Humanize. Right, yeah.
Allen:
humanize yet, but we have these kind of things. We also have reflections and we have these other things too. And so there's still like, you can usually find most stuff, but you have to add it in which, you know, give or take it's I guess it is less bloat, right? Because it's not in there by default.
Adi Iyengar:
Yeah,
Allen:
So but,
Adi Iyengar:
I mean,
Allen:
yeah.
Adi Iyengar:
again, just to be clear, I wasn't trying to bash Ruby on Rails. I've
Allen:
Yeah.
Adi Iyengar:
discussed it with all due respect, I think because Ruby is a foundation on top of which Phoenix was designed initially, right? Like if Phoenix is what Phoenix is because of Rails, you can say in a way, right? So I don't wanna bash it, but I think right now, I just, if you're starting from scratch, I mean, Phoenix is just way ahead and... ensuring you build a deterministic, more stable, scalable application than I think RealSkin ever even hoped to get to.
Allen:
Yeah, I think so too. And I think they have different crowds and stuff. And I find it quite interesting that, I don't know, I feel like it used to be that Rails was always kind of like innovative. And then now, not to say they don't have innovation, but I feel like there's a lot more innovation happening in Phoenix and stuff, which is quite cool. Especially with live view, right? It's like, okay, wow, this is interesting. And it seems like other people are doing that too. Um,
Adi Iyengar:
Yeah.
Allen:
but coming back to the, to the topic, right? So when you, when your book launched, you took a long deserve sleep, which sounds good to me right about now. And, uh, yeah, I mean, what, what's next on your agenda? Do you, do you want to take a rest for a while and then are you considering to write another book or are you already doing that now, or you're just like, this isn't really not for me. Um, I'm good where I am.
Adi Iyengar:
I think having written a book, it has definitely given me the energy to think about another one, but not right now. I think instead of seeking to write a book, if something comes in my mind, if an opportunity comes up where, oh hey, a book like this would be good, I would just be more open to it, right? But I'm not seeking to write another book. I think I'm going to kind of like, the time that this not running a book opened up and I've quantified it to around 8 to 10 percent of my time. I'm going to try to just like sleep more, play more video games and stuff because I already like, I mean, have a pretty more than a full-time job. I advise five startups on the side. I don't want to add something new to it right now or voluntarily add something new to it right now.
Allen:
Yeah, fair enough. I mean, it's that's one thing we don't have a finite amount of his time, right?
Adi Iyengar:
Right.
Allen:
So then is the wife happy that you're kind of not doing that anymore? She gets more time with you too. You didn't mention that part, by the way.
Adi Iyengar:
She does. And that's one thing I didn't compromise on earlier either. That's my source of energy. It gives me more energy than sleep does. Glad I brought it up. I just want to give a shout out to my wife again. Her name is Susan. And she is just literally without her, none of this would be possible. Having someone to support you. Because you have good days and bad days, right? stability, like a zero origin that you can go back to. Like that's always constant, right? Like that's always with me, supporting me. She's a software engineer too, so she literally read my book a couple times for me before I even gave it to the reviewers, gave me that early feedback. Like having that person is awesome. And best part is she's my best friend. She always has been my best friend. And like being married to her best friend, You know, also gives you that energy to take on, motivation energy to take on like things that seem challenging, right? Like three years ago, I would have like me writing a book, no way, you know, but I think having someone to support you at that level is so important to take on these kind of challenges.
Allen:
Yeah, fair enough. Yeah. Okay. That's that's good that she that she gives you that for me. Yeah, I mean, for me, I feel I have a different little bit different relationship where it's like for me, it's like, okay, you do your thing, I do my thing. And then when you know, we come back together and but not the method. I mean, of course, she does support me sometimes, but we're mostly kind of doing our own thing, you know, which is
Adi Iyengar:
Gotcha.
Allen:
suits me.
Adi Iyengar:
Yeah.
Allen:
So this
Adi Iyengar:
What
Allen:
is
Adi Iyengar:
it looks
Allen:
belongs
Adi Iyengar:
for you,
Allen:
to
Adi Iyengar:
man.
Allen:
suits for you, right? Yeah.
Adi Iyengar:
Yeah,
Allen:
Whatever.
Adi Iyengar:
exactly.
Allen:
Whatever flies my what was the name of the framework again?
Adi Iyengar:
Goldcrest.
Allen:
Yeah, whatever flies my go Chris.
Adi Iyengar:
Nice.
Allen:
But yeah, I mean, come back around. I mean, I think we covered a really good amount and you know, the book is out. You can get on Amazon for a slight discount. And if you if you need help, definitely reach out to you to get that right. If you and we should have a code for everybody 15% off, which is good. I mean, is there anything else that we missed for the book? If you have covered a good amount and if you're covered in more than basically no need to buy the book, we already gave you guys the whole audiobook, right?
Adi Iyengar:
No, yeah, definitely by the book. The code, obviously, is the king in the book. Yeah, I mean, there's a lot of diagrams, testing, as I mentioned before. I think I had a lot of thought-provoking exercise at the end of every chapter. So after you read a chapter, you have something to go back and further massage that brain of yours, like just revisit a few concepts that will go in the chapter. So yeah, do buy the book. Also, the tool that I wrote to write the book, that's I guess that's one that's next, Alan. I want to get it to a place where it is worthy of being made public and open source. So that's next on my plate. So watch out for that too.
Allen:
Oh yeah, I may want to check out your tool and see how it goes. Could be interesting, could be useful for me. You're so excited, you're like, yeah, yeah.
Adi Iyengar:
I'll also leave a link to that talk that I was mentioning that I gave at CodeBeam a couple of years
Allen:
Oh,
Adi Iyengar:
ago
Allen:
yeah.
Adi Iyengar:
about describing that tool. So check that out too. I think it's a neat little talk.
Allen:
Cool. Anything else you want to cover before we head over to PICS?
Adi Iyengar:
I'm all set.
Allen:
Cool. And I don't know, should I ask you to give the PIC, or should I go first?
Adi Iyengar:
I mean, my pick is the book, right? Like,
Allen:
the book.
Adi Iyengar:
yeah, that's it. Like, I'm serious. Like, reach out to me if it's expensive or someone's budget. Reach out to me and I'll make sure to find a way to get that book to you.
Allen:
Okay. For me, so as I said, I got my home studio going on and I used to, at the office I have a bit bigger desk so I use a Rodecaster Pro 2 which is quite a big kind of mixer and I needed another similar mixer for home. But I went and got the Rode Streamer X, so it has a capture card inside and also it's an audio interface. And it works perfect for me because it could fit one microphone and also I can do some sound effects. Let me see. There we go, like that.
Adi Iyengar:
That's awesome.
Allen:
Yeah. And I can also change my voice. So that's kind of interesting. Yeah, but anyways, it's been working out great. So I think if you're if you're if you got small space and you have one mic and you want to have an accelerant put in also capture game footage. I think this is a pretty good thing. I haven't actually tried the game card yet. I'm thinking to try it maybe tonight. Yeah, so that's my pick. And with that, I mean, it's been great hearing about your book because it's been a long journey. And now you did finally get me a copy. the day that we interview. So I couldn't check it out yet. No, you know, yeah. So I hope to check it out. And now you excited me really, you really excited me about the book because I would, I love to dig down deep into topics that I'm pretty familiar with on the surface level. So this is really perfect for me. Thanks so much for that.
Adi Iyengar:
Awesome, looking forward to hearing your feedback.
Allen:
Okay, and then see you guys next time on Elixir Mix. I think Sausage says bye, right?
Adi Iyengar:
That's all I says, bye.
Building Your Web Framework in Elixir with Adi Iyengar - EMx 222
0:00
Playback Speed: