Experience Walkthough: Reading a New Programming Book
Friday January 27, 2023
I had an interesting experience in buying & reading the book Learn Scala 3 The Fast Way and thought I’d share it here.
The experience relates to the relatively different way in which I read books these days.
This is not a review, just an experience. Part of my purpose here is to cover some dumb mistakes I made in the experience, and share the way I thought through those, or around those, too.
Quick Book Review Though: It’s a good book. I like the book, and will come back to it for sure. If the book looks interesting to you, I think you should buy it, probably from the author’s Gumroad page.
How It Started
So for starters: I find myself book shopping.
And I remember: Amazon can be a nice way to browse for new programming books.
(Amazon book-shopping replacement wanted!)
I add about ten books to my wish list.
I recognize that I’m not buying all ten of these books. Maybe just one. A couple. OK, three? Well, ideally one. So there’s a first problem.
I wait a day to let any temporary emotional waves settle. This is a reliable method for me, since sometimes archetypes of interest can pass by really fast and then a book just sits around, having been paid for but never opened!
As an example of that: I’ve identified programming-books-interest as a flag for “Marc needs a schedule” in my internal mental archetype/symbol library.
(So if I put a schedule together, and am from that point no longer as interested in programming books, the money could have been a tiny bit of a waste, right?)
Anyway, programming becomes REALLY interesting when I don’t have a schedule for my day, which is always kind of funny to think about.
And Scala is like that, plus I’d add the flag “would probably benefit from a unique scheduling system” due to the unique nature of the language compared to say Python, C, BASIC, etc. Which probably is good to learn in general. I like unique systems, and generally find that building more unique schedule / get-with-the-program systems is a big benefit for me.
Revisit the Wish List
I review again.
Cover art. This is strangely reliable for me in picking books. The cover art doesn’t tell the whole story, but my theory is that I’ll naturally come back to it again and again if I like the art. This “reliable intersectionality” is good juju for learning purposes.
This book is a total win in the cover art area. I love pulp-style art, movie poster art, vintage stuff—this is great just to look at.
The topic: Scala sounds fun and I’ve been interested in it for a while. Yeah, go Scala!
I scan the Table of Contents…
OK, first big issue. The book seems written in the Ti-dom teaching style, front-to-back, everything builds on everything else. The author must have put a lot of thought into the organization of the book.
But…I can’t learn this way. I’m the opposite and I learn best by tearing into and modifying finished, working examples. If a book starts with “Beginning” lessons, I’m usually in trouble and need to try the exact opposite.
I learned this from college by getting E’s in classes taught by Ti-dom professors, usually INTP. Because I couldn’t even bear to read the books, and didn’t understand why, at the time. Damn it.
So anyway, I need to see if I can learn from the book by working backwards.
I scroll to the bottom of the TOC. I see that a “timer” example program is listed toward end of TOC. BOOM.
I can work with that. I have a timer-preferring personality in EVERY way possible, being completely up front here. The book appears to provide code for a working timer. I use timers all the time. Let’s go.
A Plan Is Formulated
My plan: Buy the book, install Scala, rip out the timer code, get it working, modify it, break it, learn it, page backward through the book to understand the code, try some add-ons to the timer maybe, and then I will have learned some Scala.
Then I’ll look at the other examples too.
Later, I’ll polish my Scala and learn better Scala, maybe, but that can wait.
This should be opposite-enough to fit my learning style.
Kindle? Wonderful…but wait!
I buy the Kindle version of book at Amazon for $10. I quickly click “Read in Kindle Cloud Reader” …let’s go!
Nope. You can’t read that here, the book doesn’t work in Kindle Cloud reader. You need to use the Kindle app.
I cringe. F*CKKK. I wanted to read it nice and big on my desktop linux monitor, with a text editor open next to it.
My tablet’s broken, so now you’re telling me I gotta read this on my phone?
UGHHHHhhh. I deflate considerably. (I should have saved today’s weigh-in for this moment.)
I search up the book title, hoping there’s a publisher website and some other way to read this that’s not hyper-expensive.
I find the author’s Gumroad copy. OK this is a good sign! I sell on Gumroad too. But OK, it’s still another $10, turning this into a $20 book.
UGHHHhhhh!!!! Ugh. Kindle hatred intensifies. Still liking the book, but also hating Kindle now, along with that.
I buy the Gumroad version anyway, as I already have a plan of attack and it’s still cheaper than going out to lunch these days.
I download and file the PDF.
(Note to self, this Gumroad bonus method isn’t always possible—in a lot of cases the Kindle version is also significantly discounted vs. publisher’s mega-expensive version, but in the future I should really start at the publisher and end at Kindle if necessary)
I Have Made a Mistake. But How Huge?
And now for another mistake.
An absolute doozy of a mistake, as grandma would say.
I pause and reflect on the title. Scala…Scala…something’s off.
Realize it’s a book about Scala, but I was interested in…
I thought I was buying a Scheme book and it turns out got the names mixed up. Well isn’t this just dandy, as grandma would say!
LOL. F*CK. (Scala is expressive? That’s great, I’m expressive too. Just look at all my expressive language! I love being expressive!)
OK, but Scala was still on my list of interesting languages. I’m just not sure—it was a Java ecosystem language right? I don’t remember much about it.
I visit the (pretty) Scala website & confirm. It’s related to Java.
And Java was related to some of my most intense academic frustrations. It also seemed to be the working force behind the most mundane-yet-opaque software I ever used.
I still get the shivers just thinking about LaFs, too. “Stick with Metal, the others are buggy!” Brrr.
Plus, Java is a huge group of things. There are all these bulky classes, and you have to get the JVM and stuff.
I generally prefer lightweight-everything, due to the “enterprise software maintenance lessons” I learned while building stuff for clients back in the 2010s. Seeing that Disney and other huge orgs “use” Scala is a red flag for me. A simple guy like me could easily capsize in the metaphorical wake of commits from programmers at orgs like those.
So: If Scala is related to Java, is there TONS of infrastructure baggage that comes with it? I liked the Scheme idea because some of the distributions seem so lightweight. Well, I’ll see how the book goes, maybe the book covers this aspect.
Still, there are things about Java that I really like. For example, all the included batteries.
A Sterling Example of Meta-cognition (Maybe Not)
I stop and think about myself and my emotional state. This is an important part of any new undertaking.
I realize I’m a very cranky person right now.
This may not be the best time to be installing new-to-me software, especially if any dependencies are involved. There’s always some catch…
Getting Down to Business Anyway
I review the timer example by scrolling to that part of the PDF. It’s simple. But it’s where my laser-focus is at this moment. I am putting ALL of my bets on being able to get that working and work with it.
OK, so maybe I was imagining some ascii-art-style digits in the terminal, maybe some Casio-like functionality. Milliseconds flashing by. A bit of fun animation along with the basics. But it’s a very simple example.
I like that the script is using /usr/bin/env and it’s already looking like a scripting language I would use on the daily. I LOVE scripting in general.
I need the code though, like I need the raw text, not this PDF code. Where’s the code?
Found it. It’s not on the Gumroad page, but rather on the author’s blog page for the book. (Later I discover it’s linked in the beginning of the book—missing something like this is a known liability of my learning style, but I can deal). I browse the code on GitHub and find what I need.
Also, it’s time to install Scala CLI, the book says. I click the link in the PDF. “Invalid hostname”
It seems the link is not working but I can see a probable URL in the error message. Let’s try some of the options it brings to mind.
- cli.virtuslab.org NOPE
- scalacli.virtuslab.org NOPE
- scala-cli.virtuslab.org YEP
Is it Okular that can’t do dashes in URLs? Surely not? Some other issue? Not sure.
Hahaha they use a curl installer for the CLI. I’m so conflicted about these.
curl -sSLf https://virtuslab.github.io/scala-cli-packages/scala-setup.sh | sh
The install seems to go well. That’s always nice to see. But I still can’t run the timer script. Oh, the installer says to log out and log back in, or source ~/.profile.
I restart the terminal. Nothing.
source ~/.profile and it works now. Huh. I guess it just LOOKED like my terminal was doing that, due to its normal startup routine, but it wasn’t.
I run the timer script. WHAM. Downloading JVM temurin:17 … LMAO what is all this furious, animated action!?
Compiling project (Scala 3.2.2, JVM) Warning: there was 1 deprecation warning; re-run with -deprecation for details Compiled project (Scala 3.2.2, JVM) Usage: timer.sc minutes-before-alarm <gain-control> Ex: timer.sc 10 Ex: timer.sc 10 -20 'gain-control' should be something like -10 or -20
With tons of strange terminal action out of the way, I run the script.
But wait, there’s more!
Timer started. Wait time is 1 minutes. time remaining: 0 ... Exception in thread "main" java.lang.ExceptionInInitializerError at scalatimer_sc$.main(scalatimer.sc:98) at scalatimer_sc.main(scalatimer.sc) Caused by: java.io.FileNotFoundException: ./gong.wav (No such file or directory) at java.base/java.io.FileInputStream.open0(Native Method) at java.base/java.io.FileInputStream.open(FileInputStream.java:219) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157) at java.desktop/com.sun.media.sound.SunFileReader.getAudioInputStream(SunFileReader.java:117) at java.desktop/javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1062) at scalatimer$.playSoundfile(scalatimer.sc:70) at scalatimer$.$init$$$anonfun$2(scalatimer.sc:50) at scala.runtime.java8.JFunction1$mcVI$sp.apply(JFunction1$mcVI$sp.scala:18) at scala.collection.immutable.Range.foreach(Range.scala:190) at scalatimer$.<clinit>(scalatimer.sc:51) ... 2 more
I look at the exception/error. Yeah, I remember these things. They need syntax highlighting for these, seriously. It’s 2022 and we deserve it.
Then I happen to see right into the matrix, through all the java noise.
Oh! It couldn’t find gong.wav. I don’t have the sound file. I’m good at searching up random .wav files since about 1996 though, so that’s easy.
"parent directory" "gong.wav" site:.org …and, nothing in the .org domain space, my little barebones security measure.
OK, so I back off the paranoia a bit.
"parent directory" "gong.wav" site:.net — There we go.
It still says something is deprecated and to run with -deprecation. I do that:
timer.sc -deprecation, and get nothing I can understand. But then I re-run the script, and the deprecation notice is gone now. ??? To-learn-about, definitely later.
After a very long 1 minute, I hear the alarm sound! It repeats. OK, that was nice. I change the sound file, change the script name—little changes are working OK.
OK. Let’s wrap this up for now. What have I learned?
- I learned I can read most of the Scala code in the script pretty easily.
- I learned that I can script with it. It can be called a scripting language.
- I’m pretty much all set to script with it, with the CLI installed. I know how to install it on other systems. <— About HERE is where I start to figure that my $20 has absolutely been worth it.
- I have a bunch of questions. Yay! I love having questions.
- How do I update Scala-CLI in the future?
- How do I make the timer do seconds somehow? Or at least make it print “Wait time is 1 minute” instead of “Wait time is 1 minutes”?
- What would I like about Scala? I’m a programming generalist. So what specifics here do I like vs. the lightweight ABS for scripting, Object Pascal for retro-programming, Nim for casual learning-programming, PHP for web projects? Is there anything really hyper-differentiating or do I mainly get to learn some fancy stuff—FP, a new language, maybe some new style of expressiveness I hadn’t encountered before?
- Are there some cool Java batteries/classes I can start using in Scala scripts? Might as well take advantage of the full ecosystem which I’m pretty sure I just downloaded for this timer script.
- How are other people using Scala? What do they like? (This is DEFINITELY in the book, I’m thinking)
- What are some common mistakes beginners make? Anti-patterns and anti-performant warnings are one of my best learning methods. I may not be able to learn so great from others’ organization of info, but I can definitely learn from a list of their mistakes…
- Could I make a graphics demo with this? Draw some text, some lines, maybe a simple fractal?
That’ll do for now. I’m curious! Good.
I move this experience into my programming log, under Scala. (I do notice that if I ctrl-f for quick access to “scala”, I get all my notes on Perl scalars in the results, dammit.)
I will take a break, rest the nerves, and maybe see how things go from here. I’m looking forward though.
I managed to passionately barrel through the experience this far (just my style in these situations sometimes!), I’ve got my first promising results under my belt, and have avoided some personal learning style pitfalls that could set me back years.
Great! I’m done for now.
Later: Session 2
(I thought I’d include a bit of the follow-up, too.)
(I might have had a stiff drink between the two sessions)
I go back to the beginning of the book, since it felt 150% appropriate to do so for context at this point.
I learn that, experience- and background-wise, I’m totally part of the target audience. Feels reassuring.
I try the online exercises. Haven’t really done this kind of thing before with a book on programming. But OK, great, these are useful and interesting to work through.
However, I don’t really know where to go for enlightenment when I get something wrong. I guess maybe try five problems, get some questions from working on them, then dive into the book to find the answers?
Oh, some of the questions clearly require specific book-contents knowledge, like valid “Kirn family” names? This is not what I was expecting as compared to the typical syntax-pattern questions to which I could at least try to intuit an answer, but I’ll look into why this might be important to know.
Yeah, after trying exercises for a bit, I think about 3 of these incorrect answers is my working-memory limit before I need to go to the book. Page number references would be nice but they might also drive an author crazy.
Also, I visited awesome-scala and didn’t find e.g. SDL 2, which I was hoping for. Not much there for graphics. Maybe I’ll stick with the typical password-generation-type scripts for now.
That’ll do it for this post! Again, if you’re interested in the topic, I can certainly recommend the book. It’s priced very well and the coverage has been very helpful.
A Request of the Author
The above has been an account of my experience. I wouldn’t say I’m making any requests up there, really. It might sound complainy but it’s more of a relating of issues I had, and not at all a “please change your book” or anything of the sort.
With that said, I did have one request / wish:
- In case you’re reading this, Alvin: I’d love to see an all-inclusive list of your books in the sidebar of your website. Like, “My Books”. A formal list of published books, with links to the accompanying multiple-source-purchases pages, like Gumroad, Amazon, etc. would be very helpful. There’s already a sidebar highlighting another book, and I can see lots of publishing projects going on. There’s even a “books I’ve written” footer, but it could use an update maybe.
A big thanks to Alvin for writing the book, and I look forward to learning more about Scala 3! (I can’t find Alvin’s email address to reach out, so I’ll see if I can DM him on Twitter or something, but I doubt it’ll work)
Filed in: Books /10/ | INTP /6/ | Ti /29/
Experience Walkthough: Reading a New Programming Book →
The 2022 Wrap-up & 2023 Energy Post →
Introduction to than Ward Flen, lang whem →
Blog Updates, 2022-10 →
Keeping a List of Almost 1,100 Personal Interests: Recent Thoughts →
Things I Made for You
Own your procrastination with Whole Productivity, a new system → Get my free INTJ COVID-19 Guide → Explore your gifts with my INTJ Workbook → Other Publications → ...and the fake word of the hour: "Hoepimdor." I think this is related to a lack of discipline.