4 ms·
Better yet, why not explore why other languages insist on having a function, or a class with methods, before being able to print hello world? C# literally got
by nailer 6y ago
Better yet, why not explore why other languages insist on having a function, or a class with methods, before being able to print hello world?
C# literally got the ability to System.out.writeLine("hello world") (probably wrong, I'm not a C# programmer) in 2020.
I suspect the answer is "we care about existing programmers more than people who are learning to program".
- flohofwoe 6y agoWhat's the point of teachin newcomers something they need to give up later anyway though? (once their programs get big enough to be split over several files)
- pdpi 6y agoDifferent languages have different goals. It's fine if not all languages have simplicity and beginner-friendliness as a core concern.
- throwaway894345 6y agoThe difference is simply that compiled languages distinguish between 'static' and 'dynamic'. Static things include types, constants, and static variables. In interpreted languages, these things are all dynamic constructs--defining a type is a runtime activity that actually involves executing some code that changes the internal state of the interpreter, and it can (and regularly does) happen intermixed between other computations. 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".
- nailer 6y agoYou can call a function that takes a string type argument in a strictly typed language. This has very little to do with needing boilerplate.
- throwaway894345 6y agoI 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.
- nailer 6y ago> 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.
- throwaway894345 6y agoTo 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.