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

You may love or hate js but it makes great language to start with, runs in your browser and has infinite labyrinths of complexity in every direction - perfect for students to play with. Why nobody is using it to teach?


Because it's a nightmare with ridiculous missing hunks, like the fact that you can't put anything but primitive types in a Set usefully. Why would you use it to teach?


Yes, I'd have lesson explaining it's behavior, how it works any why it works this way and maybe assign homework to extend it to support uniqueness based on structural equality.


You can't extend it to support uniqueness based on structural equality, because the Set type uses == to test, and there is no means in the language of overriding that.


You can extend it, trivial one would be by subclassing and overriding methods to iterate over all entries doing deep-equal. Better complexity can be achieved by hashing (doesn't need to be collision free) and scanning subsets per hash etc.




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

Search: