Quinn McLaughlin’s Post

𝗣𝗮𝗿𝗹𝗲𝘇-𝘃𝗼𝘂𝘀 𝗥𝘂𝗯𝘆? Imagine a way to write computer code that was designed around humans. Designed to be beautiful. Readable. Expressive. Enjoyable. That's Ruby. Want to look up someone's last chat message? In Ruby on Rails: current_user.chats.last.user_messages.last Ruby on Rails is not the dominant paradigm - though sites like GitHub, Shopify, Basecamp etc run it. The codebase tends to be smaller. Once you're read in - it's so much easier. It just makes sense. What's most popular? Javascript - esp Node/React. Javascript was written to run in early web browsers. So, a very different design goal. Same concept in Javascript? // Database const chats = await Chat.find({ userId }).sort({ createdAt: -1 }).limit(1) const messages = await Message.find({ chatId: chats[0]._id }).sort({ createdAt: -1 }).limit(1) // API endpoint app.get('/last-message', async (req, res) => res.json(messages[0])) // React frontend const [lastMessage, setLastMessage] = useState(null) useEffect(() => { fetch('/last-message').then(r => r.json()).then(setLastMessage) }, []) Three layers. Three files. Three places to break. And then there's that beauty thing. More, from the creator of Rails, at https://lnkd.in/gv_en552 #ruby #rubyonrails #javascript #react #webdev #programming #DHH

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories