shivajikobardan
- 637
- 54
@pbuk I mean because of standard template library it is easier to study leetcode in c++.
I think you are mistaken, what gave you that idea?shivajikobardan said:@pbuk I mean because of standard template library it is easier to study leetcode in c++.
Wrichik Basu said:I would recommend people to learn Java as their first programming language. Yes, you may say it has a lot of boilerplate code. But dealing with indentation errors is not what I would like to encounter when I am absolutely new to programming, and not fully familiar with an IDE. Maybe you will say that learning OOP is not necessary for programming. True, but OOP helps build programming logic in a certain direction. Each variable always having a global scope is also an issue in Python. The loop variable is available even outside the loop. For a newbie, this could give rise to logical errors if not careful. In Java, declaring a variable inside the loop keeps it inside.
Mainly this:Vanadium 50 said:Who is the audience?
Vanadium 50 said:Is it people that need to be steered away from C++ as a good starting point?
I don't think multiple inheritance is something a beginning student should be learning anyway.jedishrfu said:One thing that’s not been brought up here is the fragile base class issue of OOP languages like Java or C++.
...
These subtleties can really mess with a beginning student
I accept what you say, however I believe it is better to be able to move to more serious projects without having to change language.jedishrfu said:The student has a clear path from Processing to more serious projects and an easier transition from hobbyist level to professional developer while maintaining what they’ve learned.
No, Python 2.7 reached end of life three years ago and should not be used by anyone for anything, let alone be taught to beginners.jedishrfu said:Processing has a similar path for Python folks when the Jython mode is selected although it’s not as easy to transition to developer level since Jython is at v2.7 and most modern Python development is done with Python 3.
I have two thoughts on this:jedishrfu said:Anyway, this is an endless flame war topic with no clear winner only many options for folks to choose from and lots of people with varying opinions and positions on what works best.
University of Cambridge Department of Computer Science and Technology said:FAQ: Can you recommend any books or activities to do that would help my application and/or studies?
A: If you choose to learn a new language, it may be a good idea to learn one that is not explicitly taught in the Tripos. Doing so obviously helps to avoid repetition, but also gives you a wider perspective on languages that can be useful later in the degree and in employment. A popular choice is Python, for which there are many tutorials available.
https://www.cst.cam.ac.uk/admissions/undergraduate/faqs
MIT Open Courseware Introductory Programming said:This page will help you begin to learn programming and computer science, with some suggested introductory courses on OCW.
These courses introduce principles of computer science and begin to develop programming skills, specifically in the Python language. Learn more about these courses’ learning goals, history and student experience in this MIT news article.
Introduction to Computer Science and Programming in Python
Introduction to Computational Thinking and Data Science
Programming for the Puzzled
https://ocw.mit.edu/course-lists/general-introductions-to-programming/
Among the academic community, particularly in STEM, it is prototyping that is mostly needed, not serious programming. For that purpose Python is a good choice. But the academic community is an extremely small sample of all programmers.pbuk said:Although there are many opinions stated among posters here and elsewhere, I believe that there is now a consensus among the academic community, particuarly in STEM, that Python is the best first language (some indicative evidence below). I think PF would benefit from a sticky post joining this consensus.
I think you have misunderstood my point, which is that if institutions such as the University of Cambridge and MIT are recommending and using Python as the first language to learn for computing and STEM students then why would it not be good for PF to do that too?Rene Dekker said:Among the academic community, particularly in STEM, it is prototyping that is mostly needed, not serious programming.
I don't understand your reference to separation of concerns as a language feature, surely it's a (highly desireable) programming style that can (and should) be used in any language?Rene Dekker said:Even people using Python would do well to learn a statically typed language with separation of concerns first.
I beg to differ on this. Python is a good language for scientific computing, no questions regarding that. But that's primarily due to the availability of libraries like numpy, scipy and matplotlib - the foundations. If these libraries were written for Java, the scenario would have been different.pbuk said:Although there are many opinions stated among posters here and elsewhere, I believe that there is now a consensus among the academic community, particuarly in STEM, that Python is the best first language (some indicative evidence below).
Then you are differing with the recommendations I quoted from the University of Cambridge and MIT which are not specific for scientists.Wrichik Basu said:I beg to differ on this.
I agree completely. Data types are encountered early in learning Python withWrichik Basu said:An absolute beginner needs to learn programming first, before going into scientific or numerical programming. Without the notion of data types, for instance, I am not convinced how programming logic can be created. A solid base in programming would help you master any programming language in the future.
# Adding numbers.
print(2 + 2) # 4
# Adding strings (concatenation).
print("2" + "2") # 22
# You can't mix types.
print(2 + "2") # TypeError: unsupported operand type(s) for +: 'int' and 'str'
Yes, you can write bad code in any language. In the 1990s the same groups struggled with FORTRAN77 legacy code, in the 2000s it was Fortran 90, the 2010s C++ and Java. Perhaps if we teach people how to write good Python code from the get-go this will be better in future.Vanadium 50 said:There are research groups out there beimg strangled (get it?) by too much Python. They depend on thousands of lines of unmaintainable Python code written by a parade of students, and never really designed. "Prototypes" are sent straight into production.
Absolutely.Vanadium 50 said:We have a discussion upstream about the "diamond of death" inheritance pattern. As a friend said "this should onl;y be used in compiler test suites, and not any actual running code." I dislike it too, not because of the probelms with it so much as it is almost never what you want.
I don't know what idiot it was that confused the perfectly sensible "Shape" example of polymormorphism and the equally sensible "calculatePerimeter" example of function overloading to come up with a Perimiter class. I hope they were sacked, but somehow their legacy lingers on. Personally I prefer the "Animal" example.Vanadium 50 said:There is a tendency of beginning C++ programs to overuse inheritance. This is aggravated by textbooks using geometric shapes to showcase it ("look, it inherits the perimeter clas") which is a bad choice - it's contrived, saves little coding, and turns the classes into monstrsities of exception handling.
Go too far down that path and you will reach the conclusion "nothing wring with just writing that code in C++".pbuk said:you can write bad code in any language
Would you like to take a try at writing this post?pbuk said:I don't think multiple inheritance is something a beginning student should be learning anyway.I accept what you say, however I believe it is better to be able to move to more serious projects without having to change language.No, Python 2.7 reached end of life three years ago and should not be used by anyone for anything, let alone be taught to beginners.I have two thoughts on this:
@Greg Bernhardt what do you think?
- Although there are many opinions stated among posters here and elsewhere, I believe that there is now a consensus among the academic community, particuarly in STEM, that Python is the best first language (some indicative evidence below). I think PF would benefit from a sticky post joining this consensus.
- Alternatively, there does at least appear to be a consensus on here for "don't learn C++ just because someone has told you it is fast", and I think a post along those lines that we could link in answers would be useful.
Since 2016 Python has been the first language taught to University of Cambride Engineering students
https://github.com/CambridgeEngineering/PartIA-Computing-Michaelmas
If by "one" you mean "a tool that auto-formats Python code", there are multiple such tools available:shivajikobardan said:I'm pretty sure there's not one in python
I'm not sure what you mean. PEP 8 gives perfectly good guidelines for indentation (and formatting of Python code in general):shivajikobardan said:Python's indentation is a bit hard to realize.
Very interesting: I have never run into this problem.jedishrfu said:One thing that’s not been brought up here is the fragile base class issue of OOP languages like Java or C++.
https://en.wikipedia.org/wiki/Fragile_base_class#:~:text=The fragile base class problem,the derived classes to malfunction.
So here is my rendition of the example you describe in C++. If this is not what you have in mind, let me know and I will take another shot at it.jedishrfu said:C++ allows for multiple inheritance and as a result can introduce some funky errors in code. As an example, say you have a class C that inherits from classes PA and PB and they in turn inherit a common class G. G has a variable x that a method in class C changes.
The question is how should one access x from methods in C? Via PA to G or via PB to G. It turns out that in C++ there are two instances of the G class and hence two x variables. The solution was to always design with getter and setter functions and not allow direct access to the variables of another class.
If such a sticky note is included, it should specify its advantages. In your "spoiler" section, only the availability of tutorials is mentioned as an advantage. If that is the only advantage, Python is not worth a sticky note. If there are more advantages, then they would need to be enumerated.pbuk said:Although there are many opinions stated among posters here and elsewhere, I believe that there is now a consensus among the academic community, particularly in STEM, that Python is the best first language (some indicative evidence below). I think PF would benefit from a sticky post joining this consensus.
And don't learn assembler just because it is fast - or either C/C++ or assembler because they create binaries that are easy on the processors other resources.pbuk said:Alternatively, there does at least appear to be a consensus on here for "don't learn C++ just because someone has told you it is fast", and I think a post along those lines that we could link in answers would be useful.
Yes, I started this thread as a first prototypeGreg Bernhardt said:Would you like to take a try at writing this post?
You must be joking - there are many IDEs for Python, including in no particular order:shivajikobardan said:I'm pretty sure there's not [an equivalent to Code::Blocks for] Python.
I admit I never tried that in Python, but I find that astonishing and not very Pythonic. I would have expected Python to promote teh 2 to a "2" and make this a "22".pbuk said:unsupported operand type(s) for +: 'int' and 'str'
That would be guessing that the intent was string concatenation rather than integer addition. But why should that be the default? One could just as easily argue that it's more likely that the programmer meant to do integer addition so the "2" should be interpreted as an integer and added to the 2 to make 4.Vanadium 50 said:I would have expected Python to promote teh 2 to a "2" and make this a "22".
That was a good decision. Shame that whoever made it was out of office when the decisions about the relationships between True, False and 1, 0 were made (and why were they not fixed in v3?). Anyway this is OT.PeterDonis said:Python would rather make the programmer be explicit and correct about stating what they intend, instead of guessing about incorrect constructs that could be interpreted multiple ways.
# The power of truth.
print(10 ** True) # 10
# The power of double truth.
print(10 ** (True + True)) = 100
# Wait for it...
print(True == 1) # True
print((True + False) == 1) # True
one = 1
print((True + False) is one) # True
print(True is one) # False - gotcha!
I agree that treating bool as a subtype of int doesn't make a lot of sense. Historically bool was tacked on as a separate type during the evolution of Python 2 but I don't think the consequences were ever fully considered.pbuk said:the relationships between True, False and 1, 0
My ranting answer: they were too busy making bad decisions about how to "fix" the handling of Unicode to make good decisions about other stuff. (AFAIK making bool its own independent type has never been on the radar of the Python core developers anyway.)pbuk said:why were they not fixed in v3?
I don't want to be harsh on you, but this is exactly the kind of thing that we are trying to avoid. If "data types" are mentioned, and you can only think of numbers and strings, then you may have learned a programming language, but have not learned software design.pbuk said:I agree completely. Data types are encountered early in learning Python with
Python:# Adding numbers. print(2 + 2) # 4 # Adding strings (concatenation). print("2" + "2") # 22 # You can't mix types. print(2 + "2") # TypeError: unsupported operand type(s) for +: 'int' and 'str'
What exactly is the difference between Python and Java in this respect?Rene Dekker said:limited support for separation of concerns
I ask myself that every time I sue Python., Wht? Why of why?PeterDonis said:But why