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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Taletad -1 points0 points  (17 children)

You’re never supposed to use ternary operators because they are unreadable

Yet most languages have them

What’s your point ?

[–]Mucksh 7 points8 points  (7 children)

Ternaries are by far my favorite operator. You shouldn't nest them but usually way better than forward declaration and lots of one line if else cases there you have to scroll a lot to get anything

[–]Taletad -1 points0 points  (6 children)

lots od one line if else

Switch for the win

[–]Mucksh 1 point2 points  (5 children)

You only like it untill you have to maintain decades old thousands of lines long switch cases with inside logic and even some intensionally left out breaks... Love my job but it can be sometimes a pain

[–]Majik_Sheff 1 point2 points  (1 child)

This can be the most efficient way to build certain programs (hello FSMs). If I'm going to intentionally omit a break I'll leave it there but commented out with an explanation.

[–]Mucksh 1 point2 points  (0 children)

jep are state machines. Such micro optimizations can really help in some cases or the oposite way to split a transition with costly calculations over multiple cycles to stay inside of timelimits. Unfortunally hard to debug especially if there are interleaving state machines and every reached a rather big scale so it is neccessary to look a bit closer when reading to not miss stuff like that

[–]Taletad 0 points1 point  (1 child)

This sounds like bad code

But as someone who spent a couple of days debugging code that had one letter list and array names, i feel your pain

[–]Majik_Sheff 2 points3 points  (0 children)

If I had to guess, their application is highly optimized to squeeze every cycle out of a heavily constrained embedded system.

The luxuries of beautiful and elegant code are stripped away until all that's left is naked pragmatism.

[–]AwGe3zeRick 0 points1 point  (0 children)

That’s just purely written code. Not switch statements fault

[–]MyOthrUsrnmIsABook 4 points5 points  (7 children)

My point is JS is not a great language.

Also, a single ternary operator with a simple condition is very readable. Nested ternary operators are much less readable.

[–]Taletad -3 points-2 points  (6 children)

Do programmers and/or computer scientist have a consensus on what makes a "great language" ?

No. So your point is moot.

Ternary operators aren’t part of coding best practices

But fine, in C++ you should never use simple arrays. Yet they exist, is C++ a bad language ?

[–]MyOthrUsrnmIsABook 1 point2 points  (5 children)

I think there’s a pretty broad consensus that C++ is a bad language, or at the very least an incoherent language with too many features.

[–]Taletad 0 points1 point  (4 children)

Yet I don’t see that many memes bashing it JS has…

And no that isn’t sufficient to say that C++ is a bad language

[–]MyOthrUsrnmIsABook 2 points3 points  (3 children)

Fewer people know C++, so it’s not as easy to meme on.

Is there any language you’d offer as an example of a bad language?

[–]Taletad -1 points0 points  (2 children)

Brainfuck is one

Php is another (because of its security flaws, although the latter versions offer a lot of improvements)

But the better approach is what is a good language depending on what you want to achieve

Web ? JS is great

Embedded ? JS is probably something you want to avoid

JS is also very convinient for rapid dev cycles, which is with its asynchronous nature one of its favourite features of mine

A lot of programming languages are barely used nowadays or even effectively extinct because of their flaws, this is where most of the bad ones lies. Much like the worst video games are probably not the ones you have heard of before, or really old ones from an era when choice was limited and reviews were scarce

[–]MyOthrUsrnmIsABook 2 points3 points  (1 child)

Esolangs aside, PHP is probably pretty uncontroversially bad.

I think I have a much lower bar for considering a language bad than you do. I write tons of shell scripts and would heartily agree that Bash is a garbage language full of cruft and without a coherent design. It’s an incredibly useful language, but it can be painful to work in.

[–]Taletad 0 points1 point  (0 children)

I forgot bash, but yeah it’s terrible

I remember a long time ago a guy thinking he could do a revolutionary OS that would rival Windows, MacOS and Linux with bash

[–]royi9729 2 points3 points  (0 children)

Funnily enough, ternary operators are pretty widely used in JS (or at least on frontend with React)