Live data from Hacker News

JSX - a faster, safer, easier alternative to JavaScript

jsx.github.com

21–30 of 73 posts

Re: JSX - a faster, safer, easier alternative to JavaScript

#21

Earlier quoted context omitted.

That's a weird thing to think. If you can simulate classes with prototypes, but you can't simulate prototypes with classes, what is the natural conclusion you can come to about which is more expressive or primitive?

When talking about programming languages, "primitive" usually means low level. For example, primitive data types ( http://en.wikipedia.org/wiki/Primitive_data_type ).

So given that, how do you come to the conclusion that prototypes are more primitive than classes?

Re: JSX - a faster, safer, easier alternative to JavaScript

#22
post #19
post #10

Earlier quoted context omitted.

That prototypes are overly complex. You can't simulate most imperative programs with functional ones because writing in a functional language eliminates a vast majority of bugs due to incomplete reasoning about memory barriers and other really hard to duplicate issues like race conditions. CHESS is an amazing piece of software precisely because it CAN simulate race conditions and reproduce them, however, if these thi…

I'm not saying you're wrong, but isn't this a bit like saying that files are overly complex because they can be used to simulate sockets?

It is, but on the other hand if you write code to work with sockets then you get a performance boost on spinning disks because your IO is sequential. And many other benefits like trivial cache prediction, buffering, etc.

I do think that prototypes have useful properties, but I'm not sure that a prototype isn't a form of an open class. I tend to think that the biggest problem with prototypes in js is the interface.

Re: JSX - a faster, safer, easier alternative to JavaScript

#24

Earlier quoted context omitted.

When talking about programming languages, "primitive" usually means low level. For example, primitive data types ( http://en.wikipedia.org/wiki/Primitive_data_type ).

So given that, how do you come to the conclusion that prototypes are more primitive than classes?

Just as you said yourself: classes can be simulated with prototypes and are therefore higher level than prototypes. In other words, prototypes are lower level (more primitive) than classes.

Re: JSX - a faster, safer, easier alternative to JavaScript

#25
post #22
post #19

Earlier quoted context omitted.

I'm not saying you're wrong, but isn't this a bit like saying that files are overly complex because they can be used to simulate sockets?

It is, but on the other hand if you write code to work with sockets then you get a performance boost on spinning disks because your IO is sequential. And many other benefits like trivial cache prediction, buffering, etc. I do think that prototypes have useful properties, but I'm not sure that a prototype isn't a form of an open class. I tend to think that the biggest problem with prototypes in js is the interface.

Prototypes in JS are problematic due to false cognates- it tried to look like Java (due to marketing department fuckery), and use the same keywords as java, but it doesn't act at all like Java which leads to some nasty surprises. This has been fixed in ES5- the correct way to inherit from a prototype is no longer via constructor functions and their prototype property, but via Object.create()

Re: JSX - a faster, safer, easier alternative to JavaScript

#26

Earlier quoted context omitted.

So given that, how do you come to the conclusion that prototypes are more primitive than classes?

Just as you said yourself: classes can be simulated with prototypes and are therefore higher level than prototypes. In other words, prototypes are lower level (more primitive) than classes.

The Gameboy color hardware can be simulated on a desktop computer in a browser, in javascript. Does that make desktop computers more primitive than Gameboys?

Re: JSX - a faster, safer, easier alternative to JavaScript

#28

Earlier quoted context omitted.

Just as you said yourself: classes can be simulated with prototypes and are therefore higher level than prototypes. In other words, prototypes are lower level (more primitive) than classes.

The Gameboy color hardware can be simulated on a desktop computer in a browser, in javascript. Does that make desktop computers more primitive than Gameboys?

It's a difference of power and size, not level of complexity. In theory you could simulate a desktop computer with a browser and javascript on a gameboy color given enough processing power and memory. (without increasing instruction set complexity / requiring more abstraction levels than on a desktop / sneakily inserting more complexity in some other way)

Actually it's a rule of hacks, isn't it? If it can exist... https://www.youtube.com/watch?v=QsZrD622qf0

Re: JSX - a faster, safer, easier alternative to JavaScript

#29
post #6

function foo(bar : string) : string... Why, why do we need unnecessary tokens?! Get rid of the stupid :'s.

I think that most new languages feel obliged to have some sort of fun syntax quirk, usually, it seems, in the form of odd token choices.

Re: JSX - a faster, safer, easier alternative to JavaScript

#30
post #14

Earlier quoted context omitted.

It would seem as though prototypes are the more expressive option if you can use them to simulate classes. In fact, one could argue that this is essentially what Python does. ...but the OP seemed to indicate that prototypes were "primitive", and it sounds like you agree with him. Are you trying to say something that I'm missing?

That's not what expressiveness means. Classes can be simulated in assembly but assembly isn't very expressive.

http://en.wikipedia.org/wiki/Expressive_power
Post reply on HN