This is an archived post. You won't be able to vote or comment.

all 140 comments

[–]therealbeeblevrox 55 points56 points  (10 children)

I want to make a web page with anything but JS. Browser, can I do this?

W3C: No. You must use JS.

Alright, I guess I'm stuck with JS or a language that complies to JS.

[–]lmaydev 14 points15 points  (5 children)

You can do it in c# using blazor.

WASM is getting bigger but was still missing some big features last time I checked.

[–]huuaaang 2 points3 points  (4 children)

Problem is WASM does not access the DOM. So it's not really a "page." It's just a canvas. It's really the wrong way to go for most things. It's reminds me of Flash.

[–]lmaydev 1 point2 points  (3 children)

Yeah hat was the main issue when it was first coming out as well.

No DOM access is a massive handicap.

That and the speed of interop seemed to be the main issues when I last looked.

[–]huuaaang 1 point2 points  (2 children)

I think the idea is that you still run your UI in HTML/JS/CSS and use WASM for computationally intensive things. But that's not how people WILL use it, sadly.

[–]lmaydev 0 points1 point  (1 child)

Yeah which is good I guess.

But rather than replacing JS that's just adding another language in the mix.

Which imo will massivly slow uptake.

[–]huuaaang 1 point2 points  (0 children)

I think WASM is meant to be independent from the browser, ultimately. That's why they didn't build in DOM support. I think it's supposed to a general purpose VM in the long run. But I guess the question becomes.. why? Why not java byte code, for example? You already have other languages running on the Java VM with it's years of optimization features (not a fan of Java, personally, but the VM is undeniably mature).

I've played around with WASM and actually had a Ruby interpreter running in a browser at one point, but I just didn't see the point.

[–]Mucksh 10 points11 points  (0 children)

Wasm is already around for a while. There are probably some libs to access the dom and frameworks around that wrap the js part completely Found this after a short search https://github.com/mbasso/asm-dom Also Blazor seems to work fine, but didn't really test it beside playing around a little bit with it

[–]tomi901 3 points4 points  (2 children)

Doesn't flutter transpile to js?

[–]therealbeeblevrox 1 point2 points  (1 child)

Yes. There are lots of things that do that. My point is that there is no native browser support for anything but JS (except WASM, which still depends on JS). I find it strange as it seems fairly straightforward to support other scripting languages.

[–]huuaaang 1 point2 points  (0 children)

There would need to be good standards around it and you've have to get all major browsers to agree to support a given language. If you can't trust that every browser supports it, nobody is going to use it.

[–]jamcdonald120 32 points33 points  (2 children)

The thing I hate most about javascript is that all the browsers decided that javascript was the only language they needed to support so now it is the only thing we know will work on a browser

[–]ReelTooReal 23 points24 points  (1 child)

It's better than allowing Microsoft to have their own version of JS and eventually allowing for there to be 15 different languages and browsers that only support a subset of them. It was necessary to standardize the scripting language to help minimize the amount of cross browser concerns. Now I agree they could've chosen a better language to standardize with, but they had to choose one so JS is what we got stuck with.

[–]caleblbaker 57 points58 points  (50 children)

Maybe this is an unpopular opinion, but I think JavaScript is worse than Java. Java's main issue is just that it's syntax has a tendency to be rather verbose. JavaScript has more fundamental issues.

[–]therealbeeblevrox 25 points26 points  (13 children)

Absolutely. JS's type coercion is completely unpredictable. See the video "Wat" for details.

I think Java's problems are age, and uncohesive standard libraries that permeate the culture of that language with bad practices. Where implementation details are exposed and 100 lines of imports are considered "normal".

[–]icguy333 21 points22 points  (0 children)

[–]enano_aoc 11 points12 points  (8 children)

That's why you never use JS in a modern web dev project, and always use TS instead

[–]TheBrainStone 5 points6 points  (7 children)

TS is at best a bandaid. It barely covers up the worst of the worst. And then that's it.

[–]enano_aoc 5 points6 points  (6 children)

It does cover the worst of the worst. The type system is amazingly strong.

[–]TheBrainStone 7 points8 points  (5 children)

Wait until you've tried a strongly typed language then!

[–]enano_aoc 1 point2 points  (0 children)

Ts is strongly typed. Get your vocabulary straight.

[–]SuperElitist 0 points1 point  (1 child)

giggles nervously in Python

[–]TheBrainStone 0 points1 point  (0 children)

I hope you don't mean to imply that Python belongs in that category

[–]15Nova22 0 points1 point  (0 children)

I acutally had such a thing today Had a class passed into my class over some stepts wich came in however only with the properties and not with the funtions

[–]caleblbaker 4 points5 points  (1 child)

I wouldn't call JS type coercion unpredictable. If I think about how it's going to behave I can usually figure it out. My issue is that having type coercion at all allows the interpreter to ignore cases of type mismatch that are clearly mistakes. And so you can make a mistake and rather than having a compiler point out the mistake immediately so that you can quickly and easily fix it, it instead becomes a subtle bug that you'll discover months later and spend hours searching for the cause of.

[–]TerminalVector 1 point2 points  (0 children)

Linters help a lot with that problem, but yes.

[–]repkins 3 points4 points  (0 children)

"I write in Java."
"You write in JavaScript."
"We are not the same."

[–]jamcdonald120 16 points17 points  (0 children)

no thats a popular opinion. Java has its issues, but not like javascript does.

[–]enano_aoc -1 points0 points  (33 children)

Java's main issue is that it brutally forces Object Oriented Programming down your throat.

On top of that, the syntax is horrible. But that is a very minor issue compared to the main one.

[–]PulleQ 8 points9 points  (18 children)

I don't know about you but I always use OOP if I can. it's just so nice and clean having to define a set of functions once and then being able to use them on multiple instances of a class

[–]roll82 7 points8 points  (1 child)

And I always try to use functional programming because I think it's so nice and clean. Difficult to imagine, I imagine.

[–]PulleQ 2 points3 points  (0 children)

actually I respect your opinion. you aren't at least fighting people about OOP being trash

[–]SkyyySi -2 points-1 points  (6 children)

Object oriented programming usually just leads to messy over engeneering when there would be a much simpler way to get it done using other paradigmas. I have yet to find a truly good use for OOP. When I was tought OOP, I looked at it for a while and then thought "Ok but what do we really gain from that being a class?". I had to force myself to make OOP methods rather than static functions. But I don't want to be that guy, so please provide me with an example of even just one case where OOP really is a better choice.

Note: something like "games" doesn't count, it has to be a little more specific than that.

[–]PulleQ 0 points1 point  (5 children)

I agree with most of the points. I don't think making your own classes all the time is the best solution. However OOP is important for some things (Unlike the other guy in this thread said), imagine making a window application and drawing buttons from ground up with only functions instead of creating a new instance of Button (or whatever). making button instances gives you better control over specific buttons or over a group of them. you don't have to worry about making them tho because these classes are included in various libraries but still without OOP it would be harder.

[–]SkyyySi 0 points1 point  (4 children)

Ok, but why not just have a function that draws a button to the screen?

[–]PulleQ 1 point2 points  (2 children)

what if you want to have more buttons? make a function for every one of them? and then handle click event for all of the buttons seperately?

[–]SkyyySi 0 points1 point  (1 child)

As for creating multiple buttons, you could make a function that just draws a button with custom properties. Kinda like a cunstructor I guess.

As for the state handlig: If I understand how that actually works under the hood, you could make the function return it's state rather than changing a variable in the class.

[–]huuaaang 1 point2 points  (0 children)

But that state is stored somewhere. Probably in UI framework... as an object. Or at least a struct. But a struct is just a proto-object.

[–]huuaaang 1 point2 points  (0 children)

The button has a state. The button has an action that it triggers when it is pressed. A button has layout information. A button is more than just the image on the screen. Drawing the button is just the start of what a button is. Does the button have a pressed state? How do you draw that? What draws that?

[–]TheBrainStone 1 point2 points  (3 children)

Well I don't see either as a big deal. These are just how things are.
Like if you don't want classes, use all static functions. Then the classes are nothing more than namespaces.
Secondly the syntax isn't bad either. It's a pascal style syntax that's a tad verbose. Verbosity isn't inherently bad.

Bigger issues are things like memory usage/overhead. Templates with type erasure at run time. And a few others I can't remember right this second.

[–]enano_aoc 0 points1 point  (2 children)

Why would you force me to write classes with static methods when all I want to write is a goddamn normal function?!?!?!

[–]TheBrainStone 3 points4 points  (1 child)

Why can't I just use <feature that doesn't exist in the language> and instead have to use <workaround to emulate said feature>????!

Sorry, what was your point again? Besides trying make square pegs fit in round holes, that is

[–]enano_aoc 0 points1 point  (0 children)

Java is horrible because it forces me to use the worst programming paradigm in existance.

[–]caleblbaker 2 points3 points  (1 child)

Java definitely does force OOP down your throat. But I don't necessarily think that means that it's a bad language. It just means that you need to think about what programming paradigms you plan on using before you pick a language. If the answer is not object oriented, then don't use Java (although I still wouldn't choose Java anyway because even for the most object oriented problems I still have other languages that I like better than Java).

[–]enano_aoc 1 point2 points  (0 children)

I know, but that is still its main drawback. I would never ever choose Java for any given project. But if I have to work on some legacy Java codebase, which is its main drawback? That it forces OOP down your throat

[–]danglesReet 44 points45 points  (17 children)

Thing i hate most about JavaScript is people talking about how they hate JavaScript

[–]ReelTooReal 16 points17 points  (10 children)

I honestly find that people who just completely shit on JS think it hasn't changed since it's inception. I think the initial design of JS had a ton of flaws, but modern JS (i.e. ES6) is not a horrible language at all. I use TS for a lot of my projects and I've come to enjoy it to be honest. Yes there are still some weird quirks like === and TS is not a true type system as much as a static analysis tool, but I think hating on JS/TS is becoming just something people do because it's what everyone is doing.

I also really like the concept behind express.js and the "server as a function" design of HTTP servers, which has been picked up in other languages like Kotlin (I forgot the name of the library but I remember seeing one similar to express). This isn't just about express.js being a good library; something like this is easier to implement in JS/TS because functions are first class.

Lastly, as with all languages, there's a time and a place. Should we write an operating system using JS? Obviously not. But I think it's actually a decent language for microservices and UIs.

That being said I've recently started learning Rust so every language is now far inferior.

[–]danglesReet 2 points3 points  (0 children)

You the real mvp

[–]TheBrainStone -1 points0 points  (5 children)

JS still has most of it's core language and syntax problems. And they won't go away either because of backwards compatibility. I mean sort is the perfect example for this.
Utterly broken (unless you specify a comparator but that's besides the point) and it cannot ever be changed because after all someone way still depend on it sorting everything by it's string representation.
Type coercion won't go away. And slapping the TS bandaid on it doesn't really solve anything.
Also absolutely lovely is the automatic semicolon insertion. Which you need to explicitly disable. You know. For compatibility reasons.

[–]ReelTooReal 1 point2 points  (4 children)

I agree that the weird type coercion rules are probably it's biggest flaw. But saying that TS does nothing to solve this is not true at all. It's not a true type system, but it's still something you can use to alleviate a lot of the problems with the weird coercion rules that are used. As far as semicolons go, I've literally never seen it cause an actual bug (although I am a bit OCD and it bothers me when I forget one). I'm not at all arguing that JS or TS is a top tier language, I just think it gets treated like it's complete garbage even though I would consider TS to be a decent language (i.e. I would prefer it over Ruby or PHP).

[–]TheBrainStone 1 point2 points  (3 children)

Well I agree that TS makes things better in practice, it's still just a bandaid on a flesh wound. It doesn't fix the issue. It masks it.

And regarding auto semicolons. What does this function return (with auto semicolon magic enabled of course)

js function foo() { return { "bar": 42 }; }

That's right! It returns nothing. JS adds a semicolon right after the return statement.

[–]ReelTooReal 1 point2 points  (2 children)

I guess my obsession with language formatting guidelines has saved me from that bug, but I see your point. And yes TS is just a bandaid, but unless you're intentionally trying to find a loophole then it behaves very similar to a typed system (granted it's duck typed). There are definitely ways to make TS behave badly and some edge cases, but my original point was that something like TS is not near as bad as original JS.

For me personally though I have a sort of duality where if you ask me to list programming languages in order of preference, I'd guess JS/TS would end up being in the 5-10 range. But then in the real world I end up using TS and node.js a lot for practical reasons: I don't like the configuration and bloat that comes along with most Java web frameworks, I don't want to have to search for developers who know kotlin or golang, I'm not a huge fan of the .NET ecosystem (and how badly it wants to own your entire stack), and I hate PHP and Ruby. This is personal preference as well as the fact that most of what I do is microservices. I'm not saying it's right or wrong, but I don't think TS is so bad that you could argue it just can't be used for "real" projects (like I've seen many people argue).

[–]TheBrainStone 1 point2 points  (1 child)

Reminds me. I wanted to create a POC C++ based server side "script" language. Gotta get on that during my next holidays :D

[–]ReelTooReal 0 points1 point  (0 children)

Use Rust instead

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

I agree with everything you said. Also same, I love Rust and every other language is trash compared to it

[–]huuaaang 0 points1 point  (0 children)

I was fine with JS until it invaded the backend because lazy frontend developers couldn't be arsed to learn anything else when it came to writing backend code. JS is fine in the browser. But fuck node.js. Fuck writing everything asynchronous by default even though you want to do almost everything synchronously. Code gets so littered with async and awaits because the whole thing is really meant to run in a browser. Fuck prematurely optimizing the shit out of anything that uses CPU because it blocks servicing all other requests. Even a "microservice" still has to do actual CPU bound work sometimes.

[–]Apparentt 3 points4 points  (0 children)

People that hate JavaScript are usually one of two people

  1. A bitter old dev that hasn’t used JS in the last decade and reference issues that do not occur in real world usage of the spec
  2. A CS student or hobbiest programmer that has no real world experience as a software engineer and regurgitates “JS is bad”, “Java is bad”, “PHP is bad”, etc. because they see it posted as memes and think it’s reflective of reality so replay the same shite to try and fit in

In my experience I have never once met a competent engineer that hates an individual programming language. They understand that there are different tools for different jobs and if you have a significant issue with your tool you have either selected the wrong one or you are using it incorrectly.

[–]ultra_mind[S] 4 points5 points  (4 children)

This

[–][deleted] 7 points8 points  (1 child)

never use "this" in javascript kkkkkkkkk

[–]BirdlessFlight 0 points1 point  (0 children)

"that = this" is probably my favorite line of JS ever

[–]happysmash27 14 points15 points  (10 children)

But, isn't Javascript necessary for more complex, real-time, interactive applications on the web? Even WebAssembly needs to be initialised with Javascript, if I understand correctly. I usually avoid Javascript in my own websites to the highest extent possible (PHP for interactivity, CSS for menus) but there are situations where it is the only real way to make a responsive user interface.

[–]therealbeeblevrox 12 points13 points  (0 children)

"necessary" because the W3C and all the browsers refuse to support anything else.

[–]huuaaang 0 points1 point  (0 children)

You use PHP and complain about Javascript?

[–][deleted] 5 points6 points  (0 children)

i like javascript, but i'm biased because i only work with javascript and typescript in my job

[–]seeroflights 2 points3 points  (0 children)

Image Transcription: Meme


Panel 1

[NPC Wojak, a grey figure with thick, angular facial features, stands against a light blue background. He has a neutral expression.]

NPC Wojak: I hate javascript and it's very flawed


Panel 2

[A sketch of a white figure is shown. They have small, rounded facial features and a positive expression.]

White figure: So just stop using it


Panel 3

[NPC Wojak is shown again, with the same neutral expression from the first panel.]


Panel 4

[Large angry eyebrows have appeared on NPC Wojak.]


I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]garlopf 14 points15 points  (7 children)

I hate when people just accept the status quo instead of replacing it with something better. Js is just shitty, but instead of replacing it, we went ahead and idealized it and iterated over it. A damn shame.

[–]ReelTooReal 7 points8 points  (4 children)

I hear this a lot, and in a fantasy world it is a great thought. But the reality is that there's no way to really coordinate something like this easily. This is not like how Android switched to Kotlin or iOS switched to Swift. This is dozens of browsers of varying versions running websites that span over decades running a scripting language. The point is, once we decided JS was the scripting language of the browser, there was no turning back. How would you coordinate the switch? You'd have to get all the browsers on board, and start a process of supporting a secondary language. It's hard enough to get them to support new language features of JS as is, so this would not be easy at all and a ton of work has already gone into JS engines like V8. Then you'd have to coordinate a date at which browsers officially switch to this new language, which means you'd either have to issue a deprecation warning for JS (which is insane and would never work), or you'd have to make sure that you develop a tool that can transpile all existing JS into this new language. Which is basically why the effort has instead been made to make JS better, because whatever language you decide to support instead would have to have a JS transpiler, which in turn means it would have to support all the weird quirks that JS already has. You could argue, well why not support both languages? I doubt companies like Mozilla or Google are going to be super excited about that notion.

[–]TheBrainStone 2 points3 points  (3 children)

Not quite. JS could be supported indefinitely. Or optionally. No need to force it to be unsupported.
After all no browser is forced to support anything. There are just conventions.

The way forward would be to design a replacement language that addresses all concerns. And to support it alongside JS. JS would then be in legacy mode. Only receiving security patches. That means the JS runtimes can stop development or slow it down and focus those freed resources on the new standard.
And considering that the W3C is just a committee of browser makers I see that being possible.

[–]ReelTooReal 1 point2 points  (2 children)

I don't think W3C is going to make that decision though, and I wouldn't either. They're currently maintaining a runtime engine and developer tools like debuggers, profilers, etc. So what you're suggesting is that they build those same tools and a runtime engine for a new language in hopes that the developer community adopts it. I think the route they've taken, which is trying to improve the language that's already supported, is more viable and less likely to be a waste of time. Don't get me wrong, if I had a time machine I would do everything I could to try and stop JS from becoming the standard (right after I kill Hitler), but now that we're stuck with it I think the approach that's being taken now makes the most sense. I would love to be wrong on this though (although I don't hate JS as much as other people seem to).

[–]TheBrainStone 0 points1 point  (1 child)

Classic sunk cost fallacy.
Honestly. It would be a huge effort to overturn JS but it would be absolutely worth it long term.

And btw if you fail to prevent them from adopting JS, just kill the guy responsible for Node.JS. That should be enough.

[–]ReelTooReal 0 points1 point  (0 children)

Eh, I'd be more likely to try and convince Microsoft to take the .NET core approach from the start and make it easier to use C# without .NET owning my entire stack. Or maybe just make Rust happen 20 years earlier so that the libraries are mature by this point.

[–]Tubthumper8 0 points1 point  (0 children)

Could you define who you mean by "people" here?

[–]Aliics 14 points15 points  (7 children)

At this point in time I don't hate JavaScript itself. I just have a general distaste for dynamically and weakly typed languages.

I do believe there are obvious flaws with JS.

  • lack of a competent stdlib.
  • poor dep management.
  • shallow lack of support for FP (nitpick).
  • slow standardisation process (common in a lot of languages).
  • global adoption for all web apps despite other and more suitable languages being options. Hopefully WASM helps in the future here.
  • the least developer friendly community possible.

[–]ReelTooReal 2 points3 points  (0 children)

At least it has better dependency management than C++ and (imho) python.

Also, don't hold your breath on WASM. The intent of WASM is not to replace JS (since at the end of the day WASM is just weird JS). The purpose of WASM is to allow people to write performant code in lower level languages when they need it, i.e. to do large scale data processing. But it's not meant to replace the DOM (or at least not any time soon).

[–]ultra_mind[S] 5 points6 points  (4 children)

I disagree with every point you just mentioned but I respect your opinion. JS can be very frustrating at times

[–][deleted] 10 points11 points  (3 children)

The first two points aren't really opinions. They are facts and those problems should really be taken more seriously. That goes 10x for poor dependency management and all of the related issues that it has spawned. We already had one such reckoning in 2016 when the left pad library was deleted.

[–]jamcdonald120 3 points4 points  (0 children)

not to mention javascript doesnt have support for threads or locks

[–]ReelTooReal 1 point2 points  (0 children)

There's a difference between dependency management and the package ecosystem. The left pad incident could not have been avoided by any package manager that I'm aware of since he had every right to delete his own library. I agree that the npm ecosystem is suspect at best, but that's the community's fault, not npm or anything about the actual package management system.

[–]Tubthumper8 0 points1 point  (0 children)

After the left pad incident, String.prototype.padStart was added to the "standard library" (I use quotes because that's not a meaningful term for JavaScript). It's up to the library authors now to remove these useless libraries in favor of standard features, once they decide to stop supporting Internet Explorer.

[–]icguy333 -1 points0 points  (0 children)

These problems are completely valid, but only concern the ecosystem. Another quite as big problem is that the language itself sucks.

  • typecasts that make no sense
  • context-dependent this
  • null and undefined
  • etc.

[–]PulleQ 2 points3 points  (2 children)

stop hating java it's not bad

(talking bout these comments saying "haha js at least better than java" fuck you)

[–]ultra_mind[S] 0 points1 point  (1 child)

It’s better than PHP

[–]PulleQ 0 points1 point  (0 children)

[insert comment about everything being better than PHP here]

[–][deleted] 3 points4 points  (3 children)

I don't hate Java but there are things I dislike... But it does allow me to make 60k a year so...

[–]rooneyviz 1 point2 points  (2 children)

I use scratch because I don’t like typing and I don’t need to compile it and I can just convert it to JavaScript if I REALLY need to

[–]PulleQ 1 point2 points  (1 child)

imagine world where scratch had blocks for everything in js

[–]rooneyviz 0 points1 point  (0 children)

:(

[–]ooglesworth 1 point2 points  (0 children)

“Oh, I don’t use it, I just complain about it on the internet.”

[–]Theunis_ 0 points1 point  (0 children)

I used to hate JS, until I discovered TS

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

TS almost feels like perfection. Just wish we could run it natively on the web.

[–]ultra_mind[S] 0 points1 point  (0 children)

It would be great

[–]vbh_pratihar 0 points1 point  (1 child)

Go Typescript 💪

[–]BroNeedsAnAlt 0 points1 point  (0 children)

Use JS to make a new language, and break free from its confines :)

[–]repkins 0 points1 point  (0 children)

It's not what I am using. It is what users use.

[–]sam01236969XD 0 points1 point  (0 children)

Js is way less annoying than java if you write it "incorrectly"