Re:An exploration of why Python doesn't require a 'main' fun...
by nailer on Tuesday July 21, 2020 @03:09PM
(#23909868)
You can call a function that takes a string type argument in a strictly typed language. This has very little to do with needing boilerplate.
Re:An exploration of why Python doesn't require a 'main' fun...
by throwaway894345 on Tuesday July 21, 2020 @04:48PM
(#23910842)
I didn't claim that static typing depends on putting things inside of an explicit main function. Only that the function "boilerplate" serves to hint to the user that the things in the function body happen at runtime to distinguish from the other things which tend to happen at compile time. Static types are an example of things that happen statically (for example, declaring types). Or course this is just a hint--it's not necessary and as previously mentioned, there are many languages that don't make this syntactic distinction.
Re:An exploration of why Python doesn't require a 'main' fun...
by nailer on Wednesday July 22, 2020 @05:41AM
(#23915385)
> the function "boilerplate" serves to hint to the user that the things in the function body happen at runtime to distinguish from the other things which tend to happen at compile time
'hinting' seems vague. Programmers who know what they're doing know that calling functions happens at run time. Obviously you can call a function without needing a wrapper function or a wrapper class + method.
Re:An exploration of why Python doesn't require a 'main' fun...
by throwaway894345 on Wednesday July 22, 2020 @01:56PM
(#23919712)
To be clear, we’re debating the merits of a special syntax that allows the syntactic intermingling of executable code and static declarations. While experienced programmers can probably sift through this and identify which things are static and which are dynamic, not all programmers are experienced (note that the original claim was that the intermingled syntax is better for beginners) and further even experienced programmers may appreciate the explicit syntactic distinction between static and dynamic. Lastly, it also makes it easier to write static analysis tooling (linters, type checkers, compilers, etc) since the intermingled syntax is more complex to implement.
It’s fine if you don’t agree with the value judgments—for example, if you would rather save a handful of characters in “hello world” at the expense of some clarity or technical simplicity. I’m just giving the rationale.
Re:An exploration of why Python doesn't require a 'main' fun...
by nailer on Thursday July 23, 2020 @06:01AM
(#23925750)
> not all programmers are experienced
You are arguing against `print('hello world')` working.
Re:An exploration of why Python doesn't require a 'main' fun...
by throwaway894345 on Friday July 24, 2020 @09:48AM
(#23939421)
Right, I’m not worried about optimizing the language for “hello world” at the expense of real code.
Of course syntactically-speaking, compiled languages could allow users to interleave these static declarations amid instructions and make it the compiler's job to correctly sort out the static from the dynamic (and indeed many languages do this); however, this makes it trickier to write good parsers and it also makes it harder for humans to distinguish at-a-glance the static from the dynamic (and this distinction is important in programming).
> I suspect the answer is "we care about existing programmers more than people who are learning to program".
Arguably if you care about people who are learning to program, you don't just punt on teaching them the distinction between static and dynamic. I think it would be better stated, "we care more about the long-term interests of novice programmers than we do about their short term frustrations".