Hacker News new | ask | show | jobs
by stryan 3141 days ago
Considering how many programming abstractions most programmers work above now, I'd say it's more like magic now then ever before. Draw the circle (add the boiler plate code), recite the words (dig up the proper API method), perform the gestures (compile with certain flags) and your spell (desktop app) will work. If you don't, it'll do nothing or worse, blow up in your face.

As a side note, if anyone's interested in looking a bit more into "programming as magic" there's a great book series called The Wizardry series about programmers being transported into a fantasy realm where magic works similarly to a programming language. The main character ends up writing a compiler based off (IIRC) APL and revolutionizes magic. The first book is called Wizard's Bane and it's light and fun reading.

16 comments

> As a side note, if anyone's interested in looking a bit more into "programming as magic" there's a great book series called The Wizardry

If you like that kind of thing and you enjoy/don't mind anime, there's also the serie Knight’s & Magic. It is about a programmer being reborn in a world where people wield big "golem" armors. The protagonist then proceed to make his own version, completly disregarding the philosophy of that world. Thinking of those golems as nothing more than machines and using magic as nothing more than "inputs/outputs" for those machines and the world.

http://www.crunchyroll.com/knights-magic

"A genius programmer and hardcore robot otaku is reborn into a world of knights and magic, where huge robots called Silhouette Knights roar across the land! Now reborn as Ernesti Echevalier, he uses his vast knowledge of machines and programming talents to begin to make his ultimate robot. But his actions have unexpected results...?! The dreams of a robot otaku will change the world!"

Ah, K&M. Lots of potential, many fun moments, but it's far from rationalist fiction. Still, if you ever need wish fulfillment that the time you spend at work beating down technical debt could instead allow you to fight monsters and cast spells leveraging the mana pool of a giant robot, it's a fun read/watch.

From an unofficial (and somewhat grammatically atrocious) English translation of the original novel [0]:

> Normally, Eru would have given up at this stage and would have chosen a more practical spell. But he knew how to solve the problem because of his unique skills ― programming concept. He had experience in designing and coding software to handle multiple variables. That's why he skipped the beginner magic phase and jumped straight into the 'modified magic' phase. Reviewing the structure of the physical boost script, Eru compressed the structure to minimise the number of variables, creating subscripts that would automatically extract the status of the body. After compiling it, he just needed to design the user interface to make it easier to control, so as to lessen the burden.

> Complicated projects like the improvement of scripts was not something that could be done easily by anyone. Eru, however, was not aware of this, completing the improvement shortly, and the patch was a big enhancement. But even so, it was still difficult to control magic that strained the mind heavily. But with his extraordinary processing ability, it was not much. No one realised that a historical revolution had occurred, but for Eru, this was just a small step in his journey.

[0] http://webcache.googleusercontent.com/search?q=cache:http://...

I also really loved the episode of "In Another World With My Smartphone" where the character aquires the spell "program" which lets a caster enchant a physical object with a command.

The regular wizards use it to, let's say, make a door open when someone says "open" or other minor one-step commands.

The protagonist, a modern human stuck in a magical world, uses it differently. He creates sequences with it. He scripts complex programs.

[Minor Spoiler] As an example, he ends up creating a magical pistol. When the users speak "reload", the pistol (which the character imbued with a few spells using "enchant") casts a detection spell to finds the closest bullets. If bullets are found, the pistol then casts the spell "aports" on it. The bullets are teleported into the chamber of the pistol. He uses the same concept but with transmogrification enchantments to add voice commands such as "sword mode" or "pistol mode" that transform the pistol into a sword and vice-versa.

I highly recommend reading the light-novel translations of "In Another World With My Smartphone" as well! You can buy them on Amazon Kindle, or you can subscribe to read the pre-prints at http://j-novel.club/.
I was a little disappointed that a 600+ year-old fairy didn't remember to properly set conditionals, though. :D
> it's far from rationalist fiction

Is that bad? Like any didactic subtype of the genre, rationalist fiction often struggles to succeed in both of the goals set for it; the only example I've as yet found enjoyable - and extremely so! I strongly recommend it - is Unsong by Scott Alexander, also of Slate Star Codex.

Not purely rational you have parahumans where most protagonists' acts have some logic behind it. Not a lot of evil people just because they're evil, and not a lot of pure heroes either.

https://parahumans.wordpress.com/ if you want something to read for next month(s).

And in case anyone isn’t aware, the sequel started yesterday at https://www.parahumans.net !
Seconding Unsong. The end felt kind of cheap to me, but the journey was absolutely worth it.
Agree on both counts.
How else would you have it end?
Unsong is not exactly rational fiction. The author itself claims it isn't (some people claim it is despite this fact, though).
I can see both sides of that argument, and I'd be lying to say I didn't consider Unsong rationalist fiction at least partly as an attempt to redeem the genre in my own estimation.
Authors aren't reliable narrators of their work.
>Ah, K&M. Lots of potential, many fun moments, but it's far from rationalist fiction.

Hasn't that gone out of style with Zola?

I did see that while browsing newer shows the other day but I guess I didn't see the programming part and thought it was too generic to watch. I'll have to give it another look.

Thanks for the recommendation!

It's yet another take on the "regular modern human gets teleported into a magical world and becomes super strong because he has knowledge" trope that is all over the place in recent animes.

That being said, it's an interesting point of view. The character goes so far as taking personal a fight against a "golem plane" solely because he fears that the invention of planes will means that this world, like ours, won't have mechas. He doesn't have a care in the world but to use magic as a means to program mechas and completely disregards the fact that magic should be exciting in itself.

I really loved the pacing of Knights and Magic, but the fact that the MC was a programmer in a past life is only relevant for maybe 3 episodes.
I followed this link and I have watched a few episodes. Can't get over the first episode intro. Developers life summed up in 30 seconds.
I just watched the whole thing based on this post. 3/5. Not really worth the 5 hours, but it was alright. The premise was neat.
I felt exactly the same while watching it. Neat promise and entertaining. Something you can binge and enjoy without thinking too much. 3/5 is a nice rating when you compare to some of this season's anime series. There are a lot of show that I would rate 0/5 or even -1/5.
The books Daemon/Freedom by Daniel Suarez was pretty entertaining on that front. The idea that people could literally affect the world around them via "magic spells" which mapped aliases of a invented language that would be picked up by microphones and then executed on computers.

There is a section that muses about the future of humanity and how in the near future, these would literally seem like magic to anyone who doens't have technical know how, and for all intents and purposes, it was.

In the Quantum Thief (actually one of its sequels) by Hannu Rajaniemi, there are Secret Names that perform magic; one of them was 'Emergency Decompression Protection' and produced a shield around the incanter.
Smartcoral's user interface is also pretty similar, though, and that shows up in Quantum Thief proper. :)
With always listening assistants, we're practically there with Google and Alexa. We just need cooler things to interact with than communication and divination (checking the weather) "spells."

As soon as we get some sort of grey goo with an API like in Big Hero 6 or wrist mounted fireball/lightning generators we're in business.

"hocus pocus fe fi fo fum, play Taylor Swift's latest album"
This is exactly the reason I despise Spring with a deep and abiding passion.

"Just add this dependency, and add these annotations to your class, and it will all Just Work."

"But...what do those annotations actually do?"

"Stop asking so many questions!"

I mean, I know the answers are out there, it's open source after all. But so much of it seems deliberately designed to obfuscate the flow of execution and make reasoning about the code as difficult as possible.

This phenomenon came to a head with J2EE. The original spec was designed apparently by people who did not know the 8 fallacies of distributed computing. It also coevolved with XML, and I think the entire experience colors the configuration as code philosophy in a bad, or even sinister, light.

When I see people design systems where, when they break, the only way to diagnose the problem is to do a code review, (not read the logs, or fire up a debugger), I wonder how they got along in their education without understanding the importance of debuggers, or why they hate their fellow programmers so much.

Spring comes out of a book that tried to reject the arcane nature of J2EE. I wonder sometimes if Mr Johnson recognizes hay the Beast he created is just as bad as the one he slayed. And how well he sleeps at night.

It got so bad they made a mini version of Spring, and even that is very declarative, and nearly impossible to explore.

When I'm really disturbed by how something actually works, my approach is to try to implement something similar myself. Object oriented C (structs with function pointers) long ago gave me some insights including why Python has an explicit 'self' for everything. There's a similar exercise you can do in C to better understand the prototype chaining way of doing OOP. Have you tried to make a simple version of e.g. @Autowire that is still capable enough to let a Java app of many modules have one module only depend on an API module and not the implementation module with everything just working without explicit injection? Sounds interesting to me, I bet that would be more enlightening than a summary page, or at least make the summary page more understandable...
"without explicit injection?"

In many, many applications explicit injection works just fine and is exactly what you want. But once you say "I am going to write a Spring Boot application", you are pretty much stuck with a big part of your application logic stuck in annotations, even when there is very little benefit over explicit code.

That's exactly how I felt about Ruby on Rails.
It's also why I prefer more "straightforward" libraries such as Tornado or CherryPy.
Wait, that's contrasting to other Python libraries that use the Rails/Spring magic? Which ones?
Django for example has a lot of magic.

A lot of the development process consists of adding fields with particular names to classes that have a long inheritance chain of their own, and it's not trivial at all to understand what all of your options are and how they work behind the scenes.

Hm I figured Django may be guilty of that. FWIW I learned web apps on RoR but my first job was Django. Django (or at least, apps in practice) was definitely less magic than Rails, although I see what you mean about a lot of the config being less transparent than one might like. I always have to eg hit SO to figure out how to add something to the admin since the model for how it works is not transparent.

I’ll definitely check out Tornado and the others for how they compare.

Currently it's my feeling about Kubernetes. Yeah not coding, but the same feeling.
I agree with annotations like this making it harder to reason about control flow, but I don't really get the consternation about "what do these annotations do?" so much. You can go read their documentation or source yourself to answer that question. How is that different than anything else? Same thing with "rails magic": yes, it sucks that you can't grep for method definitions, but you can go peruse the has_many method implementation to see what it does!
This really isn't too difficult to do, but it is a time sink I'd rather not have to deal with. With Spring in particular there's a huge amount of complexity so it can take a bit of time to determine exactly what's going on. Whereas with something like Go, I generally have full control over my applications control flow and if I need to look at a libraries source it's typically very straightforward and to the point.
"I agree with annotations like this making it harder to reason about control flow"

That is precisely my consternation. Much, much easier to reason about abstractions in the core Java language, like methods and objects, then to discover what code is being injected by an annotation. Java has outstanding IDEs that excel at navigating, analyzing, and debugging Java code, but putting so much logic in annotations is almost like you are trying to deliberately keep much of the code secret from the IDE.

Yeah. In principle, IDEs could show you what an annotation is doing, but at least in my experience that aren't particularly good at this.
I generally agree, but it's not entirely Spring's fault. The underlying APIs they're using are awful. If I were doing anything Java EE based, I'd still prefer to be using Spring Boot even with it's warts. It might be a framework for a framework (Spring MVC) for another framework(Java EE)...but it's still less of a pain than dealing with the underlying frameworks directly.
This is exactly the reason I despise Spring with a deep and abiding passion.

It's interesting you took the time to post this. As the sibling to this comment indicate, there's a lot of 'magic' in many languages and frameworks. not just Spring. You don't off an example of a tech stack you do favor so one can only guess.

I will say that when I have encountered developers and teams who also disdain otherwise popular frameworks, they sometimes choose to roll their own instead of buckling down and learning said framework. Invariably they end up with a partial implementation of what they didn't understand, that is bug ridden, ill performing, and just plain bad.

There's a lot of good stuff in Spring (and EJB, and rails, and ...) the onus is on us, as professionals to learn it and use it where and when it's appropriate.

"You don't off an example of a tech stack you do favor so one can only guess."

I think annotations are used many times in Java where abstractions like first class functions would be used in other languages.

I also find Lisp macros easier to reason about. "This compile time source code expands to this run time source code, which executes like so."

Perhaps surprisingly, I even find Ruby magic easier to reason about. "This method causes these three other methods to be defined to do x, y, z." It can get confusing, and final behavior highly dependent on the order in which the code executes, but I still feel like I have a mental model of how everything executes.

With annotations, depends on the code processing the annotations. You could have different code doing different thing with the exact same annotations. Your IDE can take you to the annotation declaration, but not directly to the code the annotation causes to execute. In the debugger, you can see the code in the call stack that was generated, but no link back to what annotation caused it to be generated.

It all just feels more like memorizing spells at Hogwarts, and less like an engineering process.

Spring desperately needed some remote interfaces to the engine to let external debuggers attach & tell you what was what. It keeps track of all this data, & you can find out what's in the various object containers if you ask really nicely with a lot of code. If this had a GUI, I think it would be an enormously sophisticated & elegant way of dealing with systems. Alas now it's a fright.
That's exactly how I feel about express middleware...
I mean... Usually you could implement a simple dependency yourself pretty trivially, for the most common case. But will your implementation be as tested and cover your user base as well as the Generally Accepted dependency implementation that has a million monthly downloads?
Diane Duane's Young Wizards series is more "magic as programming" but it's also quite good if you like stuff that's fairly YA pitched. It bridges the gap between "magic is deeply mysterious and unknowable" and "with the right set of words and invocations you can teleport" in an unusually deft way. Magic uses a more declarative language than an imperative one, but it's composed in much the same way as you might compose a program.

A magic Apple II makes an appearance, if I'm remembering correctly...

Aren't they all, a bit?
As long as we're recommending things, I'm tossing "Off To Be The Wizard" into the pool. Magic is done by modifying a secret file that modifies the world; you can create macros that modify it for you, etc., etc. Shenanigans ensue.

https://www.amazon.com/dp/B00EF8Z32I/ref=dp-kindle-redirect?...

Forth, I believe it was, rather than APL, and specifically for the simple semantics and quick composition of a stack-based language. I recall being impressed with the author's rather detailed, but still likely accessible to non-wizards, description of the decision process and its outcome.
My favorite bit was summoning the Interpreter from Starting Forth -- you could recognize him from the description before it was explained. I mean, if you've read Starting Forth already.
As a side note, if anyone's interested in looking a bit more into "programming as magic" there's a great book series called The Wizardry series about programmers being transported into a fantasy realm where magic works similarly to a programming language.

Sounds a lot like the "Magic 2.0" series by Scott Meyer.

https://www.goodreads.com/series/131379-magic-2-0

In that world, "magic" is very much a direct result of programming. I've read the first two books in the series and enjoyed them a lot. For anybody whose into that sor of thing, I recommend this series highly.

Just finished the third book. So far 1 and 2 (which takes place in Atlantis which may have borrowed heavily from Apple's design philosophy) are my favorites.

They definitely focus more on the programming nuance. It's also cool how they introduce technology and interfaces from different periods of computing due to the time traveling aspect.

Harry Potter and the Methods of Rationality also explores that topic a bit.
Better to read the review/summary as HPatMoR is extremely long and really more of an Ender's Game fanfic than an exploration of magic by rational means. (It does happen briefly but is quickly forgotten.) http://danluu.com/su3su2u1/hpmor/#bad-plotting

>At the start of the story he has a legitimate positive agenda--he wants to use science to uncover the secrets of magic. As the story develops, however, he completely loses sight of that goal, and he instead becomes just a passenger in the plot--he competes in Quirrell’s games and goes through school like any other student. When Voldemort starts including Hariezer in his plot, Hariezer floats along in a completely reactive way,etc.

>Not until spoiler dies, near the end of the story, does Hariezer pick up a positive goal again (ending death) and he does absolutely nothing to achieve it

I gather you didn't like HPMoR, like the author of the review? Here's my advice: do not read that review, even the introduction is full of spoilers.

I personally loved HPMoR, even more so than the original series. I also disagree with most of the review, either factually (I believe most of the science is sound), or because I have a different interpretation (how Harry lacking agency is even a problem?).

Correct. (and good point about spoilers) :) I just had high hopes for a story of scientific inquiry into magic. (Still do) Switched from source to review after it became clear that the story was more of a power fantasy/soapbox for the author.
> If you don't, it'll do nothing or worse, blow up in your face.

I assume I am not the only one who destroyed at least some amount of his personal data doing computer magic [1]. This would be analogous to a spell going wrong, burning the witches' hand or something similar.

[1] Be it an incorrect incantation of rm, or just a poorly aimed flick with the pixie pointer.

I am showing my age here. I destroyed a CRT monitor once when I used the wrong incantation for xorg.
Whoa, what? I'd be curious to hear more about that... How could some software config harm a display? Incorrect sync rates or something? ...and yeah, I am old enough to have used CRT displays for many years of my life, just never seen one get damaged like that! :)
Used to be, you configured X for your monitor and video card by editing a config file that specified the assorted timings and so forth. Yes, you could make your monitor very unhappy with the wrong settings.

This is probably the most useful thing ESR ever wrote: http://en.tldp.org/HOWTO/XFree86-Video-Timings-HOWTO/

My sympathies. I remember the feeling in my gut I got when I had to manipulate XFree86 (what distros shipped with when I had to do this the last time) and worrying that I'd lose my one and only monitor, but it never happened to me.
I remember that thunk.
Similarly, the Ra story on qntm.org has magic be well-defined to the point of having an intentionally boring college lecture, with the magic spells being both consistent and recognizable. The author did a writeup of some of how the language is structured.
I feel disgust for programming domains where I have to use a lot of boilerplate. This is simply because... I can't remember arbitrary bits of information well. I memorize much better if it's something connected by logic.
The presence of large amounts of boilerplate signals an opportunity for abstraction wins.
If you like this kind of stories and don't mind a work in progress you whould try https://www.reddit.com/r/HFY/comments/61ya08/oh_this_has_not... where a nerd ends up in a fantasy world.
Obligatory reference to Vernor Vinge's Fire upon the Deep and A Deepness in the Sky that explores programmer archeologists or programmer at arms.
As I recall (it's been years) it was based on Forth because a stack based postfix language is easy to implement. It can be parsed and executed in a single sequential pass.
Right it was Forth! I remember reading that got me interested in stack-based programming languages. Maybe it was in a later book he wrote something based off APL.
I recall enjoying that series. Correct me if I'm wrong, but at some point he brings a friend over to his world and gets made fun of for programming magic in Forth.
That sounds neat. Target age?