Slashdot Mirror


Exploring Active Record

An anonymous reader writes "Everyone knows that no programming language is a perfect fit for every job. This article launches a 'new series by Bruce Tate that looks at ways other languages solve major problems and what those solutions mean to Java developers. He first explores Active Record, the persistence engine behind Ruby on Rails.'"

60 of 266 comments (clear)

  1. In a comparison, Ruby suffers for one big reason by CRCulver · · Score: 4, Insightful

    By looking at Active Record Java developers can be happy and thankful they have a language taking good advantage of Unicode, unlike Ruby which treats users of non-ASCII alphabets (the overwhelming majority of people on Earth) as second-class citizens thanks to poor Unicode support.

  2. Anyone else Railed-out? by lifeisgreat · · Score: 4, Interesting
    Has anyone else played with Rails and been turned off?

    I've volunteered to create a recipe-wiki-site-thing for a friend, and coming from a background in C and SQL there was just too steep a curve to map a procedural train of thought and pre-planned SQL onto the Rails way of doing things. I already created the database schema, wrote all the SQL to get the information I want, have a lot of HTML written for the general template, and was looking at abandoning much of it for controllers, models, automagic foreign key relationships, automagic methods popping out of thin air.. I wanted more control I guess.

    So I've done most of the site in PHP instead. Direct, to the point, fast enough (though I'm thinking about a rewrite in C for a pure CGI/FastCGI binary), a minimum of automagic hand-holding - just start each page with sanity checking, authorization, the SQL the page needs and nothing more, and then format the output. No wondering how many hundred methods have been created that I don't know about, what happens when a record is deleted/updated (I'll let the database handle null/ignore/cascade thankyou) or whatever else Rails is doing behind my back.

    I'm a C guy - I don't like things being done that I don't explicitly ask for. I want init() functions. I want implicit declarations. Heck I don't even like C++ for fogging-over-functionality with inheritance, virtual functions and overloading.

    Ranting aside, I can see how Rails would mesh with a lot of people. But it's definitely not for me, and I guess (hope) a few other nutjobs around here.

    1. Re:Anyone else Railed-out? by eyeye · · Score: 2, Insightful

      So I've done most of the site in PHP instead... just start each page with sanity checking, authorization, the SQL the page needs

      TBH It just sounds like you don't know what you are doing.
      --
      Bush and Blair ate my sig!
    2. Re:Anyone else Railed-out? by I+Like+Pudding · · Score: 3, Insightful

      What sort of programming models? Frameworks? How in God's name does a framework reduce maintainability as compared to some C programmer's PHP spaghetti code?

    3. Re:Anyone else Railed-out? by soundofthemoon · · Score: 3, Insightful

      If you don't like it, don't use it. Like every other tool/framework/system ever developed, Rails will work for some and not for others. I've found Rails to be extremely productive and maintainable, but I'm an OOP die-hard and the approach is easy for me to grok.

      One thing I like about ActiveRecord is that it is database agnostic. If I need to, I can move my app from MySQL to Postgres to Oracle with very little effort. The other thing I like is that it provides a clean separation between data storage and business logic. Database programmers seem to hate that approach because it shifts the center of gravity away from the database and toward the web app. This is great for maintainability of application code, but I don't know how well it works for sharing data among multiple apps. I don't know if anyone has gotten ActiveRecord models to support the same level of integration as you can get with multiple apps running off of one database - I think there needs to be more work done to enable that, but I expect to see that work done fairly soon.

      The other cool thing about ActiveRecord is the use of metaprogramming, as discussed in the FA. I don't think we'll ever see a Java persistence layer that is as functional and easy to use as ActiveRecord, because the kind of metaprogramming tricks that Ruby enables are so much harder to do in Java.

    4. Re:Anyone else Railed-out? by ziplux · · Score: 3, Insightful

      Um...sorry, I have to disagree. Using a well-known framework makes a project anything but unmainatainable. Let's say a project is written with a framework, and the original developers no longer supports it, or he leaves your company, or whatever. At the very least there are many people out there with a basic understanding of the framework, and thus a basic understanding of the code. You can hire a Rails consultant and be fairly confident that he will be able to pick up where the old developer(s) left off. Try doing that with some custom framework (or, even worse with no framework at all). I know from personal exerience that it is very difficult to pick up a new framework; it can take weeks, and even after that it's not totally intuitive.

      Furthermore, Rails promotes good coding and design habits. While you may not agree with Model-View-Controller (not sure why, but that's a personal choice I guess), at least Rails imposes some design pattern on the developer. Without this, an inexperienced developer will be able to write completely unmaintainable code.

    5. Re:Anyone else Railed-out? by Dante+Shamest · · Score: 2, Informative
      I want init() functions.

      90% of the time, when you call an init() function, you're going to call a free() function too. Let C++ do the grunt work for you. Use the RAII pattern.

      Put your init() code in the constructor and your free() code in the destructor. That way you won't forget to call free().

      Heck I don't even like C++ for fogging-over-functionality with inheritance, virtual functions and overloading.

      You don't have to use those C++ features if you don't want to. You can program in C-style in C++ if you wish. virtual and inheritance are optional. These days templates do most of what inheritance and virtual functions can do. And I don't understand why you would dislike overloading. Aren't you tired of thinking up names for functions that do the same thing, but just take different number of arguments?

    6. Re:Anyone else Railed-out? by lifeisgreat · · Score: 3, Insightful
      It sounds like you come from a background where you mix business logic, business objects, and presentation into the same file. I suggest that you take a step back and re-examine your design choices. Controllers, modules, and views aren't exclusive to Rails; you'll find them wherever a goood, sane, well-designed code lives.

      A background of incompetence? Funnily enough when I picked up PHP, your disaster scenario was what most people seem to do without thinking about it. In my case, the MVC components are, respectively, PostgreSQL, HTML templates and PHP.

      If your original system was designed with MVC in mind, moving it to Rails should have been easy.

      I think you'll find that most Rails developers hold that it's much easier, cleaner and safer to start a project with Rails in hand, rather than graft Rails onto a pre-existing database.

      What if you forget a single function call at the beginning of one of those pages? Do you suddenly allow objects to be populated with rogue data? Rails has things like filters that make sure certain methods get executed before all actions in a given controller.

      Error checking and testing suites aren't impossible for a C developer to comprehend, you know.

    7. Re:Anyone else Railed-out? by lifeisgreat · · Score: 2, Insightful
      One thing I like about ActiveRecord is that it is database agnostic. If I need to, I can move my app from MySQL to Postgres to Oracle with very little effort.

      That's all well and good, for a subset of database functionality. ActiveRecord reminds me of wxWidgets - smoke and mirrors, bloat and lowest common denominator functionality. But don't get me wrong, for a great many jobs it's adequate and there for the taking.

      The other thing I like is that it provides a clean separation between data storage and business logic.

      That's really just a matter of the intelligence/discipline of the developer. Inexperience can mitigate the benefits of any technology, and believe me I've seen code to prove it.

    8. Re:Anyone else Railed-out? by LuminaireX · · Score: 2, Funny

      What if you forget a single function call at the beginning of one of those pages? If its like any other programming error, I go back and fix it

    9. Re:Anyone else Railed-out? by ziplux · · Score: 2, Insightful
      In my case, the MVC components are, respectively, PostgreSQL, HTML templates and PHP.


      If you wanted to, you could turn your HTML templates into RHTML (Ruby HTML). If you PHP really was just acting as a controller, it should be easy to re-write that in Rails, as it uses the same design pattern. As far as custom SQL, it's easy to keep that in Rails (although it's not really the "Rails way"); you can execute arbitrary SQL statements just like in PHP.

      Ultimately, I think we all code in what we're comfortable with. To many programmers, Rails fits their mind well because of the MVC pattern used, and in general the way Rails handles everything.

      However, I still think custom frameworks are the root of all evil for anything but the smallest projects. Do you, a single developer, really have the guts to say that your framework is better than something that has been developed by a core team of 15 over about 2 years? Do you really think that your framework is that great, that you're willing to have to train someone else to use it, when you could just leverage the work of the community? Creating a custom framework is, in all but the most obscure cases, a supreme act of selfishness.

      Next think you know...you'll be rewriting everying. You, the uber code, know best! Heck, we can write it all in C! Just rewrite all the good stuff that you take for granted in PHP. Why use PHP's session handling when you can roll your own? Oh, right, there's a whole slew of security issues there and you're likely to fuck up some small detail and open up some nasty hole where one user can get to another's session. Etc, ad nauseam.
    10. Re:Anyone else Railed-out? by JulesLt · · Score: 4, Insightful

      Which bit is causing you the problem - Ruby or Rails? My understanding is that Rails is simply providing, well, Rails to give you a rapid framework for your Ruby app - provides you with a web page that's a 'default form' along with the related MVC code. It's similar to other frameworks that provide default pages from ORM mapped classes in other languages, but I thought it was Ruby, rather than Rails, that was getting people excited.

      I'm an 'SQL' guy myself and I'm not convinced by ORM tools - or at least the way they're being hyped as a solution for having to understand the DB (Newsflash : SQL is supposed to be an abstract query language so that the developer doesn't need to understand the DB - and look how that worked - answer : Mostly it does, but when it goes wrong you're dealing with a black box). I also think that the view of many Java (and Ruby) developers that a DB provides 'persistence' is wrong. It's a failure to understand relational theory - which at least, unlike most object modelling techniques, has a firm mathematical foundation. It's also a failure to use the tools provided to you (and when Bruce Tate complains about Java productivity, this tendency of Java developers might be part of the problem - it's 'not invented here' syndrome).

      You could have used Ruby rather than PHP (a comparison I'd like to see) and I also think that there is much to be said for the MVC structure compared to shoving everything into each page.

      It feels a bit clunky in the current paradigm (pages generated on the server and refreshed to the client, client events sent to server) but it works very well as a design, and I can see it becoming more important again as browser apps support more dynamic features - getting back more towards a client-server architecture with the model on the server, view on the client. (Or more likely a local model for performance and some form of background syncing).

      --
      'Capitalists of the world, unite! Oh ... you have' (League Against Tedium)
    11. Re:Anyone else Railed-out? by shmlco · · Score: 4, Insightful
      "Inexperience can mitigate the benefits of any technology..."

      Inexperience and ignorance. And it sounds as if it applies to you and to this situation. I don't see how you can rant against "bloated" technologies you never bothered to learn. Without that knowledge, you don't understand everything that's happening behind the scenes and, since that scares you, you stick with the subset of the developmentatl universe you do know, no matter how appropriate, or inappropriate, it may be to the problem at hand.

      I strongly suspect that once you've moved on to other victims, the next developer the guy hires will take one look at your carefully-crafted optimum solution, shudder, and then rewrite the whole thing.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    12. Re:Anyone else Railed-out? by ubernostrum · · Score: 4, Insightful

      I've volunteered to create a recipe-wiki-site-thing for a friend, and coming from a background in C and SQL there was just too steep a curve to map a procedural train of thought and pre-planned SQL onto the Rails way of doing things. I already created the database schema, wrote all the SQL to get the information I want, have a lot of HTML written for the general template, and was looking at abandoning much of it for controllers, models, automagic foreign key relationships, automagic methods popping out of thin air.. I wanted more control I guess.

      So... you basically wrote the application (minus the controller), and then started thinking about using a different platform? Is it any surprise that you didn't want to switch over to Rails (disclaimer: I'm not a Rails guy. In fact, I work for the competition)?

      So I've done most of the site in PHP instead. Direct, to the point, fast enough (though I'm thinking about a rewrite in C for a pure CGI/FastCGI binary), a minimum of automagic hand-holding - just start each page with sanity checking, authorization, the SQL the page needs and nothing more, and then format the output. No wondering how many hundred methods have been created that I don't know about, what happens when a record is deleted/updated (I'll let the database handle null/ignore/cascade thankyou) or whatever else Rails is doing behind my back.

      OK. It's not like somebody's holding a gun to your head and saying you have to use a framework. Personally, I see a lot of use cases where a framework makes development a lot simpler and easier to manage, because so much of the tedious overhead of web-app development has already been done for you. Think of the framework in terms of an operating system you're programming for: rather than writing all your own device drivers, routines for drawing stuff on the screen, accepting keyboard/mouse input, etc., you've let someone else solve those problems and you're just using the provided APIs to hook up the logic that's unique to your application. And with a framework, rather than write database drivers, routines for accepting and routing input, etc., you've let someone else solve those problems and you're just using the provided APIs to hook up the logic that's unique to your application. Using a web framework is no different, really, than using any other shared library.

      As for all the cruft you complain about, when was the last time you used every single bit of functionality provided by a shared library you linked a C application against? Or is it only bad to draw in automagical functions you won't use when the application isn't being compiled? ;)

    13. Re:Anyone else Railed-out? by oldCoder · · Score: 2, Insightful
      Rails is still suffering growing pains. After that is over, it will have the problems of maturity. Rails has a lot of good ideas, and leveraging Ruby is one of them. But Rails is not well documented. It's almost as if the Rails devlopers have never seen really professional documentation and are happy to just look at the Rails source for information. For example, the API docs don't have a search box.

      I think Ruby and Rails are about the right ideas for our current and near future environment -- cheap cpu's, tight schedules, evolving web standards, clueless users, heterogeneous client hardware (browsers and pda's) and ever faster networks.

      And, by the way, the current Ruby implementation is not quite as mature as the current Perl or even Java implementations. This will change. The sweet spot for using Rails isn't today, it's the next 5 years or so. So now would be a good time to get the experience.

      Not to knock PHP, it lets just anybody put together a dynamic web site without having to know too much. It's a straightforward system ideal for power users who don't want to be computer scientists but who need to build out their ideas. I have a neighbor who's expertise is in marketing and home products who is building his own product line with PHP. Ruby would be beyond him. Who knows, he might just strike it rich with PHP.

      --

      I18N == Intergalacticization
    14. Re:Anyone else Railed-out? by Decaff · · Score: 2, Interesting

      One thing I like about ActiveRecord is that it is database agnostic. If I need to, I can move my app from MySQL to Postgres to Oracle with very little effort.

      You can move your app, but how much effort is there in moving your data model? For serious apps, quite a bit. Oracle has seriously different types of columns and restrictions on columns from Postgres or MySQL, and if you want to use really efficient SQL, you have to use SQL that is hard to port (MySQL has only recently got subselects, for example).

      This is why I think working in the opposite way to Rails - designing your data model in terms of classes and letting the ORM product generate a schema from that (still DRY, but in the other direction) makes far more sense - I can move my apps between those databases with no effort at all.

    15. Re:Anyone else Railed-out? by Local+Loop · · Score: 2, Interesting

      I agree with you, mostly. Rails is a god-awful mess under the hood. The programmers really abuse the language features (especially the ability to re-open objects) to the point where it is nearly impossible to trace through the code to figure out what is really going on.

      I tried it, ditched it and refuse to use it anymore. The last straw for me was the lack of respect for backwards compatibility in their version upgrades -- I had gotten halfway through a small a project and then they changed the API drastically!

      As for the methods they create behind your back, let's just call it what it is: Self Modifying Code. How the heck am I supposed to debug code that doesn't exist at design time?!?

      I too am a procedural guy. I used to write windows programs in C (Delphi now) and am currently doing a lot of embedded work in C. But there are some nice advantages to OOP for web development. For example:

      1. It's nice to have a common base class with a before() function that can handle auth and logging for the entire app.
      2. I can release app upgrades to beta users by copying, renaming and modifying a controller object and view directory
      3. Reusable GUI components!

      I am such a convert to (light, simple, uncomplicated) OOP that I have written my own Perl MVC framework to let me do it easily.

      But I feel that Rails' implementation of MVC is simplistic and naive. Also, despite all the hype, they haven't solved any NEW problems in web app development. For example, when is somebody going to tackle:

      1. standardized, cross-app, cross language/framework logins
      2. monolithic, parameterized page components that can easily be re-used in other apps
      3. easy support for query direction across replicated DB backends
      4. built in support for session sharing across multiple servers (with the session data kept in the DB, not in memory

      So yes, I am a fellow nutjob, but I have seen light of OO web development.

    16. Re:Anyone else Railed-out? by somersault · · Score: 2, Insightful

      Ah I think you've just hit the nail on the head as to why I'm finding programming concepts less interesting these days .. well I've always known that HTML is boring, but making everything so verbose, full of tags and structure does tend to detract from the actual job of getting things done. I do appreciate the benefit of classes and structuring code etc, but ever since going to uni I've kind of lost my drive to actually do any coding projects that I'm not being paid for.

      --
      which is totally what she said
    17. Re:Anyone else Railed-out? by Vaevictis666 · · Score: 2, Insightful
      lack of respect for backwards compatibility in their version upgrades -- I had gotten halfway through a small a project and then they changed the API drastically!

      This is an unfortunate side-effect of working in a pre-1.0 environment, regardless of what it was. I believe the current plan is to not break any APIs until 2.0 hits (and maintain the 1.x branch for security updates once 2.0 hits)

      As for the methods they create behind your back, let's just call it what it is: Self Modifying Code. How the heck am I supposed to debug code that doesn't exist at design time?!?

      Firstly, it's not self modifying code, it's metaprogramming. Self-modifying code changes during runtime. Metaprogramming (and all the class-method shortcuts you have available for ActiveRecord and ActionController subclasses) writes code for you, just like C preprocessor macros, but once it's loaded it's done. As far as debugging, I've been working in rails since July last year, and haven't needed a debugger once. Break your methods into small bitesize chunks, and write a decent test suite alongside - If something's wrong, small methods make it easier to isolate, and your tests will tell you exactly what the problem is.

      But I feel that Rails' implementation of MVC is simplistic and naive. Also, despite all the hype, they haven't solved any NEW problems in web app development.

      That's entirely true. Rails doesn't solve any new problems. It's just an MVC. What's special about it is that it gets out of your way with a minimum of fuss, allowing you to spend more time solving your problems, rather than getting the framework to do what you want.

      For example, when is somebody going to tackle:
      1. standardized, cross-app, cross language/framework logins
      4. built in support for session sharing across multiple servers (with the session data kept in the DB, not in memory

      Point 1 is being worked on as a plugin to rails, but I'm not sure I'm entirely sold on the idea. Point 4 is already done in rails, you can set one config variable (commented out in environment.rb in a default rails install) and use either your existing app database or an instance of memcached on another server.

      I'm not sure what you're getting at with 3 (I would assume that should be the job of a load-balancer or the database itself), and I'm not sure I want to see 2 at all...

    18. Re:Anyone else Railed-out? by cygnus · · Score: 2, Insightful

      actually, you can generate DDL from an OO class definition in Rails by using migrations, which is the built-in way Rails handles updating databases to the current version. you do "script/generate migration " and a skeleton gets generated for you, and then you fill it out. then just run "rake migrate" and DDL is run that generates your tables. here's a writeup of it.

      --
      Just raise the taxes on crack.
    19. Re:Anyone else Railed-out? by I+Like+Pudding · · Score: 2, Insightful

      What caliber web-devs are we talking about, where any sane persistence technique in a database-backed environment, or god-forbid a SQL query here and there, requires more than a trivial amount of time to comprehend?

      Use of a framework requires zero time to comprehend if you are familiar with it. I was mainly thinking of extending the codebase, though. The bigger the codebase, the worse a handrolled framework gets. I currently work on a large perl web app with a handrolled framework, and even trivial things like adding a couple pages are just a kick in the dick. Major changes are hell.

      I had to add some code to track items added and removed from the cart a year and a half ago. This took me over a month because I had to:

      - Insert code before and after every change to the cart. Logically, I should add this in one place - the model's add, remove, and modify item methods. Oops, SQL might modify shit behind my back without hitting the object model, so that's out.
      - Store the carts's previous state to make sure I didn't double-report changes. There's no session to store anything in the app's framework, so I had to use cookies. This lead me to find out that headers had already been sent by the time I had tried to set the cookie. OOPS. Guess I need to write an output caching layer. Then I had to track through massive amounts of handrolled framework to find every piece of code that was bypassing my cache by calling print() instead of $context->print(). Then I had to alter them to take a context. Then I had to set the context for every single template used by the cart, because half the templates didn't share common init code. Output caching should be handled out of the box.

      This isn't exactly challenging stuff as far as programming goes.

      No, not when you've set the bar so low that "it works" is your justification. I don't want things to work, I want them to work beautifully, scale, extend easily, and get rid of all the Repetitious Shit like "select total from orders where order_id='1234'" by replacing it with Good Shit like order = Orders.find('1234').

      It still amazes me just how much code people write for web apps these days.

      Because you are insane. The web is just an interface; the backend can do anything and often does.

      most of the mental effort went into the database and associated triggers/functions, and practically all the scripts do is make SQL queries presentable.

      That's because you've pushed your business logic into the DB, which makes baby Jesus cry.

      I'm still wondering about the C rewrite as well. I'd love to know how your app became CPU-bound before it became IO bound. The Rails solution to this would be to start template caching, not rewriting everything in C.

    20. Re:Anyone else Railed-out? by dubl-u · · Score: 2, Interesting

      I've volunteered to create a recipe-wiki-site-thing for a friend, and coming from a background in C and SQL there was just too steep a curve to map a procedural train of thought and pre-planned SQL onto the Rails way of doing things.

      For which, I salute you.

      Personally, I'm a big OO guy; for anything beyond a thousand lines of code, I feel the object-oriented approach makes maintenance much, much easier.

      But what makes me bat-shit crazy is people who feel like you do but aren't smart or independent enough to be honest that either a) they don't really get OO yet, or b) they get it but prefer to work otherwise. So they go and write a bunch of semi-procedural crap in an OO language, half-assedly using the various OO features wrongly. I've heard this called "procedural object oriented programming" or POOP, and it is so much worse than either good procedural code or good object-oriented code. And honestly, 75% of the Java code I get asked to review is POOP.

      So I seriously and unironically salute you for knowing what works for you, and valuing good code over following the latest trends.

      And a little P.S. to my fellow Java developers: If you have a lot of objects with data and no behavior (just getters and setters), or a bunch of objects with no data and lots of behavior, then that is not object-oriented programming. The first is a struct; the second is a function library. Object = data + behavior. If you aren't sure whether you're doing OO work, read Domain-Driven Design.

    21. Re:Anyone else Railed-out? by ikarys · · Score: 2, Informative

      Rails is MUCH more than an ORM tool with default forms. It provides you with database versioning, Scriptaculous integration (including AJAX stuff (stupid buzzword)) Elegant field validation, Mailing, Kickass MVC, Unit testing, Fairly advanced cache model, Beautiful syntax etc etc etc And combined with ruby gems (like plugins that will update/install with ease), its just too good to pass up. Every aspect of it is elegant, except unicode, and cross database transactions .... And.. i love the fact that google/yahoo will buy your company if you use it :)

  3. Wrong Mentality by MLopat · · Score: 4, Interesting

    People, and usually not developers, are still caught up in the idea of a programming language instead of the concept of applying an API or SDK to a task. My favorite example of this is the often held C++, C#, Visual Basic debate -- everyone has their syntax preference, but at the end of the day its the paradigm you apply that matters and not the language.

    A politician giving an address in German instead of French is not more effective as his points will still remain the same. The language isn't the tool, the intention is the tool.

  4. Re:In a comparison, Ruby suffers for one big reaso by syntaxglitch · · Score: 4, Interesting

    Kind of ironic, really, given that Ruby actually comes from a country that uses a non-ASCII alphabet... well, not really an alphabet at all, actually.

  5. Re:rails by syntaxglitch · · Score: 3, Funny

    Meanwhile, people who actually understand the value of and principles underlying relational databases grit their teeth and fight the urge to beat people with blunt objects.

    Not me, though. I never "got" relational database theory and am quite content to give people nightmares with my naive object-biased approach. :)

  6. Uhhh.... by wbren · · Score: 4, Funny

    Everyone knows that no programming language is a perfect fit for every job.

    I program in raw machine code. It's a perfect fit for every job, every time!

    --
    -William Brendel
    1. Re:Uhhh.... by wanorris · · Score: 2, Insightful


      I program in raw machine code. It's a perfect fit for every job, every time!


      How's client-side web page scripting working out for you?

    2. Re:Uhhh.... by A+beautiful+mind · · Score: 2, Funny

      Bah, that's nothing! The first rule of starting a programming project:

      Get five tons of sand and then...

      --
      It takes a man to suffer ignorance and smile
      Be yourself no matter what they say
    3. Re:Uhhh.... by Ziviyr · · Score: 5, Funny

      I guess the answer for that is "works great on IE!"

      --

      Someone set us up the bomb, so shine we are!
  7. Still looking for an IDE by bogaboga · · Score: 3, Funny
    I am still looking for a Ruby IDE on either Linux or Windows. May be I am looking for what does not esist, but my sense of an IDE is something like Access/VB for Microsoft's Jet Database Engine.

    Here, we simply drag and drop then program the logic behind all those widgets we've dragged onto the form. I also looked for something in relation to Python but could not find anything! I taught VB myself using this method. Current IDEs I have looked at make things confusing. Am I looking for what does not exist? Hope not!

    1. Re:Still looking for an IDE by gnud · · Score: 2, Informative

      - http://wiki.python.org/moin/IntegratedDevelopmentE nvironments
      If you need a drag'n'drop gui editor, try Eric (pyQT( or BoaConstructor (wxWindows).

    2. Re:Still looking for an IDE by lifeisgreat · · Score: 3, Informative

      Try RadRails - it's the best Rails-specific IDE I found during my brief searching. I noticed a few bugs, but at least it's still being developed.

    3. Re:Still looking for an IDE by k2r · · Score: 4, Funny

      > Here, we simply drag and drop then program the logic behind all those widgets
      > I taught VB myself using this method.
      > Current IDEs I have looked at make things confusing.

      Nothing personal but: This explains much of the VB code I had the misfortune to see in my life.

      k2r

  8. Re:Now, more buzzword-friendly? by ziplux · · Score: 2, Informative

    An object-relation mapping (ORM) that "just works" and uses reflection on the database to produce business objects without the developer writing more than 3 lines of code is anything but a minor improvement. ActiveRecord is also more than an ORM. It allows developers to declare that an object "acts as a list," which then allows the object to be sorted in an array. There are many other such "meta-programming" constructs in ActiveRecord.

    It also gives you a lot of stuff for free; migrations from one database schema to another, for example, are wrapped in ActiveRecord calls and are thus database-agnostic. You don't have to worry about packaging one SQL update file for MySQL and another for Postgres and another for MS SQL. The console is really cool too...it allows you to interactively play with your objects. You can even run it in 'sandbox' mode, so that all of your changes are rolled back when you're done playing.

  9. language matters a great deal by idlake · · Score: 4, Insightful

    everyone has their syntax preference, but at the end of the day its the paradigm you apply that matters and not the language.

    The differences between C++, C#, and VisualBasic are far deeper than syntactic. C#, for example, guarantees fault isolation, while C++ does not. C# has full reflection, while C++ does not. Programmer productivity in different languages can be orders of magnitude different.

    Of course, most working programmers have the same superficial view of programming languages as you do and will make the same glib and ill-informed analogies to natural languages that you did. That's why people keep choosing C and C++, believing the differences to other languages to be merely syntactic, and then producing code that crashes, silently mangles data, and has gaping security holes.

    Fortunately, the herd mentality is driving even people who don't know what they are doing away from C/C++. Even your own company bills itself as a .NET development house. You may not understand why C# is better for you than C++, your productivity may not increase, but the fact that you have switched means that your software will ultimately still cause fewer problems.

    1. Re:language matters a great deal by NitsujTPU · · Score: 2, Insightful

      Ask developers at Microsoft if they developed Vista in 100% C# before taking that perspective young man, you might be surprised at the response that you get.

    2. Re:language matters a great deal by idlake · · Score: 3, Interesting

      Ask developers at Microsoft if they developed Vista in 100% C# before taking that perspective young man, you might be surprised at the response that you get.

      Thank you for illustrating my point.

      Microsoft has, in fact, hired many of the top language designers of the world because they think languages matter.

      Microsoft has been pushing hard for a move to managed runtimes.

      And Microsoft's severe problems with their previous C/C++ efforts are the reason for that.

      So, lots of people at Microsoft have come to the conclusion that languages matter a great deal, and that's why they are investing probably hundreds of millions of dollars in that.

    3. Re:language matters a great deal by AArmadillo · · Score: 2, Informative
      Programmer productivity in different languages can be orders of magnitude different.
      Most studies show that this is blatantly untrue -- programmer productivity is generally independent of language chosen. In other words, given an 'average' programmer with X years of experience in their language, they will take about the same amount of time to complete a given task in their language.
    4. Re:language matters a great deal by aricusmaximus · · Score: 4, Informative

      Most studies show that this is blatantly untrue -- programmer productivity is generally independent of language chosen.

      Excuse me? Which studies?

      Certainly not this one:

      http://page.mi.fu-berlin.de/~prechelt/Biblio/jccpp rt_computer2000.pdf

      Nor this one:

      http://www.erlang.se/publications/Ulf_Wiger.pdf

      Nor even this one:

      http://www.theadvisors.com/langcomparison.htm

      And this well-regarded programmer certainly doesn't agree that the choice of language doesn't matter:

      http://www.mindview.net/WebLog/log-0025

      I tell you what -- interview a group of experienced programmers for a prospective project to write a database-backed web application with complex requirements. Tell them that they will be required to program in assembly language because "most studies show that... programmer productivity is generally independent of language chosen." Record their responses and post them to Slashdot.

  10. No kayaking for once! by LarsWestergren · · Score: 3, Funny

    I'm amazed, a whole article by Bruce and not a single anecdote about kayaking. His writing is improving. :-)

    --

    Being bitter is drinking poison and hoping someone else will die

  11. Really a time saver by pmontra · · Score: 4, Interesting

    I recently wrote two applications that included a registration form, validation checks, sending email with a URL to click to confirm the registration and finalizing the registration.
    I wrote the first one in Java and the second one with Ruby On Rails, to learn the language and experiment with the framework. The Rails application needed half as much time to be coded than the Java one, despite being totally new to Ruby and to Rails.
    The merit goes almost entirely to ActiveRecord and expecially to the validation feature.
    Another time saver is Ruby's being interpreted instead of compiled. That saves a few time at every change to the code, even if strong type checking at compile time would have occasionally saved me a lot of time. It's difficult to assess if I gained or lost time.
    What I'm looking forward to now is a good ActiveRecord implementation for Java because Rails is great but Ruby's syntax is really appalling. Even Perl (admittedly one of my languages of choice) looks more consistent. On the other side, halving development time is something that tempts me a lot. Java on Rails would be great.

  12. Rails rocks (but isn't a silver bullet) by PetriWessman · · Score: 5, Informative

    I've been playing around with Rails and AR quite a bit lately, and it has changed the way I think about programming in many (positive) ways. I come from a heavy Java / J2EE background (do that for a living, serverside systems), and Ruby + Rails is a breath of fresh air. Ruby is simply a wonderful language, there is something very "zen" about it, and Rails is inspired. Sure, it builds on a lot of old concepts, but the brilliance is where it leverages the power of the Ruby language to do things in very efficient and nice ways.

    Yes, there is a lot of "black automagic" involved in Rails. It's where the power is, and you can override pretty much everything is you want to. If you're uncomfortable with magic stuff happening behind the scenes and don't want to learn Ruby so you really understand that magic, Rails might not be for you.

    I'd claim that pretty much every serious programmer (VB scripters don't count :) should learn Ruby, at least the basics. It might not become your new favorite language (like it has for me), but it will give you a fresh new perspective on how to code stuff.

    Ruby does have a few downsides:

    • There is no Unicode support. For a language coming from Japan that's surprising (and sucks). I'm given to understand that fixing this is in the roadmap for Ruby(?).
    • It's an interpreted language (like Perl, Python etc), so if speed really is an issue for you then it's not a good choice (for most things nowadays, Ruby is more than fast enough)
    • The scoping of variables in blocks is a bit funky.
    • Some of the organization in the standard libraries is a bit weird, and there is some repetition of functionality. I think this is due to historical reasons (std lib code has evolved over the years)

    (there are probably more, but I'm still only learning the language)

    As for Rails, well, again there are downsides. Nothing is perfect.

    • No Unicode support (inherits Ruby weakness). For web apps, this really sucks.
    • Poor localization support in general (again, sucks).
    • ActiveRecord is nice, but works best for from-the-ground-up projects. Integrating with a legacy schema might get ugly, a mapping layer (like Java's Hibernate) would work better there.
    • No support for clustering and other heavy-lifting technologies. If you're building a seriously big app, Rails might not be the optimal choice. But face it, 99% of web apps don't need stuff like that. Right tool for the job, and all that
    • Still a young framework, and evolving. This is both good and bad. Bad, since the framework is changing while you code. Good, since it means that bugs (and maybe the above weaknesses, too) are getting fixed.

    So: it's not a silver bullet. Nothing is. But for a large majority of the modern-day web app use cases, it's very nice, productive and, well, elegant. It lets you to do quick prototypes and keep your code clean, you don't end up with the insecure and ugly mess most PHP apps end up being.

    1. Re:Rails rocks (but isn't a silver bullet) by consumer · · Score: 3, Informative

      I don't know about Python, but Perl and more recent versions of PHP are not interpreted. They are compiled to opcodes and then the opcodes are executed. With a persistent environment like mod_perl, you are always running the compiled code after the inital load. Both of them have much better base language performance than Ruby does at this point. I expect that Ruby will eventually work this way too.

    2. Re:Rails rocks (but isn't a silver bullet) by revscat · · Score: 3, Informative

      Well rails is a very good framework + toolset, but like every other enforcing toolset which tries to cover a lot of ground by automating stuff it has a huge problem, follow the road and you are set, if you cannot follow the road you are screwed.

      I have seen this complaint lodged many times, and at first I was concerned about it because of this, but I have yet to actually run into it. Rails is flexible enough that all the conventions it uses are overridable, and if you know of any exceptions to this please let me know, because I am still evaluating it. For example: by default AR assumes your primary key column is named id, but you can override that per-table if you like, or globally via environment.rb:

      ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore

      Similarly, while AR expects plural table names, you can override that with the following:

      ActiveRecord::Base.pluralize_table_names = false

      So I don't agree with the (overly stated, IMHO) belief that Rails falls on its face when you move outside its conventions. My experience does not match this.

  13. Re:Now, more buzzword-friendly? by thrills33ker · · Score: 3, Insightful

    Oh, get over it. Does this have to happen any time anything developed less than 10 years ago is mentioned on slashdot? Ruby on Rails being the current favourite example. Here is how it goes every time...

    Article: "here is a link to an interesting review of (insert technology here)".

    Random guru: "That's nothing! I wrote something similar myself 6 years ago using perl/punchcards/blood from my own hand!"

    Elitist Java developer: "Hahaha! You amateurs! How does your pathetic toy deal with redundant HA database clusters in a real-time mission-critical enterprise environment with a 5-nines uptime guarantee? Come back when you've grown up!!"

    And so on. Personally, I'm a big fan of Ruby on Rails. I'm rather bored of seeing it compared to Java, a language I have never used. I moved to RoR from PHP, and let me tell you, its like a breath of fresh air. Yes, I could develop the exact same websites using PHP, but it involves writing a lot more code. Aren't computers supposed to do mundane work for us? Why make life difficult for yourself - I'm interested in results, not in worrying about whether I've escaped my SQL queries correctly using some function I had to write myself because PHP can't even do that properly.

    Bottom line - RoR means better sites with less work. And that means more time to concentrate on making sites better for users, which is really what its all about.

  14. Now, if he could apply the same wisdom to SQL, etc by expro · · Score: 2, Insightful

    What turns me off is forcing you to store all your data persistence into SQL and relational tables, when it is clearly a hierarchy of objects. Why does everyone think they have to do that? The software would function much more simply and the data would typically work better without it.

  15. My favourite by Trejkaz · · Score: 2, Insightful

    "Hahaha! You amateurs! How does your pathetic toy deal with redundant HA database clusters in a real-time mission-critical enterprise environment with a 5-nines uptime guarantee? Come back when you've grown up!!"

    Rails is scalable, but not in an interesting fashion at all. You want more processing power, you run more instances. Where's the fun in that? I love it in Java land, where creating something scalable inevitably means exciting things like building a single JVM that runs on multiple machines, or wrapping things in five layers of EJB so that they can work across multiple machines.

    --
    Karma: It's all a bunch of tree-huggin' hippy crap!
  16. Re:In a comparison, Ruby suffers for one big reaso by Sircus · · Score: 2, Interesting

    I've recently been writing a project with Rails, using MySQL as the backend. Supporting UTF-8 has been no problem at all. UCS-2 support may well be lacking, but it's certainly not like you can't support people with non-ASCII alphabets.

    --
    PenguiNet: the (shareware) Windows SSH client
  17. Re:In a comparison, Ruby suffers for one big reaso by LarsWestergren · · Score: 2, Informative

    Java though, treats people who want to use UTF-32 as second-class citizens.

    Java has support for Unicode 4 since Java 5, released september 2004.

    --

    Being bitter is drinking poison and hoping someone else will die

  18. Re:Now, if he could apply the same wisdom to SQL, by Decaff · · Score: 3, Interesting

    What turns me off is forcing you to store all your data persistence into SQL and relational tables, when it is clearly a hierarchy of objects. Why does everyone think they have to do that? The software would function much more simply and the data would typically work better without it.

    It is great to see that developes are finally beginning to see the downsides of Rails!

    The thing is, not everyone does think they have to do that! There are perfectly good high-performance ORM systems that do allow you to work with a hierarchy of objects and use rich but portable query languages - examples are Hibernate, JDO and the soon-to-be released JPA (Java Persistence Architecture).

    They are as DRY (don't repeat yourself) as Rails, as with quality implementations you can automatically generate schemas from objects, or get object hierarchies generated from schemas, and they don't have to rely on endless configuration files (you can define minimal relational information as annotations in your objects).

    Also, unlike Rails, they are extremely portable. You aren't restricted to a subset of SQL to get portability. You can use a full and rich query language (like JDOQL 2.0) and that is automatically translated to high-performance vendor-specific SQL for whatever database you are using. Even if you don't want portability, the ability to do this means you get high-quality SQL largely automatically.

    Unlike Rails, they work extremely well with both legacy schemas and schemas that are shared with other applications a developers.

    Unlike Rails, some of these APIs (JDO) don't restrict you to relational systems - you can persist just as easily to things like object databases, SOAP services, LDAP, text files, filesystems etc., without changing a single line of code, and all the while using a rich query language!

    These products and APIs are available right now, have open source implementations and have been used successfully by a very large number of developers for years.

    My view is that they make Rails look primitive.

  19. Re:In a comparison, Ruby suffers for one big reaso by kahei · · Score: 4, Interesting


    Yes, Ruby and it's author have an interesting attitude to string representation in general and Unicode in particular. It's partly what inspired me to write this:

    Psychology of Unicode in Japan

    It's really been a very interesting struggle between people's psychological and I.T. needs -- a struggle that's pretty well over now, but has left behind things like Ruby's way of doing things.

    --
    Whence? Hence. Whither? Thither.
  20. Re:Now, if he could apply the same wisdom to SQL, by MemoryDragon · · Score: 2, Interesting

    Well KODO is considered to be the best persistence layer for java around, I am glad that Bea decided to opensource the KODO EJB3/JPA layer under an Apache license. And I agree Hibernate is subotimal, there are issues with performance in certain areas, there are issues with mass data, and the whole many to many handly in combination with some of the Hibernate core people (not Gavin King he always is nice) in the JBoss forums gives it the rest. I cannot await to move away from Hibernate towards EJB3 JPA based on Kodo.

  21. i don't like the Active Record pattern by WeAreAllDoomed · · Score: 2, Interesting
    i reject the notion that "the db *is* the model". that's crap - the db is the db. it's where you store the model.

    accordingly, things i dislike about active record:

    1) it seems to mirror tables pretty directly;

    2) i don't think the objects you work with in code should know how they are stored - this means they don't inherit or mix-in any database code at all. there should be separate classes that handle this.

    this holds for other languages too, of course. python in this case:
    cn = <a database connection>
    ticketStorage = TicketStorage(cn)
     
    # get list of this year's unpaid tickets
    startDate = datetime(2006, 1, 1)
    endDate = datetime(2006, 12, 31)
    tickets = ticketStore.getUnpaid(startDate, endDate)
     
    # show the tickets
    for ticket in tickets:
      print "unpaid ticket number %s was issued on %s" % (ticket.number, ticket.date)
     
    ... (do some stuff with tickets)
     
    # save changes to database
    ticketStorage.save(tickets)
    a Ticket may consist of data aggregated from several tables; the client code doesn't care about that. the TicketStorage class worries about storage.

    now, inside TicketStorage, you might use your ORM of choice, or access the DB directly, or whatever. the point is, the public methods of TicketStorage draw the line in the sand between the code using the Ticket objects and anything storage-related.

    that's my preference from a design perspective, anyway.
    --
    free software, open standards, open file formats, no software patents.
  22. Re:In a comparison, Ruby suffers for one big reaso by pilkul · · Score: 4, Insightful

    I'm not sure I get your neutral tone in that document. Even though the Unicode standard has certain minor flaws and is not entirely perfect for Japanese needs, do you really believe the arguments put forth by the Japanese nationalists at all justify the total rejection of Unicode in favor of some incompatible local standard? To me this seems a very clear case of politics getting in the way of sound technical decisions.

  23. Re:Now, if he could apply the same wisdom to SQL, by Decaff · · Score: 2, Informative

    Great, "rich query languages" that wrap richer query languages.

    No, in some cases the portable query language is more featured that the language it wraps. JDOQL implementations can provide rich querying even on systems with no built-in query language (like filesystem storage).

    That are highly portable across databases, but themselves are not portable across application layers (do *any* reporting tools support them?

    Of course they are. There are reporting tools like JasperReports that can use Hibernate Query Language directly.

    is there an ANSI standard for ORMs?)

    There are JCP standards for Java ORMs that are fully supported by many vendors.
    Is there any modern standard for SQL that is fully supported by any vendor? No.

    When a developer needs to run adhoc queries in order to diagnose problems with data in a database, to test impacts of schema migration, etc - do they write SQL or application code? Keep in mind that these are not likely to be simplistic queries...

    They can use either. Why on Earth are you assuming that these portable query languages are restricted to simplistic queries?

    Seriously SQL isn't the greatest language in the world, but I have a hard time understanding why anyone that works with database applications can't handle complex queries.

    You are missing the point. Of course they can handle complex queries. What they don't want to have to do is to re-implement thousands of those complex queries in order to migrate to another database product.

    It's like someone working on the linux command line that refuses to learn bash. Or like a web developer that refuses to learn HTML and just uses FrontPage instead.

    No. The portable query languages aren't less rich than SQL. They are simply portable. That is the big difference.

    And aside from the "When in Rome" argument, consider the benefits of learning a data-oriented approach to working with data.

    Who says this isn't the case?

    SQL is more different from java, python or ruby than lisp is. One of the best things a programmer can do is to to become fluent in multiple different types of languages. Compare SQL's set-based logic to lisp or python. Learn to think of data in terms of sets and aggregates instead of just one row at a time. Until you do that you'll never understand reporting, which is really about how to answer basic business questions.

    This is completely irrelevant. Portable query systems in Java are data-oriented, and work with sets and aggregates just like SQL. The difference is that they are 100% portable.

    But maybe that's why we've never seen a powerful reporting tool come out of the java community?

    No - you have never seen a powerful reporting tool. This does not mean there aren't any. There are plenty.

    JasperReports is a good one.

    I think posters really need to do some more research before commenting on matters like this - I keep reading posts like this that bear little relation to reality.

  24. What if you don't need to scale out? by WebCowboy · · Score: 2, Interesting

    The ActiveRecord pattern is NOT new, and it won't scale out past a few dozen tables.

    How many applications out there have more than a few dozen tables? I'd have serious concerns with a system that had a single application, with a single database, comprising of hundreds of tables. In reality such systems are quite rare--for every massive ERP implementation there are hundreds or thousands of smaller applications where Ruby on Rails' Active Record model would work very well.

    For TOY applications, it might be fine, but for say something like an ERP system with thousands of tables, it just won't scale out performance or maintanence wise, never will.

    There are other approaches to system design as well--how about applying a modular "UNIX philosophy" to an enterprise system with several
    distinctly defined "TOY applications" each dealing with a smaller number of tables, all loosely coupled together? Even big, old accounting systems are broken into "modules" after all (which historically are more tightly coupled with the main system but still deal solely with a smaller subset of tables/files).

    I, for one, like "toy applications". I don't think I've ever heard a developer get real enthusiastic about implementing or maintaining an ERP system--not the way a manager or marketing person does anyways. Come to think of it I don't know a lot of enthusiastic end users of such systems either. Perhaps a mega-corporation saves a lot of time and makes its business more efficient with its mega-ERP systems, however, feeding and caring of that beast is still tedious and annoying--it's just less tedious, annoying and expensive than dealing with mistakes, redundancies and general idiocy an enterprise has to deal with in the absence of a good business management system.

    One thing is certain: there are different tools suited to different jobs, and Ruby on Rails/Active Record is best suited to smaller-sized applications where everything is developed from the ground up. Saying it lacks legitimacy because it cannoy scale to handle apps of gigantic proportions or properly interface to complicated, arcane legacy systems (ALL contemporary ERP systems in production use today are "legacy systems" IMHO) is like saying the familiar operator interface of an automobile is a failure because it cannot "scale out" to handle "real" vehicles like high-speed super-trains, jumbo jets or spacecraft. Over 90% of us never need to scale out past four wheels going up to 125km/h and carrying a couple of passengers.

    And don't get me started on performance: Java was widely criticised for its performance, as were PHP and Perl for being interpreted and "slow"...however the use of all of those in very high-volume, demanding production systems. The hardware is out there to handle it now, and I've never heard people complain that Rails or Active Record are way too slow to handle the tasks asigned to them.

  25. Re:Hmm... by Decaff · · Score: 3, Informative

    That stuff sounds really interesting. Do you have links for some of the research?

    Yes. The best place to look is the specifications at the JCP.

    JDO 2.0 is

    http://www.jcp.org/en/jsr/detail?id=243

    EJB 3.0 (including JPA) is

    http://www.jcp.org/en/jsr/detail?id=220

    I've heard of hibernate, but not the JPA. Is that going to be part of the standard JRE? I hate having my code rely on goofy 3rd party add-ons.

    JPA is going to be a standard part of J2EE, but can be used stand-alone with JRE. There are many vendors providing implementations - Sun, Oracle, JBoss, BEA, JPOX, Versant. A significant number of these are going to be open source (JBoss, Oracle, BEA). Hibernate is also going to provide an implementation of JPA.

  26. Re:In a comparison, Ruby suffers for one big reaso by Trejkaz · · Score: 2, Insightful

    Okay, I won't, but can you tell me why I would need more than 16 bits to store a single character ? Why the hell do we need so many characters in the world ? Are there so many ways to say "Hello" that we need millions of characters to communicate with our neighbors ? I'm not saying everyone should speak english (I'm french myself), but eventually the various dialects will condense into more portable languages.

    Of course. For example, we don't need to runic characters in real life, however if you wanted to write a textbook on Anglo-Saxon linguistics, you'd be up shit creek if those characters weren't in there. Same goes for any given language.

    --
    Karma: It's all a bunch of tree-huggin' hippy crap!
  27. That's the real trick, isn't it? by rk · · Score: 2, Insightful

    You're right, that the language itself is not the only thing that matters. Extra libraries to work with makes life much more pleasant.

    But what's under the hood of that do_something_with_file_data? In this fairly trivial example, there's not much difference between a do_something_with_file_data in C versus Perl.

    Nice code examples deleted 'cause of /. stupid lameness filters inserting random spaces, even when I had spaces nearby. GRRRR! Suffice to say both were functionally equivalent and of about the same length: about 8 lines for reasonably readable code that output reasonable, though not strictly standards-compliant, HTML.

    For more complicated web work, however, I would still maintain that there are better languages than C (and Perl for that matter) to be doing the work. I'm not for a moment suggesting that I can replace what would take me a year in C with a day's work in Python (excepting the library issues), but I think that the so-called "scripting languages" are faster to develop many types of applications even without the library advantages they have.

    Execution speed arguments are less a function of the language itself than a function of those environments the languages themselves typically operate in. There are python, perl and Java compilers and I'm sure somebody has made a C interpreter for some strange reason. Most applications do not need to be as efficient as possible by virtue of the fact that a lot of them sit in an idle state most of the time anyway. There are notable exceptions (scientific computing, games, etc.), but there you're going to be writing as close to the hardware as you dare and maybe even C is too much of a luxury and you'll have to write assembly.

    I agree that a language choice, given appropriate and featurewise compatible libraries existing for the task at hand, isn't usually going to make a many orders of magnitude difference in development speed. I do still contend however that appropriate languages to the task at hand can save you a decent slice of project time. My gut instinct would be to say the average would be around 20 to 30. Not massive, but noticeable on the bottom line. Sometimes that choice will even be C. And some things still need the raw power of C. Not bagging on C at all, here! It was the fifth language* I learned, after TRS-80 Extended Color Basic, 6809 Assembly IBM 360 Assembly, and Pascal. Of those five, it's the only one I still use at all, much less remember, and I still love hacking on it.

    I will concede that my gut is not (perhaps) as accurate as a study, but my only point was to say I will still trust my experience over a random stranger on Slashdot waving "studies" around without any reference to what they're referring to.

    *- FORTH was sixth. I've forgotten it, too.