3 ms·
I have an HP 48G in my desk drawer. Back in highschool I spent months playing with it obsessively, writing games and 3D graphing programs and whatnot. Haven't t
by taneq 9y ago
I have an HP 48G in my desk drawer. Back in highschool I spent months playing with it obsessively, writing games and 3D graphing programs and whatnot. Haven't touched it since then, although I'm still fond of it in some theoretical sense. They're a great "pocket computer" for when you don't have access to a "real" computer (ie. one with a programming environment) but I don't think they're actually useful unless you're in some engineering profession where you regularly use complex formulae in the field.
- tzs 9y agoI have a 48SX. I never seriously got into programming it, but I did do one program that I was inordinately pleased with. I wanted a calendar, and found one online but it was very slow. It was written entirely in the User RPL. So I wrote my own, also entirely in RPL, but managed to get it fast enough that there was no perceptual difference between its speed and the speed of assembly language calendars. I got the speed by managing to do almost all of the formatting, which was the slow part, using User RPL string functions, which were all internally implemented as highly optimized assembly. I'd start with these two strings (spaces replaced with _ for clarity): days = "__1__2__3 ... _29_30_31" pad = "_____________________" (that's 21 spaces) Then I'd calculate s = number of days month is shorter than 31 days, and d = day of week of 1st day of month (Sunday == 0, Monday == 1, ...). Shorten the days string by 3 * s, and prepend 3 * d spaces on front of days (which can be obtained by taking an appropriate substring of the pad string). Finally, append the pad string to days. Display a header line: "_Su_Mo_Tu_We_Th_Fr_Sa" Now take the first 21 characters of days and display them on the next line under the header, then the next 21 characters on the next line, and so on for 5 lines, and that's your calendar. This could probably be improved a bit by starting with a days string that has 18 spaces in front and 12 spaces at the end. Then you just have to possibly replace some numbers with spaces if the month is shorter than 31 days, and then use the day of the 1st to choose where you start taking the 21 character substrings from.
- taneq 9y agoThere's a much under-rated rush that comes with your first real optimisation job. Mine was with a program to simplify square roots into surds - we'd had the lesson on them in year 10, then been given a sheet of about 100 different square roots to simplify. It was repetitive grunt work and so I wrote a program to do it. The first version worked, but was too slow (it simply tried number from 0 to N/2, checked if it was square, then checked if it was divisible) so I did the obvious thing and instead only checked square numbers, taking it from O(N) to O(SQRT(N)). Simple enough but it made me happy. :)
- mschaef 9y agoI had a similar sort of experience with both a 48SX and a 48GX. They were great little portable computers back in high school, but as soon as I got better access to bigger machines, I lost interest/motivation. With that said, there are some technical aspects of the 48 series that were particularly gratifying. The unified programming model (RPL all the way down to assembly) and focus on customization made it easy to extend the calculator in interesting ways. (ie: I remember writing a reasonable improvement to the stack display in a couple hundred bytes of user code, etc.) The USAG command was another fun example. The HP48's programming language was dynamically typed... every user command had a standard type check/dispatch prologue at the beginning of its code that would check the arguments on the stack and dispatch to the right block of code based on types. What USAG did was to take the name of a command, inspect the code to look for what combinations of types it could accept, and then present those in the UI a form of 'online help'. (Editing RPL programs worked similarly... the calculator didn't retain the text of a program you entered, it would reconstitute the text by inspecting the 'compiled' code). Reading back over those examples, they aren't the kind of thing you'd expect to write about a calculator... which is part of what made the HP48 series so much fun.