Return to “Dev Logs”

Post

Re: [Adam] Thursday, February 15, 2018

#167
DoctorGester wrote:
Mon Feb 26, 2018 2:58 pm
This guy gets it.
Dinosawer wrote:
Mon Feb 26, 2018 12:03 pm
pip install -U wxPython
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.
And 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 :P I even checked if my IDE found the package
Last edited by Dinosawer on Mon Feb 26, 2018 3:42 pm, edited 1 time in total.
Warning: do not ask about physics unless you really want to know about physics.
The LT IRC / Alternate link || The REKT Wiki || PUDDING
Image
Post

Re: [Adam] Thursday, February 15, 2018

#168
So... your argument boils down to.

"I don't convert my variables between types so I don't need Weakly Typed languages"

That's perfectly valid.

But for those of us who work in multiple different data formats, and have to convert between string, number, int, float, all the time. It requires much less effort to do it in a weakly typed language.

Using your website example.

The user inputs:

"3.5" oranges

In 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.

In JS, I go: "(Input*1|0)", and bang, I know 100% for certain, that no matter what the data came in as, I am now working with an Int, or a NaN.
°˖◝(ಠ‸ಠ)◜˖°
Toba - A Development Dump
Post

Re: [Adam] Thursday, February 15, 2018

#169
Silverware wrote:
Mon Feb 26, 2018 3:36 pm
In 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.
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?

However, you brought up a good point about interfacing with other formats. Working with formats as such as xml is less tedious when you are using a dynamic language. Languages such as C# have a solution for exactly that situation as well allowing to imitate dynamic languages. That's a totally valid use, although things like json schema and xml schema show that you could just map those formats to a static data structure definition.
Silverware wrote:
Mon Feb 26, 2018 3:36 pm
So... your argument boils down to.

"I don't convert my variables between types so I don't need Weakly Typed languages"
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.
Dinosawer wrote:
Mon Feb 26, 2018 3:35 pm
And 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
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!
Cornflakes_91 wrote:
Mon Feb 26, 2018 3:29 pm
now you are using ad hominems because your example didnt get your point across?
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.
Last edited by DoctorGester on Mon Feb 26, 2018 4:15 pm, edited 1 time in total.
Post

Re: [Adam] Thursday, February 15, 2018

#170
DoctorGester wrote:
Mon Feb 26, 2018 4:06 pm
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.
And still half of your "dynamic typing is bad" examples are a straight up lack of input sanitisation, not innate problems of dynamic typing.
Post

Re: [Adam] Thursday, February 15, 2018

#171
Cornflakes_91 wrote:
Mon Feb 26, 2018 4:13 pm
And still half of your "dynamic typing is bad" examples are a straight up lack of input sanitisation, not innate problems of dynamic typing.
Wow, maybe because I didn't imply that? Okay I'll dumb it down a little in a form of simple code

Code in javascript:

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 in typescript:

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 in some other C-like language:

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);
}
Damn, that's a lot more code than in dynamic languages, right?
Post

Re: [Adam] Thursday, February 15, 2018

#172
DoctorGester wrote:
Mon Feb 26, 2018 4:28 pm

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*1|0) );
}
Please, at least try to be intelligent about your arguments.
Your' Junior programmer might be a dumb, but the guy who did the DB functions? Should know that he needs to sanitize all inputs.


Typescript just evaluates as:

Code: Select all

function buyActualOranges(howMany) {
    if(typeof howMany !== 'number'){ throw "input not a number"; }
    database.insertBuyOrder(howMany);
}
So if you wanted it to be int only, easy:

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);
}
Last edited by Silverware on Mon Feb 26, 2018 5:26 pm, edited 1 time in total.
°˖◝(ಠ‸ಠ)◜˖°
Toba - A Development Dump
Post

Re: [Adam] Thursday, February 15, 2018

#174
Typescript just evaluates as:
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?

Before proceeding I strongly advice you to read the following articles and try to understand them:
https://en.wikipedia.org/wiki/Type_safety
https://en.wikipedia.org/wiki/Type_syst ... e_checking
Should know that he needs to sanitize all inputs.
Yeah, all programmers should know not to add errors in their code, what a bunch of amateurs...
Post

Re: [Adam] Thursday, February 15, 2018

#175
DoctorGester wrote:
Mon Feb 26, 2018 5:35 pm
Typescript just evaluates as:
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?
My understanding is that Typescript "compiles" to Javascript. Which is then pushed out to the browsers.
It's not some magic way of making Javascript Strictly Typed. it's just wrappers and code that abstract away some things from the programmer.

The Javascript, now that depends. In V8 (and thus Chrome) it is actually compiled and then run.
In some other browsers (mostly older ones) it's interpreted as it goes.


Wikipedia wrote:The TypeScript compiler is itself written in TypeScript and compiled to JavaScript. It is licensed under the Apache 2 License.
https://en.wikipedia.org/wiki/TypeScript

Yes, "compiles" to JavaScript. So terminology specifics aside, "evaluates as" is perfectly valid.



Since this is the case, it can check all it wants at compile time, but until the user data comes through it cannot know if the value is string, or number, or object yet.
Therefore *MUST* check the type at the start of the function, else provides no benefit.
°˖◝(ಠ‸ಠ)◜˖°
Toba - A Development Dump
Post

Re: [Adam] Thursday, February 15, 2018

#176
You did not read those articles, did you?

There is no magic way of checking types in any language. If you check java or c# bytecode it has no types or typechecking. Yet the languages are statically typed. The difference is you have a tool - the compiler, which checks type errors for you. It does not matter what the code is compiled into. Assembly has no types either and yet somehow C++ is statically typed, madness. Please try to understand the basics on how compilers and programming languages in general work. Please read the provided articles. Please try to understand the difference between compile-time and run-time. Educated discussions require people educated in the subject. It’s in the name.
Post

Re: [Adam] Thursday, February 15, 2018

#177
Wow, have you ever used JavaScript? or Typescript?

The TS "compiler" is actually a transpiler, converting TS code into the equivalent JavaScript.

The JS is then run in the browser through either an interpreted method, or by compiling.

Therefore:
For TS to offer Strict Typing, it *MUST* add type checking in.
JavaScript already offers type checking, you just have to make use of it. It's not magic, it's part of the language standard.

https://developer.mozilla.org/en-US/doc ... ors/typeof
°˖◝(ಠ‸ಠ)◜˖°
Toba - A Development Dump
Post

Re: [Adam] Thursday, February 15, 2018

#179
0111narwhalz wrote:
Mon Feb 26, 2018 8:51 pm
Way 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.
This is pretty much it.
Weakly Typed languages tend to be a lot faster to get something working in.
While Strongly Typed languages tend to run that thing a lot faster once it's written.

Which is why we use the correct language for the job. :D
°˖◝(ಠ‸ಠ)◜˖°
Toba - A Development Dump
Post

Re: [Adam] Thursday, February 15, 2018

#180
Pretty sure this whole back and forth about coding standards now ranks as one of the most heated discussions in forum history, more salt and snark here than any thread on politics or religion :lol: But I suppose we can all agree that all politicians in general are just plain awful, definitely worse than java, definitely worse than flash, almost as bad as clients who want to be involved in the development but don't really know what they want.
Image
The conquest of Nature is to be achieved through Number and Measure.
It's better to have questions you can't answer than answers you can't question.

Imagination Fertilizer

Online Now

Users browsing this forum: No registered users and 3 guests

cron