News for hackers. Stuff that matters.
Re:Escaping from Anaconda's Stranglehold on macOS by abdullahkhalids on Sunday September 01, 2024 @06:31PM (#41420952)
I teach using python. You should try explaining virtual environments to students, most of them with no programming experience, or any real notion of the state of a computer system. I do, because we recommend students use them. Every class consists of endless debugging of student systems.

After that you might understand the OP's viewpoint.

Re:Escaping from Anaconda's Stranglehold on macOS by freeopinion on Sunday September 01, 2024 @07:02PM (#41421109)
After that I wonder why people think Python is a good choice to teach as a first experience in programming. Virtual environments is actually my biggest gripe with Python.

I think it is interesting to consider why Python is so popular despite such fiascos. The answers can be very informative but can also be giant red flags.

Re:Escaping from Anaconda's Stranglehold on macOS by Al-Khwarizmi on Sunday September 01, 2024 @07:22PM (#41421194)
Because every option sucks for teaching.

C/C++? Full of footguns. Java/C#? Too complicated for beginners. Pascal? Outdated. Etc.

I personally prefer C to teach first-year CS students but just as the lesser evil. A good first programming language is sorely lacking.

(Note that I'm talking about the imperative programming paradigm. The debate on whether one should start with functional programming is outside the scope of this comment).

Re:Escaping from Anaconda's Stranglehold on macOS by Spivak on Sunday September 01, 2024 @08:24PM (#41421462)
It's weird you throw out Java because they are the teaching language. They're the stick everything else is measured against. CS101 is a sea of Eclipse. Having a programming environment where all the major structures are discoverable through menus is actually pretty useful.
Re:Escaping from Anaconda's Stranglehold on macOS by dvdkon on Monday September 02, 2024 @04:20AM (#41423576)
Java is popular as a first language, but I think it's just due to its (bygone?) general popularity. I don't think a language that forces you into a one-class-per-file mindset from day one has any business being used for teaching; students should start from the basics ("commands"/function calls, if, while, for, ...) and then discover what more complex concepts do within that framework.

Java's tooling is nice, but frankly Turbo Pascal (or something at its level) is enough for beginners.

Re:Escaping from Anaconda's Stranglehold on macOS by eru on Sunday September 01, 2024 @09:09PM (#41421691)
You can teach imperative programming with OCaml or Racket, too. :)

C is indeed pretty evil, though slightly less though with modern sanitisers, so you can get a better error message than just a segfault (or silently doing the wrong thing).

Pascal isn't really more outdated than C. Especially if you use Delphi?

Python is actually fine, you can get pretty far with just the standard library, and the libraries that you can install with your Linux distribution's package manager (eg via Pacman). I do agree that package management with Python is pretty bad out-of-the-box.

Re:Escaping from Anaconda's Stranglehold on macOS by bmitc on Sunday September 01, 2024 @10:25PM (#41422127)
> Because every option sucks for teaching.

The answer is really quite simple: F#

Re:Escaping from Anaconda's Stranglehold on macOS by moi2388 on Monday September 02, 2024 @01:05AM (#41422740)
How in the world is c# too complicated? Console app, top level statements, vs code. As easy as Python. Easier because your env isn’t messed up.

If they can’t manage that they have no business doing data science or something similar to begin with

Re:Escaping from Anaconda's Stranglehold on macOS by cuddlyogre on Monday September 02, 2024 @09:56AM (#41425416)
You sound like you have been doing this for way too long to know what it takes to teach beginners.
Re:Escaping from Anaconda's Stranglehold on macOS by neonsunset on Monday September 02, 2024 @10:55AM (#41425843)
Not for complete but for beginners lightly familiar with programming it is overall not difficult to teach the basics, often easier than to stubborn seniors who want to do it their way only :)

    var start = "commtext c00\">";
    var end = "</div>";

    using var http = new HttpClient();
    var page = await http.GetStringAsync("https://news.ycombinator.com/item?id=41425416");

    var commStart = page.IndexOf(start) + start.Length;
    var commEnd = page.IndexOf(end, commStart);

    Console.WriteLine(page[commStart..commEnd]);
or

    var host = WebApplication
        .CreateBuilder()
        .Build();

    host.MapGet("/", () => "Hello World");
    host.Run("http://+:8080");
Re:Escaping from Anaconda's Stranglehold on macOS by moi2388 on Tuesday September 03, 2024 @11:55AM (#41436171)
Not at all. I still teach interns and until 2 years ago complete beginners.

I can teach them a console app with top level statements and have it running before they have installed a Python virtual environment.

Re:Escaping from Anaconda's Stranglehold on macOS by bspammer on Sunday September 01, 2024 @07:27PM (#41421210)
It’s not just the packaging situation that makes Python a bad first language. Whenever I write in Python, I find it completely impossible to stop myself from constantly making basic, beginner-level programming mistakes. Every time I miss having a compiler and strict typing that will yell at me when I’ve done something stupid.
Re:Escaping from Anaconda's Stranglehold on macOS by eru on Sunday September 01, 2024 @09:11PM (#41421704)
Modern linters and type-checkers for Python come pretty close to something usable for these situations. But it's certainly something they tacked on to the language afterwards.

I like the recent addition of (proper) pattern matching to Python.

Re:Escaping from Anaconda's Stranglehold on macOS by bmitc on Sunday September 01, 2024 @10:27PM (#41422136)
Yea, the only way to get close to programming efficiently in Python is to turn MyPy and Pylint up to 11.
Re:Escaping from Anaconda's Stranglehold on macOS by airstrike on Sunday September 01, 2024 @09:44PM (#41421884)
I switched to Rust full time about 6 months ago and recently had to write a somewhat long Python script for something else... it felt awfully quiet without the compiler yelling at me, but that also meant I was making the same silly mistakes over and over and over and over
Re:Escaping from Anaconda's Stranglehold on macOS by abdullahkhalids on Sunday September 01, 2024 @08:18PM (#41421427)
We use it because of other people use it. I would gladly switch to Julia for scientific commuting if I could.
Re:Escaping from Anaconda's Stranglehold on macOS by zaptheimpaler on Sunday September 01, 2024 @07:08PM (#41421147)
I think docker would be a much better alternative. You can just hand students a pre-built docker with everything installed and they are free to mess up the system without any consequences.
Re:Escaping from Anaconda's Stranglehold on macOS by makeitdouble on Sunday September 01, 2024 @07:57PM (#41421339)
But then you're explaining virtualization and networking to your students, how to manage interactions in and out ("I wrote a program in Txtedit, how can I run it?"), when it's started and when it's not etc.

I could see giving them a remote access to a prebuilt env (which can be containerized) to be simpler to explain.

Re:Escaping from Anaconda's Stranglehold on macOS by Daishiman on Sunday September 01, 2024 @08:52PM (#41421602)
In finding it very difficult to see what exactly is the problem with teaching a minimum of computer and operating system fundamentals to people that have to learn programming.
Re:Escaping from Anaconda's Stranglehold on macOS by abdullahkhalids on Sunday September 01, 2024 @09:20PM (#41421762)
Not every person wants to become a software engineer, anymore than every person wants to learn to become a plumber or car mechanic. The vast majority, and by vast majority I mean more than 95% of students who are taught to code are training to be scientists, mathematicians, engineers, economists, accountants, or some such. They need to run simulations to understand their field. Any pain in the way of that is a failure of those who create software for a living.
Re:Escaping from Anaconda's Stranglehold on macOS by Daishiman on Sunday September 01, 2024 @10:32PM (#41422161)
If you're going to be spending a substantial part of your waking life working on a tool, spending a few hours to get the basics right is not an unreasonable ask. And as it turns out, all non-trivial programming languages that have some sort of packaging system or module system have some version of the problems involved.

You don't see people complaining that musical instruments are unreasonably complex when that complexity usually gets solved after a couple months of training, or when someone who wants to basic woodworking has to have at least a passing knowledge of the different types of hardwoods, MDFs, and essential joinery techniques.

Hate to say, but it definitely sounds like skills issues.

Re:Escaping from Anaconda's Stranglehold on macOS by makeitdouble on Sunday September 01, 2024 @10:28PM (#41422138)
I'd argue it's a lot more than "minimum". You need them to be comfortable with the host system, and also manage the running container, which will have a different OS most of the time, and the virtualization mechanism (docker here).

Simple things like having a student access another student's web server becomes overly complicated, as you're dealing with 4 systems talking to/through each other.

Re:Escaping from Anaconda's Stranglehold on macOS by Daishiman on Sunday September 01, 2024 @10:36PM (#41422178)
But the fundamental fact is that "accessing someone else's web server" is not that trivial of an affair and has never been when you get down and dirty into the details of networking.
Re:Escaping from Anaconda's Stranglehold on macOS by makeitdouble on Sunday September 01, 2024 @10:50PM (#41422237)
Giving access to a debug server on a local network is a single command line when running natively to the host.

Sure making them understand everything is a journey, but just spawning the server is fairly quick and painless.

Re:Escaping from Anaconda's Stranglehold on macOS by BlueTemplar on Thursday September 05, 2024 @07:10PM (#41461194)
Might as well use Guix at that point, since that kind of OS-based dependency management seems to be the future.
Re:Escaping from Anaconda's Stranglehold on macOS by bigger_cheese on Sunday September 01, 2024 @09:19PM (#41421750)
Not sure how helpful this advice is for students I'm in my late 30's have programming experience but had never touched Python until about 6 months ago.

What made Virtual environments work for me was switching to a different Editor. I use Visual Studio Code currently it works well with Virtual Environments.

When you first create a new python file in a given "project folder" it prompts you to create a new Venv and when you switch project folders it remembers and restores the Venv for each project.

One of my work colleagues pointed me to VSCode - it streamlined a lot of python things for me.

If your students are disciplined about creating a new folder for each project managing virtual environments vscode could help them.

Only issue I have is my work office has a corporate proxy setup and pip needs certificate to connect (and if I work remotely I have to turn this setting off) I wrote a shell script to toggle between the two proxy settings. Not sure if university will have the same issue proxy issues but if so this would certainly be a pain point for many students.

Re:Escaping from Anaconda's Stranglehold on macOS by promer on Sunday September 01, 2024 @11:34PM (#41422379)
This is a suggestion that deserves serious consideration. I started using VS Code after I had learned all the basics so I don't know what it feels like to be a new learner who is getting started by using VS Code. But it sounds like it worked for you. (And on campus, the proxy should not be an issue.)

It does answer the question of which text editor to use when the time comes to teach them about editing text files. For a course, it helps that it is free and available on both macOS and Windows.

I have a vague recollection that at some point I was testing without an install of Python and after I selected the Python extension for VS Code, it offered to install one for me. (I don't recall if this was on macOS or Windows and memory could be playing a trick on me.) But in any case, the people behind VS Code do seem to be trying very hard to make it easy for someone who is getting started.

I am a little uneasy about the nudges to use Copilot, but on balance, it might offer a better path for students who are getting started.

Re:Escaping from Anaconda's Stranglehold on macOS by bmitc on Sunday September 01, 2024 @10:24PM (#41422121)
Then why teach Python? All of these issues are because Python is a ridiculously poorly designed language which is still having new features added to it. It's generally a mess.
Re:Escaping from Anaconda's Stranglehold on macOS by regularfry on Monday September 02, 2024 @09:21AM (#41425183)
The issues are with one particular facet of poor design and management. The rest of it is manageable, if distasteful, and worth the effort for the ecosystem (in general).
Re:Escaping from Anaconda's Stranglehold on macOS by bmitc on Monday September 02, 2024 @01:57PM (#41427465)
There really is more than one particular face of poor design in Python. I honestly remain confused why people use and love Python so much. It very much says something.
Re:Escaping from Anaconda's Stranglehold on macOS by regularfry on Monday September 02, 2024 @07:36PM (#41429692)
Oh, there are many. There are just comparatively few that you can point at as being quite as directly responsible for dev misery as thé packaging system.
Re:Escaping from Anaconda's Stranglehold on macOS by bmitc on Tuesday September 03, 2024 @05:52PM (#41439663)
Lol. I see where you're coming from.
Re:Escaping from Anaconda's Stranglehold on macOS by Eduard on Sunday September 01, 2024 @10:36PM (#41422180)
> You should try explaining virtual environments to students

can you? Because I can't.

e.g. "What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?" ( https://stackoverflow.com/questions/41573587/what-is-the-dif... )

what is the difference between conda and anaconda?

etc etc

Re:Escaping from Anaconda's Stranglehold on macOS by rahimnathwani on Sunday September 01, 2024 @10:43PM (#41422213)
That's exactly GP's point.
Re:Escaping from Anaconda's Stranglehold on macOS by justinclift on Monday September 02, 2024 @03:25AM (#41423318)
Reckon they'd understand using something like asdf instead?

https://asdf-vm.com

The projects I work with have moved to it because it handles multiple languages (not just Python). It's made things easy to keep "the correct version of a language" that each project needs.

So far so good, anyway. :)

Re:Escaping from Anaconda's Stranglehold on macOS by whywhywhywhy on Monday September 02, 2024 @05:43AM (#41424000)
You’re swapping something that can be feasibly debugged or at least easily burnt and reformed for something that’s impossible to untangle once they’ve done two projects with different or conflicting deps into the base environment.