5 ms·
Python, seriously? How do you explain to 5-year-olds what the following line does? if __name__ == "__main__": Python is there for when you move beyond begin
by _sh 13y ago
Python, seriously? How do you explain to 5-year-olds what the following line does?
if __name__ == "__main__":
Python is there for when you move beyond beginner and you start to need libraries.
For everyone else, there's javascript: open up your browser console and you have a full IDE with breakpoints and inspection, and an interactive REPL. Object orientation is there if you want it, but what 5-year-old does? Functional paradigms are there when you're ready for them (map and foreach on arrays, for example). A smooth learning curve that gives you power when you reach for it, and a fast, flexible GUI environment. Free source code to study comes with every web site.
Best of all, its flexibility fosters many differing programming styles: consider jQuery and Angular. Very few programming ecosystems could give rise to such unique styles. I wish my first programming language was javascript, instead of C64 BASIC, with its 38911 basic bytes free.
- pessimizer 13y agoJavascript is absurdly complex, awkward, dishonest (in trying to appear to be OOP), and often a completely unintelligible mass of callbacks. I not only don't want beginner programmers to learn in javascript, I don't even want them to see js until they have experience in another functional language (although that ship has sailed.) If you honestly think if __name__ == "__main__": is more complicated than js variable scoping rules and closures, I'm intrigued by your mind.
- Bahamut 13y agoJS, as with all languages, has its flaws, but I found JS the most accessible language for me. It solved the problems I was interested in, and so putting up with its issues was fine for me.
- teach 13y agoWhen teaching Python to a 5-year-old, you wouldn't use that line. You'd just have statements in global scope and no main() function.
- lhgaghl 13y agoCan't tell if you're trolling. Ignoring the fact that you don't actually need the if __name__ == "__main__" thing in Python... <script type="text/javascript"> $(document).ready(); </script> int main() { return 0; // may or may not be needed depending on version of C/C++ } class Main { public static void main(String args) { } } Perhaps you should try Haskell, since you seem to care so much about how to write main... main = print "blah"