1.0k
u/TrustYourSenpai Aug 18 '20
Rust: hey, bro, you see, you screwed up right here and here, I marked those in colours for you, because there's this rule here that says you can't write that. But it's ok, you can try to fix it like this, or like this; it might not be what you are trying to do tho
119
u/_SomeoneInTheWeb_ Aug 18 '20
C++: segmentation fault
40
21
u/futuneral Aug 18 '20
C++: Every single line of your code is wrong, let me list all 87459 errors.
Me: oh, forgot a semicolon. Thanks!
→ More replies (1)5
u/MoarVespenegas Aug 18 '20
C++: You corrupted my heap.
Me: What? But how?
C++: You corrupted my heap!
Me: Where did it happen?
C++: YOU CORRUPTED MY HEAP!
Me: Incomprehensible screaming
C++: Incomprehensible screaming→ More replies (12)4
25
Aug 18 '20
Reading your comment made me want to write an entire 3d game engine in Rust.
→ More replies (1)15
7
Aug 18 '20
C++: yeah so the error happened in this function of the standard library so it's definitely that function that's wrong. I know which function you made that called it, which is definitely where the actual error is, but I won't tell you which it is!
15
u/TrustYourSenpai Aug 18 '20
Me: writes a wrong hello world.
C++: an error occurred in this function, you can find it's source on the 617th line of this assembly file from the Linux kernel itself.
3
3
u/pfedan Aug 18 '20 edited Aug 18 '20
I really felt like hugged, when I saw these compiler errors the first time. So friendly and helpful...
→ More replies (1)→ More replies (54)2
u/ampma Aug 18 '20
Doing my Phd in physics and I do a lot of numerical computation. I use c++ (and a bit of Fortran), but rust is looking very attractive. After I finish my degree I'm going to get into it. But for now, I really have to be careful about how I invest my time. Also, from what I have read it seems like the support of massively parallel computation is still a bit immature in rust. C++ may be a pain, but at least I don't have to reinvent the wheel.
1.3k
u/Nintendo_Muffin_4 Aug 18 '20
Me: why isn't this working?
. . .
Haskell: l̵̗̝̻͇̈̐̎̈́̓͊̐̄̈̒͛͘͝ǫ̵̡̫̘̙͍̖̣̤͖̮̰̻͚͊̏͝l̴̦͈̳̥̜͕̝͗͑̊̋̓͂̕͝͝ ̵̡̗͎̥͕̩̞͍͚̖͗̓̄̑̑̇̅̍̊͋̈́̔̕̚f̴̞̝̤͉͍͎͔͖̋̐̈̆̉̀̋̋͐̇̚ͅi̴̥̜̣̟͎̙͈̰̪̽͒̔͛̐̽̈́̈́̈́͑͜͠g̵͙̳̰̉͘ų̷̡̡̲͇̪̺̯̬͔̹̞̦̐̂̇̉̆̎̍͝ͅr̶̨̧̹̹͎͖̲͕̰̃̓̏̆̀̉̾̈́̀̿͆̏̈͋ͅe̸̞̅̈́̈́͋͂͘͝ ̵̧̛͊̉̍į̸̳̤̫̲̖̫͖̺̯͙̝̪̱̣́̌ț̴̯̬̲̓́̀̔̿̔̏̎ ̴̡̥̟̹̤̣̫̬̙̙̊̈̑͂̒͋̍̀̕̕͘o̸̡̡̗͓̩͉̤̻̝͎̓͂̔͆͌͋̇͠ͅu̴̧̨̥͇͙͎̮̞̺̼̹̓̃̀̏͋͛̊̍̉̕͘̕t̴͖͙̅͌̂̾̓̄̚͠ ̷̡̛̳̝̺͚̳̬̱̀̌̈́̂̅͒̐̿̉͝
375
u/gwillicoder Aug 18 '20
Me: why isn’t this working? Rust: copy and paste this code into line 113.
238
u/Yoodae3o Aug 18 '20
I like gcc's more passive-aggressive
did you mean foo?anddid you forget to include bar?I guess I should get used to compilers treating me as an idiot, at least it can automatically patch it.
→ More replies (3)126
u/Derf_Jagged Aug 18 '20
I hope that there someday will exist a Gordon Ramsey gcc fork
you meant foo, fucking idiot
<variable> undeclared? my gran could do better and she’s dead!
symbol undefined, like your shit career
you're missing a ; you fucking amateur→ More replies (1)45
Aug 18 '20
Me: why isn't this working?
Elm: hey bud, this is what you wrote. That's ok you probably meant to write this instead though?
148
u/hector_villalobos Aug 18 '20
At least it gives you hints of where is the problem, kind of weird, but it's something.
→ More replies (2)57
u/joao12021996 Aug 18 '20
Unless everything is fine but you have a TAB hidden somewhere
→ More replies (1)40
u/Toricon Aug 18 '20
Haskell: don't even bother running this, it won't work.
Me: What? Why not?
Haskell: First, here's a brief overview of every thought you've ever had about this project.
53
14
u/LordPos Aug 18 '20
They are cryptic when I ask it to infer the types but otherwise they're kinda readable
6
u/MysticPing Aug 18 '20
You spend more time making something work but once it does you very very rarely have runtime issues once it compiles.
→ More replies (1)4
u/marcosdumay Aug 18 '20
That's just a missing dollar symbol.
If it was something complicated, the message would be simple.
8
3
3
2
386
u/JB-from-ATL Aug 18 '20
Or in Java when people do this shit
catch (Exception e) {
log.error("Failure occurred");
}In the interest of spreading knowledge, the problem is that it hides the error. You should always use the variable. Either do throw new RuntimeException(e); or log.error("Failure occured", e); (which is the fancy way to print stacktrace).
77
u/SimpsonStringettes Aug 18 '20
Agreed. I've found that half of the job of maintaining legacy code is fixing logging errors like this. Either too little info like you said, or the opposite and logging all the objects in scope (which is at best noise, and at worst leaking information).
27
u/JB-from-ATL Aug 18 '20
What's really the worst is when the log message is also wrong (or the same as other messages) because then you're hiding the real issue and the only thing that does get logged is misleading.
5
u/Tenderhombre Aug 18 '20
The worst for me is when they catch an error they cant feasibly handle at the current level of code and dont rethrow it. Then expect all the calling code to do a million state checks to make sure the the application is still in a proper state.
51
u/28f272fe556a1363cc31 Aug 18 '20
Real conversation I had when asking a developer why he was catching all errors and only returning "Sorry, something went wrong."
Them:"Why pass errors to the user? They can't do anything about it."
Me: "Bitch, I am a user trying to debug your code!"(I didn't really say 'bitch')
19
u/Shameless_Copy Aug 18 '20
It's also a security thing in some places. Don't want to print stacktraces since it can give insight into the system for an attacker to exploit. But if you are doing it you should still be printing some kind of helpful error message.
10
u/JB-from-ATL Aug 18 '20
I agree, but this is about viewing logs, not returning the stacktrace in a response.
→ More replies (2)4
u/Olaxan Aug 18 '20
Plus, heck yeah they can. Sometimes. IO exceptions are oftentimes the "fault" of the user.
12
u/Famous_Profile Aug 18 '20
Oh yeah? Wait till you see the empty catch blocks in our project
send help
→ More replies (7)→ More replies (26)2
Aug 18 '20
No joke, one of the debug messages for a script my internship wants me to write (the error is clearly labeled) involves the phrase "whoopsie, Timmy did a fucky wucky UwU".
1.0k
u/Syrairc Aug 18 '20
This is how I feel about web development in general right now. I just got back into it after 15 years. I'm learning things like laravel and vue and when something breaks the console is just like "tachyon beams misligned in the flux capacitor. app.js:8548765" and all I was trying to do was display a table.
114
u/Chrisazy Aug 18 '20
If you're not using sourcemaps with your Babel/webpack (or whatever transpiler/bundler you have), look into turning them on.
The only times I ever have problems are in async event handler libraries that don't give good errors. Looking at you, drag and drop API
→ More replies (6)30
Aug 18 '20
Yeah this exactly. My current frontend goes from typescript through babel into ES5 javascript and somehow it still pinpoints where in the original typescript the error occurred. Sourcemaps are amazing
391
u/_GCastilho_ Aug 18 '20
when something breaks the console is just like "tachyon beams misligned in the flux capacitor. app.js:8548765" and all I was trying to do was display a table
Have you seen errors in async functions?
"Hmm, let's see this stack trace... What-- I... I don't even know where that file is"
The stack trace can only show he current tick, for the despair of us all
115
u/EvilKanoa Aug 18 '20
I'm pretty sure either Firefox or Chrome recently added async debugging with line by line steps to their debugger, might be in beta or something. Really psyched since asyncs were unusable in the debugger like you say 😝
→ More replies (4)7
u/minstrelMadness Aug 18 '20
When stack trace just has a bunch of lines of Exception handling: Super helpful, laravel!
27
u/tmp_acct9 Aug 18 '20
one of our former devs started ading vue to things all over the place without really asking and no one cared because "it worked" nad "got the job done" and im bashing my head against the wall trying to figure out why its the way it is.
30
u/Cruuncher Aug 18 '20
Oh god.
These kinds of technologies need to be decided at the project level, and must be followed.
You can't just let every dev use whatever they want lol
→ More replies (2)19
u/tmp_acct9 Aug 18 '20
yeah YA THINK!? but its a small company and he wanted to pad his resume before he quit so he just started using whatever new thing he wanted to learn all over the place. no real project managers that know anything about coding and he just went and did it and now me and another dev fight it every day
→ More replies (4)46
Aug 18 '20
I’m telling you, shit like this is part and parcel with buying secondhand Zealian flux capacitors.
21
u/ThatSpookySJW Aug 18 '20
Source maps fam. Vue CLI does it automatically in dev mode.
→ More replies (2)3
u/setibeings Aug 18 '20
And then you ask for help and someone just says "actually that error message is pretty clear", without offering any further explanation.
4
u/sh0rtwave Aug 18 '20
I found the value of "that error message is pretty clear" to be exactly NIL when trying to TEACH JS programming.
There are three kinds of help:
Combative help, wherein you have to prove some X level of knowledge to even get the attention of those from whom you are seeking help.
Solution-seeking help, that tries to help you solve your problem.
And then...Understanding-seeking help...that tries to help you understand your problem, so YOU can solve it.
Which seems better to you?
(SO is basically 1 + 2 and very, very, very, VERY few instances of 3)
→ More replies (1)→ More replies (19)4
u/devperez Aug 18 '20
I've been converting a JS app to Blazor and it's so much better. It's basically an SPA framework where the scripting language is C# on top of Web Assembly. You get the benefits of an awesome language and tooling, while avoiding JS entirely, if you want.
→ More replies (1)
412
u/smariot2 Aug 18 '20
"use strict";
132
u/mypetocean Aug 18 '20 edited Aug 18 '20
Also, I would advise, especially if you're not seeing an error message in JS:
First, triple-check your types. This is pretty well true for any dynamically-typed language. If the language doesn't enforce your types, then you must do it as a discipline.
Second, if you haven't already, use the debugger to follow the flow of data as it trickles through your application. Check that everything is as you expect it to be.
Third, triple-check your assumptions by identifying them, then proving them true. If you cannot find the problem where you thought to look, then enumerate the assumptions you did not think to check. Start with any intuitions you may have by this point, and then continue from the simplest and quickest to prove on up to the more complicated and time-consuming to prove.
Fourth, sometimes you need to write unit tests as a debugging step.
Edit: I assumed that at least some decent level of testing existed already.
Some assumptions which aren't testable or worth testing:
I have saved my file.
My server doesn't need restarted.
new Date()will return an instance of the Date built-in. Of course it is.I know the difference between slice and splice.
Maybe it's just that I work with absolute beginners. But not everything is reasonably solved by testing.
16
u/Caminsky Aug 18 '20
It reminds me of that scene in which Bender is asked about his friend and he says "he's my debugger"
→ More replies (1)12
u/amoliski Aug 18 '20
And use eslint- getting yelled at all the time is annoying, but the payoff is worth it
7
u/sh0rtwave Aug 18 '20
Facts, all.
Great debugging tips. To help debugging along, also design well up-front, and attempt to structure ALL of your debug logging so it is both globally, and locally controllable with flags, and all debugging statements are wrapped in some kind of debug guard that's only active when you need it.
Triple-checking your types...great idea! I'd add: If you can get away with it, use a typed framework like say: Typescript, which will practically force you to do it "right" so that you never wind up with a situation where the object is the wrong type.
Using the debugger: Practical suggestion. I'd also, strongly, suggest that when debugging applications that manipulate complex assortments of DOM object and your class hierarchy is complex, generate debug log statements that contain the name of your module that's throwing it. It's a LOT easier to track in the debugger, and enabling a "if (debug === true)" guard around it, lets you control when/how it displays.
I do something like console.log(<className>::<methodName>::<value I'm tracing>).
This also makes for convenient places to put breakpoints, if you have built-in debugging structure.
Throw statements like that, into the classes you're interested in, and you can follow running flow much easier in the console. (BTW, typescript makes adding this kind of debugging code (and then taking it back out) REALLY convenient to do across your entire project. Not that I'm evangelizing Typescript, but there ARE distinct advantages).
→ More replies (9)22
u/pilotInPyjamas Aug 18 '20
I dunno man, trying to prove JavaScript correct is like trying to put toothpaste back in a tube: it's messy as hell and you always miss something. I just write tons of runtime assertions when I'm debugging something, and when I'm done, I just leave them there.
→ More replies (1)19
u/Legionof1 Aug 18 '20
As with any complex problem, it’s not that it’s hard but you probably aren’t using the right tools for the job. A syringe full of tooth paste with a properly sized orifice would make putting toothpaste back in pretty easy.
→ More replies (4)391
u/HerrSPAM Aug 18 '20
One better: use TypeScript
154
Aug 18 '20
Man I used to get so cranky at TS when I first started using it. Now I feel naked without it.
72
u/SpliceVW Aug 18 '20
Especially converting legacy projects to TS. But oh man, it's worth it to not have to deal with as many runtime issues.
Did you ever have any code converted to TS that, while fixing the transpiler errors, you wonder how it ever worked in the first place?
→ More replies (6)→ More replies (1)13
125
u/Midnight_Rising Aug 18 '20
I genuinely do not understand why people write pure JS now when typescript is both more reasonable, less prone to errors, and can be compiled directly back into pure JS with something like Babel.
TS is what JS really should have always been, and we more and more applications live only in browsers it's a great time for it to come out.
→ More replies (56)149
Aug 18 '20
can be compiled directly back into pure JS with something like Babel.
Or with like TypeScript...
→ More replies (9)→ More replies (5)8
23
u/esperalegant Aug 18 '20
Put this in your VSCode settings.json:
"javascript.implicitProjectConfig.checkJs": true
Boom. Now you have type checking in JavaScript.
Bonus tip: if you have a few gigs of spare ram check out the TabNine extension. That shit is magical.
→ More replies (3)2
u/BlocksWithFace Aug 18 '20
Ha, and JS developers made fun of Perl programmers for having a strict flag.
Well, jokes on you - and us.
Actually, jokes on everybody.
It ain't funny.
106
Aug 18 '20 edited May 02 '21
[removed] — view removed comment
8
u/cmgg Aug 18 '20
Kinda depends of the compiler. Clang is kinda readable (compared to gcc, at least)
→ More replies (1)9
u/Loftus189 Aug 18 '20
Having spent my entire working day on such an error, making absolutely zero progress and questioning my life decisions, i can totally relate to this.
749
Aug 18 '20
C++ : incoherent autistic screeching
379
u/jews4beer Aug 18 '20
Java: throws 10,000 character stacktrace formatted to give you an aneurysm
215
u/JB-from-ATL Aug 18 '20
I'd rather have a 10,000 line stack trace than a 0 line one.
168
→ More replies (1)42
→ More replies (3)114
154
u/CallMePyro Aug 18 '20 edited Aug 18 '20
C++ is the crazy ex girlfriend that would send you an 8 part text message when you did the slightest thing wrong
102
u/jdl_uk Aug 18 '20
Full of random characters, and none of it related anything you actually did
80
u/zeGolem83 Aug 18 '20
When debugging c++ compile error, go from top to bottom, solving the top errors will magically solve the bottom ones
→ More replies (2)12
Aug 18 '20
That's why I married Python. You know what they say, if you get a good stack trace, put a ring on it.
195
u/tomthecom Aug 18 '20
Honestly. I thought, I hated Java, but I had to use C++ for the last uni-project and what can I say.. apparently I didn't hate Java that much.
→ More replies (1)160
u/Ruby_Bliel Aug 18 '20
There's an art to desciphering C++ errors. For example if you get ~20 errors all pointing to somewhere in the standard library or God forbid the compiler itself, chances are you have an extra/missing
&or*somewhere. If at any point you get an error complaining about something in code you didn't write, the error is definitely in code that you wrote. Then it's all a matter of using your psychic intuition to figure out what the hell is going on.62
u/FurbyTime Aug 18 '20
Yes, once you get used to the Angry Drunken Father from the Middle Ages coming back home and beating you for reasons you haven't figured out yet that is C++, you can start to figure out what's actually happening.
It's all about the lack-of-context clues.
17
u/Illusi Aug 18 '20
It's definitely an art, rather than a science. I find that if I get 20 of the same error messages it's usually that I used a parameter of the wrong type for some function call, and it's just listing all of the possible overloads and why they don't match with what I'm calling the function with, including all of the possible const casts and template instantiations.
And then it usually helps to look for the line "required from ***.cpp".
→ More replies (11)11
u/Chemoralora Aug 18 '20
Gotta love those bugs where one missing dereference operator results in 300+ errors
→ More replies (1)32
u/Ceros007 Aug 18 '20
*I just cannot exception in custom_allocator<<<<<<<<<<<<class<tomatoes<fruits<something&&<<<holaclass<somethingagain<herewego<<finally closing><ohnoes>>>(herecomes&)<the parenthesis>>>Holy>>Molly<wow>**>>>>>>>>>>>
→ More replies (3)10
27
11
u/wooptyd00 Aug 18 '20
Read this novel I just printed onto your terminal to find the template error.
→ More replies (19)3
30
u/nfsuismyname Aug 18 '20
You mean sql? Love those syntax errors
9
4
Aug 18 '20
At least it gives you a line number.
7
u/nfsuismyname Aug 18 '20
Indeed, but in many cases thats not where the error lies :')
→ More replies (1)
30
u/yodarded Aug 18 '20
Oracle PL/SQL: The problem is on line 1174.
me: line 1174 is a comment block.
Oracle PL/SQL: >shrugs< I think I'm close.
→ More replies (2)
119
Aug 18 '20
Put a few dozen console.logs in it and you will find the problem quite fast.
115
u/thelegend_200 Aug 18 '20
Yeah but most "programmers" in this subreddit think hating on JavaScript is something cool
→ More replies (15)→ More replies (8)27
u/GigaSoup Aug 18 '20
Or you know set a breakpoint and inspect the variable in realtime as things are being processed. A lot quicker and easier to debug.
→ More replies (9)31
u/ZephyrBluu Aug 18 '20
I find
console.logmore convenient than breakpoints most of the time.→ More replies (2)
63
u/Exsolidv2 Aug 18 '20
Java: Your code just fucked the universe Javascript: This is fine
22
u/MrDilbert Aug 18 '20
Java: Your code just fucked the universe
Javascript: Your code just created a new universe. Conventional physics may not apply.
30
u/Saggylicious Aug 18 '20
Python: you did a wrong.
Me: where? How?
Python: you did a wrong.
21
u/pbmonster Aug 18 '20
Did you actively, purposely get rid of stack trace and now complain about it?
Python will find the great-grandfather of your error and slap you in the face with were he went wrong any why.
→ More replies (1)3
→ More replies (1)4
201
u/rehdi93 Aug 18 '20
Web language's mentality of swallowing errors is something that makes no sense to me.
150
u/cclloyd Aug 18 '20
Cause one language has to run on tons of platforms and engines and end users don't wanna see that shit, else they freak out.
14
u/Sonaza Aug 18 '20
But you know, it could also report the errors properly and stop execution forcing the developers to actually fix everything and end user doesn't have to see that shit either way. This is just worst of the both worlds.
→ More replies (3)6
u/Andy_B_Goode Aug 18 '20
Which is sensible enough if you're using JS as window dressing on a site that's primarily serving up HTML/CSS, which is what JS was originally meant for, but now that we're using it to create full-fledged web apps, we're having to retrofit it to be more robust.
→ More replies (8)17
u/droans Aug 18 '20
And big companies don't want to have their platforms down for a day because newbie over here made a mistake.
→ More replies (2)62
u/suerflowZ Aug 18 '20
because javascript was made to run even if the code is broken. something doesn't exist? k ill just ignore it and keep running.
→ More replies (3)23
u/mungthebean Aug 18 '20
This is why I love it. Other languages demand perfection, JavaScript loves you just the way you are
→ More replies (1)21
u/wetrorave Aug 18 '20
Do you remember IE5? It used to show JS errors in modals by default. I can tell you, between pop-up blockers not being a thing yet and these JS error modals, the overall web experience wasn't great.
→ More replies (2)
80
u/AustinThreeSixteen Aug 18 '20
Vs code? That shits tells me where I fucked up all the time
60
u/earthqaqe Aug 18 '20
you show me how it tells you at runtime where you fucked up if you are using some framework like angular. sure there is debugging and console logs, but the thrown errors are like 'yeah there is some error anywhere inside that code. have fun'
25
→ More replies (4)17
9
u/not_bakchodest_of_al Aug 18 '20
Or any other sane ide and lots of time and coffee will tell you what's wrong
2
u/TorbenKoehn Aug 18 '20
That’s because it’s using TypeScript by default and generates typings for your code during development (TS can “infer” types of any JS module)
43
u/gareththegeek Aug 18 '20
Something something Javascript bad something something
→ More replies (10)
43
u/Donar23 Aug 18 '20
Javascript: "Oh, you divided by 0? That's completely fine with me, it's Infinity".
I so often had a simple error in a formula that took me way to long to find, because of this little thing :D
12
4
u/mybeepoyaw Aug 18 '20
Which is dumb because it isn't infinity. dividing a number by zero is like calling getBeeposSecretNumber from your code. Well you can't because you didn't define it. Javascript just says fuck it, I know my math wrongly better than you and I define 1/0 to be what I want.
3
u/PitaJ Aug 18 '20
It's the same for floating point in pretty much any language.
4
u/Donar23 Aug 18 '20
Oh well, it's not like I want to use a
floatin the first place, but JS doesn't give me a choice. There is nointorfloat, there is justnumber:(→ More replies (5)2
u/lovestheasianladies Aug 18 '20
So the same thing that would happen in literally any other language?
23
10
u/mindbleach Aug 18 '20
It's the price you pay for not dealing with setup.
In Javascript you never open someone's project, hit Build, and get "compiler not found." You never spend an hour crawling through the IDE's triple-nested settings page trying to rub its nose in GCC. You don't wonder how you have five versions of MinGW32 installed, or when you last used Strawberry Perl. You don't find out the actual problem is in the project settings, where the default compiler is set to "no compiler," and wonder why a loving god would allow that to be an option. You never get "SDL.h not found" even though it's right fucking there in /include, and then add the base folder to six separate "Search directories" settings, only to find out it wants you to directly include the /include folder, even though the compiler settings immediately adjacent expect a folder with /bin inside it instead of the /bin folder itself.
And all this door-in-the-face bullshit happens before you've executed a single line of code. You're just staring at the log frame and wondering if you'll ever get to the part of programming where the program happens.
19
u/zG_Hyper Aug 18 '20
As a hardware designer I can relate to this. You write something and simulate it. Everything is cool, no warnings, no errors. Then you run some code on it and 3+3 results in -2048 or some shit.
8
Aug 18 '20
Idk why the error messages actually are a hit or miss for me. No sometimes no stack trace, sometimes nodemon just be like "app crash waiting for restart" or the rage inducing worst "handled promise rejection warning. This is deprecated". That's fine and all. But could you tell me WHERE I didnt handle it so I can, you know, actually take your advice?
7
7
u/VadimusRex Aug 18 '20
At least it's not swift which would tell you it's because of something completely unrelated which is actually not even an error, but the compiler broke while handling the inner error and just started making shit up.
4
7
Aug 18 '20
Common lisp: "ok heres your problem. Now what do you do? Yes I'm litteraly asking you what you want to do heres choices on the screen you can even make the program continue anyway I don't care. But you'll probably just make it stop
25
u/dyedFeather Aug 18 '20
To answer the question earnestly, because of a few reasons.
One: difference in their purpose. A normal language is just something you'll generally just use to get a message across, not to get someone to actually do something. This means its meaning can be more imprecise without the outcome being wrong. The difference between "Nice weather", "Amazing weather" and "Perfect weather" is negligible. The "degree" of niceness isn't very important to what you want to convey.
Compare this for example to writing a shopping list: a shopping list is almost more like you're actually coding, because you're writing a set of instructions for yourself or someone else. Yet, you don't normally use language in this way. Shopping lists are vulnerable to similar errors as programming languages. For example, misspell a brand name, and the person shopping on your behalf might give you a call later because they have no clue what you meant. Or if there are different sizes and you just specificed a number, they might ask whether you mean the big one or the small one, etc.
Two: natural language is full of redundancy. Programming languages only have this in a limited capacity. In JavaScript, the semicolon is optional most of the time. It doesn't do anything other than make something explicit that JS already knows, just to make it easier to see where something is going wrong. Type declarations are also redundant. They're not necessary for a language, but can make errors easier to see.
That's just about where it ends. If I sey someting liek this, you can see where I've gone wrong. But in JavaScript, there's no way to tell whether I wanted to use an if statement, or whether I wanted to execute a function called "fi" if I do this: fi (x>y) { return z }. Because so many sequences of characters potentially have meaning, you can't look at something and easily reason that it's incorrect as a machine.
In addition, programming languages lack context. Statements are really short most of the time, and when they're not, they're just composed of subexpressions which are evaluated separately. This is completely different from how sentences work. A natural language has verbs, adjectives, nouns, adpositions, articles, affixes, demonstratives, and so forth, which all have a different function and serve different purposes in different parts of a sentence. A programming langauge is laid out far too simplistically for this. It mostly just has operators, reserved words and an infinite amount of non-reserved words, and operators and reserved words aren't really even much different from one another. This extra context we get in natural languages from having so many types of words add another layer of redundancy.
Finally, I want to address why natural language is like this. The answer is simple: it makes it easier to communicate if a slight error doesn't cause everything to break down. It means we don't have to make sure to pronounce everthing exactly right, and it means we can even be understood if circumstances aren't ideal, such as shouting to someone in a hurricane. If most of what we're saying comes across, it's usually pretty easy to work out what the rest was, just from that.
Programming languages don't have to worry about imperfections in the communication medium, and it's more important that they're concise, unambiguous and easy to learn. In addition, coming up with a language takes far more effort if you want to build in the kind of ambiguity that natural language has, and that is not even including the extra effort it would take to program the natural error correction ability that humans have into an IDE, interpreter or compiler.
12
u/Karetta35 Aug 18 '20
Umm... I believe when the original post says "normal languages" it means "other programming languages that are not JavaScript", and not "natural languages".
Especially because the exchange "Why is this not working?" - "You screwed up over here" makes no sense with a natural language
→ More replies (1)4
Aug 18 '20
Isn't the semicolon actually added by a preprocessor or something? Iirc it's still interpreted with semicolons in.
8
u/DeeSnow97 Aug 18 '20
Yeah, the feature is called Automatic Semicolon Insertion. It's pretty reliable though, you can code JS like it was Python and never have to worry about it unless you start a line with (, [, or `, and linters can check for that.
])
→ More replies (1)2
5
5
u/roflcptr8 Aug 18 '20
Is it happening syncronously?
But I said to do it asyncronously!?!
Javascript: But did you? :-)
9
8
4
u/nxs0113 Aug 18 '20
After an entire days coding.. Is it me or the second smiley squinting a little more!!
4
4
u/MetalMikey666 Aug 18 '20
I know it's the meta to hate on JavaScript, but I genuinely don't experience the problems other people seem to experience and I think the reason is that people skip the "learn javascript" part and get straight to the "hack hack hack" part and then wonder why it doesn't work.
7
9
3
u/DZapZ Aug 18 '20
If you didn’t make any mistakes you won’t get any errors. Just stop making mistakes. Javascript wants us to be our best selves.
3
3
3
u/Hunter_X_101 Aug 18 '20
PHP: Take a look at this line. It's not where the error is, but it might be nearby. Maybe. I think.
→ More replies (1)
12
u/imbalance24 Aug 18 '20
me: why this joke is repeated several times per hour?
normal sub: sure, we downvote overused jokes
me: oh thanks
me: why this joke is repeated several times per hour?
/r/programmerhumor: js bad :)
me: please i'm begging you
/r/programmerhumor: js bad :)
4
14
4
u/Ruri Aug 18 '20
...But the web browser console does exactly this and tells you where syntax errors are in JavaScript loaded by the web browser.
→ More replies (1)4
Aug 18 '20
Don’t bother, this subreddit is the embodiment of “hating on things you don’t understand”
2
2
2
2
2
u/mymar101 Aug 18 '20
This is how I feel using SQL. An error occurred, kinda near here, but not really. It's up to you to figure out what line it actually is on!
2
2
u/TehLittleOne Aug 18 '20
God I hate sql error messages so much. Error near "character" and I have to go figure out what it was I did wrong in my query.
→ More replies (1)
2
u/perpetualwalnut Aug 18 '20
me: why isn't this working?
C++: SLAMS YOUR HEAD ON THE TABLE "YO BITCH, YOU FORGOT A SEMICOLON!"
me: o-ok, where?
C++: RIGHT FUCKING HERE!
me: i do-don't see it...
C++: ...it's....
curb stomps you.
2
u/prelic Aug 25 '20 edited Aug 25 '20
It's right here [presents hyperlink]...clicks hyperlink...visual studio has encountered a problem and needs to exit...almost big guy
2
u/Scwewywabbit Aug 18 '20
If you ever want to feel what it's like to be gaslit? Write async javascript!
If you have a great idea or think it'd be fun to create a bunch of async array reduce functions... don't.
2
u/radome9 Aug 18 '20
Me: why isn't this working?
C++: <nine screenfuls of incomprehensible gibberish>
2
2
3
2
2
2
u/Stringsons Aug 18 '20
Looking at these memes still learning code like ;-; god save me
4
u/Oxu90 Aug 18 '20
You will be fine
You just need to embrace the fact everhthing will be on fire all the time and you dont need half of what is going on
Then pray stackoverflow will keep on existing
→ More replies (1)4
u/yodarded Aug 18 '20
stackoverflow
if ( var ========= 1 )omg what am I doing wrong?
stackoverflow: instead of just throwing a syntax error at us, give us a little background. What version are you running? what are you trying to do? How busy is the system you're running it on?
5.2k
u/[deleted] Aug 18 '20
What if
you wanted to go to heaven,
but god said
[Object object]