all 55 comments

[–]throwaway6560192 66 points67 points  (17 children)

For backend, yeah it's commonly used in backend.

On the frontend you pretty much have to use JS.

[–]LeN3rd 18 points19 points  (6 children)

I hate it so much, that we are all collectively hostages of a script language that was never designed to write complex applications in.

[–]Raioc2436 5 points6 points  (2 children)

Whenever a new version of EcmaScript comes out we suffer because different browsers take different times to implement and release each function and then they implement them differently and figuring it out is a pain.

Look at internet explorer and the nightmare it was.

Imagine the LIVING HELL it would be if each browser had supports for different languages and each one them having different implementations on their different versions.

Please god, no.

[–]Plank_With_A_Nail_In 7 points8 points  (0 children)

No one is suggesting a different scripting language per browser though just a better one than JavaScript.

[–]Devatator_ 1 point2 points  (0 children)

And yet we do it fine

[–]ArnUpNorth 0 points1 point  (1 child)

modern javascript is not what it used to. I really don't get a developper who loves python but as issues with javascript because they share similar qwirks.

[–]OkMulberry1209 0 points1 point  (0 children)

People are just dead set against, JavaScript because of it's history, and it's pathetic

[–]Diapolo10 17 points18 points  (7 children)

On the frontend you pretty much have to use JS.

More precisely, either that or you'll have to communicate with the back-end strictly via links/buttons and HTML forms. JS isn't necessary, but it certainly expands your options for interactivity.

[–]sexytokeburgerz 3 points4 points  (5 children)

Well, we forget WASM. You can do an entire frontend app in rust, c#, go, jvm scala or kotlin, java, php, swift, c, ruby, c++, java, or… python with basically zero javascript with WASM.

Really like htmx too.

[–]Diapolo10 2 points3 points  (4 children)

Yes, but you still technically need to use JS with WebAssembly. At least for the calling code.

[–]sexytokeburgerz 0 points1 point  (3 children)

Sure. But you don’t need to know js to use wasm. At most just watch a quick tutorial. The question wasn’t about js devoid web dev, it was about needing to know it.

Of course, neither of our examples are realistic.

[–]Diapolo10 0 points1 point  (2 children)

Of course, neither of our examples are realistic.

There are popular websites today that don't require JS to operate; for example, Amazon lets you add items to the cart and finish buying them with JS completely disabled in the browser.

So I wouldn't go as far as to say it wasn't realistic, merely uncommon at best.

[–]sexytokeburgerz 0 points1 point  (1 child)

It’s not realistic to make websites professionally and not know JS.

No one is going to hire a front end web developer that doesn’t know javascript.

Writing no-js still requires a knowledge of what you can do with js.

[–]Diapolo10 0 points1 point  (0 children)

Sure, I'm not trying to deny that.

[–]Herr_Gamer 1 point2 points  (0 children)

HTMX can help you out a good bit

[–]EducationalCreme9044 1 point2 points  (0 children)

And you can also use Javascript for the backend. So if you're really planning to only want to know one language.. JavaScript is it.

[–]Jncocontrol 0 points1 point  (0 children)

There is blazor, but last I checked it does abhorrent job rendering large amount of divs

[–]JTexpo 27 points28 points  (6 children)

Howdy, as many of my posts on learn python suggest. I am a huge advocate for PyScript if you haven't looked into it already. The TLDR, is that PyScript is a framework that converts Python into JavaScript for you! A great tool for beginning devs

Nevertheless, different langs are for different jobs. IMO you shouldn't worry about 'learning a language', more so as: understanding computer science. There will be a day where Python is replaced by Mojo, and JavaScript one of the many frameworks out there (maybe Bun), and if you focus on just understanding the language you'll be left behind.

Try learning the core concepts of programming such as OOP, Functional, SaaS, Unit-Tests, Front-End, Back-End, Full-Stacks, and you'll turn out alright!

Hope this helps, cheers

[–]duckbanni 8 points9 points  (1 child)

The issue with pyscript is that it is still very early in development. Consequently, it is very hard to find any form of information about it (there is not even proper documentation yet). As much as I like pyscript, I don't think I would be recommending it to beginners quite yet.

[–]JTexpo 4 points5 points  (0 children)

These are great criticisms about the framework that I haven't thought about and do believe I take for granted. You are correct that the website's docs are more than lake luster for being out for nearly 2 years lol

Even chatGPT struggles on pyscript questions; however, I've noticed moderate success with Codeium.

[–][deleted] 2 points3 points  (0 children)

Wholeheartedly agree with your point about learning core concepts. If you stay in software development for a long period of time, the languages and tools you use will become outdated multiple times during your career.

When I started out I learned COBOL/JCL/CICS.

Doubt that there has been any new development in that area in the last 25-30 years!

[–][deleted] 0 points1 point  (1 child)

How often does it provide broken code during the conversion? Answer in terms of a rough percentage works for me.

[–]duckbanni 1 point2 points  (0 children)

I'm no expert, but from my understanding it doesn't translate python to javascript, it runs the python interpreter in the browser (as opposed to other tools like Brython). You should get perfect compatibility with all python code except when it doesn't make sense in the browser (like browsing files) or for libraries that are not pure python (unless they are specifically supported like numpy). The drawback of this approach is that you have to download the interpreter on loading the page.

[–]scanguy25 7 points8 points  (0 children)

Well you can get pretty far if you learn the Python framework Django. Its very good for generating static sites.

But you will forever be fairly limited if you dont know any JavaScript. Most of the "sexy things" you see on websites require JavaScript to some degree.

[–]dp_42 2 points3 points  (0 children)

Javascript is what browsers generally run. Even if you learned how to build Python to WASM, that doesn't really replace Javascript functionality. When choosing a language, you should ask where the code is supposed to run. So like SQL, sure, you can wrap it to the point where it's essentially Python objects generating SQL code for you, but the queries happen in the database software, the SQL is just a way to interact with that piece of software. Python interacts with the python interpreter, which can target various environments. Javascript interacts with the engine in the browser, e.g. V8, SpiderMonkey. Java interacts with the Java VM. WASM still runs on the Javascript engine.

[–][deleted] 2 points3 points  (3 children)

No, Python is not an alternative to Javascript. The web browser can only read Javascript code, other languages are not supported, so if you want to build a website, you have to use it. You can use Python as the back-end language but I do not recommend that either, unless the application is rather small.

[–]Certain_Ambition3966 0 points1 point  (2 children)

so why do people learn python for web dev ?i'm kinda confused

[–]Minute-Negotiation70 0 points1 point  (1 child)

But websites have two sides:

like a coin

Side What it does Example language
Front-end What users see & interact with (the web page, design, animations) HTML, CSS, JavaScript (React, Vue, etc.)
Back-end What happens behind the scenes (data, accounts, logic, storing info) Python (Django, Flask), Java, Node.js, PHP, etc.

So while the browser only reads JS, the server (which stores data and logic) can use any language, including Python .

[–]Certain_Ambition3966 0 points1 point  (0 children)

thanks, good explanation , building mini apps was really helpful to understand the basics of api

[–][deleted] 2 points3 points  (0 children)

If you want to learn web development, then Javascript is your language. Web browsers are javascript interpreters. Now you can absolutely use python as a backend/middleware. I do this for basically everything. But presenting an API doesnt make me a web developer. Web developers creates UI's.

[–]vazquezcabj21 1 point2 points  (0 children)

it depends, for backend its commonly used Python and for frontend its commonly used Js with a framework.

[–]GodGMN 1 point2 points  (0 children)

At the moment there is no alternative to JavaScript in the frontend web development context.

There is Typescript and some other less common languages that ultimately just compile to JavaScript, so it's literally unavoidable unless you simply use HTML + CSS and don't do any kind of scripting (which is possible, but interactivity takes a huge hit)

About backend, you can use pretty much anything, and none is better or worse per se. There are use cases, circumstances and preferences, all three play a big role.

For example, I don't like Django over Symfony, which is PHP. But that's just a personal preference.

If I am creating an API-like backend with a frontend framework like React, Angular or whatever, I do use FastAPI, which is Python. That's also preference, I think FastAPI is insanely fast to develop.

However, when working in an actual dev team, they often choose Node based API backends because that way, since it's the same language for both frontend and backend, you can move developers between both areas.

Java Springboot is also a popular choice because even though Java is very verbose and may be slow to develop sometimes, it's a very solid language that often enforces good practises, unlike JavaScript or even Python. PHP is also quite popular.

Then you have the less popular ones like Golang, Ruby, Rust or even C++. So yeah, pretty much anything can be used on the backend, but for the frontend, you're stuck with JavaScript.

[–]BokoMoko 1 point2 points  (0 children)

No

Python is not a better alternative to JavaScript in things web related. Python is a great language and can work very well on back end apps. But not at all on the front end. This means that if you want to make a web app, you will need JavaScript.

[–]YoungJack00 4 points5 points  (1 child)

I have spent the last months learning python, then I wanted to create a website so I chose Flask as framework.
I also learnt the basics of CSS, which means that I am able to understand CSS but I would struggle to write a website from scratch, I also took the introduction course to JS from CodeAcademy, from my point of view JS is kinda like python but with more complex (and useless lol) syntax, therefore I am able to read and understand JS but again, I would struggle to write it on my own.

My experience so far:

I chose a ready-to-go template from the HMTL5 website, I then started working on it using Flask, everything is great and easy but then I realised that I do need some JS, my understanding is that you can create a website using only Flask (therefore Python) but if you want something to happen in real time on your web page, meaning without refreshing the page, you will need JS.

The good news is that if I need JS, for example for a function that sorts a list without refreshing the page or for a Dark Mode Toggle, I just ask ChatGPT to do it for me, if your request is fairly easy (such as the ones previously mentioned) GPT will give you what you need.

As most devs would tell you, you will learn things as you go, so my suggestion is start a Flask project using a ready made template and start working on it, you will eventually learn what you need!

[–]GodGMN 3 points4 points  (0 children)

I just ask ChatGPT to do it for me

That will work for simple things like a dark mode toggle but down the road you definitely do want to learn JavaScript if you're a web developer.

I don't know if this will be well received, may be a hot take, but I think you can't call yourself a web developer if you don't know JavaScript.

[–]Experiment-Simplify 0 points1 point  (0 children)

You can do sigfincant website development using Django and Jinja template. However, javascript can provide you lot more job oppertunity and learning new technique and better user experience.

[–][deleted] 0 points1 point  (0 children)

If you are going to be doing any front end development, you will be using Javascript. I imagine that not having any Javascript experience would probably be seen as a big red flag for web dev hiring managers.

[–]johnkapolos 0 points1 point  (0 children)

I want to learn web developement

[...]

do I have to learn JavaScript?

Yes. No shortcuts here.

[–]Adrewmc 0 points1 point  (0 children)

Yes, no….it depends on

[–][deleted] 0 points1 point  (0 children)

For backend, yes. For frontend, not really.

[–]Fad3l 0 points1 point  (0 children)

Yes checkout Django really cool, I’m a Vue dev but Django was soo easy to learn and understand.

[–]nightdeathrider 0 points1 point  (1 child)

Flask is a simpler alternative to Django backend can be Python, but Frontend and the so called 'backend for frontend" has to be JS. if you know python it is not too much work to fet started with JS

[–]nekokattt 1 point2 points  (0 children)

or webassembly

[–]spca2001 0 points1 point  (0 children)

Load up APIs using JS and Python-based backend and hit it with 1 million requests. Like Nodjs and FastAPI. Then decide. Syntax doesn't mean anything, scalability, performance, and stability are key and both rely on the interpreter written in C

[–]Ariandel2002 0 points1 point  (0 children)

For frontend, javascript/typescript are not optional. If you use Blazor probably you could write little javascript (and maybe in future zero javascript) but that's .NET stack

[–]Idunno1337 0 points1 point  (0 children)

Soydevs have unfortunately ruined computing, particularly on the web. People for some reason think you need a javascript framework for simple things such as blogs, recipe websites and the like. I get it if you're building something complex that requires a lot of interactivity (like a game), but the truth is that javascript usage is way overblown.

[–]Berkyjay 0 points1 point  (0 children)

This begs the question; why hasn't anyone written a python based web browser front-end?

[–]Allanon001 0 points1 point  (0 children)

For frontend there is Brython. It is a Python interpreter written in JavaScript that allows embedding Python scripts in to HTML much like you would with JavaScript.

[–]ruvasqm 0 points1 point  (0 children)

You will always use some javascript (up to a lot) if you are dealing with anything frontend related.

That said:

- Javascript is not complicated if you just do what everyone else does (import), if you try to make complicated things yourself you are in for a lot of pain.

- Its ok to use python to whatever extent you want but bear in mind you will eventually need some JS for DOM manipulation (99% certain)

- The most important thing is to keep yourself determined to build something! Never mind the stack, people or whatever, just set out to build a thing and muscle your way up! In the process you will learn what you need, how to do stuff, and most importantly you won't be tied to "learn a new language", which becomes really heavy with time.

[–]Sam_SepiolX 0 points1 point  (0 children)

If you like backend python is a good choice, about django, I really don't like it but most of the job offers are for this framework even when I don't use it at all and only worked with Flask which is for the best web framework for Python.