Programming thread

  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
It's still lost on me why programming should be the exception to a general rule of STEM pedagogy which is: "start simple, then make things complex later". No one learns physics or chemistry like what is being suggested here.
the general rule of stem pedagogy to me seems to be "start with the fundamentals and learn how shit works at the bottom before using the fancy shit"
which is why i like the idea of starting simple with scheme or a particularly schemish subset of javascript or lua or c or something to learn the very basics before moving to ungodly complicated messes of programming languages like python
 
IMO, the best way to learn a subject is in the order of discovery or innovation. I feel like motivating new material by necessity is important to feeling the natural 'flow' of the material.
My entry point for programming was a book about pygame when I was 9, but I quickly got hooked on how expressive I could be through software, and it became a passion of mine.
 
In that case one would start with assembler, or even just logic gates. nand2tetris takes that approach. I like the idea but I'm not sure it's the best way.
well logic gates aren't the only way to think about computing in the most simple possible way
along with your typical turing machines, register machines, stack machines, and other various abstract machines, there are also less messy mathematical formalisms for programming like the venerable λ-calculus which unfortunately as a model has way less to do with average electrical computers than certain other models
and you don't have to start at the very bottom, just low enough that you can just barely see the bottom
 
545602587_1223574919811155_9121836502477199334_n.webp

My contribution to the pedagogy discourse is that the best language is the one you can complete a project in.
 
Well, yes, otherwise when I go to update from the source(s) then they don't match and I get even more duplicates.
And the filenames aren't "Broken" they're just not Python friendly, likely some other encoding like CP1252, but rather than play guess the encoding I want to just record the filename as stored on the disk in the database, and unzip the file, and do other horrible things to the file, but using the original name.
Fair enough. Looks like you're stuck with passing bytes around then.

I would say those two categories address very different concerns.
Sure, but that's not nearly as fun or inflammatory. I don't think that Rust's "safety" is worth switching away from C (or C++) but Python is a proper "next step" above C. Whether that's actually worth anything or not is a different matter. I do think that it's a better first/beginner language though.

Ex: C++ and Rust can be used for kernel development but I can't see Python being used there at all (except for things like build scripts).
What percentage of programmers are kernel developers? The majority of programmers (especially Rust shills) aren't doing kernel/embedded, and those that are are probably using C (or maybe C++ without exceptions, etc.). Python is good enough for a lot of programs (a lot of heavy lifting libraries, e.g. numpy, are written in C, but the programmer doesn't interact with C directly so I'm counting that as Python). I used to write C++ before switching to C and most of the time "why would you do that? how can you even write anything in C? it doesn't even have my favourite high level language feature!" can be answered with either "I don't need it", "I don't want it", or "That's what Python is for".

Am I getting ragebaited?
:-)

It lacks the best feature of C++ (that Rust borrowed ;)), which is RAII.
RAII is one of the few things that I miss from C++, along with operator overloading and proper custom types. I've considered "C with classes" before, but I haven't written a serious program in it yet. Python does have with, and there is a __del__ magic method, which is basically temu RAII? It's been good enough so far, though.

Python is only a step up from shell. Making any decently sized program in it is pain. [...] Unless you actually treat is as quasi shell, only gluing foreign libraries.
Portable Shell++ ? Works on Windows and Linux (and without any #ifdef'ing!) I'm tempted to say "skill issue" on this one, tbh. Writing a large program in any language adds complexity that needs to be managed.

Also Python performance is actually so horrible that it starts to matter again.
If you're waiting 300ms on I/O, does it really matter if the code takes 1ms or 20ms to run? One of the best features of Python is that you can just (re-)write a module in C and there's no gay "ffi" annotations that you have to scatter everywhere. You can eventually re-write the "glue" in C too. Second-best language is a gateway drug to best language. Writing directly in C is probably better, but sometimes a "rapid prototyping" stage is useful and Python is better for that.

Is it really that good for learning programming though?
It depends on if you want to learn how the computer works, or how to make the computer do stuff. Most people don't care how the computer works, or how to do things properly, or why JavaScript is an ungodly abomination, etc.

Python gets rid of a lot of noise, it doesn't get in the way (most of the time), and it's easy to start with a small subset and gradually add concepts. It isn't the worst language to learn with.
 
Fair enough. Looks like you're stuck with passing bytes around then.
yes filenames should always be treated as a sequence of bytes without '/' or NUL on unix and as god-knows-what on windows because windows is insane (iirc it's utf16 but it also allows fun things like invalid surrogate pairs?)
there is a __del__ magic method, which is basically temu RAII?
not exactly, that is actually a gc finalizer, which has certain footguns if you actually try to use it as if it were actual raii
Python is a proper "next step" above C. Whether that's actually worth anything or not is a different matter. I do think that it's a better first/beginner language though.
it is a next step, but it might not be the best next step above c
the "i want a nice portable application language like c but less painful" niche has dozens and dozens of potential languages
for that you could be using go or c# or haskell or any of the languages in the ml family or common lisp or perl or fucking rust or (god forbid) node.js
 
What percentage of programmers are kernel developers? The majority of programmers (especially Rust shills) aren't doing kernel/embedded, and those that are are probably using C (or maybe C++ without exceptions, etc.). Python is good enough for a lot of programs (a lot of heavy lifting libraries, e.g. numpy, are written in C, but the programmer doesn't interact with C directly so I'm counting that as Python). I used to write C++ before switching to C and most of the time "why would you do that? how can you even write anything in C? it doesn't even have my favourite high level language feature!" can be answered with either "I don't need it", "I don't want it", or "That's what Python is for".
I can't find it even via Google Books with results restricted to 1995 or before, but I remember at one point reading a C programming language book for 80s microcomputers and C was described as a "glue language", presumably for components written in some form of assembly. (Recall that Game Boy games and even Rollercoaster Tycoon were written entirely in assembly.) By the 90s I can see more references to Tcl etc. being the glue language and the target just kept moving over time.
 
It's still lost on me why programming should be the exception to a general rule of STEM pedagogy which is: "start simple, then make things complex later". No one learns physics or chemistry like what is being suggested here. Or even music for example: typically no one starts with Bach or Philip Glass.
Yeah, but with Python instead of playing twinkle twinkle little star, you just "import Bach" and it plays and you might add some notes in background.
The thing is people start with Python because they want to fast track to making big programs instead of simple ones.
So IMHO python is fine if you want to hack something and not really want to learn. Not that you can't do it in Python, it's just that culture around it is kinda against it.
 
yes filenames should always be treated as a sequence of bytes without '/' or NUL on unix and as god-knows-what on windows because windows is insane (iirc it's utf16 but it also allows fun things like invalid surrogate pairs?)
Windows jumped onto the unicode train quite early, so they used UCS-2 from before surrogate pairs were introduced, with UTF-16 layered on top now. I believe windows 10 started to support UTF-8 though, but I don't know how that's going, or if the attempt will be successful.

not exactly, that is actually a gc finalizer, which has certain footguns if you actually try to use it as if it were actual raii
I know there's the usual garbage collector "whenever the interpreter feels like it, or maybe not at all", which is why with is usually used for opening/closing files, but I haven't ran into any issues for simple memory clean up so far. Is there anything else in particular that I should keep in mind?

it is a next step, but it might not be the best next step above c
the "i want a nice portable application language like c but less painful" niche has dozens and dozens of potential languages
for that you could be using go or c# or haskell or any of the languages in the ml family or common lisp or perl or fucking rust or (god forbid) node.js
Python is probably the most "beginner friendly" though, which is where this conversation began, and it's decently widespread and well known. It also embeds into C quite easily, which is nice e.g. for game modding (I think Lua might be easier to embed, but then I'd have to write Lua). Who knows, maybe I'll go full greybeard and switch to Perl.
 
The thing is people start with Python because they want to fast track to making big programs instead of simple ones.
I really haven't seen any tutorial material on Python that looks like that
So IMHO python is fine if you want to hack something and not really want to learn.
Depends on what counts or doesn't count as wanting to learn. There've been several competing ideas just from a few of us autists in this thread and the total amount of material to learn is so vast that no one can hope to learn it in one lifetime.
 
Windows jumped onto the unicode train quite early, so they used UCS-2 from before surrogate pairs were introduced, with UTF-16 layered on top now.
ucs-2 is the communism of unicode encoding: really sounded like a good idea at first on paper but sadly it didn't work very well in practice
I believe windows 10 started to support UTF-8 though, but I don't know how that's going, or if the attempt will be successful.
unlikely, since windows is doomed to uphold its bad design choices for backwards compatibility forever, and as a result the ucs-2 technical debt will haunt it forever
I know there's the usual garbage collector "whenever the interpreter feels like it, or maybe not at all", which is why with is usually used for opening/closing files, but I haven't ran into any issues for simple memory clean up so far. Is there anything else in particular that I should keep in mind?
i don't really think so
i guess it's just a bit non-idiomatic to have explicit destructors in a garbage collected language, but on the other hand, following idioms autistically is a common way to end up with incomprehensible spaghetti when the idiom inevitably doesn't apply
Who knows, maybe I'll go full greybeard and switch to Perl.
and then maybe you go absolute whitebeard and put on your robe and wizard hat and start scheming
 
I know there's the usual garbage collector "whenever the interpreter feels like it, or maybe not at all", which is why with is usually used for opening/closing files, but I haven't ran into any issues for simple memory clean up so far. Is there anything else in particular that I should keep in mind?
In python, anything that can be an iterable/generator is probably better of as such, within reason. Well written python loops/maps/filters can be fairly snappy because under the hood they're essentially dirty async. I write all my shit around iterables and only collect them when I need an actual collection type
 
Back
Top Bottom