What are you coding?

I’ve just discovered an enum. It’s named StatusBool, and is intended to track the status of in a database removed from the origin. The place the data comes from stores value as strings, so we have to use an enum if we’re constraing the range. All fine so far. But the range of StausBool is

Unknown
True
False
Other

Quaternary Boolean is not what I want on Friday afternoon.

4 Likes

This one is new. I only knew about: null, true, false

2 Likes

I saw a thing…

3 Likes

Last night I had an Idea.

And now I can input this:

assemble Ion_Thruster Probe Juno Saturn
manoeuvre Earth_Orbit Saturn
manoeuvre Lunar_Orbit Ion_Thruster T2
year
separate Ion_Thruster
manoeuvre Moon Juno

and get out this:

  • assemble Ion_Thruster Probe Juno Saturn

  • Assemble A at Earth with Ion Thruster, Probe, Juno, Saturn
  • manoeuvre Earth_Orbit Saturn

  • Starting mass 23, difficulty 8, need 184
  • Thrust Saturn: 200
  • manoeuvre Lunar_Orbit Ion_Thruster T2

  • Starting mass 3, difficulty 3, need 9
  • Thrust Ion Thruster: 10
  • year

  • Advancing 2 to next arrival.
  • Year is now 1958
  • separate Ion_Thruster

  • A split off Ion Thruster to make B
  • manoeuvre Moon Juno

  • Starting mass 2, difficulty 2, need 4
  • Thrust Juno: 4
---
A:
  components:
    Probe: 1
  location: Moon
  time: 0
B:
  components:
    Ion Thruster: 1
  location: Lunar Orbit
  time: 0
1 Like

I have spent a fortnight or so, over the last few months, learning about how to manage multiple worker threads on Apple operating systems on Apple’s ARM processors. Like many ARM processors, the cores are grouped into clusters, which have a shared level of cache.

Apple’s OSes will tell you many things about the cores, but are very enigmatic about the ordinal numbers of those cores. That’s because they don’t provide an API for pinning threads to cores; they insist that the OS can do that better. They didn’t tell you much about the cores until we pointed that out for macOS 11, and they added query functions in macOS 12.

I have been trying to get our multi-threaded performance tests to run in a reasonably consistent amount of elapsed time, so that we can use them to observe the effects of changes in algorithms. The noise level when I started was horrible: factors of two in elapsed time for identical code and test data.

In late January, I got it to an acceptable level of consistency and that was released. A customer soon came back with a bug report, pointing out that it had got significantly slower. It had. The performance tests had been so noisy that we weren’t sure, but their example was good, and demonstrated that it was slower.

On Thursday, I spent the afternoon refining their example, and then carefully taking out my changes. It appears that the slowdowns were caused by the overheads of turning the priority of each thread up when it had work to do, and down again when it didn’t. Apple’s pthreads implementation is slow, because it isn’t the native threading of the OS, but a wrapper over the native Mach threads.

The thing that had worked to get consistency was reaching through the pthreads layer to use a Mach threads feature that pthreads lacks: the ability to say that specific threads should be associated with each other because they’ll be communicating frequently. This is obscure macOS functionality, to say the least. What I pulled out on Thursday was all the work I’d done before adding associations, following Apple’s guidelines. I have ideas about doing more, but I need to let my brain cool down a bit first. I also need to let statistics from the daily performance test runs accumulate!

I want to award that customer a “Good bug report!” prize.

5 Likes

It’s grown a bit.

./process test-getyourasstomars 
  • assemble Earth_Orbit Shuttle 3 Daedalus 4 sft 3 Food 2 Astronaut

  • Assemble A at Earth Orbit with Shuttle, Daedalus, Daedalus, Daedalus, Small Fuel Tank, Small Fuel Tank, Small Fuel Tank, Small Fuel Tank, Food, Food, Food, Astronaut, Astronaut
  • manoeuvre Mars_Fly-By 3 sft

  • Starting mass 18, difficulty 3, need 54
  • Thrust Small Fuel Tank: 22 + Small Fuel Tank: 22 + Small Fuel Tank: 22 = 66
  • year

  • Advancing 3 to next arrival.
  • Astronauts eat 1 Food.
  • Astronauts eat 1 Food.
  • Astronauts eat 1 Food.
  • A arrives at Mars Fly-By.
  • Year is now 1959
  • manoeuvre Mars_Orbit/Aerobrake sft

  • Starting mass 9, difficulty 1, need 9
  • Thrust Small Fuel Tank: 22
  • A arrives at Mars Orbit.
  • separate 3 Daedalus

  • A split Daedalus, Daedalus, Daedalus to make B
  • manoeuvre Mars

  • Starting mass 4, difficulty 0, need 0
  • No thrust developed.
  • A arrives at Mars.
3 Likes

The statistics looked good. I put the changes into the latest production “branch” and they were good there. We sent the customer a trial library last week, and they liked it. It ships this week.

And today, I got to write back to a third-party developer whose macOS app, CPUSETTER, didn’t actually help us, but he explained how it worked, which helped me towards the right line of reasoning. I told him how that works, which may help it emerge into the general world of macOS programming.

ETA: And thinking about it has caused me to realise how to take out a little unnecessary work.

2 Likes

“Prepping” or rather anticipating Advent of Code, I’ve been playing http://code.golf

I have now solved 11 holes.
8 in java and 4 in python (I did Pascal’s Triangle twice)

Weirdly, python is generally shorter for these kinds of puzzles but I get better rankings for java because of course I know java so much better. And a lot more people play in Python. My best ranking was for “Day of the Week” in Java and 2nd best just now with Roman Numerals also in Java. I had to actually write a method for the latter.

I failed to even grasp how to begin the Quine in either Java or Python. (I will eventually, no spoilers, I could consult Rosetta Code, but I won’t). I am sure that languages like brainfuck or perl have an easy time writing a programm that prints itself. My brain just refuses recursion at the moment.

I had a look at “J” today and despaired.

At least I am getting better at python.
And I learned how to minimize java boilerplate :smiley:

1 Like

I’ve never been a code golf fan. I mean, I suppose I can see the appeal, but to me part of being a good programmer is making it really obvious to someone else how it works.

3 Likes

it’s not software that I write there. It’s just problem solving with the added trickiness of trying to do it in tricksy ways. I have also been using it to practice my python skills :slight_smile:

for advent of code I will most definitely strive for more clarity.
but I do enjoy finding out things like initializing lists in python like this:
t=[[]]*20

or figuring out that even java has funny things like this:
"M".repeat(5) which outputs MMMMM not that we normally need that.

also I can do this on my work computers while waiting for stuff to happen without anyone looking over my shoulder realizing that I am at play and not at work.

4 Likes

You don’t need it, until you need to vary the number…

2 Likes

My days at work are currently about 50% coding, 50% writing about coding and 50% telling other people how write their code.

I don’t think I have the capacity for Advent of code but I’ll watch along with interest again :slight_smile:

3 Likes

Shoukd I do it in

  • Rust
  • PostScript
  • Something else
0 voters

I once did a math assignment in postscript. WhIch I ran on a printer, of course. it was the fastest machine I had access to, which is insane, but does explain why the printer cost more than a small car…

3 Likes

Yup! It’s a very 1980s language but I really like the stack-based approach. This probably means I should learn https://www.uiua.org/ .

1 Like

That is a page filled with unintuitive things.

2 Likes

I want to learn a new language but not for Advent of Code. I struggle enough with the puzzles as is. I’ll do Java again. might include some python this year. we’ll see.

2 Likes

So … I’ve started working on my little project that inspired the Ontology + Taxonomy for Boardgames thread:

  • download my collection via the BGG API
  • download the game data for my collection via the BGG API
  • store everything in a local database
  • the goal being to begin adding to the data I get from BGG in a way that allows me to analyze my games better
  • if it turns out to be useful, I’ll make it available. For now I am just dabbling.

Because of the project I did recently at work I decided I wanted to use python and mongodb. I have not previously worked with any of the NoSQL variants. All the work I did as a java dev in the last 20+ years included relational databases.

And it’s a little crazy-ish what has been appearing in my IDE. (Note: a while ago I treated myself to a license for the all-in-edition of IntelliJ including their AI assistant, the J being just a name at this point, it’s a polyglot IDE now).

The AI assistant’s auto-complete for python is scary good for (some simple boilerplatish) tasks. Because a) the word ‘simple’ and b) python is probably the most common language in the web and extremely well documented. But still… it’s even more impressive than a year ago. (from other recent experiments: it also knows math far better than it did a year ago. )

To start I just told the chat that I want to talk to the API that lives at: https://boardgamegeek.com/xmlapi2/

I expected to get some simple rest client code or a web request thing… instead it gave me that and all the parameters needed for the API in question while telling me to test this for ID 13, letting me know 13 is Catan. It’s probably from some documentation of the API that I haven’t been able to find (I haven’t looked very hard). I know it is just auto-complete but still…

And then I am starting to do stuff like “I want to store this in the mongodb” and it gives me the store method. And a day later I decided I needed to also retrieve data of course and it autocompletes this from just the method name “get_game…”, I know it is just 4 lines of code that I don’t have to write… but multiply that and it starts being a real timesaver especially because I don’t have to leave my IDE to search for stuff on stackoverflow anymore.

I want to add this is all just code snippets. It can’t write software, just code. And it is very interactive. And someone without the necessary coding/software skills still wouldn’t be able to write anything with it. But I barely know python and I can write code now with a speed that I am beginning to think, if the next work project includes python, I can do it.

I am rambling but … mind blown.

4 Likes

Conversational AI: a new place to copy code from instead of Stack Overflow

4 Likes

On that subject: last night, I wanted a way to be able to type in a number of (Millennium Blades) card names, but to also verify the names were actual cards and to have tab-completion available (because I’m a network engineer, and that’s what we do)

So I asked ChatGPT to do it for me. This is the first I’ve actually tried something like this and I am impressed.

1 Like