Pjs

Languages and libraries

javascript class library

SHOW HN2012

Pjs

Classes for javascript that you'd actually use

github.com

#javascript#classes#prototypal inheritance#oop

52points
23comments
#458of 1,677 in 2012
Top 28%of 2012 by points

How HN took it

DebatedReal support and real criticism

3 positive, 4 neutral or asking, 2 mixed, 3 critical, out of 12 comments about the project. Thread score -0.04.

Idea: 1 for, 1 againstPerformance: 1 for, 1 againstDesign: 0 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Small and elegant, does the job well

    From 2 comments
    • 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…
      ale55andro on HN
    • 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…
      limeblack on HN
  • Useful wrapper that keeps prototypes accessible

    From 1 comment
    • 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…
      wvenable on HN

Objections

  • Confusing that MyClass() and new MyClass behave differently

    From 1 comment
    • Pretty nice. Ends up being similar in structure to classes in coffeescript. The very last lines worry me a bit though: ``` // instantiate objects by calling the class MyClass()…
      ricardobeat on HN
  • Adding class libraries to JavaScript is unnecessary

    From 2 comments
    • 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…
      mathrawka on HN
    • 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…
      ale55andro on HN
  • Methods on prototype may be memory heavy for many instances

    From 1 comment
    • 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…
      bmuon on HN

Requests

  • Expose creation via P.create or P.inherit

    From 1 comment
    • ``` 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?
      ricardobeat on HN

Questions

  • How does it differ from MooTools

    From 1 comment
    • 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…
      kibibyte on HN
  • Does it work with Node.js

    From 1 comment

Alternatives named

  • MooTools

    From 1 comment
    • Mootools does all kinds of stuff. This just allows you to create classes in a traditional way with inheritance and super afaik
      Flam on HN
  • klass

    From 1 comment
    • been using this one recently: https://github.com/ded/klass
      leeoniya on HN
  • CoffeeScript classes

    From 1 comment
    • Pretty nice. Ends up being similar in structure to classes in coffeescript. The very last lines worry me a bit though: ``` // instantiate objects by calling the class MyClass()…
      ricardobeat on HN
  • Object.create prototypes

    From 1 comment
    • 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…
      bmuon on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/3422721)