News for hackers. Stuff that matters.
Re:Introducing PyScript (summary of PyCon keynote) by bipson on Thursday June 23, 2022 @03:38AM (#31846166)
I think comparing it to C isn't fair.

The incumbent is not C, it is JavaScript. Initially JavaScript was also simply run on an interpreter. And it wasn't particularly fast until it got considerable attention by Google & Co, and browsers competing for "who can run this silly JavaScript benchmark the fastest".

Then complaining about how more abstract languages like Python are inefficient compared to C is not fair. These calls to range and Exception handlers are there on purpose, to help the developer avoid writing boilerplate code for the millionth time, and focusing on the problem itself, writing cool things.

C would be a terrible language for the Web I would argue. Web "development" was never a thing for the greybeards and "I dream in assembler"-types (not that I want to exclude anyone, I mean it didn't attract that crowd and another instead). Any challenger for JavaScript must be approachable, easy to understand, easy to write and read. Easy to fix and modify (most "Web Apps" are already obsolete the moment they hit deployment).

Heck, why not go full x86 instructions? Hm, then there are millions of iPhones and Androids on the Web that are not x86... Write our own Assembler?! Let's call it WebAssembly!

Oh, wait.

Re:Introducing PyScript (summary of PyCon keynote) by codedokode on Thursday June 23, 2022 @04:54AM (#31846562)
I didn't write that you need to program your website in C. Obviously it is more convenient to use high-level languages. Everybody wants to write less code. I use Python myself, although not for work. But it would be a good idea to design high-level languages so that it would be easy to compile and optimize them.

For example, JS has no classes and uses prototype inheritance, and you can even change prototype at runtime. This is absolutely useless, inconvenient feature and it makes optimization (like JIT compilation) much more difficult (for example, before calling a method you must ensure that the prototype didn't change, the method was not replaced and so on).

In 95% (arbitrary number) of cases you just need classes with a fixed set of fields and methods known at compile time, which is very optimizer-friendly.

Re:Introducing PyScript (summary of PyCon keynote) by hdjjhhvvhga on Thursday June 23, 2022 @06:19AM (#31847104)
> I think comparing it to C isn't fair.

On the opposite: not only it isn't unfair, it's absolutely necessary. Over the years we witnessed the birth of so many languages, and each of them promised to be more safe than C while keeping performance "close to C". Now we have a cornucopia of programming languages, many of them are definitely "safer" than C (in the sense that it is more difficult or impossible to create some types of errors like buffer overflows), but in terms of performance there still seems to be a considerable gap. Having bad performance is bad for the users, bad for the environment (in terms of direct energy consumption and more power-hungry hardware needed), and bad for software companies (who are limited in what they can do).

Re:Introducing PyScript (summary of PyCon keynote) by danuker on Thursday June 23, 2022 @04:32AM (#31846455)
> Web "development" was never a thing for the greybeards

Hacker News is written in some Lisp, and I spend more time here than on any bloated SPA.

Reddit with the old UI is a close second.

Re:Introducing PyScript (summary of PyCon keynote) by sevazhidkov on Thursday June 23, 2022 @05:20AM (#31846703)
I believe Hacker News’s backend is written on a Lisp (or, more precisely, Arc). In this context, JavaScript, Python and C are being debated for a role of client-side language handling DOM events.

Also, C and Lisp are different breeds. It’s wrong to put them in one bucket of “greybeard” languages. Some Lisps gained traction in the front end space (see ClojureScript).

Re:Introducing PyScript (summary of PyCon keynote) by Zababa on Thursday June 23, 2022 @05:36AM (#31846799)
Hacker News does have a bit of frontend, written in JavaScript. You can see some here https://news.ycombinator.com/hn.js, I'm unaware if it's everything or just a part.
Re:Introducing PyScript (summary of PyCon keynote) by adsharma on Thursday June 23, 2022 @10:44AM (#31849807)
You can transpile this to a more efficient systems language using py2many or another transpiler and all these problems go away if you're willing to sacrifice some of the dynamic features of the language and embrace static types.