4 ms·
Speaking as someone who made this exact jump a couple years back, here's the big differences I remember. * The languages are very different, syntactically. Ru
by vec 13y ago
Speaking as someone who made this exact jump a couple years back, here's the big differences I remember.
* The languages are very different, syntactically. Ruby's blocks and enumerators really don't have an analog in PHP, and they'll take some getting used to. There's also some pretty deep philosophical differences in what the two languages mean by "class". That said, they sit at about the same abstraction layer, so line by line the complexity and flow shouldn't be that big of a jump.
* Rails is more like, say, Zend Framework than raw PHP. It enforces an MVC layout on your code and does what looks at first like a lot of magic to figure out which template files correspond to which pages. When you're starting out the rails scaffold generators are your friend.
* Ruby's standard library has a lot less in it than PHPs, so no XML parser or SQL client out of the box. Gems, and bundler in particular, makes it much easier to add third party code, though. You'll spend a lot more time bikeshedding over which third-party library to use, but the competition generally leads to more pleasant APIs in the long run.
* Ruby convention is to have more files and less code per file. A lot of your template files will only end up being three or four lines long. It's honestly easier in the long run, but get an editor that supports that workflow (multiple tabs, fuzzy file open, find-in-project, etc).
* RoR is almost completely independent of Apache for configuration. You get to move all the logic that was in .htaccess into ruby code in your app somewhere, and you get much more freedom over defining what you want your URLs to look like. You'll need to familiarize yourself with a concept called reverse proxying to figure out how this works in production, though.
* Not strictly ruby, but the rails asset pipeline is magic. Once you get used to it you'll never want to do frontend coding without it.
- quackerhacker 13y agoSeeing as I have no choice to learning Ruby if I become apart of this dev team, this is great to know. One of the greatest strengths that I absolutely utilize all the time in PHP is the libraries (curl, gd2, xml parsing, mysql, ect)...I couldn't imagine doing effective programming without it now. Oh well, another challenge, another achievement. Thanks Vec!
- tmzt 13y agoRuby has bindings for most of those libraries (or classes of libraries, like XML parsers.) I think CURL is handled in a more abstract way in Rails, but I haven't really gotten to work with Http clients in Rails yet.