News for hackers. Stuff that matters.
Re:Modern Javascript: Everything you missed over the last 10... by gentleman11 on Saturday May 15, 2021 @12:23PM (#27166564)
If people didn’t like JavaScript for front end work, it’s not like they could just switch to python
Re:Modern Javascript: Everything you missed over the last 10... by garyrob on Saturday May 15, 2021 @12:28PM (#27166614)
This brand-new book on using Python (via Transcrypt) in the browser to build a React app may be helpful in that regard: https://pyreact.com. Just started reading it. Seems very good so far.
Re:Modern Javascript: Everything you missed over the last 10... by gentleman11 on Saturday May 15, 2021 @12:33PM (#27166655)
Is the result ie 11 compatible and performant? Honestly curious
Re:Modern Javascript: Everything you missed over the last 10... by Master_Odin on Saturday May 15, 2021 @08:09PM (#27170101)
MS products are going to stop working with IE 11 come August, seems like it's time as an industry to force its retirement on any holdout managers.
Re:Modern Javascript: Everything you missed over the last 10... by bobthepanda on Saturday May 15, 2021 @12:29PM (#27166623)
WASM is supposed to unlock non-Javascript for the browser, no?

Also there have been attempts before but nothing really stuck. How many non-Googlers use Dart?

Re:Modern Javascript: Everything you missed over the last 10... by echelon on Saturday May 15, 2021 @01:29PM (#27167147)
You can write Rust for the frontend right now. It's pretty neat.

Yew [1] is one of the early Rust frameworks for client side work. It allows for multi-threaded (!) execution and javascript interop.

Not many other languages make sense as you have to pack in the whole runtime, GC, etc. Rust is pretty well positioned for WASM, and it's going to take off soon.

[1] https://github.com/yewstack/yew

Re:Modern Javascript: Everything you missed over the last 10... by irrational on Saturday May 15, 2021 @01:27PM (#27167121)
No? WASM doesn't replace JavaScript. Think of it as a high-performance library that JavaScript can make use of.
Re:Modern Javascript: Everything you missed over the last 10... by globular-toast on Saturday May 15, 2021 @12:27PM (#27166611)
I use both JS and Python for work and not a day goes by where I don't wish history had taken a different course and Python had ended up embedded in web browsers.
Re:Modern Javascript: Everything you missed over the last 10... by qbasic_forever on Saturday May 15, 2021 @01:33PM (#27167200)
There was a strange time in the dark days of IE6 dominance 20 years ago that you actually could write page scripts in non-javascript languages. VBScript was a big option that some people used, and IIRC there was a way to get python support in IE (and Windows) script host too. When I was first learning Javascript in ~1998 I remember all the docs showed how to do stuff in both JS and VB script tags: https://stackoverflow.com/questions/17483782/vbscript-suppor...
Re:Modern Javascript: Everything you missed over the last 10... by paozac on Saturday May 15, 2021 @12:38PM (#27166703)
Or Lua
Re:Modern Javascript: Everything you missed over the last 10... by dragonwriter on Saturday May 15, 2021 @12:57PM (#27166878)
> If people didn’t like JavaScript for front end work, it’s not like they could just switch to python

Sure, they can, both via compile-to-JS solutions like Transcrypt [0], and via generate-the-frontend-with-backend-Python solutions like idom [1], Plotly Dash [2], and others.

[0] https://www.transcrypt.org/

[1] https://idom-docs.herokuapp.com/docs/index.html

[2] https://dash.plotly.com/

Re:Modern Javascript: Everything you missed over the last 10... by esrauch on Saturday May 15, 2021 @01:08PM (#27166960)
It turns out that even if you accept "Python is great and JavaScript sucks" that "Python compiled to JavaScript" ends up even worse than JavaScript.
Re:Modern Javascript: Everything you missed over the last 10... by dragonwriter on Saturday May 15, 2021 @01:31PM (#27167167)
> It turns out that even if you accept "Python is great and JavaScript sucks" that "Python compiled to JavaScript" ends up even worse than JavaScript.

Clearly, there are people that disagree with this value judgement, and the existence of that disagreement is an existence proof that Python for frontend is, in fact, a choice people can make, even if it is one you find unattractive.

Re:Modern Javascript: Everything you missed over the last 10... by esrauch on Saturday May 15, 2021 @01:44PM (#27167289)
I also have gotten DMs on Reddit from companies looking for devs since I commented on a thread 10 years ago about an obscure toy language: it doesn't mean thats a reasonable choice for technology.

I think theres legitimate reasons to compile Python to JS, but "JS is bad" can't be one of them, since you still have JS that you have to worry about. It makes sense for codesharing with server code or preexisting business logic.

Over the years I've debugged js compiled from various languages, and it's seriously a terrible experience: however bad you think debugging handwritten js is, reading and debugging generated js is strictly worse (and you will have to)

Re:Modern Javascript: Everything you missed over the last 10... by dragonwriter on Saturday May 15, 2021 @01:57PM (#27167393)
> however crazy you think handwritten js is, generated js is just obviously worse to try to read (and you will have to)

Or...maybe I won’t; I’ve used plenty of compile-to-JS languages (including what starts as “js” with JSX and modern features but gets compiled to plain, and more widely supported, JS), and I spend as much time reading and debugging JS in its compiled form as I do reading and and debugging .NET or Python bytecode instead of source, which is none.

Re:Modern Javascript: Everything you missed over the last 10... by ad404b8a372f2b9 on Saturday May 15, 2021 @01:04PM (#27166934)
That's not a solution if you end up with Javascript in the end. (Also Dash is absolutely terrible, horrible documentation, horrible code.)
Re:Modern Javascript: Everything you missed over the last 10... by dragonwriter on Saturday May 15, 2021 @01:27PM (#27167127)
> That's not a solution if you end up with Javascript in the end. (

It is, just as using compile-to-(or interpreted-by-a-runtime-in-)-native-code languages is a solution to “I don’t like raw x86_64 machine code for desktop applications”, even if you end up running machine code in the end.

> Also Dash is absolutely terrible, horrible documentation, horrible code.

“X is not a choice people can make” is a different claim than “One example of X is not something I personally would recommend”.

Re:Modern Javascript: Everything you missed over the last 10... by ad404b8a372f2b9 on Saturday May 15, 2021 @04:45PM (#27168850)
The issue is that writing code that goes through a JS-transpiler is more complicated than just writing Javascript, unless the language you choose is Javascript-adjacent, whereas writing code that compiles to machine code is infinitely less complicated than just writing machine code.

As to your second point, that's why I put it in parentheses, of course it doesn't refute your claim but if you use as example a technology that has awful documentation because of this two-language paradigm, and leads to garbage code both at the Python stage and the Javascript stage, to me it doesn't paint a good picture of the whole concept.

Re:Modern Javascript: Everything you missed over the last 10... by vbsteven on Saturday May 15, 2021 @01:13PM (#27166995)
Why is that not a solution? The concept of compiling/transpiling a language into the target language for the runtime is everywhere.

Even native languages like C/C++/Rust compile their language into binary format that the platform can run. It just so happens that the web runtime format is JS instead of binary machine instructions.

Re:Modern Javascript: Everything you missed over the last 10... by HideousKojima on Saturday May 15, 2021 @01:22PM (#27167082)
Because debugging your transpiled JavaScript becomes a nightmare in a language you already hate
Re:Modern Javascript: Everything you missed over the last 10... by dragonwriter on Saturday May 15, 2021 @01:40PM (#27167254)
> Because debugging your transpiled JavaScript becomes a nightmare in a language you already hate

That’s what sourcemaps are for; you don’t have to debug compiled instead of source format on the web just like you don't on other platforms.

Re:Modern Javascript: Everything you missed over the last 10... by ptx on Saturday May 15, 2021 @07:34PM (#27169918)
IDOM looks a lot like what I had been thinking of implementing, but with the additional benefit of actually existing. :) Thanks for the pointer!
Re:Modern Javascript: Everything you missed over the last 10... by tshaddox on Saturday May 15, 2021 @12:52PM (#27166827)
Can’t easily write Django code in JavaScript either. In general it’s not like working programmers get to choose any programming language whatsoever for the hardware and platform they’re writing software for.
Re:Modern Javascript: Everything you missed over the last 10... by pessimizer on Saturday May 15, 2021 @01:21PM (#27167077)
You don't have to use Django (you can choose one of the billion alternative CMSes), but everyone has to use a browser. Hell, Django itself has to write javascript.
Re:Modern Javascript: Everything you missed over the last 10... by sirsinsalot on Saturday May 15, 2021 @02:30PM (#27167672)
Django is not a CMS
Re:Modern Javascript: Everything you missed over the last 10... by ironmagma on Saturday May 15, 2021 @12:55PM (#27166853)
There are a wealth of alternatives though... ClojureScript, Elm, ReasonML, and Purescript just to name a few.
Re:Modern Javascript: Everything you missed over the last 10... by aphextron on Saturday May 15, 2021 @12:32PM (#27166646)
>If people didn’t like JavaScript for front end work, it’s not like they could just switch to python

Sure you could. You can develop for the web in practically any language you like these days. People use JavaScript because it has native support for the DOM that nothing else can match. Until we get away from the DOM for application development, it will always be king.

Re:Modern Javascript: Everything you missed over the last 10... by magila on Saturday May 15, 2021 @12:41PM (#27166727)
That has nothing to do with Javascript's merits as a language though. It's simply the only language browsers expose the DOM to natively.
Re:Modern Javascript: Everything you missed over the last 10... by aphextron on Saturday May 15, 2021 @12:45PM (#27166761)
>That has nothing to do with Javascript's merits as a language though.

Sure it does. DOM support is built into the very core of JS as a language, and that has shaped the entire history of its' development and subsequent API choices. It's not just a library that it happens to support, the way it would be with any other language.

Re:Modern Javascript: Everything you missed over the last 10... by roofwellhams on Saturday May 15, 2021 @12:39PM (#27166714)
Try to debug that nightmare. Usually you'll need to debug compiled code.
Re:Modern Javascript: Everything you missed over the last 10... by gentleman11 on Saturday May 15, 2021 @02:28PM (#27167651)
Do sourcemaps not help? I’m not experienced with python to js, but they help with minified js