Slashdot Mirror


Developer Hacks Together Object-Oriented HTML (github.com)

An anonymous reader writes: Ever since I started coding, I have always loved object-oriented design patterns. I built an HTML preprocessor that adds inheritance, polymorphism, and public methods to this venerable language. It offers more freedom than a templating engine and has a wider variety of use cases. Pull requests appreciated!

19 of 184 comments (clear)

  1. Spare us. by HornWumpus · · Score: 4, Insightful

    Another genius, building his own framework, just what the world needs.

    --
    John McAfee 'It was like that time I hired that Bangkok prostitute; to do my taxes, while I fucked my accountant'
    1. Re:Spare us. by jellomizer · · Score: 2, Insightful

      Object oriented is very overblown methodology. It has its advantages but overall it just gets in the way, because it takes the effort away from logic and workflow and more towards design. So you often end up with a well designed product that doesn't do what it needs to do.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    2. Re:Spare us. by Anonymous Coward · · Score: 2, Insightful

      Your response is about as short-sighted as possible. I'm sure you would prefer to have been spared all of the other many geniuses that have tinkered and built across the many generations. Sure, many of those creations have been left on the scrapheap of time, but the remaining ones facilitate and amplify our abilities.

      Go move into a cave in the deep wilderness where you can spare yourself.

    3. Re:Spare us. by Dutch+Gun · · Score: 4, Insightful

      You know, I disagree vehemently with those who proclaim OO an abject failure. But I'm always a bit bemused with people who feel the need to build OO into everything, whether it needs it or not. The trick, of course, is to use it as it makes sense.

      One of the problems with OO is that poorly designed programs can be much worse to grok the logic and flow of than poorly designed procedural programs, mostly because of how scattered the logic can be throughout an object hierarchy.

      A much more modern* trend is to avoid deep class hierarchies whenever practical, preferring instead to try to use smaller, more reusable objects that are only responsible for a single task, and use composition of objects. This allows you to more easily test each individual component and assure correctness of behavior, and then build on that behavior. These days, a lot of my classes are very shallow, either a single class, or perhaps derived from an interface class to hide implementation details when necessary.

      Class hierarchies still have their place on occasion. There are still cases when you must manage a number of types of related-but-different objects with a lot of common properties. But if you keep this paradigm to a minimum, you'll be a lot happier with OOP, and keep your code more manageable.

      * If you consider the last 15 years or so "modern"

      --
      Irony: Agile development has too much intertia to be abandoned now.
    4. Re:Spare us. by Billly+Gates · · Score: 2

      You are soo right. He should have written it in JavaScript instead

    5. Re:Spare us. by ls671 · · Score: 3, Interesting

      Nice post! Most of my utility classes are stateless and contain only static methods. A lot of common logic is in there instead of being in the instantiated class. Inheritance here and there were it makes sense.

      Yet, I still see OO heads around who think; the more it inherits, the more it is OO. The ultimate case is those projects where all classes inherit from an often called "RootObject" that contains all utility methods for the project hence effectively making all utility methods global methods.

      --
      Everything I write is lies, read between the lines.
    6. Re:Spare us. by Pseudonym · · Score: 3, Interesting

      Yes, but also no.

      Look at JavaScript. ECMAScript 2015 finally added something kind of resembling real classes. Why is that?

      Because the first job of JS has always been to manipulate DOM which was designed in the "90s class hierarchy bloat" aesthetic. The need, but not the ability, was there from the beginning.

      If Eich had managed to get Scheme in, we wouldn't be having this conversation now.

      Tha half-arsed Smalltalk/Erlang style OO that node.js developers seem to be embracing is more "real" than this. I do not think that OO is a failure. I think that Alan Kay has beaten Grady Booch but the world hasn't realised it yet.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  2. its classless to post stories about your own stuff by Anonymous Coward · · Score: 4, Funny

    It's really, really CLASSLESS to post stories about your own projects. That said, it's a preprocessor, that's all. Not seeing how this is different from say, PHP?

  3. Stale project, new news? by Anonymous Coward · · Score: 5, Insightful

    This repo hasn't had a commit in 2 years, why is this interesting now?

    1. Re: Stale project, new news? by Anonymous Coward · · Score: 4, Insightful

      That's just how late Slashdot is. When he submitted it, it was brand new.

    2. Re: Stale project, new news? by NicknameUnavailable · · Score: 2

      This has gotten ridiculous lately. Even science.slashdot.org tends to be 1-2 days behind drudge report.

  4. No thanks... by __aaclcg7560 · · Score: 2

    I use the Pelican static website generator for my static websites. I got Python to massage the data and Jinja2 for the template engine. I see no need to us OOP on the backend. If I did, Python can do OOP.

  5. Not news by Anonymous Coward · · Score: 2

    It says:

    Latest commit d79333a on Jul 22, 2015 @Michaelkielstra Michaelkielstra Commented.

    That's 2 years ago, so I wouldn't call this news. Also, it's just a template engine, so it isn't new either.

  6. Re:its classless to post stories about your own st by __aaclcg7560 · · Score: 2

    I hope not. I'm still polishing my Python script for scraping Slashdot comment history. When I publish it on GitHub, I'll be submitting it to Slashdot. Anonymously, of course.

  7. html is a markup language by johanw · · Score: 3

    that describes the structure of a document. It is not a graphical design language, as most webdesigners think, or a programming language as most webdevelopers think. It is as much of either as LaTeX.

  8. venerable language by phantomfive · · Score: 3, Interesting

    I'm suspicious of anyone who calls HTML 'venerable.' They should call it, "notorious" or "infamous," maybe, "expectorant." Marc Andreesen points out there are just problems with it, and I can't see OOP fixing things.

    So, I looked at this guy's project, and it's better than I expected. The major problem it solves is: "how do you avoid repeating yourself, while still keeping things flexible?" The common approach right now is to either throw it into a CSS library (like Bootstrap) or write Javascript to produce the HTML. The latter idea there sounds like a joke but it's not.

    In comparison, this lets you break things into components (like React does), but without any cost to the front end. Overall a good approach, but likely to get lost in the noise of a thousand other web frameworks.

    --
    "First they came for the slanderers and i said nothing."
  9. I don't see any OO by Half-pint+HAL · · Score: 3, Interesting

    The Github page doesn't give any examples that look like OO to me, which is A) not surprising, because what the hell would an OO markup language look like and B) very surprising, given that the whole DOM is OO from the ground up in modern rendering engines.

    Anyway, on a tangent...

    I see no real call for OO in web rendering, but the one thing I think is missing from HTML is the ability to parameterise things like column widths etc. Why cant I call column 1's width "x" and ask the renderer to make column 2's width "3x"? Or use these parameters across tables, so that the columns in table 1, table 2 and table 3 are all the same size?

    I know this can be done with CSS, but in order to do that, I need to choose a particular size -- I can say "I don't care about the actual size, but these 3 things should all be as big as each other."

    --
    Got them moderator blues I blieve I walk out the do', With these mod-points I been gettin', I 'most never post no mo'
    1. Re:I don't see any OO by darkain · · Score: 2

      column sizing with X, and then X*3 or whatever for the next is actually possible now with flex-box. Instead of setting actual sizes, you can just set ratios (example, width:10px on first, width:30px on the next), and set the columns to flex-grow:1. This will grow them out proportionally to fill up their parent container width, instead of staying the fixed input value. Essentially it works like old HTML table formatting, but with quite a bit more granularity, and each row can optionally be different proportions (unaligned columns)

  10. Re:XSLT still seems like the better choice by omnichad · · Score: 2

    because it's a horrible mess

    It wasn't a horrible mess. Developers made horrible messes with it. And browsers did try to make sense of imperfect xHTML. I don't know of one that wouldn't render something when it came across errors.

    I still type HTML in somewhat valid xHTML, even when incorporating HTML5-specific tags - because the alternative just isn't readable.