Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This; the moment I realized I was never going to choose to do CRUD web stuff in Go was when I realized that this was the perspective Golang developers have on ORMs.


That's funny... knowing that ORMs aren't everywhere actually makes me more likely to use Go. I still have Hibernate flashbacks.


Hibernate is not a good example of an ORM, frankly. (I myself have horrors of both Hibernate and TopLink, which was the top Java ORM way back when.)

Ruby's ActiveRecord is a much better choice. It has an excellent balance between SQL and OO. It doesn't pretend that SQL doesn't exist; on the contrary, it encourgaes SQL use, and merely maps tables to objects, adds a bunch of useful features (data validation, change management, automatic joins, declarative migrations) and gets out of your way most of the time.

For example:

    users = User.where("created_at > ?", Time.now - 1.year).
      order('name').limit(10)
Results are lazily loaded and composable, so you can do:

    users = User.where("created_at > ?", Time.now - 1.year)
    if (page = params[:page])
      users = users.offset((page - 1) * 10).limit(10)
    end
Joining is easy:

    users = Users.joins(:accounts).
      where(accounts: {type: 'facebook')).first
becomes something like:

    select users.*
    from users
    join accounts on accounts.id = users.account_id
    where accounts.type = 'facebook'
    limit 1


Have you used rails ORM (activerecord) or sqlalchemy ? (I haven't used the latter much but people rave about it). Hibernate is an ORM taken to the extremes




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: