A little more than eight years ago, I came across a nice documentary: "Fractals - The Colors of Inifnity", narrated by Arthur C. Clarke (yes, THE Arthur C. Clarke!), with music provided by Dave Gilmour of Pink Floyd; to top it off, I was tripping on LSD for the first time when I saw it, and I had to rewind at least once to check if something I had seen was actually on the screen or just in my head (to my disappointment at the time, it was actually on the screen).
It's a nice documentary, though. Highly recommend it. They even have an interview with Benoit Mandelbrot himself, may he rest in peace.
Two years after that, I wrote my first Mandelbrot-renderer. First in Python, but that was waaaay too slow, then in C, which was a lot faster (duh!), and then I made it even faster by telling the compiler to use SSE. (To some, that sounds trivial, but it was something I had never done before.)
I have always suspected that it is like a rite of passage, building at least one simple-minded Mandelbrot renderer. I rewrote mine after two more years to take advantage of multiple threads and wrote another one to render the Buddhabrot[1]. Then I remembered an article I had read years before, about the Parallel Virtual Machine, PVM. So, the next weekend, I turned my Mandelbrot renderer into a distributed application.
So Kudos to the author. Tackling the Mandelbrot set has the dual advantage of being interesting and you can make pretty pictures along the way. It is great fun, and I learned a few things along the way. What more could I ask for?
> I have always suspected that it is like a rite of passage, building at least one simple-minded Mandelbrot renderer.
At the university where I study and work as a TA, all CS students have to write a Mandelbrot generator (we provide a simple GUI for them) in the second programming course.
Everyone is always very happy with the results and many consider it one of the coolest things they've done with programming up until then. I think assignments like those make them more enthusiastic about programming, which we (imo) need more of.
For me it was a Mandelbrot renderer typed in from a computer magazine, in BBC Basic, on a 2MHz ARM with five-byte floating point. It'd do a 256x256 four-colour render overnight.
These days?
$ sudo apt install xaos
$ xaos
Click in the window, hold the mouse button down, watch.
I wrote my first Mandelbrot renderer around 1990. I've been a graphics programmer for almost 30 years, and it still absolutely blows my mind. I understand the math, but I still watch ultra-mega-zooms on YouTube and marvel that such an object exists.
My high school science fair project in 1989 was the Mandelbrot set, and I was using my Amiga to generate them, then some funky dot-matrix printer voodoo to get even grayscaling for the prints. I barely made the cutoff time, even though I'd spent weeks working on the project, because each possible render took at least a day, and my code had a lot of hiccups. (IIRC, everything was written in Modula-2. I need to see if I can find those old disks somewhere.)
It's funny that of all the things I'm 'jealous' of in modern tech, the thing that still blows me away is just how fast I can generate/zoom around fractal sets, just for the hell of it, on my phone. This much computing power in the palm of one's hand was inconceivable to me at the time!
One of my most enjoyable projects was writing a Mandelbrot generator for the Gameboy. It was so slow that if you wanted to fill the very low res screen you'd be the better part through your battery life. Great fun though.
I have not owned an nVidia card in years. However, I am about to buy a new PC, and I got a used GeForce GTX 960 for cheap from a coworker, so I have the option at least. ;-)
This brings back memories of my being in high school; I'd get there in the morning, run over to our Computer Programming classroom, and load a floppy into the one Apple IIe that was connected to a color TV.
I load and run a Applesoft BASIC program that plotted the Mandelbrot set - oh...so...slowly. It's one saving grace was that it used a special ML program (something I found in Byte magazine or somewhere) which - on a machine equipped with an 80 column card (and the extra memory it afforded) would enable a high-resolution mode with access to all 16 colors.
So I'd run it - and let it plot...
By the time lunchtime came around, it would be finished, and it saved the image to the floppy. I'd then manually pick some new coordinates, and run it again to "zoom" in to an interesting area.
My last period was in that class (it was an elective, and one year I took it twice per day just to pass the time and gain an easy "A") - and by that time the new plot would be done and saved.
The next day I'd repeat it again. After about four iterations, though, it would be running too slow to finish a plot in time. So - I'd start again, and zoom in somewhere else. The teacher enjoyed it, and the other students liked seeing the pretty pictures.
Oh man, high school. Our grade 11 CS class had us developing with C# and running our projects on local Xbox 360s. Being able to target the current gen console hardware was extremely engaging.
For the final projects most of the students made simple games such as pong or breakout. But I decided to write a Mandelbrot/Julia set viewer and had to dig into writing my own shaders in HLSL? (been a few years). At the end of the day flying around the sets with a controller in real time to Jonathan Coultons "Mandelbrot Set" felt bloody amazing.
The first Mandelbrot renderer I ever used was an easter egg in Chips Challenge on the Atari Lynx. (Type in MAND as the level password and off you go!) Incredibly slow but it had me hooked. Most of my very early programming efforts on calculators or in QBasic were Mandelbrot set renderers.
These days, a fractal renderer is one of my go-to toy projects to learn a new language/environment. It pulls together basic code, graphics, GUI, file operations etc. and produces something pretty too, while giving me a feel for the speed of the environment in question.
Presumably "Machine Language" which is what we called Assembly, back when the translation between what you wrote and what the CPU actually did was pretty transparent.
The ML programming language, of course. I'm always confused when ML stands for machine learning, because I think the post will be about programming languages, but isn't.
Pretty sure it's "machine language" here. Writing ML compiler for Apple II would have been... interesting (disclaimer: I'm not actually completely familiar with either the Apple II or ML, but I have a general idea of the capabilities of both).
I’m not really going to get into set theory because I don’t know anything about it tbqh, but maybe it’s worth a mention? Wonder what would be a really good succinct but not wrong explanation of set theory…"
"Sets wtf is a set", I don't know Bob, what is grammar, and why doesn't your article have any?
"lol, sets? one of the fundamental sections of mathematics? Wut r those lel? who cares I do js, fuck learning about what's going on when you're here to write a trite, subpar blog post on the subject".
"...but maybe it's worth a mention?" I don't know, is literally one of the fundamental parts of the underlying mathematics important?
"...Wonder what would be a really good succinct but not wrong explanation of set theory…" Here's an idea, take literally 3 seconds, or the minimal amount of effort you have and search 'introduction to set theory'. I can almost guarantee that there is a plethora of fantastic resources out there. Hell, Wikipedia is often more than adequate for mathematics topics. Also, unless you're a James Joyce tier writer, this stream of consciousness style writing is exceedingly poor form and should be avoided. It adds nothing and really only serves to tell the reader how little you know.
It seems to me that the entire point of the post was "let's write a bare-bones program to create pretty pictures out of fractals", and that's what the post does.
Set theory is fantastically interesting and powerful, but it's very very understandable to brush past it so we can get to the pretty pictures.
Also, if I do actually "take 3 seconds and search 'introduction to set theory'" I find two (excellent)[0] resources that, in their introductory paragraphs alone, rival the largest sections of the original link.
was no less annoying. But you can't cover everything and given that sets aren't important to this post, indeed covering them would be more confusing since the Javascript Set.prototype has things such as being finite, and strict equality.
This article is not an introduction to the mandelbrot set, it's "how to draw the mandelbrot set in javascript". I read this as a programming blog post not a mathematics blog post and enjoyed it.
Maybe this is how kids talk these days. There is going to be some Millenial who is a math genius an order of magnitude beyond Terry Tao, and what if they talk like this? Such things are going to happen. I find it amusing.
I live overseas and have no reason to talk to kids so I'm totally out of touch with the "real Millenial generation". But I want to know how they talk and think about things. I tried "Millenials react to X" videos but nothing is that useful.
I don't think it's very good if I'm totally out of touch or don't understand the Millenial generation at all. For me ( 80s so that's a gen-x-er? ) Millenials really seem like an important generation to understand...they grew up with the internet. They act differently online to the rest of us ( more privacy conscious and so on ). It's frustrating that I can't find any first-hand sources or interviews to see how they think and talk -- except things that are parody / making fun of it...or just theorizing by "experts".
The other side of this is about inspiration. I realized that as I got older, my "generational culture" ( for want of a better word ) is basically static. The shows, the movies, the music, the people, the scene, the lifepaths, opinions and ideas of peers...it's all just...so familiar. So boringly familiar. And unchanging.
Only the new generations can really have some vibrance, vitality and fresh inspiration, in a very organic sense, in my opinion. Not just fresh relative to another, static generational culture, but somehow inherently fresh and inspiring. It really makes me appreciate youth in a way I didn't before. As, if nothing else, this source of a fresh way of looking at the world. I also think that youth who grew up in the last 17 years, have to be some of the most interesting, or somehow express the most faithful reflections our world right now -- because they were literally shaped by all the huge changes that Earth has gone through -- Western political changes, rise of China, terrorism, social media. So I think to some extent if people want to understand the world we live in now, we have to understand the generation that grew up shaped by it.
I'm 22, so I suppose I'm a 'kid' to some here, and I stopped reading this very quickly. It's not funny, clever, or well-written.
The text certainly didn't inspire me to enable JS so I could see the code or images.
I think it's a shame we seem to be veering ever more toward 'code is all that matters' (or whatever the product of work is if not code) - not writing, presentation, communication, etc. - the result is rampant unprofessionalism.
It also may be neat for some people, but I found it went way too much into details of the technology used to draw the fractal, rather than the fractal itself. There's a good 10 image and 20 box of code just to initialize Canvas. Do you really need to explain how to dedicate a paragraph on how to set an id on an html element and another on how to grab the element in javascript?
Oh and I can't believe Github still does that whole "hosted with <3" bullshit.
I thought that was the point: the author was sharing their learning process for using canvas to draw in the browser through the goal of generating fractal images. Thus enabling others to start from zero and get to a point of drawing sets on canvas elements.
Indeed. I consider myself to be a curmudgeonly old man and even I don't understand why all the other curmudgeons seem to have got out their pitchforks over this.
Granted, I only skimmed the article and read in detail the parts that were most interesting to me, but I thought it was decent. Certainly, as an introduction - something to whet the appetite and spark interest on a subject in someone who knows nothing about it - I thought it did a great job, and I liked the fact the author has bothered to link to other resources if you want to take things further.
Sure, the writing style isn't going to be to everyone's taste, but, whatever.
At first I hated it and didn't get why the looooong introduction to the canvas (that part could have been much shorter). But eventually I think he did a great job explaining the subject to people with close to zero knowledge, and his step by step approach, while tedious, was awesome.
One of the first programs I ever wrote was a Mandelbrot renderer in GW-BASIC, on an 8086 PC with a CGA card running DOS 3.3. This wasn't in the '80s when this would have made sense, rather this was circa 1994 because this was literally the only computer that was available to me. Nonetheless it was mind-blowing to me.
CGA had a 320x200 4-color mode. My program had a hardcoded bounding box that it would evaluate, and generate a 320x200 rendering of. I had to leave it running overnight for it to run to completion. I would set up the bounding box in the source file, start running the program, then wait until the next day for it to complete. It was awesome. Modern hardware could probably do the same thing in a few milliseconds. I'm sure it being written in GW-BASIC didn't help. :) Still, good times. That was the first thing I ever did that sort of resembled graphics programming.
Actually I don't think this is as ridiculous as you might think.
I spent quite a bit of time with a mate of mine over the summer of 1992 writing compression algorithms in GW-BASIC on his dad's 8086 powered PC, equipped with CGA graphics. Another friend had a computer with EGA (gasp!) graphics. Almost no-one had a "decent" (i.e., even remotely current) spec PC back then, and I was on an Amiga 500.
When, just after we'd finished our A-level exams in 1994, first friend's dad upgraded to a 486SX33 with some sort of SVGA card that was capable of running DOOM - and doing so smoothly - minds were duly blown. And that's where that summer went.
A bit unrelated, but it's weird that Medium doesn't seem to support embedded code, and instead only seems to work with gists.
It made the mobile experience pretty bad (all I get are links to the gists) and it would definitely "pollute" my gist history with a lot of little code snippets.
On the note of the topic itself, though, this was a fun read for building fractals in JavaScript!
"I thought, “Hey, I’m a Web Developer™! I should use JavaScript for this because JavaScript is the best lol!” "
While that's clearly meant to be somewhat of a joke (from a medium account called dailyjs as well), it's this kind of annoying attitude that has lead to js being forced into lots of other avenues.
Also, is js really even the best tool for this? I feel like you're going to get far better pictures and faster results from language closer to the metal like C/Rust/Java(???).
JS is almost never the "best" tool for any job. But the browser is (arguably) the most pervasive environment, reaching the largest audience, so JS has the farthest potential reach of any tool. That is the trade off of web development -- pick a sub-optimal tool in exchange for highest potential market share.
In other words... No. But experimenting with JS still can have value.
Sure, you'll be able to render faster. But how much time will you spend building a UI? And you still won't have anything to inline in the web page. Part of the appeal of doing this kind of stuff in JS is to be able to share it without requiring people download and install something.
Realistically speaking, any toy fractal renderer like this will be an order of magnitude or two away from a heavily tuned one employing every trick in the book anyway, regardless of language.
Recently I was fiddling with Julia sets. I find the HTML5 canvas quite comfortable to work with, and after implementing the renderer as a WebGL shader, it was a snappy update/refresh/get feedback loop.
Javascript is a nice hacking tool if you keep it in the browser.
If you want to generate fractals in-browser? Y... actually, no, at least not for modern browsers.
WebGL is, and the author actually uses this for his "final" implementation (linked from article).
I sort of get the JS hate (sort of) but if you want to do things in the browser then you're either using JS, or something that compiles to JS, or WebGL (1).
(1) If you're really lucky and only care about targeting supporting browsers you might also consider WebAssembly, and then you can use C or Rust, but for many scenarios that's still not an option. (And I doubt it would be faster than a shader-based WebGL implementation that runs on the GPU, for this scenario.)
I often write fractal renderers when I'm bored, usually batch rather than interactive ones. My most recent was able to parallel draw using several hundred servers, it was great fun.
Next steps for me after mandelbrot, on my most recent run, were the burning ship fractal, then fractals using floating point (Glynn Trees) and imaginary exponents, then Pickover Biomorphs (which I love to look at) Never quite got my phoenixes working....
It's sort of a JavaScript in-joke. The originaly "Wat?" talk was somewhat entertaining but it's now become ubiquitous enough that I'd probably throttle its progenitor given half a chance.
This site has an excellent series of in-depth interviews with Mandelbrot; profiling his early life, his capacity to think mathematically "in pictures", and goal to link seemingly disparate fields such as "social" and "natural" sciences through fractal mathematics.
Many don't seem to realise that the black circles in the middle of spirals and other smooth curves are due to the iteration count being too low. The spirals don't stop and the only filled shapes in the mandelbrot set look very much like the zoomed out view.
Am I the only one that was a bit disappointed to find it's a beginner introduction to the Mandelbrot set? The title led me to believe there was some modification or something new =/
It's a real, real joy to read all these memories about the set, thank you all!
> Although I'm a huge fan of tech writing for beginners, in this case I could have done with 0.6 as much whimsy.
Can I meet you in the middle somewhere?
No, but seriously, there are what I consider very good reasons to adopt this tone. It's easier to write in a loose conversational style, first of all, and it's much more approachable for a wider variety of readers. But most importantly, to me anyway, is that I want to avoid even the semblance of an authoritative voice derived solely from the tone of the writing. Case in point:
> It's just a way of saying: "Outside the scope of this textbook".
That's exactly right. I'm not going to explain such a huge branch of mathematics with any justice in a short blog post, so I'm not even going to try. The cursory definition of "what you probably think it is" is more than adequate to get to the point, and I want to be clear about what I do and do not actually understand. To me though, "Outside the scope of this post" bespeaks of an author's deep and abiding understanding of the subject, as if he or she doesn't feel it necessary to deign to share that understanding just yet. For me, for this subject, This is not accurate, and I don't want readers to feel
like it is.
> only serves to tell the reader how little you know.
This is also exactly right. I don't know much about sets, at all. I could read about them! I'd love to read about them, and I probably will sometime. But I don't know much about them right now. I think it's _more_ important, not less, that I am clear about that. This post is written for someone who doesn't have a strong math background and is only just learning about the Mandelbrot set, in effect, me from a few months ago.
The authoritativeness of the post should come from the provable validity of the contents, not the airs of the author. I had this post vetted by JavaScript ~ninjas~ and a Math phd to avoid putting out bad information, that's much more important to me than proving that I know everything, because I don't.
That said, I want it to be an enjoyable read for anyone, so I'll keep the tonal crits in mind.
> A bit unrelated, but it's weird that Medium doesn't seem to support embedded code, and instead only seems to work with gists. It made the mobile experience pretty bad (all I get are links to the gists) and it would definitely "pollute" my gist history with a lot of little code snippets
I agree.
> Am I the only one that was a bit disappointed to find it's a beginner introduction to the Mandelbrot set? The title led me to believe there was some modification or something new =/
I'm sorry; but if I had truly discovered a new fractal set, I probably wouldn't
be publishing it on Medium first. :) Mandelwat was just too good a pun.
> Somebody introduce this guy to the Mandlebulb.
The Mandlebulb blows my mind.
> I understand this is meant as a joke, but I also think that's part of the reason why Node became so big.
I agree.
> I feel like you're going to get far better pictures and faster results from language closer to the metal like C/Rust/Java(???).
Yes, this is self evidently correct. Did you even open the post? One of the first hyperlinks goes to the widget that I finished the project with, which uses WebGL to render ~60fps interactive zooms up to the limits of 32 bit floats: http://mandelbrot.jfo.click
Thank you all for reading, it is really awesome to be able to share something I just learned and am excited about with so many people!!
It's a nice documentary, though. Highly recommend it. They even have an interview with Benoit Mandelbrot himself, may he rest in peace.
Two years after that, I wrote my first Mandelbrot-renderer. First in Python, but that was waaaay too slow, then in C, which was a lot faster (duh!), and then I made it even faster by telling the compiler to use SSE. (To some, that sounds trivial, but it was something I had never done before.)
I have always suspected that it is like a rite of passage, building at least one simple-minded Mandelbrot renderer. I rewrote mine after two more years to take advantage of multiple threads and wrote another one to render the Buddhabrot[1]. Then I remembered an article I had read years before, about the Parallel Virtual Machine, PVM. So, the next weekend, I turned my Mandelbrot renderer into a distributed application.
So Kudos to the author. Tackling the Mandelbrot set has the dual advantage of being interesting and you can make pretty pictures along the way. It is great fun, and I learned a few things along the way. What more could I ask for?
[1] https://en.wikipedia.org/wiki/Buddhabrot