6 ms·
I can't believe all the negative comments here. Someone has implemented Python in JavaScript. I personally think that is incredible.
by cmbaus 13y ago
I can't believe all the negative comments here. Someone has implemented Python in JavaScript. I personally think that is incredible.
- lowboy 13y agoI think it's the hubris that's putting people off: > Brython is designed to replace Javascript as the scripting language for the Web
- MatthewPhillips 13y agoThat's a silly complaint. Doesn't every language designer feel that their product is better than the thing it desires to replace?
- readme 13y agoA better question: Is python really any better than JavaScript? Sure, it has advantages here and there. But there are things I like about JavaScript that are better than python. For example, having anonymous functions that are more than a single expression inside a lambda. Yes, I know you can declare a function inside another and you get a closure. But, JavaScript's syntax is just nicer.
- kyrias 13y agoObligatory https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- jMyles 13y agoWow. I had never seen that. There are literally tears streaming down my face I was laughing so hard.
- sesqu 13y agoI enjoyed it more this time than I did when I last saw it, perhaps because I was more familiar with the showcased peculiarities last time (the theme is garbage in, garbage out).
- obstacle1 13y agoJavaScript's syntax being 'nicer' seems pretty subjective.
- StavrosK 13y agoIn all my Python years, I have never needed to write a long anonymous function. I consider it a bit of a code smell. This isn't to say it's wrong to do in JS, just that the patterns in Python are different so you don't use this in practice.
- cmbaus 13y agoIf I wrote a Python implementation in JavaScript, I'd probably have some hubris about it as well. I'm not sure if the developer is one person or if they wrote the landing page as well, but let's assume it is that same person. If someone has focused enough energy to implement a language in JavaScript, it is probably fair say that marketing isn't his or her primary skill. At the same time, reading over the text again, people have said crazier things and done much less. If the developer's goal is to replace JavaScript with Python and his or her first attempt is to implement Python in JavaScript, I, for one, applaud their effort.
- brudgers 13y agoIn programmers, hubris is - along with laziness and impatience - a great virtue. In Larry Wall, they gave the world Perl.
- emiliobumachar 13y ago"It will" would register as hubris, but "designed to" seems harmless to me.
- mirashii 13y ago> Someone has implemented Python in JavaScript. This isn't really true. This is far from a Python implementation. At best you could call it a Python-esque syntax to Javascript translator. And that's perhaps still useful. But to call this a Python implementation is quite simply a lie.
- amirouche 13y agoThis is not a translator but an interpreter, there is no compilation. edit: except FUD, can you provide some points on which brython is failling, please ?
- brythonfailing 13y agoNot that I have anything against Brython (which imo is a cool project, although I'm not so sure if it's practical yet), but since you asked for it, here's an example where it does differ from python: x = 0 def impure(): global x x += 1 return x print(0 < impure() <= 1) In python, impure() would only be evaluated once returning True, but Brython's chaining evaluates it twice, and so it returns False instead. Of course, this example isn't exactly something you'd usually see in actual code (heck, it's probably even bad practice in most situations) BUT the point here is that while most of python might be compatible with this, there exists some inconsistencies that causes one's previously working python code to fail (and these bugs would probably be very difficult to trace). Of course, Brython is still young and has time to hopefully fix these issues. (In fact, this is the second time I've tried this project. Back then they didn't even have the chaining feature working, so it's nice that they are making progress.)
- richo 13y agoNifty example, but this is why we have integration test suites. PyPy, jython, ironpython etc all had/have incompatibilities as the language evolves and as they work out the quirks in their respective runtimes. This isn't compatible with cpython (afaik, none of the other runtimes have ever been COMPLETELY compatible, but this is much further off), but hell, it's pretty awesome. As an aside, I'd shoot anyone who did that ^^ without a pretty amazing explaination.
- msprague 13y agoAgreed! I'm all for constructive criticism, but some of the comments in this thread are unnecessarily negative. This project looks really cool!
- stavros 13y agoI really do hope this (or something like it) takes off. More choice in languages is better, and JS has been the only option for too long. It would be amazing if browsers added interpreters natively, then we could check for a native interpreter and fall back to loading a JS one like brython.
- bhdz 13y agoI have a better idea for a new language based on python: and walked: "through the valley"' he's and feared: not: "evil"! # he.and_walked("through the valley").and_feared(not("evil"))! drop down:' criminal scum! # criminal_scum.drop_down()! eat: breakfast' you! # you.eat(breakfast)! kill: with pistol' maim: blunt object' opponent's check dead: # opponent.maim(blunt_object).kill(with_pistol).check_dead() print person's name's last print person's last' name # ;) # print person.name.last if my's cookies's jar's empty:: print "Cookie Monster, why is the Cookie jar empty?" why: cookie jar's empty:' cookie monster # why cookie monster, why? :) why: cookie jar's empty:' cookie monster's why: "?" it's called Glas :)