Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python as First Langauge
#11
Thanks for the hint to Type Annotations. I missed that till now. It is used in none of the books I looked into or in sample code. For a guy like me that has written tens of thousands of lines of code in strictly typed languages, it looks like an absolute necessity.

And yes, my Spyder environment issues the warning message that w is assigned (w=8) but never used, which is correct. The example is not a good one because it is the same in Java and Python. You can change any element of a compound object, but the object itself. You can achieve that only in C/C++. It was just an example of a weak point in Zeller's arguments.

Thanks so far. Have not decided yet.
Reply
#12
For speed, PYPY is pretty good has a justin time compiler ...
For your classroom, Jupiter is really nice, you have text and code live at the same time !
:)
Reply
#13
Quote:Jupiter is really nice
it's 'jupyter'. https://jupyter.org/

To try: https://jupyter.org/try
Reply
#14
I have now decided for Java.

The reason is that Java is closer to the machine. I want the students to think about the way an algorithm works and to get a picture of what is actually happening in the computer. Otherwise, they will come up with solutions that perform very badly. E.g., it is simply not okay to forget about the underline machine architecture and use infinite integers all the time. This sloppy style might avoid some thinking, but at a cost.

I also do not like students to not use loops. While all those list tricks in Python are short, they are cryptic, especially for a beginner. What is a slice object, a range in Python 3? I admit that it is more verbose to achieve the same in Java, but a lot easier to understand.

For a speed comparison: I just tried to fill create a list of 100000 integer elements in Python and fill it with 1 to 100000. That takes 5 msec. It does not matter if you do it with x.append(k) or a presized list and x[k]=k. Then I did the same in Java in 0.15 msec. That is 30 times faster! If you are using the list class in Java List<Integer> it takes 0.5 msec, which is still 10 times faster. Sorry, but I come from Numerical Analysis.

So let it be Java. I also have to consider that I have three other high class subjects (Complex Analysis, Calculus, Measure Theory) in the next semester, and I understand Java much better than Python.

Thanks for all your input!
Reply
#15
mga010 Wrote:Then I did the same in Java in 0.15 msec
Java is an excellent language. That said, I am sure you have already heard about this quotation
Donald Knuth Wrote:“The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming.”

The Art of Computer Programming
Developper's time matters too.
mga010 Wrote:I understand Java much better than Python.
That is a much more serious argument! It may indeed improve the course's quality.
Reply
#16
Yep, I know this. And, indeed, developer time counts. And also, you need not optimize everything.

I always tell a story when I hear this: I once did an exercise that a colleague gave to students myself. They were to read 2000 spam mails, identify all words, make a statistics of that, and finally test the statistics to tell spam from non-spam in a sample of another 2000 mails. That's a simple AI task. But they had to do that in Matlab. Okay, I did it pulling out all tricks of Matlab I could find in the net to get it under the required 90 seconds. Barely made it, and it took me almost a day of work. Then I repeated the same in Java, finished it with very simple code (and I mean beginner level code) in two hours, and it ran in 3.5 seconds. What has that to do with our discussion? Matlab addicts say it is a language where you easily get results without much coding, thus shorter development cycles and faster results. It is simply not true. Verbose code in C/Java/C++ does the same much faster and is easier to understand. Mainly, because you do not have to worry about tricks.

I consider Python a script language now that is used to call C code. The beginner students of mathematics should learn the basics, not the scripting language.

Another story as a side remark: I have a student right now doing some pattern matching algorithms for a thesis, and he is doing it in Python. His main complaint, however, is that his algorithms are so slow. He is optimizing every bit he finds, which is a good attitude. But maybe the language itself is holding him back.
Reply
#17
I have been writing code since 1968. I started in computer engineering, and switched to software.

I agree that it is very important for students to understand the architecture of a computer.

I also believe in wheels, but have no real desire to try and reinvent one.

I started with machine code, then lisp and Fortran, eventually C and finally Python (only a small amount of java when it was necessary)
All great languages, but I must tell you, I have never loved a language more than I do Python. (almost as passionate for C).
Reply
#18
Its architecture vs conceptual expression.

Computer Science is architecture based. The ideal language is Assembler. There one is faced with every nuance of the architecture. It is machine based, with speed as the first priority, and ergonomics as immaterial. C and Java are attempts to simplify this process, but their repititious nature and complexity make them ergonomically inefficient.

In the hard sciences such as Engineering and Biochemistry one should not have to worry about compiler internals. If I am trying to calculate protein conformations, or doing fourier analysis I want the code to be as much like the actual mathematics as possible, as errors in logic are no less important than errors in type casting.

Computers have shown themselves to be quite good at computing the needed types, so as much of the architectural stuff as possible should be offloaded onto the compiler, rather than the programmer. This is where the high level languages like Python, Perl, Node and others come in. The ability to evaluate conceptual ideas with the least amount of distraction.

The high level languages normally come with high level error detection. My Visual C 2019 compiler mainly spits out cryptic gibberish about type errors or missing header files, for example. Python will often spit out a 'fix' for the errors it finds.

Point being is that the tediousness of lower level languages such as Java and C can turn alot of students off. And also make it difficult to understand the key concepts. It certainly did it for me. Take OOP. I was never able to understand the point of classes until I seen the way it was implemented in Python.

That said, I do not understand how lower level computer science would be taught in Java rather than the C languages. In the past I worked with a colleague on a Java project and found that it is extremely wasteful of resources and dreadfully slow compared to similar apps written in C languages. Does anyone really write enterprise apps in Java anymore?
Reply
#19
Python there's enough new stuff for the students that you want to avoid any extra complications and Python is free to use, has all the libraries you could possibly imagine, a fantastic community and global support network, is user-friendly, and is one of the very best options out there for machine learning and data analysis or etc..
Reply
#20
The value of a language should be in how it solves the issue.
No difference in using right size of hammer for job at hand.
Mathematician seldom solve issues "at high " level - so teach
a language which wont be boring to use.
Beside - K&R book is only around 150 pages ...









(Jul-02-2020, 10:09 AM)mga010 Wrote: I do not know where to ask this. This forum is linked from Python.org. So it seems just right.

I am going to teach a first-year university course in programming next year for students of mathematics (Bachelor and High School Teaching). Through all the years, I have used Java as the first language. The reason for this is that Java is as fast as C and very close to the basic syntax of C, but cross-system and with a huge library for all sorts of programming scenarios. Python was always rejected because it is too high level and abstract, hiding the basic concepts from the user. Going from Java to C is easy, but not so from Python to C. Python is also not well suited for basic real-world or numerical programming because it is at least five times slower than Java, and often even more performance is lost.

Now I am aware that there are nice and useful things like Numpy or Matplotlib, and even libraries for machine learning. Those are C in the background, and they don't exist in Java in that form. This inclines me strongly towards Python. But, in the basic course, this will never be reached. And I think for someone that understands basic commands, data types, and objects, it is fairly easy to learn the Python concepts necessary to use these libraries.

So, here is my question: What good reasons can you give to convince me to use Python instead of something basic like C or Java?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020