Live data from Hacker News

PyJS: write your JavaScript-powered web applications entirely in Python

pyjs.org

31–40 of 41 posts

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#31

Personally, I like CoffeeScript syntax combined with JavaScript's "a hash is an object" better than Python's object syntax (too much unnecessary use of "self" and class method decorators could be better achieved with the @ sigil). What I would really find interesting is a CoffeeScript-like language that can compile to both Python and JS (with snake_case for Python and camelCase for JS). Couple it with a JS client-sid…

What about nim (http://nim-lang.org/) ?

It's more python-like than CoffeeScript-like, but still looks lighter than Python, without the overuse of 'self'. It can compile to C for the server part and to Javascript for the client part. The obvious difference with your project is that it targets nim, not python, and thus cannot reuse any of the python libraries. Being so close to C it can use whatever is written in it though.

Check out this page for a good feel of it:

http://hookrace.net/blog/what-is-special-about-nim/

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#32

Earlier quoted context omitted.

CoffeeScript feels for me like more flexible Python. Only thing I was missing until ES6 were generators. I simply love how I can wrap line from csv file in custom CoffeeScript object just by declaring class like: class Entry constructor: ([@id, @description, @amount]) -> and doing new Entry(line.split(','))

An equivalent in Python is >>> Entry = namedtuple("Entry", "id description amount") >>> Entry(*line.split(',')) Entry(id='1', description='an entry', amount='99')

Neat, but can I add few methods to my Entry touple?

Can it inherit from something else?

Can something else inherit from Entry?

Won't named touple have some of its own methods that my methods could have collided with?

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#33

Earlier quoted context omitted.

An equivalent in Python is >>> Entry = namedtuple("Entry", "id description amount") >>> Entry(*line.split(',')) Entry(id='1', description='an entry', amount='99')

Neat, but can I add few methods to my Entry touple? Can it inherit from something else? Can something else inherit from Entry? Won't named touple have some of its own methods that my methods could have collided with?

You can use a `namedtuple` class as a base class, e.g. like this:

    class Entry(namedtuple('Entry', ('id', 'description', 'amount')), SomethingElse):
        def more_methods(self):
            pass

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#34

Earlier quoted context omitted.

An equivalent in Python is >>> Entry = namedtuple("Entry", "id description amount") >>> Entry(*line.split(',')) Entry(id='1', description='an entry', amount='99')

Neat, but can I add few methods to my Entry touple? Can it inherit from something else? Can something else inherit from Entry? Won't named touple have some of its own methods that my methods could have collided with?

>Neat, but can I add few methods to my Entry touple?

Yes, if you subclass it.

> Can something else inherit from Entry?

Yes, it can be subclassed.

>Won't named touple have some of its own methods that my methods could have collided with

Yes and no, it has the "index" and "count" methods any tuple should have, which can easily be overridden by specifying them as attributes in the second argument to the contructor, through reassignment during initialization or method overriding.

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#35

Personally, I like CoffeeScript syntax combined with JavaScript's "a hash is an object" better than Python's object syntax (too much unnecessary use of "self" and class method decorators could be better achieved with the @ sigil). What I would really find interesting is a CoffeeScript-like language that can compile to both Python and JS (with snake_case for Python and camelCase for JS). Couple it with a JS client-sid…

I like your idea of a language that can compile to Python or JavaScript. I wish there were a straightforward & proven business model that could be applied to programming languages. I have a feeling we would see much more interesting development in this area if there were bigger rewards for coming up with something better than the status quo.

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#36
post #35

Personally, I like CoffeeScript syntax combined with JavaScript's "a hash is an object" better than Python's object syntax (too much unnecessary use of "self" and class method decorators could be better achieved with the @ sigil). What I would really find interesting is a CoffeeScript-like language that can compile to both Python and JS (with snake_case for Python and camelCase for JS). Couple it with a JS client-sid…

I like your idea of a language that can compile to Python or JavaScript. I wish there were a straightforward & proven business model that could be applied to programming languages. I have a feeling we would see much more interesting development in this area if there were bigger rewards for coming up with something better than the status quo.

Haxe can target both JS and Python (as well as many other things). It doesn't seem to be very well known, probably because it originally came about for developing Flash content.

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#37

Personally, I like CoffeeScript syntax combined with JavaScript's "a hash is an object" better than Python's object syntax (too much unnecessary use of "self" and class method decorators could be better achieved with the @ sigil). What I would really find interesting is a CoffeeScript-like language that can compile to both Python and JS (with snake_case for Python and camelCase for JS). Couple it with a JS client-sid…

I do have reservation about Python to be the language to be cross-compiled to anything, then there is NodeJS on server side as well, so what the hell :(

Whenever a new stack popup, I always wonder 1) who us it 2) why they use it 3) what they use it for

Hopefully more people share their stacks on http://www.stackbus.com/ (FYI, I build it) so that it help others to decide better.

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#38
post #37

Personally, I like CoffeeScript syntax combined with JavaScript's "a hash is an object" better than Python's object syntax (too much unnecessary use of "self" and class method decorators could be better achieved with the @ sigil). What I would really find interesting is a CoffeeScript-like language that can compile to both Python and JS (with snake_case for Python and camelCase for JS). Couple it with a JS client-sid…

I do have reservation about Python to be the language to be cross-compiled to anything, then there is NodeJS on server side as well, so what the hell :( Whenever a new stack popup, I always wonder 1) who us it 2) why they use it 3) what they use it for Hopefully more people share their stacks on http://www.stackbus.com/ (FYI, I build it) so that it help others to decide better.

i'm going to write my next web app in python on the front end and nodejs on the server just because fuck it.

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#39
post #37

Personally, I like CoffeeScript syntax combined with JavaScript's "a hash is an object" better than Python's object syntax (too much unnecessary use of "self" and class method decorators could be better achieved with the @ sigil). What I would really find interesting is a CoffeeScript-like language that can compile to both Python and JS (with snake_case for Python and camelCase for JS). Couple it with a JS client-sid…

I do have reservation about Python to be the language to be cross-compiled to anything, then there is NodeJS on server side as well, so what the hell :( Whenever a new stack popup, I always wonder 1) who us it 2) why they use it 3) what they use it for Hopefully more people share their stacks on http://www.stackbus.com/ (FYI, I build it) so that it help others to decide better.

What stack did you use to build stackbus.com?

Re: PyJS: write your JavaScript-powered web applications entirely in Python

#40

Earlier quoted context omitted.

Neat, but can I add few methods to my Entry touple? Can it inherit from something else? Can something else inherit from Entry? Won't named touple have some of its own methods that my methods could have collided with?

You can use a `namedtuple` class as a base class, e.g. like this: class Entry(namedtuple('Entry', ('id', 'description', 'amount')), SomethingElse): def more_methods(self): pass

Thank you for this example. It's exactly the thing I had with CoffeeScript
Post reply on HN