Dissecting Discourse for Newbies


(mrsentinel) #1

Discourse Devs, I am new to programming altogether and really liked the discourse project. I am steadily learning Ruby and Rails to understand the architecture behind Discourse. What would be really helpful for guys like me is a learning roadmap so that someone could focus on learning the right languages to fully understand the UI and backend of Discourse. Here is what I know I need to study:

Ruby
Rails
PostgreSQL
Ember.JS
Javascript
HTML/CSS

I have seen some mention to coffee script, so if I need to learn that let me know. Also, if anyone has suggestions as to the progression of the learning of those programming/scripting languages I would greatly appreciate it!


(Jens Maier) #2

You’ll want to start with Ruby, but fortunately for you, Ruby is a really benign language to learn. There are a few oddities, such as the differences between blocks, procs and lambdas and eigenclasses add a lot of magic (sometimes even voodoo), but you don’t actually need to know all those things to get started with Rails.

The next thing you’ll need is ECMAScript, a.k.a. JavaScript. Try to understand prototypes and what this really does and you’re set.

Somewhere along the way you’ll want to pick up SQL and relation algebra. Postgres does a few things differently, but those are easily Google’d. Unless you want to define a custom full text search definition or move logic from Ruby to PL/SQL, basic joins and aggregations will take you quite a way.

The problem is that those were the easy ones, because next up are Rails and Ember. Despite being merely applications of Ruby and JavaScript, these frameworks are massive in scale and at this point the nature of dynamic languages works against you. No IDE in the world will be able to tell you precisely what methods an object will respond to. The fact that Discourse itself is huge as well isn’t exactly helping, and too few classes have formal documentation.

Getting this deep into Ruby on Rails development from absolute zero will be quite the epic journey…

Anyway, I highly recommend Why’s (Poignant) Guide to Ruby – it’s not as much a guide to Ruby as it is a programmer mentality self-test. If you’re not having fun while reading that, programming is probably not for you.


(mrsentinel) #3

This is an excellent response. I started with codecademy and Why’s guide and am branching out to learn more Ruby. Rails is certainly a beast. I have been trudging through the rails guide located here: Getting Started with Rails — Ruby on Rails Guides

I get the concept of controllers, views, etc but when you look at a project like Discourse, it just seems like endless amounts of information to try and digest. Now that I understand some of the basics of Ruby I can open up some of the ruby code and understand the intent, but I feel like I am constantly searching for a root file to begin with that branches out to the other files. For someone who is only used to seeing small programs with a few libraries required, it is definitely different to see the code separated out as it is in rails.

What would be great is to explain how an experienced programmer dissects a project like Discourse right after they fork it on Github. Having someone explain what folders they look in, which files to focus on reading through, etc will definitely help someone like me who just tries to read through every ruby file I come across.


(Kane York) #4

config/routes.rb is a good branching-out file.

When you read this:

get "srv/status" => "forums#status"

That means that when a request is received for /srv/status, Rails will grab the ForumsController (file app/controllers/forums_controller.rb) and call the status method. (I think that’s called an ‘action’.)

The status method basically just runs this line:

render text: 'ok'

So the page served is:

ok

Look for render json:, render_serialized, etc, etc.


(AstonJ) #5

You want a roadmap? Here ya go:

Best way to learn Rails, from yours truly :slight_smile:


(mrsentinel) #6

Outstanding. Thanks!


(Tobias Eigen) #7

Bookmarked.

Out standing in the field, even.