Re: [Adam] Thursday, February 15, 2018
Posted: Mon Feb 26, 2018 3:29 pm
now you are using ad hominems because your example didnt get your point across?
now you are using ad hominems because your example didnt get your point across?
And you could do that research and actually click the installer link further to:DoctorGester wrote: ↑Mon Feb 26, 2018 2:58 pmThis guy gets it.
Have you actually checked that? I'm aware of pip obviously, I was specifically arguing that a set of libraries needs special handling and can't be simply installed using pip. Maybe it can now, it sure wasn't the case when I used it.
https://wiki.wxpython.org/How%20to%20install%20wxPython\
Like if you maybe actually do some research before talking.
Yeah no, you are trying to stretch it too hard. You obviously work with strings from the very beginning. You parse it into an int, since it fails you reject the request with the message that you were expecting an int. That's the whole deal. Anything else is a terrible practice. Your code will accept things like true or [ 1 ] as valid inputs. Did you foresee that? Whoops, guess you just introduced a subtle bug into your public application, but who cares, amirite?Silverware wrote: ↑Mon Feb 26, 2018 3:36 pmIn C, you have to check the type of the input, see that it is a string, convert it to an int, because you were expecting an int. See that failed, so try converting to a Float, since that worked, and you were expecting an int, you now have to convert to an Int, and then start working with it.
That's not what my argument was at all, no. To reiterate my point: the compiler helps you a ton when developing projects of any size. Missing out on that form of automated error-checking in a big project is unwise. Either way people end up with either type annotations or a ton of unit tests. Both of those are extra work which could be avoid by using a statically compiled language.Silverware wrote: ↑Mon Feb 26, 2018 3:36 pmSo... your argument boils down to.
"I don't convert my variables between types so I don't need Weakly Typed languages"
Yeah like I said this is for a new version which appeared fairly recently and when I developed my application 3-4 years ago I was surprised I couldn't just do "pip install wxWidgets". Pretty sure the same thing stopped me from even trying pyQt and that seems to be installable from pip now as well. Which is good!Dinosawer wrote: ↑Mon Feb 26, 2018 3:35 pmAnd you could do that research and actually click the installer link further to:
https://www.wxpython.org/pages/downloads/
where I got that command from, because I did in fact do the research before posting I even checked if my IDE found the package
No, because you seem to only answer to that specific message taking it out of context. If you read the previous posts from me and other people you'll see that we are talking exactly about that stuff, so your condescending "ever heard of" is out of place.Cornflakes_91 wrote: ↑Mon Feb 26, 2018 3:29 pmnow you are using ad hominems because your example didnt get your point across?
And still half of your "dynamic typing is bad" examples are a straight up lack of input sanitisation, not innate problems of dynamic typing.DoctorGester wrote: ↑Mon Feb 26, 2018 4:06 pmNo, because you seem to only answer to that specific message taking it out of context. If you read the previous posts from me and other people you'll see that we are talking exactly about that stuff, so your condescending "ever heard of" is out of place.
Wow, maybe because I didn't imply that? Okay I'll dumb it down a little in a form of simple codeCornflakes_91 wrote: ↑Mon Feb 26, 2018 4:13 pmAnd still half of your "dynamic typing is bad" examples are a straight up lack of input sanitisation, not innate problems of dynamic typing.
Code: Select all
function processUserInput(inputAsJsonObject) {
const howManyOrangesToBuy = inputAsJsonObject.howMany;
buyActualOranges(howManyOrangesToBuy); // Whoops, I'm a junior programmer and I forgot to sanitize my input! "howMany" can be anything, what a dumb mistake!
}
function buyActualOranges(howMany) {
database.insertBuyOrder(howMany);
}
Code: Select all
function processUserInput(inputAsJsonObject: object) {
const howManyOrangesToBuy = inputAsJsonObject.howMany;
// Whoops, I forgot to sanitize my input again. However, this code will not compile unless I explicitly turn "howManyOrangesToBuy" into a number
// Guess what, my stupid mistake was caught by the compiler
buyActualOranges(howManyOrangesToBuy);
}
function buyActualOranges(howMany: number) { // Yes, since typescript is a javascript-compiled language there is no "int" type, I hope I'll not get strawmanned for that
database.insertBuyOrder(howMany);
}
Code: Select all
void processUserInput(JsonObject input) {
var howManyOrangesToBuy = input.getAsString("howMany");
buyActualOranges(howManyOrangesToBuy); // Compile time error
}
// Wow, guess what, compiler checked for me that
// 1. The input is not a bogus value like a string or an array
// 2. The input is not a floating point value
// 3. The input is non-negative
function buyActualOranges(unsigned int howMany) {
database.insertBuyOrder(howMany);
}
Please, at least try to be intelligent about your arguments.DoctorGester wrote: ↑Mon Feb 26, 2018 4:28 pmCode: Select all
function processUserInput(inputAsJsonObject) { const howManyOrangesToBuy = inputAsJsonObject.howMany; buyActualOranges(howManyOrangesToBuy); // Whoops, I'm a junior programmer and I forgot to sanitize my input! "howMany" can be anything, what a dumb mistake! } function buyActualOranges(howMany) { database.insertBuyOrder( (howMany*1|0) ); }
Code: Select all
function buyActualOranges(howMany) {
if(typeof howMany !== 'number'){ throw "input not a number"; }
database.insertBuyOrder(howMany);
}
Code: Select all
function buyActualOranges(howMany) {
if(typeof howMany !== 'number'){ throw "input not a number"; }
if(howMany !== (howMany|0)){ throw "input not an Int"; }
database.insertBuyOrder(howMany);
}
Yeah, no. It absolutely does not evaluate to anything like that. Where did you get that from? Compiled languages do not work like that. They check at COMPILE time, that's the whole point. You don't need to run the code to check that all types are correct. If you didn't understand that, then what's the point of participating in the argument even?Typescript just evaluates as:
Yeah, all programmers should know not to add errors in their code, what a bunch of amateurs...Should know that he needs to sanitize all inputs.
My understanding is that Typescript "compiles" to Javascript. Which is then pushed out to the browsers.DoctorGester wrote: ↑Mon Feb 26, 2018 5:35 pmYeah, no. It absolutely does not evaluate to anything like that. Where did you get that from? Compiled languages do not work like that. They check at COMPILE time, that's the whole point. You don't need to run the code to check that all types are correct. If you didn't understand that, then what's the point of participating in the argument even?Typescript just evaluates as:
https://en.wikipedia.org/wiki/TypeScriptWikipedia wrote:The TypeScript compiler is itself written in TypeScript and compiled to JavaScript. It is licensed under the Apache 2 License.
This is pretty much it.0111narwhalz wrote: ↑Mon Feb 26, 2018 8:51 pmWay I see it, you have to ensure that your inputs are the right type at some point. Static typing does this in compile time, while dynamic typing does it at runtime. The first is better for end-result performance and the second is for protyping.