News for hackers. Stuff that matters.
Re:Python Wheels Crosses 90% by gorgoiler on Monday June 08, 2020 @02:26AM (#23454101)
In the past week my coding colleague (whose age is only just into double digits) and I have had to:

* insert lines of code into asciidoctor Ruby to debug how the command line interface differs from the library interface;

* read through Raspberry Pi SenseHat code to figure out that the drivers won’t load via SSH (you have to plug in an HDMI cable!);

* rummage through Python’s PY Sequence List to answer the question “what kind of sort does Python actually use?”.

The problem with shipping binaries is it lowers the standard for being able to build from source.

If a package is easier to ship as a binary because the source is hard to distribute reliably, we give up hope of end users being able to modify and build their own versions.

This is obviously bad for freedom. It’s also hard for debugging and learning.

Re:Python Wheels Crosses 90% by stinos on Monday June 08, 2020 @03:46AM (#23454486)
If a package is easier to ship as a binary because the source is hard to distribute reliably, we give up hope of end users being able to modify and build their own versions

You might be giving up hope too soon, because what you describe has in my experience been the life story of source code from the start, to some extent. And I'm not blaming it for that. Distributing source code (well, not the distribution itself, but getting it to build) on all possible systems out there is hard and impossible to get 100% correct. It's simply inevitable to encounter systems on which it doesn't build because of their specific configuration, or user error.

Despite that, end users have been building their own versions and still do. Users who really want to don't let themselves hold back by a compiler error. Granted it's possibly that in a perfect world where everything would just work there would be somewhat more users doing that, but there's no such thing as a perfect world.

Moreover I do have the impression things are actually much better these days, mainly thanks to CI which makes it easy to get out of the bubble and build on multiple platforms. At least I don't have that feeling anymore of 2 decades ago where I sort of was prepared to waste hours getting anything to build which got handed to me on the internet. Still, it would be very interesting to go and see the percentage of projects out there which just build according to the instructions.

Re:Python Wheels Crosses 90% by abathur on Monday June 08, 2020 @08:16AM (#23455843)
You might find the Nix package manager fruitful. (Fair warning: Nix isn't "easy", but it is powerful. It takes some work to find your sea legs.)

It isn't always possible, but Nix places a lot of emphasis on building software from source (or downloading a pre-built copy from a binary cache), and it has fairly good support for overriding/customizing the expression that builds one or more pieces of software.

A few months ago I was trying to debug a test in the Oil shell project that broke only on macOS for very unclear reasons. I eventually figured out that, in a specific mode, bash (which both Nix and macOS use as sh by default) was filtering out a specific environment variable that this specific test was trying to set, before running a target program with a sh shebang. I only needed to add a few lines to the project's build expression to patch bash and use the patched version for the tests (all without affecting the system/user bash).

Re:Python Wheels Crosses 90% by nh2 on Monday June 08, 2020 @11:29AM (#23457356)
I expect Nix to become more popular due to its ability to build static binaries.

The key benefit that nixpkgs has over other Linux distributions' package sets on this topic are:

1. It allows you to _program_ your package set, thus adding static-linking overrides to 1000s of libraries/executables in a go, instead of having to modify each package manually.

2. It allows the end user to choose what linking they want, as opposed to the Linux distribution making that decision for them upfront.

3. It allows to do this from any Linux distribution.

Re:Python Wheels Crosses 90% by kelnos on Monday June 08, 2020 @03:34AM (#23454420)
> read through Raspberry Pi SenseHat code to figure out that the drivers won’t load via SSH (you have to plug in an HDMI cable!)

I'm really curious about this. Why would a driver care about whether you load it on a "real" tty vs. over the network? How does it even know?

Re:Python Wheels Crosses 90% by gorgoiler on Monday June 08, 2020 @05:24AM (#23455010)
I have to admit the facts known to me are simply: plugging in the HDMI cable stopped the bug.

We didn’t dig further than that, though the error was quite obscure until we read the source code, at which point we realized that the “FB” the error mentioned meant the Linux console framebuffer.

I assume the Python module for operating this device ships with a GUI, which is couple to some Linux framebuffer initialization code, which in turn only works if the framebuffer is enabled, which presumably it isn’t if the host boots without an HDMI device connected.

Re:Python Wheels Crosses 90% by sigjuice on Monday June 08, 2020 @07:53AM (#23455720)
I have a Raspberry Pi with a Sense Hat that has never had an HDMI cable plugged into it. I have written small programs with the Python module that operate the LED matrix that work fine AFAICT. The LED matrix also happens to be a framebuffer device, and it is possible that your error was about the LED matrix.

The LED matrix is an RGB565 framebuffer with the id "RPi-Sense FB". The appropriate device node can be written to as a standard file or mmap-ed.

https://www.raspberrypi.org/documentation/hardware/sense-hat...

Re:Python Wheels Crosses 90% by executesorder66 on Monday June 08, 2020 @03:33AM (#23454413)
You have a 10 year old coding colleague?
Re:Python Wheels Crosses 90% by gorgoiler on Monday June 08, 2020 @05:21AM (#23454988)
Not quite that young. I am a teacher with 85 teenagers under my wing, at the last count.

An important part of school is learning how to learn. It is a constant struggle with pupils to get them to actually think instead of googling for an answer.

Sometimes it feels a bit like I am a grumpy oldie telling them things like _in my day we had to look things up in books instead of using Google!_ but most of the time it’s valuable in and of itself to go through things from first principles.

(The sensehat bug was a case in point.)

As far as source code is concerned, it turned out to be quite tractable to follow the Python source code at least far enough to find the timsort.txt document.

If any of these kids go on to have technical careers, there will be plenty enough time for googling answers later on in life. Hopefully some of them will be writing the answers too.

Re:Python Wheels Crosses 90% by deeringc on Monday June 08, 2020 @05:47AM (#23455130)
On the flip side, it seems to me like having all of this friction may lose many folks early on. I absolutely agree that debugging and problem solving are core skills to master and fundamental for any programmer. As is understanding the system from first principles, and how all of the different sub systems interact. But in my opinion they shouldn't necessarily be the first thing someone encounters when they try to do X.
Re:Python Wheels Crosses 90% by fnord123 on Monday June 08, 2020 @05:47AM (#23455128)
tbh the only source of truth is the code. Documentation and comments are all lies! shakes fist
Re:Python Wheels Crosses 90% by toyg on Monday June 08, 2020 @07:08AM (#23455519)
It's a bit like tech support, where you have to assume the user is always lying.
Re:Python Wheels Crosses 90% by maxbond on Monday June 08, 2020 @09:20AM (#23456233)
I once got locked out of my Amazon account because I went through a weird flow where I ended up changing my email without clicking a confirmation link, and I made a typo, so it was changed to a nonexistant email.

No one in tech support believed me. No one was willing to help me. They told me to make a new account.

I've done my best not to buy from Amazon since.

Please don't be hostile to users.

Re:Python Wheels Crosses 90% by toyg on Monday June 08, 2020 @09:31AM (#23456323)
That's more fraud detection than tech-support, sadly. Even if they believed you, they might not have been authorized to help. You wouldn't want random people to hijack your account by crying "typo" to the support guys.
Re:Python Wheels Crosses 90% by dragonsngoblins on Monday June 08, 2020 @09:37PM (#23462746)
Surely they could revert it back to the previous email account though?

Possibly after you provide some kind of validation like the last few digits of credit card tied to that account or something?

Re:Python Wheels Crosses 90% by toyg on Tuesday June 09, 2020 @06:02AM (#23465234)
I'm almost sure Amazon used to allow you to log on with old email-password combinations, until they got flak for it. Not sure what they do now.
Re:Python Wheels Crosses 90% by fnord123 on Monday June 08, 2020 @03:56AM (#23454528)
I think it's a tongue in cheek way to say that they are teaching their 10 year old child to code and they have had to shave some painful yaks.
Re:Python Wheels Crosses 90% by heavenlyblue on Monday June 08, 2020 @03:52AM (#23454512)
The answer to “which sorting algorithm python uses” is the first result in Google. The third is official python docs.
Re:Python Wheels Crosses 90% by gorgoiler on Monday June 08, 2020 @05:29AM (#23455037)
The context was one where we were learning about how things work, rather than wanting to just know the answer per se.

I always _try_ to show how one can answer problems from first principles before resorting to “go look it up on stack overflow”.

It boosts ones sense of usefulness as a teacher if one can occasionally give more in depth answers as teachable moments.

For one thing, demonstrating deeper understand is how you score high marks in exams.

Re:Python Wheels Crosses 90% by heavenlyblue on Monday June 08, 2020 @06:00AM (#23455190)
I don't understand what you mean by "first principles".

Open up Python's source code and check - this is first principles-first hand.

As a matter of fact I am going to go as far as saying that reading source code is the _only_ way to actually be any good in software engineering because it's the only source of truth that never gets out of sync with the de-facto.

Did you expect to find a blog post about it (you can find it on the first page of Google search I mentioned)? Or a YouTube video (didn't pay attention to that)? Books are reasonably good but usually get out of sync quite fast.

And going back to first principles: the reason most of the literature may not mention what sorting algorithm Python uses is because a) it's irrelevant as a first principle knowledge b) it gets quickly out of sync.

Re:Python Wheels Crosses 90% by dnadler on Monday June 08, 2020 @10:50AM (#23456963)
I think you've misread the comment. You seem to both have the same definition of first principles.
Re:Python Wheels Crosses 90% by yodelshady on Monday June 08, 2020 @05:45AM (#23455119)
> read through Raspberry Pi SenseHat code to figure out that the drivers won’t load via SSH (you have to plug in an HDMI cable!);

What? I can assure you this is not true.

My R Pi has never touched an HDMI cable and runs a sense HAT just fine. What OS?

Re:Python Wheels Crosses 90% by haberman on Monday June 08, 2020 @11:49AM (#23457614)
I agree that being able to read source and modify the code for experimentation are important.

In my experience, the best way to read source code and experiment are to get the source from the upstream repo (eg. GitHub) and read/build from that. I do this with code written in C or C++ all the time.

The code is always out there (unless you're talking about proprietary software, which none of your examples above are).

Re:Python Wheels Crosses 90% by sulZ on Monday June 08, 2020 @05:47PM (#23461179)
> * read through Raspberry Pi SenseHat code to figure out that the drivers won’t load via SSH (you have to plug in an HDMI cable!);

I've suspected that for a long time without confirming it personally, so thank you for your time.

Re:Python Wheels Crosses 90% by cowsandmilk on Monday June 08, 2020 @05:52AM (#23455161)
> rummage through Python’s PY Sequence List to answer the question “what kind of sort does Python actually use?”.

If you needed to dig through source code to find out that python use Timsort, I genuinely am curious about how bad you are at search engines.

I believe in reading source code to answer some things, but that example is really odd for anyone who has researched sorting algorithms since Python literally invented a sort used by many other languages now.

Re:Python Wheels Crosses 90% by gorgoiler on Monday June 08, 2020 @06:02AM (#23455201)
Ahem, a more uncharitable person might retort with:

If you need a billion dollar search engine and an internet connection to make sense of the source code on your local machine, I am genuinely curious how bad you are at reading source code!

But as I said, that’s pretty uncharitable. Because of course I didn’t have the source code for Python locally.

I downloaded it after Googling “Python source code”.

Re:Python Wheels Crosses 90% by cycomanic on Monday June 08, 2020 @07:46AM (#23455692)
This reply made my day, thanks!
Re:Python Wheels Crosses 90% by kidsil on Monday June 08, 2020 @06:07AM (#23455221)
+ Negatively commenting on someone else's coding abilities.

+ Explaining something that is "obviously common knowledge".

+ Reducing motivation of participant to share their experience.

I think we have HN bingo right here.

Re:Python Wheels Crosses 90% by FridgeSeal on Monday June 08, 2020 @07:24AM (#23455601)
It needs “here’s why you should have used XYZ instead, obviously” to really round it out in my opinion.
Re:Python Wheels Crosses 90% by snovv_crash on Monday June 08, 2020 @10:22AM (#23456701)
Don't forget someone plugging their startup which solves this problem for the price of only 2 coffees per month.
Re:Python Wheels Crosses 90% by badrequest on Monday June 08, 2020 @06:49AM (#23455435)
Is it your experience that a significant portion of folks who write code in some form or fashion have "researched sorting algorithms?"