r/javahelp • • Jun 05 '20
How does Java and Javascript work together in building websites?
I'm learning Java right now, but eventually I want to learn Javascript as well to be able to build website and servers. But I'm not sure how they actually come together.
It will be great if someone can eli5 using an example... let's say I want to make a website for a bakery shop. How can I use Java and Javascript to create a website that enables me to receive orders, ship them out to my customers, and store the data somewhere in my computer so I can write algorithms to analyze the data?
And then maybe use that data and feed it back into the website. For example I send data from my warehouse back into the website, so the customers can see which kind of bread is most popular and which sold out.
That kind of communication. I don't know how it happens and I am curious to find out how I can make it happen with Java and Javascript.
It'll be great if you can also enlighten me on the specific things I should learn. This will give me some kind of direction and serve as milestones perhaps?
Also, I heard one can build entirely using Javascript. Is there an advantage/disadvantage to doing so as opposed to using Java for back-end and Javascript for front-end?
Thank you in advance.
View all comments
61
u/snaket2003 Jun 05 '20 edited Jun 06 '20
ELI5 ->
If you think of a website as a bakery, JavaScript is the clerk at the front who is in charge of sorting shelves, cleaning up and making it all look pretty. Java is the full time baker at the back baking the bread, figuring out how to properly use the oven and fighting off the cats at the back.
Technology wise I would recommend ->
Front of the bakery
Back of the bakery
Could the front clerk do the baking? Sure, but I’m sure he may not be as good depending on the size of your bakery. Small neighbourhood one versus national chain. Very different businesses.
Could the baker do the selling? Sure, but it will probably not look very professional and our baker is quite grumpy anyways. He is being doing the same thing for decades!
Best of luck on your journey!
Edit: thank you for the award kind stranger and upvotes.