Kojo is an innovative app to learn with. But, learn what? You may be wondering. If so, you may want to read the meandering footnote at the bottom of this page. But, do that later. First read on and see what you can do with Kojo now.
Kojo comes as a desktop app that you can download and use for free. But, there is also a web app called iKojo which you can play with and get a feel for the wondrous capabilities of this technology. We have included below, right in this page, two dozen iKojo examples you can run. And, you can do that right now even on your smartphone.
First, let's see a few screenshots of Kojo and iKojo and start running some of the examples. Later, we will list many things you can learn while having fun with Kojo.
The first figure above shows Kojo desktop app running on an Apple computer. The next one shows iKojo online app running on an internet browser, in this case, Chrome. By the way, if you see only one figure above, just click (or tap on your phone) on the little wedge within the circle to show the other two figures. Of course, we don't have to use Chrome. We can view and run these iKojo pages using Internet Explorer or the new Edge browser in any computer running Windows, or Safari in any Apple device, iPhone or MacBook, etc... The example is one of the programs we'll see below. It is called the three body problem. And finally, the third figure shows iKojo running on a smartphone, in this case an Android. But iPhones,would work, too. This example simulates two planets, blue and green, going around a red star. The code traces the orbits of the planets that we see in the figure. More on those two in the companion page on simulations with iKojo.
Enough talk! Ready to run some code and start having fun? Click on any of the links below to get it to run for you. It doesn't matter whether you're on your smartphone or a computer. So, pick one that sounds interesting to you, click on the link and see what it does. And, then, try reading the short code in the iKojo window and see if you can make sense of it. If not, don't worry. It's a new language! A language such that when you talk in it, or rather, write in it, computers listen to you very attentively and do what you tell them to do. More importantly, just do what little kids do. Pay attention. Be curious like George. Play with the code. Tweak it and re-run. Keep your wonder flowing out!
Primary colors. How to draw simple shapes using colors, you know, red, blue and yellow, and more
Painting with random squares. Please don't skip over this one. I know squares and randomness might sound boring. But, just click on the link and be surprised how little it takes to create something beautiful..
A computer generated tree. No artist was harmed or even involved here. A slightly different and arguably better version is here. Check it out and compare the two if you'd like to get into some of the subtleties of computer science. Already?! Here is another variation on the same theme where we draw a fern.
Simple shapes. Two ellipses. And a rectangle drawn by our cute little turtle
Simulate motion on a pool table: Do you think you wanna learn how to simulate motion? At least, give it a shot. Are you wondering whether you can? Yes, you definitely can! But, the more important question is why you might care. Maybe you remember the movie called the Matrix. Or, you are just curious. I will leave that to you. This code is interesting for a different reason, too: most of it was written by ChatGPT. It didn't work as the famed AI wrote it at first. But, the bugs -- meaning errors in that code -- were very easy for me to correct. Quick disclaimer: I am a human just like you. But, maybe unlike you, I love to write code in Kojo and have been doing it for a while now. The code in the link at the beginning of this bullet is good and will work for you. But, most importantly, AI is a pretty good teacher, if you're a willing student! Please read how well it explains the code here. See if it makes sense to you. It does to me, but, I have a PhD in computers, so, I may not be the best judge ☺. You can try to run the code by ChatGPT directly and find out how errors crept in this large-language model (LLM). If you are still puzzled, check out the the following page which introduces the basics more properly and gives you a chance to play with all kinds of simulators and simulations: Simulation hypothesis! Even if you are not puzzled, take a quick look and run the three body problem and other simulations there. They are a lot fun.
Unit circle, trigonometric fun, how sine and cosine curves are generated through the motion around a circle, and a glimpse of waves like sound and light and earthquakes...
Phase space anyone? Phase space is a useful concept for advanced physics classes like general relativity or quantum mechanics. But, it is actually quite simple, trigonometric fun. Here we have two balls, red and blue, in a simple, uniform, circular orbit. But, there is a third one, a purple ball, that is derived from the first two. See if you can find out how exactly the purple ball follows the blue and the red balls at the same time. And further, see if you can also think and appreciate why your Republican and conservative and Democratic and progressive minded friends and neighbors think and reason as they do, and more importantly, how you can synthesize their seemingly contradictory words and actions into one.
Do you have fair dice to roll? If not, try this. This is one way to make sure your opponent doesn't cheat when you play backgammon. But, run it a few times and you'll see that you always get a pair. What's going on? See the comments at the end of the code. There are some hints there to get you to think it over a bit. If you are still stumped and would like to roll two dice as in real life, here is the solution.
Let's make a deal! Some of you may be familiar with the classic TV show host Monty Hall. The puzzle of three closed doors behind which are two goats and a sports car! What to do? Run this code a few times. That will help you find the right strategy. There is even a function that runs many simulations, collects statistics and computes expected outcomes. It is called runTrials. See if you can edit the script to activate it.
Prime numbers. Do you know that there are infinitely many of them? Don't just believe it, prove it for yourself. Are you up for the challenge. Read more on that here.
Factorials! This is a simple math concept and a function. Given any natural counting number, say 5, the factorial is the product of all numbers from 1 all the way up to and including that number. In the case of 5, it is: 1x2x3x4x5 = 120. And we call it 5! (yes, the exclamation mark has a special meaning in math!) We say, 3! = 6, 6! = 720, 10! = 3628800, more than 3 million! Nobody wants to do that many multiplications by hand. We got computers to do this. But, how do we get computers to calculate them for us? There are many ways. And, in this program, we show two of them.
Plot a quadratic equation. If you're feeling nostalgic for algebra like me, here is a parabola drawn by our own little turtle in Kojo. Play with the coefficients and the constant in the quadratic equation and tweak things a bit. See if you can figure out how to flip the curve over. Here is one way. Can you tell the difference? Have mathematical fun
Greedy rectangle packing. We have five rectangles and we want to pack them into the smallest possible area. This is a simple, greedy algorithm where we move each rectangle a random amount many times and pick only the moves that give us a smaller area. There is an elegant solution to this very simple instance of the np-hard optimization problem. You can see it at the end of this page after all the footnotes. But it would take a few re-runs of this script to stumble upon it. In fact, on my computer, it took more like 20 runs before I hit upon it. We will later add an implementation of the potent simulated annealing algorithm as an example of global optimization and get this solution more reliably.
Untangle me. Here is a puzzle. Just move the dots so that the lines that connect them don't cross each other. Click on the red square to get a different random placement of all the dots. The program for this puzzle is a bit more complex as it uses object oriented and functional programming constructs. Still, it is less than 70 lines long. Trying to understand it would be a good challenge for mathematically minded high schoolers. But, for anyone, it is easy to play. If you want a simpler puzzle or want to make it harder, tweak the value ES (edge size). 3 for easier. 5 for harder.
Tic tac toe any one? This is the famous game for two. I would love to be your opponent. But, for now, I pretend to be your teacher. By the way, the desktop version of this game has an unbeatable algorithm. See if you can install it on your computer. For now, hopefully, you have an annoying little brother or sister, or a friend to play with. Just take turns clicking on the board. By the way, this program is fairly advanced for beginners. It's almost 200 lines long, too. That's pretty expressive for any modern language. Others usually take a lot longer to implement this simple game. Anyways, take a quick look at the code. But, for now, just play with it.
Game of Life! We've talked about artificial brains and artificial intelligence. How about artificial life? This is it! Game of Life is also known as a zero-person game. Yes, you read it right: it plays on its own. You just sit back, relax and enjoy. If you are curious, you can read more about it by clicking here.
On your phone? Try out a little game. This is a real one-person online (obviously) arcade style game. Can you last 30 seconds avoiding a crash with the incoming traffic? You are the Blue ball. Don't hit any Red ones. BTW, notice that it took less than 80 lines, but 32 iterations to get it to work (phew). You can tell by looking at the numbers at the end of the link address.. Games are easy to play, but hard to create! Here is a classic Asteroid Shooter from AARP!
Fat chance! Counting can be fun and help us make sense of probabilities and statistics and the world around us. The best book I read on the topic is Fat Chance: Probability from 0 to 1. And, I also took a wonderful online class from Harvard University (yes harvard.edu) (and it is free!). This fiddle captures all the formulas (and a few examples) I've gleaned from the book and class. Here is a simplified and improved version of that fiddle which comes with a function called sample. It takes two arguments: n and k. Run the function to see four different ways of choosing k numbers (or in general k objects) from all the numbers from 1 to n (or in general n objects). When you run the fiddle, it shows ways of choosing 2 numbers from 1 to 5. That's sample(5,2). Find that line (it's line #1!), and change to it: sample(3, 2) or sample(4,3) and re-run. Do you get what you see? We might care about the order of the numbers, or not. We might also want to allow repeats or not. And, in each case, we get different results. There are many real life problems that can be solved as such. Read the book (or take the online class) to find out about some of them. The professors are not only world-class, but also fun!
Boolean operations -- If it rains and our game is cancelled, then we'll have to reschedule. Or, should we look for an indoor venue? But, indoor is not the same as outdoor, is it? Life is full of such questions and decisions where we consider alternative options. Or, at a simpler level, try to do an advanced search with google here: Advanced Google Search and you'll find ways to combine such options as "any of these words," "none of these words," and so on and so forth. It might sound somewhat confusing. Is there a way to nail this down? What are the foundations of such "logical" operations? Would you believe it if I told you that we could represent any complicated decision as a combination of just three simple operations called AND, OR and NOT? In fact, with a little bit of an added complication, we can define the inverse of the AND operation as NOT-AND (or simply NAND) and just use that! Just one simple function, and believe me that it is very simple (or believe me not, but, run this fiddle and find out for yourself), lets us represent all possible computations? It's hard to believe, but it's true. If you are curious, check out: NAND logic. By the way, Boolean means true or false. We can use the number 0 to represent false and the number 1 to represent true and as such get computers to do all kinds of computations for us using those (and those in turn are called binary operations, or simply 0 or 1). But, of course, we need a lot more than just one bit (each 0 or 1 is called a bit) to represent larger numbers -- e.g., 2 would be 10, no, not ten, but one-zero, and 42 would be 101010 -- letters, pixels, colors and anything under the sun :-)
Talking about the Sun... Let's see how surprisingly powerful folding is. It's all thanks to simple arithmetic.
More to come... And there is a lot more on the desktop app: rich computer graphics, more games including Othello (also called Reversi, see the picture below), and even a zoom-able Mandelbrot set (that's shown in one of the pictures below, too). So, go ahead, just download and install it on your PC or Mac. Then, run any of the fiddles under the Menu called Showcases and the Menu called Samples and much more... BTW. if you speak Turkish, Kojo can be enjoyed and programmed in Turkish, too! Download it from here. It comes with even the scala keywords, the lowest-level primitives of the coolest language yet, in Turkish!
So now you have a good feel for what you can do and learn with Kojo and iKojo. But, before we close, let's review what this learning environment provides to those who are willing to challenge themselves and learn:
Programming made fun and visual with turtle drawing and animated pictures. And not a with a toy language for beginners either! See bullet 7 below.
Math, arithmetic, factoring, prime numbers, angles, unit circle, trigonometry, sine and cosine waves, complex numbers, fractals (yes, we even have a zoom-able Mandelbrot set!)
Physics, like motion, mechanics, Newton's law of gravity, two-body/three-body problems (no not the new Netflix sci-fi series).
CGI, computer generated images, computer art
How computer games work, how computer interfaces work
What AI is. The two kinds of AI: (1) the good old traditional, meaning symbolic and logical AI, and (2) the newer kind, statistical, ChatGPT kind of AI. How they both work.
Easy intro to STEM and computer programming with one of the most modern and powerful languages, called scala. See: scala-lang.org. Also see cheatsheet to get you ramp up on scala here. BTW. note that Kojo desktop app has another tutorial you can learn scala fundamentals. You can download it here.
The sky's the limit...
Footnote:
Learning is fun, at least sometimes, or, it is supposed to be. It is also a lot more fun to learn if we know well how to learn! I first became aware of the subtle notion of learning how to learn back in my high school days. It was told to me and my school mates by a distinguished alum of the same high school. My alma mater -- Ankara Fen Lisesi, AFL, the high school of science in Turkey -- was established in the days of the Marshall Plan in Europe (1948 and on) with funding from NSF and Ford Foundation. This was a privilege granted to Turkey for being a NATO member in the days of the Cold War and also letting Greece become one, too (any member can veto any new candidate. Can we add both Ukraine and Russia at the same time, please :-). You know, in geopolitics, give and take is the name of the game. Or else, it's the powerful dominating the lesser nations. Oops, sorry for the tangential.. As I was saying, the department head, then in 1987, of the newly minted Electrical and Electronics Engineering department at Bilkent University in Ankara, Turkey, was Abdullah Atalar, one of the early graduates of AFL. Almost a legendary genius in Turkey, he had gotten his PhD from Stanford University in hard core electrical engineering and was now subtly helping with the promotional effort to recruit us, the best students in Turkey, to apply and choose to study in the first private university in Turkey. Oh, btw, they also promised to give us not only full scholarships (all tuition paid for four years), but also a small stipend to spend on food every month. So, when Prof. Atalar promised that we would be learning how to learn, we were all hooked. At least I was. Needless to say, I spent the next four years at Bilkent, Ankara, Turkey getting a BS (and that may sound like a curse, but it simply stands for Bachelor of Science. And, yes, I didn't have a wife during those four years :-). After all, when we want to learn, we all want to learn from the best teachers, don't we? And, you, too, I hope want to do the same, and therefore you are here, reading this. You are in the right place :-). BTW. when it comes to best teachers, we better talk a bit about Socrates, too. You can read that by clicking here.