Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Bimpfi4307yHow about ES6 or Typescript?
I recently started a project with Typescript using strict and i think i'll use it for future projects because of the compile-time type checking. -
@Bimpfi I suppose I'd first need to decide which IDE to use from now on. I'm currently using Notepad++, but am not happy with it. I've had a lot of suggestions as comments to other rants, such as Sublime, Atom etc., but so far none of them has really cut it for me.
-
@TerriToniAX About the IDE, I recommend Visual Studio Code. I love coding in JS with it and they are some cool extension and built-in debug which I use all the time with NodeJS.
-
Bimpfi4307y@TerriToniAX like @MrMargouillat I also can recommend VS Code for js/ts. I use it for js/ts too and love it due to MrMargouillat mentioned reasons.
-
zshh38487yMaking undefined values into "" sounds really stupid to me. That's like super silently failing without any notification to the developer that something went wrong. No, that's not a good language feature. "undefined" at least tells you something.
-
Bimpfi4307y@simeg That's one reasons why debugging in php can be such a pain. I don't hate php at all but things like that let me think twice about using it.
-
@simeg I agree that when something goes wrong, you should get to know about it. But I strongly disagree that putting the exception message inside the string would be the way to go. No the string is not undefined, but "undefined". Then it suddenly is something, a string of 9 characters. That if anything is really stupid. No, the way I think it should work is that an undefined string is an empty string, but JS should throw an exception that I as developer could see in the console, along with the line number where the exception occured. As it is now, JS actually fails silently when trying to concatenate an undefined string because it is not really undefined but "undefined". See my point?
-
@Bimpfi I agree, both PHP and Javascript are a pain to debug. This probably goes for most interpreted and loosely typed languages.
-
zshh38487y@TerriToniAX I don't see your point I think. But I agree, exceptions in the console would be nice. I also agree php and JS are cumbersome to debug.
-
@simeg OK, I'll try to clarify my point. Imagine the following scenario:
var str;
...
for(var key in elements)
{
str += elements[key]["content"];
}
Now, JS should throw an error when concatening str as it is undefined. But there never is an error as JS translates the undefined variable str into "undefined" which is a valid string. In other words JS tricks itself to believe everything is OK. This is the exact opposite of giving the developer useful information. -
zshh38487y@TerriToniAX Yes this point I see. But I don't see how by giving an empty string is better? "undefined" at least tells you that something is undefined, with an empty string you don't know. It could be two empty strings that are being concatenated and then all of the sudden you're debugging a false-negative.
-
@simeg I still beg to differ. My point is that variables shall only be used as variables, and error messages shall be thrown as exceptions. What if a = b/0 would result in a = "division by zero"? No, that's insane. IMHO, returning exceptions as the value of variables is bad practice.
Related Rants
I love javascript, but sometimes it's just an incredibly stupid language, such as when undefined variables get interpreted as string literal "undefined" when concatenating strings. I like it better how, for example, PHP handles undefined values, that nulls just turn into "". Better still: typed languages, where most stupid mistakes are caught already at compilation, instead of having to spend hours to track down where that mysterious "undefined" comes from. As I said, I love javascript - because it is easy to code, flexible and forgiving in many ways. But I hate it for the exact same reason, for being such a sloppy fluffy...thing, and a bugger to debug. If javascript would be an animal, it would be a cute and cuddly cat that you instantly find adorable, but it's actually quite fat and lazy, plus its fur is littered with ticks and other bugs.
undefined
js
javascript