6 ms·
How to Build a Web App with and Without Rails Libraries
- grenoire 6y ago>Building your own Ruby web application from scratch however isn’t only educational—I’d argue that it’s also a rite of passage in a Ruby and Rails developer’s career! >Just kidding. Well, perhaps it should be? It's a pet-project level of software alright, and it's got a million issues; but I'd argue that dealing with HTTP and HTML at the lowest level is the best way to internalise the foundations of web development.
- tobyhinloopen 6y agoWriting my own HTTP server in C++ and passing it through to Google’s V8 and allowing me to use print() to output from JS was very educational for me. At the same time NodeJs came out (:
- jack_riminton 6y agoThis is how we learned Ruby at bootcamp. The problem was that once we got to the more complex Rails parts, the instructors didn't have the time to fully explain it so it was explained as "Magic, don't worry about it too much" which was extremely frustrating
- ZephyrBlu 6y agoRealistically you generally won't have time to fully understand how most things work though.
- jack_riminton 6y agoI know, and accepting that frustration is part of becoming a developer, but there are others schools such as Lambda where you do go into more depth because its 9 months instead of 3
- Toutouxc 6y agoI believe we should really dial down the usage of the word "magic". There are some parts of Rails that feel "magical" as in "surprisingly easy to use" or "very convenient", but it's nothing like "magic that nobody understands". You can always read the actual implementation in your IDE, and Rails code is nice and readable with comments and examples. It's just as easy or difficult to reason about as other complex codebases. I don't remember myself ever hitting a wall and still not understanding what's going on two hours later.
- jac241 6y agoI am with you on this. What's magical in Rails? It imports classes for you by name based on their file path, "resources" routes to one of seven methods, templates are expected to be in a directory and named based on controller name and action, it defines methods on models for you based on the column names in the database, it runs files you you put in the initializers directory. All of this stuff is convenient, gets rid of boilerplate, and isn't hard to understand.
- deleted 6y ago[deleted]
- toomanybeersies 6y agoI've been a Rails developer for half a decade now, and I wish I had the time to list all the occasions where I've just about thrown my MacBook out of the window trying to do something that Rails wasn't specifically built to do, or been shot in the foot by ActiveRecord trying to be too smart for its own good. Solving autoloading problems is always a favourite too. I enjoy using Rails, but sometimes it's a pain in the ass, and usually because it tries to be too clever to reduce the amount of boiler platey code you need to write. In terms of code management, I'd much rather have explicit dependencies. Less `belongs_to :thing`, and more `belongs_to :thing, foreign_key: 'thing_id', klass: Thing`. Makes refactoring and code navigation so much easier. Also, pre-Rails 5, the defaults for DB migrations and relations were trash.
- nijave 6y agoOf course it no longer seems magical when you understand the implementation. The issue is understanding the application without working your way up from the inner bowels of Rails source. Things auto running and importing themselves seems magical because no other mainstream language does that
- mhasbini 6y agoWhen I get a chance, I try to dig into the "magic" parts of the tools I'm using. I've wrote a bit on this on my blog in the context of creating a (nano) web framework similar to Rails [1] and a (nano) http client library similar to requests [2]. I find this to help assure me that if I have to go one layer deep in abstraction I'd still be able to learn how it works. [1] https://mhasbini.com/blog/lets-build-a-web-framework.html https://mhasbini.com/blog/lets-build-a-web-framework.html [2] https://mhasbini.com/blog/lets-build-an-http-client.html https://mhasbini.com/blog/lets-build-an-http-client.html
- eu 6y agoThat's why I abandoned RoR early..
- ksec 6y ago>Maple is yet another software developer who made it without a formal education in CS. She currently works on the TruffleRuby team at Shopify where speedy Ruby code isn’t a fantasy. Interesting Shopify is sponsoring both TrufflyRuby and YJIT on MRI.
- byroot 6y agoIt's always good to hedge your bets. The two represent the common dichotomy between a reimplementation that potentially reach much higher performance, but will continuously have to battle for compatibility, and an in-tree development that will be limited by backward compatibility etc, but that if merged would be guaranteed to stay up to date. Maxime explains this well in her YJIT talk [0], and it's the same with other languages such as Python, where PyPy is in most cases much faster, but tend to lag a version or two behind. [0] https://www.youtube.com/watch?v=vucLAqv7qpc https://www.youtube.com/watch?v=vucLAqv7qpc
- chucke 6y agoWithout rails, I usually use any of the other rack compatible frameworks, such as roda, sinatra or padrino. This article is conveying the message that,without rails, "in the beginning, we had TCP sockets.."
- jventura 6y agoNot trying to self-promote myself, but I have something similar (creating an HTTP server from scratch) but in Python [0]. I'm a Professor, I teach web development (to BSc and MSc students), and I always go through the "socket experience" before using any framework at all (usually Django, sometimes Flask). This lab exercise and another one for webservices (basically routing and sending json responses through the socket) are quite elucidative for them regarding web apps. In the end, the message they get is that the internet is all text going back and forth (plus or minus some details). [0] https://joaoventura.net/blog/2017/python-webserver/ https://joaoventura.net/blog/2017/python-webserver/
- cdogl 6y agoThe trick that really opened my eyes was this: $ telnet google.com 80 Trying 142.250.70.238... Connected to google.com. Escape character is '^]'. GET / HTTP/1.1 HTTP/1.1 200 OK Then adding a couple of headers - and realising that it really was just text. You can really tell the difference with young developers who've made that leap.
- deleted 6y ago[deleted]
- chr 6y agoDitto for HTTPS: % openssl s_client -quiet -connect google.com:443 depth=2 OU = GlobalSign Root CA - R2, O = GlobalSign, CN = GlobalSign verify return:1 depth=1 C = US, O = Google Trust Services, CN = GTS CA 1O1 verify return:1 depth=0 C = US, ST = California, L = Mountain View, O = Google LLC, CN = *.google.com verify return:1 GET / HTTP/1.1 Connection: close HTTP/1.1 200 OK
- mro_name 6y agoI find CGIs very interesting when scaling towards n=1 – they just do a bit of parsing and add no dependencies to your project. And with very few code (and still no dependencies) you get tiny, useful tools (plug alarm!) like https://demo.mro.name/geohash.cgi https://demo.mro.name/geohash.cgi
- TobySKT 6y agoBuilding an EHR system: Definition, Benefits, Problems, and Examples Find out how doctors feel about electronic health records and what it takes to create a successful EHR system. https://steelkiwi.com/blog/how-to-build-ehr-software/ https://steelkiwi.com/blog/how-to-build-ehr-software/
- nickelcitymario 6y agoReally enjoyed this, but I'm surprised by this line of code: loop do client = server.accept An infinite loop to listen for incoming requests? Is that really the right way to do this? Wouldn't this cripple your server eventually?
- randomdata 6y agoPresumably accept blocks, so your application would effectively pause at that point until a request needs to be handled. The loop brings the application back to waiting once the previous request is handled.
- nickelcitymario 6y agoAhhhh, that makes sense. Knew I had to be missing something. Thanks!
- deleted 6y ago[deleted]
- blizkreeg 6y agoHas anyone here extensively worked with Rails and then gone on to work heavily with Node/Express, or vice versa? Would love to hear your overall experience and thoughts between the two.
- jkcorrea 6y agoLearned to dev in Rails, went to work in big tech building internal tools in Python (mostly Flask), Node, and Go, and am now happily building my own startup in Rails. I honestly am baffled as to why anyone would not choose rails for most web apps, let alone basic CRUD apps. Maybe Django would be an alright substitute, I just dislike Python as a language/ecosystem. And the Rails core and gem ecosystem is just so mature at this point, any new feature you need is just a gem install away (hyperbole a bit). In the end, it's not a huge deal which stack you go with and great, successful companies have been built on all of these and even weirder stacks. Just wish the world settled on one so we could double down on the tooling around it :)
- jkcorrea 6y ago"Baffled" was a bit strong I guess. I enjoy a lot of different language/ecosystems (.net, erlang, typescript if you can call it an ecosystem) and see lots of reasons why you may build on them. Also recognize starting a project with what language/tools you know best is often more important than picking the most optimal one for the job.
- cutler 6y ago> I honestly am baffled as to why anyone would not choose rails for most web apps Maybe it's the insane memory requirements of Rails leading ot large AWS bills. It can be worse than running a JVM for a fraction of the performance. Rails didn't go out of fashion for nothing.
- mehphp 6y agoWell, same reason you don't like Django, I just dislike Rails (ruby is aight).
- ronyfadel 6y ago
- toomanybeersies 6y agoI think that every software developer should implement an HTTP server from nothing more than sockets as part of their learning journey. It's a great way to validate what you've learned, and gives you good experience with implementing usable software to a specification (in this case, RFC 2616). I have fond memories of implementing one in C (complete with multithreading and request queuing) at university. I found it immensely satisfying, I felt like I was Tim Berners-Lee back in 1990! That knowledge came in handy some years later when I worked building a TLS intercepting proxy (basically mitmproxy, but not) as part of an automated testing tool. That job really validated why I studied computer science; I had all the prerequisite understanding to jump straight into the task from day 1.
- dylanz 6y ago... and a good resource for network programming is the classic "Beej's Guide to Network Programming": https://beej.us/guide/bgnet/ https://beej.us/guide/bgnet/
- mucholove 6y agoI’m building an app in Objective-C. It is shares code on Mac, iOS and server and I’ve done it with the express purpose of learning every single little bit of the stack. (In part, to discover why Smalltalk didn’t make it.) I just finished a class I call GTKManySocketManager which abstracts away over the “polling” functions (poll/select/epoll). I wish I knew it was this easy when I learned Javascript. I hate hunting a library to do something for me—and, when I do find code I want to use, it is almost always best to modify it. Love it. Long live the socket. Build your own stack because it’s worth it’s worth it.