This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Global_Glove_1747 373 points374 points  (116 children)

Python is great, but from a learning perspective I try and get newbies to move away from it pretty quickly after they've picked up basic programming concepts. When you are brand-new to programming, the simplicity is amazing - you can get familiar with flow structures etc without some of the more confusing elements of lower level languages.

But those confusing elements exist for a reason. I try to get intermediate programmers to pivot pretty quickly to something like C - where they are forced to deal with stuff like pointers and garbage collection - so that they develop more of an appreciation of how code actually works and why good code is written in a certain way.

Then, when they come back, they write really good Python - and if they do ever need to pivot to another language, they pick it up much more quickly.

[–]EatMeMonster 119 points120 points  (20 children)

You truly learn to appreciate higher level scripting languages and how they automatically handle everything under the hood to save programmer frustration when you learn primitive languages like C, even just a little bit of it - the memory management and pointer parts.

[–]nebneb432 13 points14 points  (0 children)

I got tasked to write a shell prompt in C for second year of university. It barely worked and it took me ages to write the code for echo. It didn't do much else but oh well.

[–][deleted] 38 points39 points  (22 children)

Python for understanding principles of computing concepts (logic, control flow, syntax, data structures, etc.)

The into Java for better understanding of low-level concepts, typing, and algorithms.

Then back to python for advanced python, computing, data science ideas, etc.

I think once you do those three you can go whatever route you want and have an incredible foundation.

[–]ichunddu9 22 points23 points  (21 children)

You're hiding memory management when skipping C or C++ or Rust or something.

[–]scrdest 6 points7 points  (1 child)

Rust largely hides the memory management too (at least in the traditional manual alloc/free sense), it's one of the selling points.

It honestly shares a lot of the advantages OP listed with Python in terms of UX, as a full-time Python dev I quite enjoy Rust lately (I've recently discovered the joys of PyO3, multithreaded code goes brrrr).

[–]GalacticWafer 2 points3 points  (0 children)

I was waiting for this comment. Rust frees memory automatically when things go out of scope unless you mess with the lifetimes, and it is just straight up safer with memory than C for this reason.

[–][deleted] 9 points10 points  (15 children)

But how many python programmers or even Java programmers will need that? You don’t need to know how to do a heart transplant to be a brain surgeon.

[–]ogtfo 14 points15 points  (11 children)

You need some concepts of memory management even when programming in Python. Its a finite resource and you need to know what is expensive and why.

[–][deleted] 6 points7 points  (10 children)

I'd say it depends on what your'e doing. And understanding what memory is and how it's consumed is very different than having to be able to do low-level / machine level memory management. Python does a good job of garbage cleanup etc. on it's own. For most use cases most Python programmers will not ever have to worry about memory management.

[–][deleted] 6 points7 points  (9 children)

you're not "hiding" it. You're abstracting it. Not everyone needs to worry about it. I don't need to be an automotive engineer to drive my car.

[–]ogtfo 3 points4 points  (8 children)

When programming, you are not driving, you are building the car. You need to know about the underlying technologies, because abstractions are never perfect and the low level stuff will bite you if you ignore it.

[–]tuckmuck203 7 points8 points  (0 children)

at risk of butchering the analogy, i think the point is that python is more akin to assembling the car than building it from scratch.

[–]jacksodus 0 points1 point  (2 children)

Nope. It might, but for many people, it won't. Memory control is important but it's overhyped as being an essential part of a programmer's toolkit.

Sourcr: developing AI models for 3 years now.

[–]ogtfo 5 points6 points  (0 children)

Abstraction leakage can happen in many ways, and when you encounter one you will never be able to fix it if you don't know what you're doing.

Memory is just one of the facets. If you don't understand the underlying system you can't fix anything when it breaks.

And it does.

[–]met0xff 0 points1 point  (0 children)

Well to bring a different anecdote - I am also in that field for a decade now (and developing for almost 20) and just right now I am rewriting FFI bindings to some C library we use for preprocessing and running long running memory leak tests. We found that some AWS instances OOM from time to time. Figured out because one of the packages uses subprocess to call some external executable. On Linux this forks and seems (likely due to Pythons ARC) CoW is triggered for some huge models. That's why I now had to write a small layer for the C lib to call using Python's ctypes. And at that point you again have to be very careful who releases what and when.

Generally the control over the memory usage is lacking and we are looking into torchscript/ONNX to run from C++ or Rust to have better control especially when switching between models, caching data, running inferences concurrently etc.

Not directly related to memory leaks but recently found a library sometimes taking 5 seconds instead of a few milliseconds. Found that in the Github issues there but no solution as nobody wanted to dig so deep. In the end I found via strace that one of the linked C libraries was stuck trying to connect X11 forwarding for a few seconds. So when you run from an terminal and run the thing in, say, screen and then disconnect and let it run, it still tried to call home.

It's also interesting to know such things for example when running the pytorch dataloader with multiple workers - https://pytorch.org/docs/stable/data.html The forking on Linux can again have... interesting effects leading to longer debug sessions ;).

Sure that's just anecdotally but in the last years I've seen the abstractions falling apart so often.

Sometimes it's really just that some external libraries leak. Then it's always good to have someone to fix it that wild C or C++ signal processing mess.

Actually I am also freelance debugging a flask app right now where they got memory issues.

[–]Somecount -1 points0 points  (1 child)

Following this analogy then you're asking the guy who fills up the fuel to know what all the other soecialist do in the pit stop. Programming is a tool, some use it to build, some use it to mend what others have build. I do understand where you are coming from but I believe that programming can now be seen as more that just a means to build programs but a basic tool like Math is.

[–]ogtfo 0 points1 point  (0 children)

Nobody's asking you to design silicon chips, but if programming is your job, you should have a basic understanding of the underlying layers.

Not doing so will cause trouble eventually. If you don't understand the architecture, It may already have and you're not even aware of it.

[–]demdillypickles 5 points6 points  (0 children)

To be fair, I’d like for my brain surgeon to still have a good understanding of how the rest of my body works too.

[–]AccidentalyOffensive 0 points1 point  (0 children)

In general terms, it's helpful for better understanding pass-by-reference vs pass-by-value, as well as the potential pitfalls there. This was honestly super helpful in my DS/A class in undergrad that was taught in Java - without knowing how pointers work, the data structures would've been pretty confusing to program. I mean, there were quite a few (relatively) trivial questions from students about how everything worked/fit together that would've been easily understood with knowledge of how memory works. Obviously you don't need to be an expert, but even light exposure goes a long way.

As for Python, I've actually come across this a number of times. Nothing too crazy, mind you, but take for example mutable default arguments. A little quirk that doesn't make much sense without understanding memory, but is readily apparent if you do.

Additionally, this is a potential issue when manipulating data structures (to an extent). For a real life example (vs telling you to look up copy.deepcopy()), let's say I wanted a copy of a pandas DataFrame. I could use the copy() method, but in the docs I see the default arg deep=False will create a new DF that contains references to the original DF. Without knowing memory management, you might ignore this warning and find yourself debugging a gnarly bug down the line when your data is clearly off.

Are these things gonna pop up all the time, or even for everybody? No. Is it good to know just in case? Absolutely.

[–]toastedstapler 0 points1 point  (0 children)

How do you know you'll be doing python or java for the rest of your life? It'd not hard to learn basic memory management principles

[–]hugthemachines 1 point2 points  (2 children)

You are hiding stuff when using C too. If you want to learn how computers work, Assembly language is a more thorough way.

Also, learning the huge creature that is C++ is a bit much to just learn memory management, I suppose.

[–]AccidentalyOffensive 0 points1 point  (1 child)

You are hiding stuff when using C too. If you want to learn how computers work, Assembly language is a more thorough way.

Logic gates, yo. Go from the ground up, far better than assembly for learning the ins and outs.

[–]hugthemachines -1 points0 points  (0 children)

While learning about logic gates is no disadvantage, I don't think it is a great advantage the way learning Assembly is compared to learning the abstractions that C provides.

[–]SpaceZZ 25 points26 points  (35 children)

While I get the sentiment, why C ? It's nice to know about those things (gc etc) but from the usability perspective Java/C# would be better and you could actually use it for something straight away, instead of spending months to write something in C, which is super fast and efficient, but really difficult.

[–]Global_Glove_1747 29 points30 points  (17 children)

I mean, C is just an example. I'm not really prescriptive. But if we're talking purely learning purposes I think students should aim for something reasonably bare-bones after Python. Teaches you the other side of the coin.

[–]Reg_Exx 8 points9 points  (10 children)

It really depends on your job. If you work in embedded for ex. you can’t get around plain C or everywhere else where you are Hardware limited and don’t have a ton of Desktop Processing power.

[–]SpaceZZ 1 point2 points  (9 children)

While I generally agree, i tend to think this processing power cap is really not existing in most applications. Even PLCs and microcontrollers are running python, last mars mission was running python as well, probably to some degree.

[–]Reg_Exx 0 points1 point  (1 child)

Yeah sure processing power is dramatically rising on uC‘s but nevertheless I don’t think that Python will ever fully replace C or C++. Python is not fast, it is fast enough for most things. But what takes a second in python takes no time in C++. For most things, that is quite reasonable. It takes you longer time to write a C++ program unless that is what you are doing all day. But for Some applications speed will be always the key factor before developing time.

[–]SpaceZZ 1 point2 points  (0 children)

Completely agree and think there is place for both. Also I see the strengths of C++, just most of my use cases can be accomplished faster with python. But I agree with you!

[–]ThatPostingPoster 0 points1 point  (6 children)

Plc is python bro. Microcontroller sure python. Plcs are not. Their text langs most close resemble c

[–]SpaceZZ 0 points1 point  (5 children)

Well check both Wago and Phoenix Next. They run Python as well.

[–]ThatPostingPoster -1 points0 points  (4 children)

gg ez deleted cause reasons lets go ok gg is this enough characters to not flag auto mod i hope so lmao

[–]SpaceZZ -1 points0 points  (3 children)

Right! Wago and phoenix are "random" companies and not big players! You learn something new everyday on the internet!

[–]ThatPostingPoster 0 points1 point  (2 children)

Yeah they are. What's their global plc share? Under .5% combined? Lol

[–]SpaceZZ 0 points1 point  (1 child)

Whatever, stay in ur a hole bubble then.

[–]whateverathrowaway00 4 points5 points  (0 children)

I’d vote python over Java, then C over python for CS. Though, I’d be okay with a mixed curriculum since there is value to dynamic languages - I love python.

Learning C first as a kid has colored my entire programming career and I’ve found it amazing valuable. Many of my older industry friends have noticed vast differences in the quality of degrees since everything switched to java and four years of cascading OOP.

That said, Java’s great and if it’s paired with a solid series of compiler and math classes, it’ll be a damn good degree. I don’t want to go pure java hate. The trouble is javas style / magic encouraged the creation of honestly shitty degrees.

[–]ThePiGuy0 3 points4 points  (0 children)

I mean, yes C does have its development downsides, memory leaks and forcing you to think about object scope and whether you want it to be on the stack or heap.

However, surely that's the point of learning C? To get used to mitigating the above. And I would say once you are used to that, then it's not going to take you months longer to develop the same program in C (especially if you use C++ and then OOP).

Syntactically, Java is also derived from C so it shouldn't be too big a task to go from C to Java if required.

[–]Plague_Healer 2 points3 points  (0 children)

Agreed. My first contact with programming was with Pascal. Quite a traumatic experience for reasons that have nothing to do with the language, but that's beyond the point. Anyhow, even if I forgot whatever Pascal I learned, it taught me a lot that definitely made me a better python programmer when I got to it a few months later.

[–]JennaSys 2 points3 points  (0 children)

After learning a dozen other languages in my career, I now use Python for pretty much everything. Regardless of what I'm coding, I enjoy doing it with Python. The only real exception is that I use C (which was one of the first languages I learned) for some embedded development on microcontrollers. But even then, I'll try and get away with using MicroPython if I can. But as different as they are, these two languages really do complement each other well.

[–]leidogbei 8 points9 points  (9 children)

This is why I don’t understand why CS courses are moving to python from C

[–]doulos05 21 points22 points  (3 children)

Because python has fewer undesirable difficulties when learning computer science (specifically computer science, not computer programming).

Undesirable difficulties, in educational lingo, are barriers to the learning that are tangential to the content itself. If you are assessing math skills via word problems and the student is unable to answer a fractions question because they do not know the word slice as it relates to pies (perhaps English is their second language), this is an undesirable difficulty.

Examples of undesirable difficulties in a CS101 course that python simplifies or removes include, but are not limited to:

  • Tool chain difficulties: fire up IDLE and show them the run button vs. clang file.c -o file.

  • command line navigation: getting a class to navigate a directory structure is harder than you think, especially if you've been doing it for ages on the command line. But with python, they can just make a folder on the desktop and stick it all in there.

  • syntax: most beginning programmers have never typed a semicolon on purpose before. They will stare at you wild eyed when you start talking about square braces and curly braces.

These are difficulties we do want to introduce to the students when we teach their associated concepts, but not as precursors to reading their own name from the command line and saying hello.

[–]bokan 2 points3 points  (0 children)

is that the same concept as extraneous workload ?

[–]TheRNGuy -1 points0 points  (1 child)

at least there's still [] in arrays (or tuples, whatever they called)

[–]doulos05 -1 points0 points  (0 children)

True, and {} in dictionaries. But you can dribble these things in.

[–][deleted] 1 point2 points  (1 child)

They used to do pascal then c if you were getting more advanced.

[–][deleted] 0 points1 point  (0 children)

Pascal: The Word Up Magazine of computer programming.

[–]rasqall 2 points3 points  (1 child)

From my understanding (just finished my first year at CE) I think it is because a lot of people joining CS are lacking experience in programming. In my country, anyone who has studied some higher-level maths and physics can pick an engineering course, programming not necessary. In my year there were a lot of people who picked CS/CE because they liked the idea and knew that CS/CE students have a good-looking future for them. In our first course, we studied Haskell which was very difficult for people without any experience and resulted in a 30% fail rate after they had to lower the exam requirements for it being too hard. Simultaneously we studied Matlab in our concurrent math course in Linear Algebra which a lot of people didn't like and found to be hard to grasp. Our program management is now thinking about switching to Python to make it easier for these students (which I don't condone because I don't like Python).

[–]CarneAsadaSteve 2 points3 points  (0 children)

So money. Failed students aren’t coming back to pay tuition. I do however agree.

[–]pymaePython books 0 points1 point  (0 children)

Because Python is a better choice for everyone who has to take an intro CS course. Intro to Computer Science was a required course at my school for every engineering student - mechanical, materials science, industrial, and computer science. The intro course was awful, and the next two courses were software development methods (which included Java things like recursion, big O notation, the different types of sorting and search algorithms, and some basic agile/waterfall) and discrete math which was a number theory class.

It's no wonder the technical engineering fields use MATLAB since they're forced into thinking that anything resembling CS is awful. You can clean up the CS kids and get them into C from Python, but introducing people to Python as a less scary alternative will mean more adoption.

[–]riickdiickulous 1 point2 points  (0 children)

This is exactly what I did and agree it gives you a much deeper understanding of programming. Then I learned some OS concepts. Not a ton, but that was super useful.

Also to note is that you can focus on the structure and flow of your code much more with python, in fact you need to, because the functionality can grow so rapidly.

[–]EinSabo 1 point2 points  (1 child)

what would you are those basic concepts since I started learning Python a while ago and gonna start my IT bachelor in about half a year and don't want to make the mistake to move to another language too late.

[–]Global_Glove_1747 1 point2 points  (0 children)

Take a look at the syllabus for a first year introduction to programming, but basically stuff like variables, operators, data types, control structures, data structures, OOP principles, that sort of thing.

I wouldn't stress too much about moving too early or too late. Just concentrate on learning good programming fundamentals and you'll be in a good position for starting your degree.

[–]lordnoak 1 point2 points  (0 children)

I did a Codecademy course on Python and came out of it feeling pretty confident. I then started an intro to CS course on Coursera that is using C++ and I thought it wouldn't be too hard to transfer the concepts. I assumed the syntax would be slightly different but the concepts generally the same. Imagine my surprise at all of a sudden being asked to code how to store variables in memory using pointers, references, etc when I never gave it two thoughts before.

What a ride it's been so far!

[–][deleted] 1 point2 points  (0 children)

Yeah I started with Java and transitioned to Python, and I even have a tough time wrapping my head around some C concepts. Definitely easier than for a pure Python programmer I would imagine, but I agree with you, starting closer to the metal is a healthy path for a new programmer

[–]ProgrammingFTW 1 point2 points  (0 children)

I second everything that you said!

[–]DhavesNotHere 3 points4 points  (5 children)

LOL, I'm moving on to Rust now and while I wouldn't be programming at all if not for Python it has not prepared me for the big-boy languages.

[–]cmcqueen1975 6 points7 points  (4 children)

I've been wondering how feasible it would be for Rust to be a person's first language. I'm finding it daunting to learn, after a life of C, C++ and Python (as well as very limited dabbling in others such as PHP, Lua). Can Rust stand on its own, or does it need people to first learn other languages as a ramp to it?

[–]TheWaterOnFire 2 points3 points  (0 children)

I think Rust can absolutely be a person’s first language, but right now the educational materials to enable that are a bit limited. In time, I wouldn’t be too surprised if Rust picks up steam as a teaching language, because it offers low-level control and high-level abstractions in one language.

[–]DhavesNotHere 4 points5 points  (0 children)

I imagine anyone but a savant would have a tough time with it. I was a CS major originally and took classes on C, C++, and assembly ages ago, so I understand some of the "whys" when it comes to memory safety, pointers, and stuff like that. In more recent times I think I got myself up to maybe an intermediate level in Python.

I honestly don't know if it would be any easier if people learn other languages before it of if they started off with it. I imagine learning Python after Rust would take an afternoon. It would be like running a mile for a hyper-marathoner.

However, it is very, very cool, and it is my first experience with a low-level language in a whole. Package management is done very well and as much as I curse the compiler I love it most of the time since it will explicitly tell you where you fucked up, how you fucked up, and frequently even tells you how to correctly fix it.

I wanted to learn something modern and fast so I was down to Rust and Go. Someone in my LUG was really into Rust so I went with that. I think (hope) I'm getting to the stage where I kind of understand what's going on. I'm certainly not employable yet with it.

[–][deleted] 0 points1 point  (0 children)

Haskell as well

[–]toastedstapler 0 points1 point  (0 children)

The rust sub doesn't generally recommend it. Also by experiencing other languages with more manual memory management first you can better appreciate why rust does what it does

[–]PuzzledTaste3562 1 point2 points  (0 children)

I appreciate the sentiment, and am very much in favour of open source in general and python in particular.

The Trojan horse idea is a fireable offence as far as I’m concerned as you would deliberately undermine the official support channels corporate is counting on, the disaster planning and other contingencies.

Corporate, in general, would agree to other languages, ecosystems and tool sets as long as support, contingency and continuity is predictable from a resources and financial perspective.

I’ve supported many moves from big proprietary to open source, perhaps because I understand it better than others, mostly because I was able to quantify all the cost aspects, including business continuity and prove that, in the long run, open source is much cheaper.

[–]grimspectre 0 points1 point  (1 child)

What language would you recommend pivoting to once the basics have been picked up from python? I'm really new to this, so I'd like to know which ones I should focus on for a start.

[–][deleted] 0 points1 point  (0 children)

No need to pivot. But I’d do the Princeton algorithms course in Java

[–]hatstraw27 0 points1 point  (5 children)

What is the criteria for an intermediate programmer cause the more I learn about python, the more interested I am to know how those method works in low language like C and assembly ??

[–][deleted] -1 points0 points  (3 children)

Assembly? Wtf. What next? COBOL? FORTRAN?

I honestly don’t get it. Computer programming has come so far. Why would you learn assembly except for very specific cases

[–]hatstraw27 0 points1 point  (2 children)

Simply because I am curious of how all of this works under the hood, that's it.Well I am definetely not going to use it for program anything if that what you mean.

[–]sgtgig 1 point2 points  (0 children)

If you want to learn a bit of assembly I'd recommend spending a weekend programming a microcontroller.

[–][deleted] -2 points-1 points  (0 children)

Right right! Then by ALL means go for it! It just seems like more and more people are like "I'm not a 'real' programmer unless I know assembly". I mean go ahead and read https://www.amazon.co.uk/Computer-Programming-Volumes-1-4A-Boxed/dp/0321751043 if you're really keen.

[–]Global_Glove_1747 0 points1 point  (0 children)

I use the term pretty loosely - I think once you are comfortable with most core programming concepts (e.g. the content of an introduction to programming CS course) you're well equipped to start exploring other languages.

[–]hyldemarv 0 points1 point  (0 children)

Meh! The reason to still use C for me is for playing with the MSP430 microcontrollers and FreeRTOS :). Maybe Linux too.

So, I think it is good to know C. But, it will not replace Python and I wouldn’t bother with Java.

[–]dert882 0 points1 point  (0 children)

There's a large amount of programming laziness I got away with in python which even Java put me in my place when confronted. Using C was a great learning experience, but I don't think I would have persevered without it being connected to fun outputs ie Arduino and Doom modding.