Ask HN: Where are the happiest engineers? - eric-hu

Title pretty much says it all.  A brief search on HN didn't reveal much. <comment><AUTHOR> Probably in the happiest countries:

[http://qz.com/390827/the-happiest-countries-in-the-world- ran...](http://qz.com/390827/the-happiest-countries-in-the-world-ranked/)

<comment><USER2> I would think that happy developer are located where interesting projects are, not where there is a more vacation days or whatever system ranks "quality of life" indexes.

<comment><AUTHOR> What makes "interesting projects" a good way to measure happiness? Within the workplace there must be many more factors that can influence happiness like relationships with coworkers and superiors, and then there's personal lives etc.

The world happiness reports come from the data in these surveys, they look at a lot of different things -

[http://www.gallup.com/poll/105226/world-poll- methodology.asp...](http://www.gallup.com/poll/105226/world-poll- methodology.aspx)

</comment></comment></comment><comment><USER3> At every other company.

Always.

No exceptions.</comment>


YC Startup School Live Notes - <AUTHOR> http://ryansrich.com/startup-school-notes

<comment><AUTHOR> Update: my computer died shortly after Andrew's talk with Jessica. I finished off the day with some old fashioned hand written notes. I'll transcribe those this evening and get them posted.

<comment><USER2> On behalf of HN and YC, thanks for doing this today! Your live stream filled in for our live stream, and a lot of people—including us—appreciated it.

<comment><AUTHOR> That's awesome! Glad you all enjoyed it.

</comment></comment></comment><comment><USER3> "I'm an age bigot." \- Ron Conway

A horrible attitude - one I thought was receding. To actively promote it is quite disturbing to me.

<comment><AUTHOR> For a bit of context. Ron was specifically speaking about VC partners that find and pick companies to invest in. He notes that the folks actually using these new products should be the ones deciding if they are worthwhile investments.

<comment><USER4> I was there as well this morning, and this is correct.

Ron C. added: "People in their 20s are the good pickers," and said he wants his investment team at SV Angel to recruit younger folks to join them by the time they hit 30 years old. He said that older and more experienced investors are better at giving advice to the companies they fund.

In other words, the "age bigot" quip refers to the people _picking_ the investments, not the people _receiving_ investments. I don't know what Ron C's views are about younger vs. older founders, and as far as I recall he didn't make them apparent today.

</comment></comment></comment><comment><USER5> Nice, I also came across a great collection of quotes from startup school collected on this blog: [https://medium.com/how-to-start-a- startup](https://medium.com/how-to-start-a-startup)

PG: [https://medium.com/how-to-start-a-startup/50-quotes-from- pau...](https://medium.com/how-to-start-a-startup/50-quotes-from-paul-graham- on-counterintuitive-parts-of-startups-and-how-to-have-ideas-4209154ff319)

Sam Altman: [https://medium.com/how-to-start-a-startup/47-quotes-from- sam...](https://medium.com/how-to-start-a-startup/47-quotes-from-sam-altman- on-startup-execution-4fa62de31e8d)

Peter Thiel: [https://medium.com/how-to-start-a-startup/32-quotes-from- pet...](https://medium.com/how-to-start-a-startup/32-quotes-from-peter-thiel- on-business-strategy-and-monopoly-theory-6025a479f1a7)

</comment><comment><USER6> This is great -- thanks for sharing :). But of you find these notes informational, I urge you to watch the videos themselves later when they're made available, since what will strike each of us as the greatest takeaways will differ pretty wildly depending on what stage of life we're in, which space we're interested in, etc. (Also, things like "they want to hire really smart 20 year olds) can be interpreted in a variety of ways since it's taken largely out of context of the greater discussion)

It obviously takes a much larger time commitment, but worth it IMO.

</comment><comment><USER7> Mine: [https://github.com/ashishb/startup_school_2014](https://github.com/ashishb/startup_school_2014)

</comment><comment><USER8> No notes on the office hours? Those were great not only in covering many important points but also showing what to expect in a possible YC interview.

<comment><AUTHOR> Sorry about that. My laptop ran out of juice. I was able to grab a bit of charge during the break but I doubt I'll have enough to finish out the day.

I'll be sure to type up my hand written notes and post sometime tomorrow or Monday.

<comment><USER9> Wan to borrow my laptop for a while to post the written notes? ;) I'm in the back.

</comment></comment></comment><comment><USER10> Thanks for sharing this! Really appreciate. (Feels like I'm in college and forgot to take notes during the class ;) )

</comment><comment><USER11> Anybody has links to videos for playback?

<comment><USER12> I guess YC will put them online on their youtube channel: [https://www.youtube.com/channel/UCcefcZRL2oaA_uBNeo5UOWg](https://www.youtube.com/channel/UCcefcZRL2oaA_uBNeo5UOWg)

For previous startup schools they released videos after a few weeks.

</comment></comment><comment><USER13> Thank's for doing this! Great to recap what happened after the event

</comment><comment><USER14> Thank you for doing that, I (and probably others) really appreciate.

</comment><comment><USER15> What did you all think of Andrew Mason's talk?

</comment><comment><USER16> Great work! Thanks.</comment>


Visual Cues Used to Evaluate Grasps from Images (2016) [pdf] - <AUTHOR> https://mws.is/2016ICRApaper.pdf <comment><AUTHOR> Just a note, I'm sharing this because it was my first brush with scientific research, and it got published at an international conference (ICRA)! I was a highschool student and it made me choose to major in cs.</comment>


Microship.com: The Library of Technomadics - <AUTHOR> https://microship.com/ <comment><USER2> This is the Computing Across America guy, Steven K. Roberts. I saw only that book cover online as a young computer enthusiast and was inspired. Here's a recent post from his blog and another article I found about his projects. Thanks for sharing.

[https://microship.com/digitizing-our- lives/](https://microship.com/digitizing-our-lives/)

[https://hackaday.com/2009/09/18/vintage-video-computing- acro...](https://hackaday.com/2009/09/18/vintage-video-computing-across- america/)

<comment><USER3> I met him at Dayton shortly after the book came out. He was a geek among geeks.

</comment></comment><comment><USER4> This site is wild. Such absolute, passionate geekery - it's beautiful.

The name annoys me endlessly though. I also live on a boat, Microship, which was named without checking domain availability.

For anyone who enjoys endless engineering rabbit holes, I'd highly recommend boat life. It's quite the ride.

<comment><USER5> Hey, another HN liveaboard! I live on my 10m steel cabin cruiser in the Netherlands that I built myself from a bare hull :) I'll put up some photos if anyone's interested.

Where in the world do you liveaboard, and what do you live on, if you don't mind me asking?

Any other liveaboards here on HN? We should form a club :)

(and I completely agree, microship.com is incredible!)

<comment><USER4> Nice! I'm on a rather odd looking ~11m steel power cat in Australia.

Currently rebuilding it from the hull with my partner. Built like a tank and a lot of fun to quite literally hack on.

I'll eventually get around to putting together an engineering blog for some of the projects, but the domain just points to an instagram account with high level summaries for now: [https://ourtinyboat.com](https://ourtinyboat.com).

</comment></comment></comment><comment><USER6> I aspire to have a mobile lab as cool as Steve's.

I have known Steve since the Winnebiko days, I met him at a conference and later Sun Labs hosted his lab efforts so I got a chance to work with him on various mobility ideas. It was always inspiring to just brainstorm about things. He started using fiber glass covered cardboard for the bike 'bags' and I used the same technique to build a helmet / grocery box for my scooter.

If civilization collapses you want him on your team :-)

</comment><comment><USER7> This is one of the first websites I accessed in my life!

Discovery Channel used to have a show about the internet in the 90s where it featured this guy and his bicycle, and the name stuck with me. So when I finally bought a modem it was one of the sites I accessed.

I even remember linking it from my personal website back in 1996 or 1997.

Here's the video: [https://microship.com/microship-project-on-cyberlife- discove...](https://microship.com/microship-project-on-cyberlife-discovery- channel-1996/)

<comment><USER8> Wow, the Internet Archive has it every year back to 97. Don't usually see that.

[https://web.archive.org/web/*/https://microship.com/](https://web.archive.org/web/*/https://microship.com/)

<comment><USER9> We try! :-)

</comment></comment></comment><comment><USER10> It seems that most of his bespoke designs didn't lend themselves to reuse and further refinement. There was no open source community to maintain and advance his inventions and no manufacturer seems to have come out with things like touch-based security systems or watercooled helmets.

Maybe this kind of geekery is dead anyway; overshadowed by the startup dream, bought up wholesale by FAANG salaries and crushed by the threat of a whiteboard job interview?

</comment><comment><USER11> How do you get into having a life like this? Is it just building a passion project / idea then expanding if others enjoy + sponsor it.

It seems like he was the main dude on everything from construction to software.

I assume this would also mean getting an MS or PhD to be able to teach college courses?

<comment><USER12> > How do you get into having a life like this?

Stay single and childless ;-)

</comment></comment><comment><USER13> I remember reading about his bike in, I think, Wired magazine when I was growing up in the 90's. Very inspiring.

Now he lives on a boat and appears to have a better equipped (and better organised) lab and workshop than I do living in a house. Still inspiring 30 years later.

</comment><comment><USER14> Steven K. Roberts is amazing. He was very influential on my ideas around technology when I was about 12. Super awesome guy. Never afraid of living on the bleeding edge

</comment><comment><USER15> Considering the amount of anxiety reading about this type of lifestyle induces in me, shows how much of a fear of unknown some of us live in perpetually.

<comment><USER16> I totally relate to that. What slowly changed me was travel. Each time I travelled expanded my comfort zone...and the early trips were just normal things like visiting family and nearby towns for working a part time side job.

Though a reason it worked for me might be that I did not travel to be pampered or in quest of luxury. So the explicit differences were mostly ordinary equivalencies not level of service oriented.

</comment></comment><comment><USER17> Thanks for posting this reminder. I never met Roberts but whenever I lead a tour at the Computer History Museum I walk by the Winnebiko. It's on display there, looking just like the top left picture on the above page. (Also, I have spent a lot of time in Friday Harbor so can attest he's chosen a lovely place to settle.)</comment>


How to Start Learning Computer Graphics Programming - <AUTHOR> https://erkaman.github.io/posts/beginner_computer_graphics.html <comment><USER2> For anyone looking for a great starter codebase that you can poke around in to learn the fundamentals of CG, check out Scotty3D [0], the base code for CMU's computer graphics class 15-462/662 (I am a TA for this class). It is a supplemental codebase to the lecture slides [1], which are all available online. The idea is that Scotty3D is a full 3D modeling suite akin to Blender or Maya, but all of the actual functionality is stripped out, waiting to be implemented by students.

It includes code for 3D model loading, linear algebra, basic (OpenGL) rendering, and UX, and provides stubs for you to implement:

        - local geometry operations (ex: edge split,
          vertex/edge/face bevel, vertex/edge/face delete, etc)
        - global geometry operations (ex: upsampling via catmull
          clark subdivision, downsampling using quadric error, etc)
        - a path tracer that supports Diffuse/Mirror/Glass
          materials with Fresnel reflections and environment
          lighting (ex: you can render the cornell box)
        - an animation suite that implements skinning, spline
          interpolation, and basic simulation (wave sims)

There's a lot of documentation in the wiki [2] to help you get started. A great resource, even if you can't take the class yourself!

[0] [https://github.com/cmu462/Scotty3D](https://github.com/cmu462/Scotty3D)

[1] [http://15462.courses.cs.cmu.edu/fall2018/lectures](http://15462.courses.cs.cmu.edu/fall2018/lectures)

[2] [https://github.com/cmu462/Scotty3D/wiki](https://github.com/cmu462/Scotty3D/wiki)

<comment><USER3> Ah, the good old OpenGL fixed function pipeline, deprecated for over 11 years now.

For something a bit more modern, I'd recommend [0], but one might argue that old OpenGL is easier to learn since you don't have to setup your own shaders.

[0] [https://learnopengl.com/Introduction](https://learnopengl.com/Introduction)

<comment><USER4> There's something charming and engaging about the "legacy" fixed function pipeline that we've lost with our increasing focus on lower and lower level APIs. The ability to have a 10 line hello-world program that draws a colored triangle on the screen is magical, and encouraging to beginners, and that experience can't be replaced by the massive boilerplate and "copy-paste-this- stuff-dont-worry-about-what-it-does-yet" you need to do in order to do graphics the more modern way.

With Apple working to eliminate all traces of OpenGL with Metal, and Microsoft already having abandoned it close to two decades ago, I feel it's close to the end of the road for fixed function OpenGL. It was a wonderful part of graphics development history that, sadly, future beginners will likely not be able to experience.

<comment><USER5> One more instance of how the interests of vendors and the interests of developers are not aligned. Microsoft and Apple don't want you learning portable skills -- they want to limit your future prospects to developing only for their specific platform.

<comment><USER6> noob here - how come no one is making a cross platform API to abstract away this stuff? whenever i read about opengl or vulkan or metal or whatever w/ the tutorial going "learn this engine to bypass complexities of bare api usage", it's my first thought

<comment><USER7> > noob here - how come no one is making a cross platform API to abstract away > this stuff?

... but there are hundred of cross-platform APIs to abstract this stuff - unity3d, unreal engine, qt3d, etc...

<comment><USER8> Unity or Unreal aren't 3D rendering APIs, they're game engines

</comment></comment></comment></comment></comment></comment></comment><comment><USER9> I think the author of this guide doesn't remember the mindset that a beginner is in when they first start learning graphics programming (or really any subject).

Why is someone reading this tutorial in the first place? It's likely because they have some end goal in mind, and are looking to get from 0 to that goal as quickly as possible. For most readers, this is probably making a game. Following the advice of this guide will give the reader a deep understanding of how 3d graphics works, but it won't bring them much closer to making a game than they were when they started.

Why am I bothering to point this out? Because countless guides like this exist that confuse neophytes into believing that the subject they wish to learn is difficult and requires learning countless prerequisites before they can get started tangibly moving towards their goal. It's demotivating. A lot of the knowledge in this guide is good to know but ultimately not immediately relevant to someone seeking to achieve some higher level graphics goal. It feels like the equivalent of trying to teach someone programming by starting them at assembly.

I personally think that this guide should be directed towards someone who has had experience noodling around with OpenGL or a game engine and wants to reach the next level. In order for any of the lessons this guide wishes to teach to be impactful, the reader needs the necessary context to understand why learning them is relevant to 3d graphics and by extension the reader's end goal. Starting off by making a ray tracer is a cool idea for example, but does the author honestly believe that it's more useful than just learning OpenGL first? It might be more "confusing", but they're going to have to learn OpenGL (or some game engine) at some point whether they want to or not if their goal is to make a game.

<comment><USER10> It depends on what you mean by "graphics programming". If that means "implement a game on top of a tall stack of abstractions" then sure, this isn't the answer you're looking for, but I'd call that "game programming".

If "graphics programming" is implementing the rendering engine for the game (recall his final goal is "draw a triangle"), I believe his point is that it's easier to learn the required APIs for that if you understand the concepts behind them first (rather than just leaping into meaningless copypasta), and the best way to learn those concepts is to work with them directly.

</comment></comment><comment><USER11> Start with WebGL, Shadertoy.com, and jsfiddle.net.

No other tooling needed until you've got the basics of vertex buffers and shaders down.

(20 year graphics veteran here who's boostrapped some coworkers)

<comment><USER12> What about 2D graphics? Sprites? Old school stuff? I keep meaning to fire up DOSBox-X and go through some old tutorials. I really just want to put pixels on the screen and work my way up from there - everything else just seems to get in the way.

<comment><USER13> Personally I'd recommend grabbing an old copy of qbasic with dosbox and going to town on some old tutorials here [http://www.petesqbsite.com/sections/tutorials/graphics.shtml](http://www.petesqbsite.com/sections/tutorials/graphics.shtml)

I know some would say it's a bad language, but back in the day it was incredibly accessible and spawned a lot of shared code and tutorials. If you focus on the techniques and algorithms, treat the language as pseudocode rather than "the right way to do things", you can have a lot of fun and learn quickly things you can translate to whatever your language of choice is.

<comment><USER14> I think most of those will work on QB64, too. So you could end up end with fast, native executable files on Windows, MacOS, and Linux. That doesn't matter much for those tutorials, but QB64 might be ever so slightly quicker to get up and running than DosBox + QBasic.

<comment><USER13> Great point! I had forgotten about QB64. Heck, I may give it a go myself. This thread gave me an itch for software rendering again.

</comment></comment></comment></comment></comment><comment><USER15> It depends on your motivation but if you really want to learn about graphics programming (as opposed to learning an API) then I think the best way to do so is to remove any API from the picture. There is an absolutely phenomenal book that does just this: Andre LaMothe's 'Tricks of the 3D Game Programming Gurus'. It was published in 2003 but when you remove APIs from the picture it's just as relevant today and will remain so for the foreseeable future.

The book starts with little more than plotting a pixel on the screen. By the end you'll have a complete lit, shaded, 3D game engine that you've written entirely from scratch. And in the process you will learn absolutely everything that goes into it.

And one thing I'd add is that this might sound somewhat overwhelming but it's really not. The book is extremely well written and clearly was a labor of love. If you get some pleasure out of math and code, you'll have no technical troubles working your way through the book and in the end will be rewarded with an intimate, flexible understanding of graphics development that won't be hamstrung by dependence on a specific API.

[1] - [https://www.amazon.com/Tricks-Programming-Gurus-Advanced- Gra...](https://www.amazon.com/Tricks-Programming-Gurus-Advanced-Graphics- Rasterization/dp/0672318350)

</comment><comment><USER16> I will highly recommend ray tracing in weekend [http://www.realtimerendering.com/raytracing/Ray%20Tracing%20...](http://www.realtimerendering.com/raytracing/Ray%20Tracing%20in%20a%20Weekend.pdf)

<comment><USER17> +1 The author released all the "ray tracing in a weekend" pdfs last year through a "pay what you want" model: [https://twitter.com/Peter_shirley/status/984947257035243520](https://twitter.com/Peter_shirley/status/984947257035243520)

<comment><USER18> They're all in a google drive (hosted my Shirley). It was previously shared on HN.

[https://drive.google.com/drive/folders/14yayBb9XiL16lmuhbYhh...](https://drive.google.com/drive/folders/14yayBb9XiL16lmuhbYhhvea8mKUUK77W)

</comment></comment></comment><comment><USER19> I've been learning (mostly 2D) graphics as my side project for a couple years now. I spend a ton of time on this project. I still feel like a beginner. It is one of the more complex topics I've ever delved into.

I've crawled through more topics than I can list here. Many of them were not easy to learn, due to disorganized learning resources and materials.

Documentation and information is scattered, frequently outdated, sometimes sparse, and just downright messy. OpenGL and its many quirks and legacy versions muddy the waters too. I've considered trying to pull this into one big guide, hopefully resulting in something like the Filament docs [1].

Side note: macOS (my dev env) is a terrible place to write OpenGL, I've learned. Debugging tools are practically non-existent.

[1] [https://google.github.io/filament/Filament.md.html](https://google.github.io/filament/Filament.md.html)

</comment><comment><USER20> The most incredible educational experience of my life was this course I did at Columbia University while in High School on game programming. At the end of the course we made our own game with OpenGL, but for the first week or so we'd have basically math classes in the morning on he physics of lighting, and then in the afternoon we'd implement the things we did in C. It was where I was introduced to lots of math concepts, including vector math that I would not see in school for another year or so.

At any rate, at the end we built our own raytracer, and say a text file with vertices that was given to us produce an image on the screen from 100% code that we'd written ourselves. It was one of the most empowering, deep intellectual experiences I've ever had.

<comment><USER21> Out of interest, does learning linear algebra in this way give you a deeper sense of linear algebra? Do you think you think you are able to formulate other problems more effectively in terms of LA as a result?

<comment><USER20> Absolutely. Like, for the average school kid learning about vector multiplication or dot products of things of this kind are so abstract and seem kinda pointless. But the way he taught it, we had a problem in terms of making things look real. And the math was motivated as a strategy to solving those issues. Based on the real world problem, it was great to develop intuition for the results.

</comment></comment></comment><comment><USER22> I enjoyed going through The Book of Shaders[1] by Patricio Gonzalez Vivo. It comes with an interactive programming environment that's great if you're just getting started.

It's free but please consider donating if you find it useful.

[1] [https://thebookofshaders.com/](https://thebookofshaders.com/)

</comment><comment><USER23> 3Blue1Brown has a great series on Linear Algebra. His explanations are so clear that by the 2nd or 3rd video you'll already understand how it applies to computer graphics.

[https://youtu.be/fNk_zzaMoSs](https://youtu.be/fNk_zzaMoSs)

<comment><USER24> I agree. I've had quite a bit of exposure to linear algebra through other textbooks and online courses, and the 3Blue1Brown series explains the intuition better than just about anyone. In particular, the video on determinants really crystallized the concept for me.

</comment></comment><comment><USER25> I picked up graphics maybe three years ago and have been mostly learnt all the stuff I needed through different sites scattered all over the internet.

For ray tracing Peter Shirleys books are very good.

OpenGL stuff are usually found at docs.gl, [https://learnopengl.com/About](https://learnopengl.com/About).

For Physically Based Rendering (PBR) material checkout the bool Real-time Rendering and all the cool stuff has been coming out of Siggraph these past years, [https://blog.selfshadow.com/publications/s2013-shading- cours...](https://blog.selfshadow.com/publications/s2013-shading-course/).

If you can, go take an elementary linear algebra course or prepare to spend time studying these. It is well worth it.

One thing I have found when hacking on my own engine (see here: [https://github.com/Entalpi/MeineKraft](https://github.com/Entalpi/MeineKraft)) is that graphics APIs (especially OpenGL) can have a lot of hidden meanings or even old names still being used, etc. Try to find out how the API evolved and get the reasoning behind the design decisions. This way it makes more sense and it gets a bit easier to learn.

GLHF

</comment><comment><USER26> Shameless self-promotion:

On my YouTube channel, I have over 100 WebGL Tutorial videos, and over 50 3d math related videos.

[https://www.youtube.com/user/iamdavidwparker](https://www.youtube.com/user/iamdavidwparker)

</comment><comment><USER27> The single most helpful thing I discovered for _learning_ android opengl es graphics programming is that it _does_ have error messages, after all! [abbrev code, use to lookup docs]

      int error;
        while((error=GLES20.glGetError())!=GLES20.GL_NO_ERROR) {
        msg += android.opengl.GLU.gluErrorString(error);
      }

Also, the offical android opengl es 2.0 tutorial is wrong in subtle ways (after the non-subtle wrongnesses were corrected).

TIL "advice" can be countable: [https://blog.oxforddictionaries.com/2014/05/30/advise- advice...](https://blog.oxforddictionaries.com/2014/05/30/advise-advice/)

> _Advice_ is mainly used with the first meaning, and in this meaning it is a > mass noun (that is, it has no plural). The business/legal meaning, however, > is a count noun: it has a plural form, _advices_.

<comment><USER28> When getting started with a new OpenGL project, the first thing you should do is to enable the debug output [0] w/ glDebugMessageCallback. You also need to enable the debug bit when creating a GL context.

This will give you human readable error messages (as in complete sentences of what went wrong) as well as some other info to pinpoint what went wrong and where.

Additionally, it's a good idea to use Renderdoc [1] or your $GPU_VENDOR's debugging and profiling tools.

[0] [https://www.khronos.org/opengl/wiki/Debug_Output](https://www.khronos.org/opengl/wiki/Debug_Output) [1] [https://renderdoc.org/](https://renderdoc.org/)

<comment><USER27> Good to know about! For openGL ES, it looks like it wasn't implemented until version 3.2, the most recent (I don't have a device with that version).

[https://developer.android.com/reference/android/opengl/GLES3...](https://developer.android.com/reference/android/opengl/GLES32.html#glDebugMessageCallback\(android.opengl.GLES32.DebugProc\))

</comment></comment></comment><comment><USER29> If anyone wants to play around with Computational Geometry and Python, I'd recommend as a great starting point: [http://blancosilva.github.io/post/2014/10/28/Computational-G...](http://blancosilva.github.io/post/2014/10/28/Computational- Geometry-in-Python.html)

Also, Apress has a cool book about Python and graphics with some pretty intense source code found here: [https://github.com/Apress/python- graphics](https://github.com/Apress/python-graphics)

<comment><USER29> quick note on the first link...I think graphs are done using tikz: [http://blancosilva.github.io/post/2010/12/12/using-tikz- as-a...](http://blancosilva.github.io/post/2010/12/12/using-tikz-as-an- igse.html)

</comment></comment><comment><USER30> Here is my work in progress for intro OpenGL programming

[http://billsix.github.io/modelviewprojection/](http://billsix.github.io/modelviewprojection/)

It in python, doesn't involve matrices. It really only requires high school math, with the exception of the z axis.

Hope it's helpful!

</comment><comment><USER31> Jamis Buck has a new-ish book out called "The Ray Tracer Challenge" that I've been slowly working through.

So far I really like the way it's written: everything is test-based, so you get a problem like: "given matrix X and vector Y, X * Y should be vector Z" and then you implement both the test and the code in whatever language you like.

[https://pragprog.com/book/jbtracer/the-ray-tracer- challenge](https://pragprog.com/book/jbtracer/the-ray-tracer-challenge)

</comment><comment><USER32> There are so many comments here missing the point saying "why? just use "X" API" or "this is a waste of time when you will need 'X' API anyway" etc. but they miss the point. It's about 'how' graphics work, not building game engines.

Computer graphics is more about producing an image on a computer screen and whether it's for image processing or a game engine renderer it's the same process and very useful to know whichever field you want to pursue.

</comment><comment><USER33> I would love to see a similar "jumping off point" for audio programming. Anybody know of one?

<comment><USER34> This is my own limited experience, so I hope an expert also answers. In the Handmade Hero video series/project, he codes a game engine from scratch. I didn't get very far into it, but I followed along coding it myself, using what I learned watching him. He writes it in a way that all the platform-specific code is in its own file, and he does it in DirectX, although other people have ported it to other platforms. Early in the series, he gets it to where you can create a sound buffer of samples and play it out to the speakers. So I played around with simply adding sine waves to generate things such as dial tones, busy signals, and DTMF dialing sounds. I would consider that "ground up" for the Windows platform. It should be pretty simple from there to load audio samples from files, adjust their volume, play them back faster/slower, and mix them together. And/or generate more complicated sythensized music. There is a book about building modular synthesizers, and I was thinking about using that but doing it in software.

<comment><USER35> The best motivator for me was to start building a Standard MIDI Format sequencer and test its output on MIDI files. The underlying MIDI standard is a well-understood protocol with many resources, while SMF adds some room for creative interpretation since it's meant to work across sample-based synths, FM, etc. I started with a simple square-wave beeper, added polyphony and volume envelopes, and built it up from there. By the end, the architecture I had initially built was melting down, but it was playing Soundfonts to some degree, and I could confidently claim to understand audio coding.

There's a lot of room to do things incorrectly and not notice in audio, which makes it forgiving to learn: e.g. playing a sample at a different pitch can be done badly by adding or removing arbitrary samples, but resampling it with minimal distortion is actually a fairly intensive DSP problem. Or when computing a volume, the linear amplitude usually isn't the parameter you want to work with(see every UI where volume changes imperceptibly until you reach the bottom 10% of the slider), and while there are computations to convert between linear and dB values, you still have to qualify it with one of these various references and suffixes[0]. There's a lot of crossover between audio and electrical signal terminology that can make it hard to follow this material.

So you can spend a lot of time doing simple things well!

[0] [https://en.wikipedia.org/wiki/Decibel#Voltage](https://en.wikipedia.org/wiki/Decibel#Voltage)

<comment><USER34> Very cool! Thank you! That gives me a lot more ideas.

</comment></comment></comment></comment><comment><USER36> The best way to learn computer graphics programming is to first ask what you want to do with it. Most people interested in this topic have some end goal, be it just writing a game. In that case, writing raytracers and rasterizers may just be a waste of time, when the main interest isn't the interworkings of math, but to put something up the screen. For a reasonably wide range of modern tools, its absolutely not necessary to know any deep math to bring to screen what you want.

</comment><comment><USER37> Start with [https://webglfundamentals.org](https://webglfundamentals.org) ?

</comment><comment><USER38> Scratchapixel[1] is also a helpful resource for explaining the basic concepts.

[1] [http://www.scratchapixel.com/](http://www.scratchapixel.com/)

</comment><comment><USER39> I'll plug the materials for the one-weekend class I taught on computer graphics: [https://avik-das.github.io/build-your-own-raytracer/](https://avik- das.github.io/build-your-own-raytracer/)

I didn't assume a particular mathematical background for the students, so I introduced the relevant math in what I hope was a motivated way. Hopefully it can help others as well.

</comment><comment><USER40> My very first raytracer was [http://canonical.org/~kragen/sw/aspmisc/my-very- first-raytra...](http://canonical.org/~kragen/sw/aspmisc/my-very-first- raytracer.html) and was quite a bit easier than I expected. My second one was a bit under 1K in Clojure: [http://canonical.org/~kragen/sw/dev3/raytracer1k.clj](http://canonical.org/~kragen/sw/dev3/raytracer1k.clj) or unobfuscated: [http://canonical.org/~kragen/sw/dev3/circle.clj](http://canonical.org/~kragen/sw/dev3/circle.clj)

I was pleasantly surprised by how easy it was to compute the pixels, but getting them on the screen was a huge hassle. So I wrote [https://gitlab.com/kragen/bubbleos/tree/master/yeso](https://gitlab.com/kragen/bubbleos/tree/master/yeso) to make it trivial. I haven't ported a raytracer to it yet; I'll do that soon!

</comment><comment><USER32> Thanks for the extra links, I'm building a base software rendering engine in Go just for this purpose. It still needs work to get to a good 'base' but it can be used as is to start learning CG from your notes and links. [https://github.com/MickDuprez/go-window](https://github.com/MickDuprez/go- window) cheers.

</comment><comment><USER41> I invite everyone to try all of these techniques and math tools in ShaderGif [42]. Hopefully you'll learn and make nice gifs in the process. Learning new math concepts is even better when you create art and share it after!

[42] [https://shadergif.com/](https://shadergif.com/)

</comment><comment><USER42> I've always been a fan of the NeHe GL tutorials. I learned programming starting with these 'back in the day' and really enjoyed it. Its modernized now but still maintained.

[http://nehe.gamedev.net/](http://nehe.gamedev.net/)

</comment><comment><USER43> I don't think the hindrance when starting to learn graphics programming is the math or the lack of ideas of what to build. The biggest problem is that the most known APIs (DirectX, OpenGL and especially DirectX 12 and Vulkan) are so badly designed and so poorly documented that it deters anyone trying to start doing anything. All these API are like magic invocation you have to make the calls in just the right order or it doesn't work at all. There is no real specification of what goes underneath and it can't be because the actual implementation is written by different vendors (Nvidia or AMD) which only slightly abides to the specification.

</comment><comment><USER44> This is the old-line "bottom up" approach.

It might be more appropriate today to work top down. Install Unreal Engine, build a simple demo, and look at the code it generated and you can modify.

<comment><USER45> Zero graphics experience, so I may be asking an idiotic question, but why learn anything other than a framework like UE?

I'm a web guy, so all I know is frameworks (Angular, React, etc.).

<comment><USER46> You'll ultimately become a better dev (e.g. higher quality code, faster, and more maintainable) as you learn more of the underlying stuff. For web dev definitely learn how to do everything in "vanilla" js, html, and css at least a few times.

</comment></comment></comment><comment><USER47> fwiw, pbrt can be read online for free since earlier last year: [http://www.pbr-book.org/](http://www.pbr-book.org/)

</comment><comment><USER48> I think this article, and the comments here, are a splendid example of how deep (and often confusing) 3D graphics can be.

One of the things I appreciated about the Glide3D API for the old VooDoo cards back in the day was how basic it was relative to the work of getting the 3D stuff on the screen.

There are several ways in which you can "learn" 3D graphics; You can get it by theory, you can get it by API, and you can get it by modelling.

If you're someone who is a theory person you should start at the beginning and learn linear algebra and vector arithmetic. You can learn about projections, and camera "views" and project your 3D scene onto a 2D surface whether it is a computer screen or a plotter page. Once you get there you can then do hidden line, and then hidden surface removal. You can learn about the 'Z' plane and the clipping frustrum which lets you not worry about things that won't appear in your projection. With a relatively simple array of coordinates type data structure you can project triangles or NURBs onto your surface and draw pretty pictures. Then you can start learning about light and all the many ways it interacts with materials. At the end of this journey you can take a 3D model and render it in a photorealistic way, one frame at a time.

The second way to learn 3D programming is the API path. Here you don't really learn too much of the math, although having that background will help you understand what the functions are doing. You learn an API like Unity or Vulkan. These APIs have taken a lot the basic 3D programming and done it for you, you need to learn how to write shaders which decorate your surfaces in ways that simulate light or water or fog Etc. Generally you construct a scene with calls to set up the frame, and then call 'render' with the appropriate screen resource referenced. Blam! instant 3D scene.

The third way you might come at this is modelling things, building models in Maya or some other modelling tool that are built with skeletons, which is simply a data structure that identifies how different parts of the model can move in relation to other parts. You probably don't have to know anything about 3D math, but you have to have a good eye for construction of the models and the area in which those models are placed.

There are so many ways to go at this particular quest, each have their own challenges and rewards.

</comment><comment><USER49> If anyone would like to see ray tracer code, have a look at pov-ray [http://povray.org](http://povray.org) Its a venerable old ray tracer but has some of the best features around and the code is very readable (once you've got the basics). It's a different way to do things than the vertex/shader style rendering pipeline.

</comment><comment><USER50> For anybody looking for a minimal cross-plateforme _modern_ OpenGL hello world with a lot of comments: [https://github.com/eliemichel/AugenLight](https://github.com/eliemichel/AugenLight)

By _modern_ I mean as in OpenGL 4.5 Core Profile, using future-oriented APIs (e.g. named buffers). Any feedback welcome!

</comment><comment><USER51> I'm always on the lookout for tutorials that go deeper than just implementing single one off things. Been meaning to go through Handmade Hero.

[https://www.youtube.com/user/handmadeheroarchive/videos](https://www.youtube.com/user/handmadeheroarchive/videos)

</comment><comment><USER52> I'm currently enrolled in an online Computer Graphics course on edX that has been an excellent introduction to the subject: [https://www.edx.org/course/computer- graphics](https://www.edx.org/course/computer-graphics)

</comment><comment><USER53> I've found SFML an easy way to get some stuff on the screen in 2D.

As far as true 3D graphics, I made a Minecraft clone using OpenGL... it was a nice project as, surprisingly, you end up using all the basic techniques as you tweak it, particularly when you try to get lighting and shadows working.

</comment><comment><USER54> I'd definitely second the ray tracer recommendation, starting from a 2D canvas and building a ray tracer to render a shaded sphere was really an "ah-ha" moment, as the math is quite approachable and you can get a cool result with not much more than some trigonometry.

</comment><comment><USER55> This sounds good for those who want to learn graphics programming for gaming and / or for animation etc. But where should a beginner start from to learn GUI programming without using existing frameworks or widget toolkits?

</comment><comment><USER56> The article says "How to start" but it's more like "What to start with". Anyway, I'll really like to have a reference for good computer graphics lecture videos which I am failing to find

</comment><comment><USER57> I found myself having to remember how to do matrix calculations. Before I could count to 100 I was going back and back until I was reviewing basic math on the Khan Academy. Embarrassing but that is where to start.

</comment><comment><USER58> Is it worth it to get into this area as an experienced dev?

</comment><comment><USER59> Does anyone know something similar but for data projects/science? Preferably something with practical data, not just the math.

<comment><USER60> I've heard good things about Andrew Ng's Coursera machine learning class, and it's free:

[https://www.coursera.org/learn/machine- learning](https://www.coursera.org/learn/machine-learning)

There is a free intro to data science class on Udacity as well:

[https://www.udacity.com/course/intro-to-data-science-- ud359](https://www.udacity.com/course/intro-to-data-science--ud359)

Lastly, there's always Kaggle, which has plenty of resources to learn from, and competitions as well:

[https://www.kaggle.com/](https://www.kaggle.com/)

<comment><USER61> I can vouch for Andrew Ng's class. Its really top notch.

</comment></comment></comment><comment><USER62> [https://open.gl](https://open.gl) is the best OpenGL tutorial IMO.

</comment><comment><USER63> Well, i was waiting for some starting graphics programming guide.

</comment><comment><USER64> Raytracing and Rasterization sounds so cool :D

</comment><comment><USER65> A smart idea, i like it</comment>


Clojure from the ground-up: debugging - momo-reina https://aphyr.com/posts/319-clojure-from-the-ground-up-debugging

<comment><AUTHOR> Kyle's suggestions have a ton of value, but do note that debugging Clojure(Script) can also be a pedestrian activity if you so desire. All the usual mainstream bell/whistles IDE-based interactive debugging is available today in CursiveClojure - break on all exceptions, eval in frame, etc.

Also ClojureScript has had accurate source mapping in Safari, Chrome, Firefox, and Node.js for quite a long time now and recently moved to support targets like iOS. It's a huge time saver even for an experienced Clojure programmer :)

<comment><USER2> And if you favour open source IDEs the Eclipse based Counterclockwise [http://doc.ccw-ide.org/](http://doc.ccw-ide.org/) will provide the same debugging experience for Clojure.

<comment><USER3> I love ccw as a coding tool and the full editor repl is great too but I haven't been able to get breakpoints to work on it ever. Another thing that irks me about it lately is no real clojurescript support! That said it is still my primary clojure tool and things like figwheel help close the gap.

</comment></comment></comment><comment><USER4> I'm trying so hard to love Clojure, but I keep running into examples of code like this in the world: [http://imgur.com/79FlpTL](http://imgur.com/79FlpTL). I don't write dense Lisp code like that, but unfortunately a lot of other people do. And I spend far more time reading code than writing it.

<comment><AUTHOR> Well that code seems pretty readable to me and appears to preserve some interesting properties of the original paper as mentioned below the source :)

As far as spending more time reading Clojure than writing it I experience this myself - and I'm pretty sure this isn't a bad thing.

<comment><USER4> I meant that in general, we as programmers will spend more time reading (our, others') code than writing it. Nature of the business. Did not mean to imply this was a bad thing.

When I consider adopting a language, part of that consideration is how well I can read others' idiomatic code. It's so important for understanding libraries. I'm still just having a hard time with Clojure. I know it clicks for a lot of people though.

</comment></comment></comment><comment><USER5> Error messages and stack traces look pretty ugly.

In Common Lisp:

        CL-USER 51 > (bake (make-instance 'pie :flavor :blackberry) 375 10.25)

        Error: The value 3843.75 of #:|predicate1555| is not a predicate in CONDP.
          1 (continue) Supply a new value of #:|predicate1555|.
          2 (abort) Return to level 0.
          3 Return to top loop level 0.

A clear error message and a way to repair it.

A stack frame:

        Call to BAKE {offset 394}
          PIE               : #<PIE 402000993B>
          TEMP              : 375
          TIME              : 10.25
          DBG::|predicate|  : 3843.75
          DBG::|expression| : #<Function < 411007995C>
          DBG::G            : 3843.75

<comment><USER6> Which CL is that?

<comment><USER5> LispWorks, the one Rich Hickey used for quite some time... ;-)

<comment><USER6> Yeah, I feared that. That's the paid-for one, isn't it?

</comment></comment></comment></comment><comment><USER5> SBCL at compile time:

        * (defun bake (pie temp time)
          "Bakes a cake for a certain amount of time, returning a cake with a new
          :tastiness level."
          (setf (tastiness pie)
                (condp (* temp time) #'<
                       (400 :burned)
                       (350 :perfect)
                       (300 :soggy))))
        ; in: DEFUN BAKE
        ;     (CONDP (* TEMP TIME)
        ;         #'<
        ;       (400 :BURNED)
        ;       (350 :PERFECT)
        ;       (300 :SOGGY))
        ; ==>
        ;   (LET ((#:PREDICATE2 (* TEMP TIME)) (#:EXPRESSION3 #'<))
        ;     (DECLARE (TYPE FUNCTION #:PREDICATE2))
        ;     (CHECK-TYPE #:PREDICATE2 FUNCTION "a predicate in CONDP")
        ;     (COND ((FUNCALL #:PREDICATE2 #:EXPRESSION3 400) :BURNED)
        ;           ((FUNCALL #:PREDICATE2 #:EXPRESSION3 350) :PERFECT)
        ;           ((FUNCALL #:PREDICATE2 #:EXPRESSION3 300) :SOGGY)))
        ;
        ; caught WARNING:
        ;   Derived type of (* TEMP TIME) is
        ;     (VALUES NUMBER &OPTIONAL),
        ;   conflicting with its asserted type
        ;     FUNCTION.
        ;   See also:
        ;     The SBCL Manual, Node "Handling of Types"
        ;
        ; compilation unit finished
        ;   caught 1 WARNING condition

Pretty cool...

</comment><comment><USER7> Does anyone know what color theme those code boxes use?

I apologize for being so shallow :)</comment>


Ask HN: How can I get into Software without absolutely 0 experience? - <AUTHOR> I am currently a Mortgage Banker. Completely burned out. I need change. How can I break into an entry level Software position immediately with 0 experience? I have 0 savings, so going back to school is out of the question. It is also not plausible to learn on nights/weekends. I need to be able to quit my current job and take a paycut; I am OK with that. Just want to get out while my sanity is in tact.<p>Help? <comment><USER2> Are you talking about software development? If that's the case like any career it's hard to just jump into a position with no knowledge of what you will be doing. Programming isn't something that you can just find a job in overnight. I would suggest attempting to spend some time at least on [https://www.codecademy.com/](https://www.codecademy.com/) learning to code with any time that you can spare. You don't necessarily need a degree to get a job as a software developer but you will for sure at least need to know the basics and learn the concepts of software development. Do a lot of googling and learning to code. Create a few side projects to put on a resume to show that you at least are able to produce results which an employer will want to see. If you're not able to spend anytime with learning then why even look for another career?

</comment><comment><USER3> You should first make sure this is really what you want to do.

It isn't glamorous. The pay is highly variable. The hours can be long and stressful.

There are definitely only certain people who enjoy this kind of work and have the aptitude for it.

</comment><comment><USER4> If you can afford to take a pay cut, you can afford to spend less for a few months at current salary to build up some savings. Then you'll have more options.</comment>


A Universe in One Line of Code with 10 PRINT - <AUTHOR> https://www.makeartwithpython.com/blog/10-print-in-python/ <comment><USER2> This has me reflecting on how I learned to program, compared to how people learn to program today.

I learned to program using BASIC when I was between 5 and 10 years old. My dad was a software engineer at DEC, and he had a kit computer in our basement that he let us play with once in a while. My first program was a number-guessing game, and it went something like this:

        10  NUMBER = 23
        20  PRINT "I'm thinking of a number."
        30  INPUT "Make a guess: " $GUESS
        40  IF GUESS < NUMBER THEN
        50    PRINT "Too low!"
        60    GOTO 30
        70  ELSEIF GUESS > NUMBER THEN
        80    PRINT "Too high!"
        90    GOTO 30
        100 PRINT "You got it!"

That was pretty straightforward, because everything about it was linear except for the GOTOs. You can think about each step with very little planning, and when you need a break in program flow you can use a GOTO. It also means when teaching, you can introduce each new concept as the need arises: store a value, print a statement, prompt for input, check a condition, and go back to a previous statement.

Let's see the same program in Python:

        number = 23
        print("I'm thinking of a number.")

        guess = 0
        while guess != number:
            guess = input("Make a guess: ")
            guess = int(guess)
            if guess < number:
                print("Too low!")
            elif guess > number:
                print("Too high!")
            else:
                print("You got it!")

The overall program logic isn't much different when you read the code. But to write this code, you need to know a number of things in advance. You need to know how you're going to approach the problem. You need to know what a loop is, and specifically what a while loop is. Conceptually, especially for a young person, a while loop is much more abstract than a GOTO statement.

I am happy that people get to learn a language like Python as their first language today. They can do much more interesting things, in a shorter amount of time, than they could in basic 40 years ago. But the very first programs people write seem fundamentally different, and that's not a bad thing.

<comment><USER3> Hehe the guessing game was my fist too, way before I even had a computer.

I think what we have lost from the old 8-bit computers and their BASIC, was the ability to instantly have something show on the screen, like the classic Sinclair Spectrum spider web:

        10 FOR n=0 TO 31
        20 PLOT n*11,0
        30 DRAW -n*11, 175-n*8
        40 NEXT n

(or something like that) That stuff got me hooked.

<comment><USER4> You can get pretty close to that with JavaScript, especially with all the CodePen-like sites out there -- but even without those, the JavaScript console is pretty similar to the old BASIC prompt in terms of immediacy and ubiquity.

JavaScript also has this in common with BASIC: the language bigots hate it. :-)

<comment><USER5> I like BASIC, C, D, Objective C, Perl, Lua, 8080 and x86 Assembly (no code for around 15 years, but still) and probably few others catched my eye, like Io, LISP, Haskell, but I had no time to master these, only done a bunch of snippets discovering their power. But I hate js (and php) with all of my soul's strings, no matter how much time I spent learning or fixing it. How about that single data point.

Otoh, I bet most js bigots only know one language very good, guess what it's name is.

</comment></comment></comment></comment><comment><USER6> In the distant past, when I was an undergraduate at Wits University in Johannesburg (around 1970), someone discovered APL and they posted a 1-line APL program that printed the multiplication matrix for all numbers from 1 to 10. This lead to a flurry of postings on the (real!) bulletin board, but the show-stopper was a very short program written in IBM Assembler language, using macros. The code was written by a brilliant physicist named Colin Marquard who also single-handedly re-wrote (in assembler!) the so-called time-sharing system that we used for our courses. (IBM selectric typewriters connected by a proprietary network to the 360). Colin later had to flee South Africa (see, for example, [https://goo.gl/Hw3WWb](https://goo.gl/Hw3WWb)) because of his anti-apartheid activities.

<comment><USER6> I also found this: [http://www.catb.org/jargon/html/O/one-liner- wars.html](http://www.catb.org/jargon/html/O/one-liner-wars.html) about APL one-liners

</comment></comment><comment><USER7> For the python example, instead of using "\" and "/", you could just use the PETSCII characters that the original 10 PRINT as they were ported to unicode.

This is my version

      python3 -c "while 1: print(chr(int(9585.5 + __import__('random').random())), end='')"

<comment><USER8> I tried a JS version, but first I locked my browser window (lol, while (true)), then used console.log which in a browser will always do a newline and deduplicate double logs, then used a string concatenation and the result just isn't as interesting, nor the code as sexy. Note also that ascii codes are different, so no magic with floats and such.

        var str = ''
        for (var i = 0; i < 1000; i++) {
          Math.random() > 0.5 ? str += '/' : str += '\\'
        }
        console.log(str)

</comment></comment><comment><USER9> Geez I feel old when I read a post where the OP feels the need to explain how BASIC works !

It's kind for those who weren't there at the time (and is a logical thing to do)

Where are those 30 years gone :) ?

<comment><USER10> Understood it because it looked like the code for my childhood calc (TI 83 :p)

<comment><USER11> I had no concept of computer programming growing up. It was playing around with my TI-84 around junior year of high school that exposed me to it. I saw the PROGRAM button so I looked in the calculator manual and started writing TI-BASIC. I told my precalc teacher about it and she looked at me funny. She had no idea you could write programs on graphing calculators. I will always appreciate my TI-84.

<comment><USER12> Exactly the same story here. I really enjoyed my time tinkering with the TI-84.

<comment><USER10> Yeah ! School was so boring, programming calc is what got me into computer science. I'll never forget all my programs for IFS fractals, Syracuse suite visualization, Tic Tac Toe, Minesweeper...

</comment></comment></comment></comment></comment><comment><USER13> This reminds me of another great article.

[http://www.learningclojure.com/2010/09/graphics-like- its-197...](http://www.learningclojure.com/2010/09/graphics-like-its-1979-how- to-get.html)

The author talks about how its harder to get graphics on the screen without installing prerequisite software than it used to be, and goes on to sing the praises of the ZX Spectrum and its concise and well written manual. He finishes the article with some fun coding experiments writing Clojure code in the spirit of the ZX.

<comment><USER14> If you are not too picky, there's always JavaScript and Canvas.

<comment><USER15> That's "without prerequisites" nowadays? Interesting. In my world, this requires installing one of the most complex pieces of software in existence (a web browser, plus its dependencies), on top of a graphical OS (also a highly complex network of interdependencies).

<comment><USER4> > In my world, this requires installing one of the most complex pieces of > software in existence (a web browser, plus its dependencies), on top of a > graphical OS (also a highly complex network of interdependencies).

In most people's world (where "most" is probably > 95%), their computer comes with those things already installed.

<comment><USER15> Complex architectural stacks have costs beyond install in most people's world: how many layers of indirection between <canvas> and actually drawing on the screen? That's a lot of cycles spent doing busywork.

</comment></comment></comment></comment></comment><comment><USER16> There's an interesting book that uses that C64 one liner to "understand the cultural context of computing" and it's an open access book: [https://mitpress.mit.edu/books/10-print- chr2055rnd1-goto-10](https://mitpress.mit.edu/books/10-print- chr2055rnd1-goto-10)

<comment><USER17> The opening line of the article is:

"10 PRINT[1] is a new book which explores the magical power of a single line of code."

[1] [https://www.amazon.com/10-PRINT-CHR-205-5-RND- ebook/dp/B00C9...](https://www.amazon.com/10-PRINT-CHR-205-5-RND- ebook/dp/B00C9K9OE2/ref=as_li_ss_tl?ie=UTF8&qid=1510162754&sr=8-1&keywords=10+print&linkCode=ll1&tag=travelingfore-20&linkId=2962f94a2dbc433edeb005c125fb6e7e)

<comment><USER18> I got a hardcover of this book when I bought a used C64 off eBay. I was hoping to see it mentioned!

</comment></comment></comment><comment><USER19> I dunno what the need for using pygame was if the goal was to replicate this you could just use print in the REPL with a loop or recursion

<comment><USER20> The Commodore 64 version has square characters that are close to being aligned with each other. You can get the same characters output in a few lines of Python, but you can't replicate the look unless you make a careful choice of font to render it in. The output from the REPL with my normal terminal font looks like a bunch of characters more than it does a randomly-generated maze. The visual connection just isn't there.

<comment><USER21> One can also do better with the right choice of characters: ╲ ╱

      from random import choice; print(''.join(choice(('╲', '╱')) for i in range(10000)))

</comment></comment></comment><comment><USER22> You can match the spirit of it pretty closely with Perl.

perl -C -e '$|++;X:print chr(9585.5+rand());goto X'

<comment><USER23> Why "9585.5", is that a particular unicode character? That only displays squares on my terminal. I've tried to replace this with 205.5 like in the example but that would only display Î or Í.

<comment><USER22> 9585 is ╱ 9586 is ╲ (both mentioned elsewhere in the thread by their hex equivalents 2571 and 2572)

Try a different terminal maybe? Works in xterm, xfce, etc, for me. Also, I have LANG set to en_US.UTF-8

The ".5" is because Perl's chr() will convert it to an int by chopping off the decimal portion. rand() returns a floating point number between 0 and 1. That's very similar to what the BASIC program is doing.

</comment></comment></comment><comment><USER24> It would actually be doable in 2-3 lines using Unicode characters 2571 and 2572 (both hex), respectively "╱" and "╲".

<comment><USER25>
      import sys, random

      while True:
          sys.stdout.write(random.choice([u'\u2571', u'\u2572']))
          sys.stdout.flush()

They're called box drawing characters, it's how ncurses applications draw their GUI.

[https://en.wikipedia.org/wiki/Box- drawing_character](https://en.wikipedia.org/wiki/Box-drawing_character)

<comment><USER26> # Without unicode or pygame (using Python3)

      import sys, random
      while True :
        print( random.choice( [ chr( 92 ) , chr( 47 ) ] ) , end = "" )
        sys.stdout.flush( )

<comment><USER27> This one doesn't look correct in the terminal though as the characters don't join up

(parent):

      ╱╱╱╲╲╲╲╲╲╱╲╲╲╱╱╱╲╱╱╱╲╲╲
      ╱╱╲╲╲╲╲╲╲╲╱╱╲╲╲╱╲╲╱╱╲╲╲

vs (yours)

      \\\/\\\//\//\\///\\\\////\
      /\////\\\//\\\/\/\/\\\\/

Also in the terminal there isn't the space between the lines for the parent either (that's just HN formatting), but there is a space when using \ or /

<comment><USER28> The C64 font is (almost?) square, this also contributes to the nice effect.

<comment><USER29> It's square as it's 8x8 pixels, but the pixels themselves are not. There's a difference in aspect ratio between PAL and NTSC variants, and because the C64 was usually connected to a CRT, pretty much all bets are off.

</comment></comment></comment></comment></comment></comment><comment><USER30> They definitely didn't succeed in reviving the magic of that one-liner. I could see myself explaining the BASIC code to my little brother, but when it comes to the new version I don't think I would succeed.

</comment><comment><USER31> Speaking of one-liners, this one is pretty cool: [https://twitter.com/isislovecruft/status/447568252223647744](https://twitter.com/isislovecruft/status/447568252223647744)

</comment><comment><USER32> Hi! One of the authors of 10 PRINT here.

You might enjoy this browser-based graphical variation. Many people also made Processing-based variations, too:

[http://diydsp.com/fun/10print/10_print_param.html](http://diydsp.com/fun/10print/10_print_param.html)

<comment><USER33> Hi diydsp ! Do you still do low-level microcontrollers audio hacking ? kudos for that clever art generation !

<comment><USER32> Hey makapuf! Good to see you here!!! I'm mostly using a color these days and spending time on the rest of the instrument! See [http://dsp.guitars](http://dsp.guitars) for example!

<comment><USER33> Very Interesting !

</comment></comment></comment></comment><comment><USER34> I too cut my programming teeth in BASIC, first on my brother's Challenger 1P and then on my very own CoCo I. While it was fun being closer to the metal I'd much rather of had the 16GB laptop connected to the 43" monitor that I have now at 46 when I was 8.

btw, you can get pretty close to the spirit of the code with just a few more lines of Javascript:

        var col = 0;
        setInterval(() => {
          document.body.innerHTML += String.fromCharCode(47+(Math.round(Math.random())*45)) + (++col % 80 ? "" : "
")
        }, 10);

or if you want to code golf you can get it into 1 line:

        var col = 0, fn = setInterval(() => {document.body.innerHTML += String.fromCharCode(47+(Math.round(Math.random())*45)) + (++col % 80 ? "" : "
")}, 10);

You can see it in action here:

[https://jsfiddle.net/x5mz341z/](https://jsfiddle.net/x5mz341z/)

(edited to point to new jsfiddle with css body rules)

<comment><USER35> doesn't really work with a proportional font.

<comment><USER34> Agreed - I created a new jsfiddle with a couple of body style rules and updated the link.

<comment><USER36> created a new fiddle taking various suggestions through the post...

[https://jsfiddle.net/tj1zwqat/](https://jsfiddle.net/tj1zwqat/)

interesting that it renders perfect ( for me ) in chrome, and a bit of an offset in firefox

js

setInterval(() => {document.body.innerHTML += (Math.random() > 0.5 ? "╲":"╱")}, 1)

css

body { line-height:1em; max-width: 500px; word-wrap:break-word;}

</comment></comment></comment></comment><comment><USER5> For those interesting what "; :" is, ";" is print's command syntax for not putting a newline, and ":" is a command separator. Old basics were lexically rich, e.g. box drawing looked like:

      LINE (x1, y1) - (x2, y2), 2, BF

[B]ox, [F]ill

<comment><USER37> Newer BASICs were, too. In fact, the statement you wrote above was still valid in Visual Basic 6.0, provided that it was inside a method in a form (window) - in which case it drew the line on that window. If you wanted to draw it on another one, then you had to use the dot-syntax, but the rest of it would be the same, e.g.:

       otherForm.LINE (x1, y1) - (x2, y2), 2, BF

Curiously, LINE was an actual method, with regular parameters; it's just that it had this irregular syntax when calling it. VB had a bunch of special-cased rules for some identifiers like that, for back-compat reasons. Pretty much anything you could do in QB, you could do in VB - CIRCLE, PSET etc.

[https://msdn.microsoft.com/en- us/library/aa230480(v=vs.60).a...](https://msdn.microsoft.com/en- us/library/aa230480\(v=vs.60\).aspx)

This all got ditched in VB.NET in favor of a regular syntax.

But my favorite part in old BASICs was that the function MID$() - which in other languages is usually known as "substring" or "substr" \- was special- cased so that it could be used as target of assignment. So:

       s$ = "foobar"
       PRINT MID$(s$, 2, 3)   ' oba
       MID$(s$, 1, 2) = "uu"
       PRINT s$               ' fuubar

And yes, VB has this, too. In fact, even VB.NET does (although it did away with $).

</comment></comment><comment><USER38> When BASIC needs to be explained. Is it everyone else, or am I just getting old? :'(

</comment><comment><USER39> I remember a one-liner in BBC basic that gave you the snake game.

I wish I could see that again. Not sure if it was in one of the old acorn electron mags.

It seemed like magic, did some pretty low level stuff.

</comment><comment><USER40> I'm one of the lucky people who got to type that line into the C64 basic console as a kid back in the 80's. Then I played the Great Giana Sisters.

</comment><comment><USER41> This single line code

        {def U1 {lambda {:n} {if {< :n 0} then else {if {< {floor {* {random} 2}} 1} then ╲ else ╱} {U1 {- :n 1}}}}} {U1 1000}

draws the labyrinthic universe in any web browser. See [http://lambdaway.free.fr/workshop/?view=U1](http://lambdaway.free.fr/workshop/?view=U1)

<comment><USER41> This is a smaller one:

       {map {lambda {_} {if {< {floor {* {random} 2}} 1} then ╲ else ╱}} {serie 1 2000}}

</comment></comment><comment><USER42> [https://10print.org](https://10print.org)

</comment><comment><USER43> Two favorite programs of my childhood:

      10 REM drawing a galaxy
      20 FOR r=1 to 50
      30 CIRCLE 150, 100, r
      40 NEXT r
      50 ...

      10 REM playing a song
      20 BEEP 1,0: BEEP 1,2: BEEP .5,3: BEEP.5,2: BEEP 1,0
      30 ...

</comment><comment><USER44> One line Tetris in Acorn BBC Basic:

[https://survex.com/~olly/rheolism/dsm_rheolism/](https://survex.com/~olly/rheolism/dsm_rheolism/)

</comment><comment><USER45> Nice to get a shout out with the GIF credit from my YouTube video. After I saw Casey Reas speak at Eyeo about the 10 PRINT book, I recorded that with Vice. While the other authors made a version, Slate for some reason used my version, and it was my 15 minutes I guess, heh. It is a great book, and I still flip through it now and again. This is a great post, and I have a lot of fondness for the C64 from when I was a kid.

</comment><comment><USER46> I still remember my very first program. It was similar to the maze, but "animated":

10 PRINT " __ __ __ __ __" ;

20 PRINT " ";

30 GOTO 10

If you choose the right # of *'s and ' 's you get a series of diagonals moving across the screen (since the semicolons prevented the carriage return). For me, the impression of travelling along a bridge was completely captivating, and I was hooked on programming ever since.

</comment><comment><USER47> Cool. Looking at this closer, I realized this doesn't create a maze with multiple branching paths. It creates just linear paths.

</comment><comment><USER48> Same program in Lobster (a Python-alike statically typed language with built- in graphics): [https://github.com/aardappel/lobster/blob/master/lobster/sam...](https://github.com/aardappel/lobster/blob/master/lobster/samples/mazepattern.lobster)

</comment><comment><USER49> I have a strange feeling of synchronicity, I saw this code for the first time only this morning on the 8bit guy's YT channel, looks like this page just pre- dates that video though. [https://youtu.be/KAivGLHJzJM?t=18m54s](https://youtu.be/KAivGLHJzJM?t=18m54s)

</comment><comment><USER50> Does the random number generator in C64 basic start with the same seed? I know the QBasic rand function was horrid.

<comment><USER51> Yes, I remember when they demonstrated this to us in elementary school with C16-s. It's clock based IIRC :)

<comment><USER52> I remember doing it on my Vic-20, and I had done ASCII graphics on my Commodore PET in 1978! I had a thermal printer for my Vic-20 the width of receipt paper. I wrote a program from an astronomy calculation book to show where the 4 major moons of Jupiter were on an almost line due to their orbital planes being parallel to our line of sight here on Earth. So much easier to just get going with stuff then from bootup. It's why I like the interpreter that comes with J (jsoftware.com). Rosetta almost-one-liner for the Sierpinski triangle in J:

      load 'viewmat'
      'rgb'viewmat--. |. (~:_1&|.)^:(<@#) (2^8){.1

</comment></comment></comment><comment><USER53> This reads like a parody of Pygame. Why write something in a single line of Commodore Basic when you can do it in 50 lines of Python?

<comment><USER54> This is "a hello world for pygame", not "PRINT 10 for python".

</comment></comment><comment><USER55> I did exactly that in about 1978 on the Commodore PET and showed it at a meeting.

</comment><comment><USER56> Title should be 'A Universe in One Line of Code with PRINT' because 10 is just the line number.

Line numbers are used in console BASIC to reference and edit a line, it normally doesn't have a screen editor.

</comment><comment><USER57> Neither a game nor a single line (using semicolons is disingenuous)

<comment><USER58> This might vary by language, but in the ones I'm familiar with, the culture of "one-liners" has always permitted multiple statements on the line with statement separators. E.g. the awk one-liners: [http://www.pement.org/awk/awk1line.txt](http://www.pement.org/awk/awk1line.txt) (similar for Perl and shell).

<comment><USER57> Okay, fair enough. I'll grant you this.

But this certainly doesn't fit in one line by my standard. It linebreaks in my standard tiling setup. `from random import choice; print(''.join(choice(('\\\', '/')) for i in range 10000)))`

</comment></comment></comment><comment><USER59> Or Powershell:

      While ($True) { Write-Host (Get-Random '\','/') -NoNewLine }

</comment><comment><USER60> In Julia:

        while true; print(rand(Bool) ? '╲' : '╱'); end

</comment><comment><USER61> elixir one-liner:

        for _ <- 1..1000, do: IO.write Enum.random(["\u2571","\u2572"]); IO.write "\n"

</comment><comment><USER62> I'm impressed C64 Basic had floating point!

</comment><comment><USER63> Interesting, thanks for sharing this.</comment>