[{"data":1,"prerenderedAt":258},["ShallowReactive",2],{"project-3422721":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":34,"aspects":35,"strip":41,"post_text":43,"what":44,"said":70,"maker_in_thread":155,"shape":164,"grid":168,"attempts":220,"same_week":221,"maker_shows":37,"maker_hidden":250,"reader_version":251,"card":252},"3422721","Pjs","Classes for javascript that you'd actually use","title","Show HN: Classes for javascript that you'd actually use","http:\u002F\u002Fgithub.com\u002Fjayferd\u002Fpjs","github.com","jneen",1325650768,2012,52,23,458,1677,28,"notable","languages","javascript class library","library",[24,25,26,27],"javascript","classes","prototypal inheritance","oop","debated",-0.043,{"positive":31,"neutral":32,"mixed":33,"critical":31},3,4,2,12,{"idea":36,"design":38,"performance":40},{"positive":37,"critical":37},1,{"positive":39,"critical":37},0,{"positive":37,"critical":37},[39,39,39,39,39,39,37,42,37,39,39,31,39,37,39,42,31,31,31,31,39,42,31],5,null,{"problem":45,"audience":56,"pricing":43,"motivation":43,"time_to_build":43,"stack":64,"openness":69,"stage":69,"team_size":69},{"value":46,"source":47,"evidence":48},"Makes classes easier to write in JavaScript without hiding prototypes","inferred",[49,53],{"id":50,"by":51,"text":52},"3423057","wvenable","Because, for many things one wants to accomplish, prototype-based programming is so verbose and error-prone. Adding a simple class-based abstraction over top (which doesn't hide…",{"id":54,"by":11,"text":55},"3425264","This is why Pjs is so small - it's just prototypal inheritance, with the bad parts taken out. You have to know how prototypes work to use Pjs.",{"value":57,"source":47,"evidence":58},"JavaScript developers",[59,60],{"id":50,"by":51,"text":52},{"id":61,"by":62,"text":63},"3422935","aurynn","I'd use this. Does it work with node.js?",[65],{"value":66,"source":47,"evidence":67},"JavaScript",[68],{"id":54,"by":11,"text":55},"unknown",{"praise":71,"objections":88,"requests":111,"questions":118,"alternatives":130},[72,84],{"value":73,"source":74,"evidence":75},"Small and elegant, does the job well","commenter",[76,80],{"id":77,"by":78,"text":79},"3423262","ale55andro","normally all you'd need is a 2 liner utility method to facilitate inheritance. For the rest you can use js as it is with it's actual language features which maybe a little…",{"id":81,"by":82,"text":83},"3423146","limeblack","pjs certainly deserves props for being creative with the function passing, and variable context. I haven't seen that exact usage before. It seems every couple weeks javascript…",{"value":85,"source":74,"evidence":86},"Useful wrapper that keeps prototypes accessible",[87],{"id":50,"by":51,"text":52},[89,96,104],{"value":90,"source":74,"evidence":91},"Confusing that MyClass() and new MyClass behave differently",[92],{"id":93,"by":94,"text":95},"3423448","ricardobeat","Pretty nice. Ends up being similar in structure to classes in coffeescript. The very last lines worry me a bit though: ``` \u002F\u002F instantiate objects by calling the class MyClass()…",{"value":97,"source":74,"evidence":98},"Adding class libraries to JavaScript is unnecessary",[99,103],{"id":100,"by":101,"text":102},"3423035","mathrawka","It seems that everyone wants to add classes to Javascript. I understand that prototype-based programming is a bit of a change from class-based programming, but this is starting…",{"id":77,"by":78,"text":79},{"value":105,"source":74,"evidence":106},"Methods on prototype may be memory heavy for many instances",[107],{"id":108,"by":109,"text":110},"3424202","bmuon","Pjs may work for a small number of objects, but if you're dealing with a large number of intances from a single class Pjs is going to use much more memory than needed. That's…",[112],{"value":113,"source":74,"evidence":114},"Expose creation via P.create or P.inherit",[115],{"id":116,"by":94,"text":117},"3431667","``` new MyClass('bacon', 'eggs') ``` is perfectly possible, or am I misunderstanding your sentence? How about exposing creation via `P.create`, `P.inherit` or something like it?",[119,126],{"value":120,"source":74,"evidence":121},"How does it differ from MooTools",[122],{"id":123,"by":124,"text":125},"3422950","kibibyte","What are the differences between this and something like MooTools? What benefits does P.js offer? (Note: I was only introduced to MooTools today, so I have limited knowledge…",{"value":127,"source":74,"evidence":128},"Does it work with Node.js",[129],{"id":61,"by":62,"text":63},[131,138,145,149],{"value":132,"source":74,"evidence":133},"MooTools",[134],{"id":135,"by":136,"text":137},"3423280","Flam","Mootools does all kinds of stuff. This just allows you to create classes in a traditional way with inheritance and super afaik",{"value":139,"source":74,"evidence":140},"klass",[141],{"id":142,"by":143,"text":144},"3424538","leeoniya","been using this one recently: https:\u002F\u002Fgithub.com\u002Fded\u002Fklass",{"value":146,"source":74,"evidence":147},"CoffeeScript classes",[148],{"id":93,"by":94,"text":95},{"value":150,"source":74,"evidence":151},"Object.create prototypes",[152],{"id":153,"by":109,"text":154},"3424156","Object.create has two parts: the \"create a new object with this other object as its prototype\" part and the \"define properties\" part. The first part can be easily reproduced in…",{"comments":42,"answered":37,"key":156},[157,158,161],{"id":54,"text":55},{"id":159,"text":160},"3425258","Yeah, I'll admit that's a bit confusing. I did want to provide a way do something like Object.create in environments where it's not available. This way you can do…",{"id":162,"text":163},"3427684","(apologies for the double post) Doing away with `new` in this way also has the added advantage of allowing people to create objects with varargs, which is impossible otherwise.",{"commenters":165,"max_depth":42,"maker_replies":42,"first_comment_mins":166,"lifespan_hours":167},15,74,119,[169,173,176,179,181,182,184,186,187,189,191,192,193,195,197,200,203,205,207,209,211,214,217],[170,39,39,171,172,39],"3423122","commenter\u002Fneutral\u002Fnone","jarek-foksa",[174,39,39,171,175,39],"3423754","mattmanser",[177,39,39,171,178,39],"3423918","mixu",[180,39,39,171,109,39],"3424174",[153,39,39,171,109,39],[54,39,39,183,11,37],"project\u002Fpositive\u002Fidea",[100,37,37,185,101,39],"project\u002Fcritical\u002Fidea",[50,37,42,183,51,39],[93,33,37,188,94,39],"project\u002Fcritical\u002Fdesign",[159,33,39,190,11,37],"maker\u002Fneutral\u002Fdesign",[162,33,39,190,11,37],[116,33,31,190,94,39],[194,33,39,190,11,37],"3441370",[108,31,37,196,109,39],"project\u002Fcritical\u002Fperformance",[198,31,39,199,11,37],"3425239","maker\u002Fneutral\u002Fperformance",[201,31,42,202,109,39],"3430298","project\u002Fpositive\u002Fperformance",[77,32,31,204,78,39],"project\u002Fmixed\u002Fidea",[123,42,31,206,124,39],"project\u002Fneutral\u002Fnone",[135,42,31,208,136,39],"project\u002Fneutral\u002Fidea",[81,210,31,204,82,39],6,[142,212,39,213,143,39],7,"other\u002Fneutral\u002Fnone",[61,215,42,216,62,39],8,"project\u002Fpositive\u002Fnone",[218,215,31,206,219,39],"3423033","benatkin",[],[222,227,232,236,241,246],{"id":223,"name":224,"points":225,"category":226},"3413594","Scrollorama",395,"dev_tools",{"id":228,"name":229,"points":230,"category":231},"3417830","nnrccar",300,"ai",{"id":233,"name":234,"points":235,"category":226},"3404330","Honeybadger",147,{"id":237,"name":238,"points":239,"category":240},"3422493","momentum",85,"infrastructure",{"id":242,"name":243,"points":244,"category":245},"3416952","Damn Simple Carpooling",53,"productivity",{"id":247,"name":248,"points":249,"category":20},"3419840","Tofu",49,false,"v2",{"id":253,"name":5,"line":6,"ai":250,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":254,"top":18,"kw":255,"maker":11,"domain":10,"tier":19,"attempts":39,"strip":256,"url":9,"mix":257,"praise":73,"objection":90,"sub":21},3422721,-0.04,[24,25,26,27],"00000015100301053333053",[31,32,33,31],1794036492190]