Camen Design Forum

Why isn't JavaScript like BASIC?

append delete Kroc

I wrote an article some time ago (http://www.osnews.com/story/23464/Why_Johnny_Can_t_Code) about BASIC programming and how computers now lacked any kind of 'direct interface' to creating.

I'm here to post these questions:

* What's your experience of BASIC, on what computers?
* What things prevent a child from making use of your current programming environment / languages you use?

I was thinking yesterday about how I would one day teach my son how to program in the absence of the programming environments that existed in my time.

I was poking around with a BBC Micro emulator and found that, compared to the very limited BASIC on the C64, the BBC could draw graphics and make sound with the simplest of ease. This was all good, but it lacks sprites and only has four or so very awful colours. There's no real happy medium between old micro computers because of the limits of the hardware; we don't have something that's as rich as the BBC basic, but with the graphic capabilities of the C64 -- and even then you have an insular, sandbox experience which lacks relevance in this day and age. The code you write is largely inaccessible outside of the emulator, and there's no simple way to import content from external sources.

So I had a quick Google to look for what sorts of modern BASICs exist. There's quite a few, actually, even a port of BBC BASIC native to Windows. The problems I find with these products is that they either are too trapped in recreating the past rather than living in the present, aren't focused on the will of children as users, or are too insular and sandboxed to provide an easy and natural progression from simple to complex reality (i.e once you're done with BASIC, you have to learn something new; and unlearn some old things!)

I have had the inspiration to propose something very particularly Camen Design in approach.

How about a JavaScript API that exposes the full functionality of the browser in a manner that is as simple and accessible as BASIC?

:: Present

JavaScript is the present. Despite my upbringing, it isn't my opinion that my child needs to learn BASIC from a thirty (forty by then) year old computer.

:: Practical, extensible, progressive

Learning to code JavaScript in a simplified environment is practical. One can very easily progress from the API into real JavaScript with no hard cut-off line. JavaScript is practical as the child can make real things that work on real websites that work on real devices available to everybody. Every child should feel the power that is publishing their work to the world, just as I felt with making my own website with Geocities (Tripod in my case).

Whilst anybody with a feel for the current trends of the web can easily imagine a full-on spanking website like Code Academy, jsBin with fully featured web-based text-editor and debugging suite, I am Kroc Camen and I do not do things that way. It is over engineering that hides true knowledge away from the user. So in true Camen Design fashion I am going to explain my idea using the three principles of Camen Design:

:: 3. Let everybody else do their job

This JavaScript BASIC would be only an API and not a development environment / webapp / debugger. The child can use a real text editor and a real debugger like Firebug so that they learn how to use real tools from the beginning, instead of learning in a sandbox that does not apply to the real world.

:: 2. Solve only my problem

I want to teach my child to code, that is all. I do not want to reinvent programming, I do not want to make the latest, hippest, HTML5 web app and go on to reinvent programming paradigms. I want to provide nothing more than a tiny bridge in functionality to make the journey easier.

:: 1. Code is Art

Making code into art is about allowing the developer to use the methods and tools they want to style their code in the way they want. Providing a blank canvas and not pre-populating it with mine or your ideas of how is best to start. As mentioned before any existing text editor, web browser and debugger can be used.

---

Thoughts?

Reply RSS

Replies

append delete #1. eeeps

* What's your experience of BASIC, on what computers?

TI-83 BASIC was my entry into programming. I started with a quadratic equation program that let me do my homework more quickly/accurately than I could have done by hand, and ended a couple of years later with a tic-tac-toe program whose graph-based-drawing techniques were, in retrospect, pretty neat, but whose *airquotes* A.I. */airquotes* was a buggy gordian knot of GOTO statements that eventually made me throw up my hands and abandon the whole thing.

* What things prevent a child from making use of your current programming environment / languages you use?

That they're not seen as readily applicable to any real, current problem in their lives, and aren't available on devices that they already use regularly.

I fell into TI-83 BASIC because the TI was a thing that I was already using when doing my math homework... and learning to program helped me solve a very specific, real problem (quadratic equation homework sets), quickly… only after that quick win did I get curious about how this logical world inside the calculator worked, and what I could do with it. After bitten with that curiosity bug, the portability and always-in-the-backpack-availability of the machine kicked in -- suddenly I was programming every day on the way to school.

Hypothesis: you need to things to begin to learn anything new 1) a real problem to solve & 2) highly-available tools to solve it with.

i.e., how I eventually *really* learned javascript, at my first job: the whole structure of the modern office-job workday revolves around sitting infront of a desktop machine for 8 hours a stretch... the boss needed a new website and I needed something to do; I could fill my time, learn a new skill, make myself useful, and not make any real waves (like I would have if I had, say, decided to build my boss a new desk or something… even though there was a woodshop in the freaking office, one needed a reason to be using it … self-initiating a project on a computer was far less likely to raise any suspicions). Next thing you know I'm reading Flannagan's O'Riley book on weekends and coding up automatic drawing programs for the fun of it.

I should note that a "problem" can take all kinds of forms -- I learned chess as a kid because my friend knew how to play, there was a fancy chess set in the living room of his house, and it was a way to fill the time & compete when I went over to hang out with him after school.

append delete #2. Johann

I have no useful input right now but I would just like to say that I love this idea to bits. We have a GAZILLION compiles-to-javascript thingies, there really *ought* to be one dedicated to make simple programming interesting and fun. This needs to happen.

append delete #3. Ben

I agree with Johann.

I never encountered BASIC. My first free access to a computer was my laptop when I was 18. I've taught myself programming based on what was useful to me. I started with C because I was told (by a university friend) that I should, then moved in to the web languages because it was useful. I now program primarily in PHP and Java and have been doing so for 5 years.

However, learning has been an effort. Java is... logical (exceedingly so), but overdone for simple applications. For example, when I was doing my dissertation for my first degree, I needed to calculate heart rates based on an average of the time difference between 5 ECG QRS waves. The maths is simple, but I had hundreds of traces to work through. I needed a tool to calculate this in.

Nowadays for these sorts of problems, I would do it in JavaScript, but at the time I didn't know JavaScript. So I wrote it in C. This is exactly the sort of task I think your project sounds designed for, and it sounds wonderful.

A desire for programming has to stem from seeing it fix your personal problems. The reason (I think) more people aren't doing it is the barrier to entry. On windows, you even need to install the C compiler in order to do what I did. That's ridiculous. JavaScript processing is on everyone's computer via their browsers. Writing a BASIC library for it sounds a magnificent way of lowering this barrier to entry and creating an environment where solving problems, as well as creating things can be fostered.

I love it. I hope you go further with this project.

append delete #4. Kroc

I would need to do a lot of research first about BASIC and what makes JavaScript (and modern development environments) unfriendly.

I do believe that for immediacy of results, there is no better programming language than BASIC. On a BBC it takes two lines of text to draw a circle. Want to do that in Java? JavaScript? C? The pain is not only how many LOC it takes, the real burden is the amount of background knowledge that is needed just to piece together the blank canvas before you start.

Some of the things that a child shouldn't have to know up front to produce results are OOP, functions and scoping. Anybody have the faintest idea how to play a tune of notes in JavaScript using the new HTML5 sound API? Nope. It's about as intuitive and obvious as a tax form. Therefore there should be a global BASIC-like function something along the lines of `synth (["c#", "d", "e", "f#"]);`.

My aims would be to boil down enough complex functionality into a set of straightforward functions that a child can bash out a game in a couple of hundred lines without the need to build their own framework first :|

append delete #5. theraje

Just as an aside -- have you checked out QB64? It may provide that 'happy medium' for which you search.

append delete #6. TCB

Just some random thoughts about this, but first a minor rant. I disagree with the basic premise that computers now lack any 'direct interface' to creating computer programs. Every OS ships with at least a basic text editor, and good free ones are readily available. That and a browser are already a better programming environment than I had on the Commodore PET in my high school's chemistry lab.

On that computer, writing BASIC programs was pretty much the coolest thing you could do, and just about the only thing. What's different now is that there are a _whole lot_ of cool things you can do with a computer. Kids are using them creatively for photography and movie making, art and design, communication, music, and of course games. The cheesiest online flash games are way more exciting than all but the very best old time BASIC games I could write and play. So while the programming environment has generally improved, it's obscured by an avalanche of additional functionality that computers now have.

So why can't Johnny code? We had three Commodore PETs in our chemistry lab, and J.B. was always sitting in front of one of them. But it was hardly ever a problem finding an open one after school. Most people just aren't that interested in programming. Back then those people just left the computers alone. Now they've got them for other things, but they still aren't interested in programming and that's fine. You could just as easily ask why more people aren't growing their own food or carving their own gunstocks. Life is short and everyone has to make decisions about what to do with it.

If anything there are more people involved in coding than there were 20 or 30 years ago. All you need is a few dollars a month for a hosting account and a Wordpress theme to be a web design firm. There are probably thousands - millions - of people doing that very thing. And little by little, some of them are being drawn deeper and deeper into the code.

The opportunities for teaching kids programming are better than ever. Kids have ready access to computers and are already familiar with their basic functions. The internet is a source of inspiration, a resource for learning, and an incredible opportunity for self-publishing. HTML and CSS are easy to learn. A kid can make a pretty cool web page from scratch in a short time with very little instruction and see immediate results in a browser even without a web host. If they could just add a little JS action, now that would be shiny!

That's what sounds so great about your JavaScript project. JavaScript is the next logical step, but it's suddenly no longer so fun and easy. If you could bridge that chasm, I'd use it. Python is often suggested as a beginner's programming language, and in some ways it seems like today's BASIC. But at least in the initial stages of learning, it's too tied to the command line. Most kids (myself included) are going to want to get more quickly to the explosions without wading through a lot of text and math experiments. Using JavaScript in a browser would be a great alternative as far as being able to play around with real, functional programming and make something satisfying with it.

It sounds like what you have in mind is a sort of KrocBASIC written with JavaScript. Or is it meant to be more of a simplified JS? Either way, it's a great idea. A kid could create a game or another app and send the html file to their friends and family or post it online to publish and share it. It would be something real they could actually own.

Educationally, it would be cool if it was also a sort of simplified JavaScript, so that it would be a small step leading naturally toward learning to program with JS rather than being just another programming language on its own. This is what you seemed to be saying at first, making JS itself more accessible. That would certainly add a layer of complexity to the project, making it "fit" naturally with JS. How will you make JavaScript easier to understand and use? What exactly are the rough spots that need smoothing over, and how can it be done without sacrificing too much functionality? In what ways would it be different from any other JS library like JQuery? What then would be the path from this simplified JS to full-blown JS programming? Using JS also involves using the DOM, HTML and CSS, so all of that is lurking in the background.

The main things that make BASIC (and Python) simple and accessible seem to be *natural language* and a certain *linear logic*. It's easy to call a function in BASIC. You just `GOTO 550` and `RETURN`. You don't even need to think of it as a function. You just go there, do that, return.

One thing I think is important to keep in mind is kids' expectations of what a computer program does. When I was first learning BASIC, it was pretty exciting just to be able to make my name repeat and fill up the screen. (OK, at least the first time.) But my kids are accustomed to 3-D graphics, realistic physics, immersive U-I, surround sound, rich and dynamic websites.… They judge the success or failure of what they create by the standard that's available to them in the real world. So hopefully you'll be able to give them the tools to achieve something that lives up to their expectations.

You're probably aware of the Scratch project (http://scratch.mit.edu/). It's sort of like the Lego bricks of programming. It's a fun way for kids to get started and have immediate success in programming. It's not a Camen Design style project by any means, but it might be helpful to you in researching the set of straightforward functions to include in your language, as well as understanding the educational underpinnings of a beginning programming language for kids.

It won't be easy, especially to do it well. But helping to expose the creative power of the browser without burying it under a proprietary, pre-packaged interface is a worthwhile project and I hope this idea will continue to grow.

append delete #7. Kroc

Thanks for the great, engaging responses everybody. :)

@eeeps: Calculator programming is something I would have loved to have got into, but those kind of calculators were far too expensive. I would gaze at the different models in the home catalogues, dreaming of the possibilities. Physicality is an important part of the desire to program a device IMO. Calculators lend themselves greatly to this as they have an array of buttons to play with and any kind of computer portability was very special back then; especially in something as small as a calculator.

I briefly used a ZX88 (https://en.wikipedia.org/wiki/Cambridge_Z88) in middle school, a device I would have adored to have proper access to to do some programming. The form factor lends to the imagination. The PC has always lacked that imagination-factor IMO.

@TCB

it's obscured by an avalanche of additional functionality that computers now have.

Not only that, but developing software is no longer considered a primary function of a computer that a consumer wants. Even the venerable task of Word Processing has disappeared and been overtaken by 3GHz 6GB RAM laptops used solely to check Facebook. I don't believe that everybody wants to be a programmer, or even needs to be -- It's a particular mindset IMO -- but I feel it necessary that my child learn, if nothing else, that the computer is a tool that they can put to use to help them in whatever it is they _are_ interested in and therefore they don't have to be beholden to walled gardens and "content-providers".

JavaScript is the next logical step, but it's suddenly no longer so fun and easy.

The pioneers have moved on, the fetishist "pure" programmers have moved in and want to change JavaScript into a "real" programming language. Notice that all the stuff being added to JS now (ES5+6 &c.) practically require a CS degree to understand and don't actually make things _easier_, just more _abstract_. I hate this direction, I hate it with a passion. I want JS to be small, simple and down-right hackish.

It sounds like what you have in mind is a sort of KrocBASIC written with JavaScript. Or is it meant to be more of a simplified JS? [...] It would be cool if it was also a sort of simplified JavaScript, so that it would be a small step leading naturally toward learning to program with JS rather than being just another programming language on its own.

A simplified API (not necessarily "form") of JavaScript is my intention. I could design a new JS-like language and write a script interpreter in JS, sure, but this would only teach the child a lie, a system that doesn't exist in the real world. Something to "un-learn" when one progresses to working with "real" code. I want the child to learn real JavaScript right from the beginning. So it would be actual JavaScript, but with 'shortcuts' to simply certain actions such as generating a canvas and drawing sprites &c. Therefore the code would be real JS, running merely an API library (a lot like jQuery). Later on, the child can learn the real methods behind the 'shortcuts', and phase out the use of the JS-BASIC 'library'.

How will you make JavaScript easier to understand and use?

The core of JavaScript itself is quite easy to learn and use (syntax, strings, arrays, objects). The APIs that tie JS to the browser however can be quite complex, particularly DOM. Some tasks require a lot of code to form a base first, such as sprite manipulation and animation.

What exactly are the rough spots that need smoothing over, and how can it be done without sacrificing too much functionality?

DOM, sprites - particularly animation, sound. The sort of things that one needs to get a game up and running quickly. A big problem with JavaScript is that to write a game -- any game -- one has to start by writing a framework to wrap up a lot of necessary stuff that isn't baked into JS. We need to provide that up front so that a child can start piecing together a game without having to conceptualise and design their own framework first :P

The difference between what I suggest with JS-BASIC and existing frameworks, particularly game ones, is that we are not outright hiding complexity, we will instead provide shortcuts only. Nothing will prevent the programmer from mixing "real" JS with JS-BASIC, so functional holes can be filled in with all the usual JS. JS-BASIC will only provide helper functions that shortcut the needlessly complex APIs in JS, such as audio synthesis.

" In what ways would it be different from any other JS library like JQuery?"

jQuery doesn't simplify difficult programming concepts for children such as OOP, parallelism and browser behaviour. Even with jQuery, you still have to write a framework to get a working game-timer and frame-buffer. We can build those in and make them implicit.

We can actually include jQuery and build off of it. It's a great way of navigating the DOM and we can include some jQuery as part JS-BASIC so that the child can 'get things done' as well as learning some jQuery along the way -- practical and not wasteful knowledge.

What then would be the path from this simplified JS to full-blown JS programming?

As highlighted before, JS-BASIC would be simple shortcuts rather than a replacement for any of JS. One can either use the JS-BASIC command, or do the same thing with several JS commands. Since the child will be learning JS at the same time as using JS-BASIC, this shouldn't be a difficult concept.

The main things that make BASIC (and Python) simple and accessible seem to be *natural language* and a certain *linear logic*.

Yes, it's that linear logic which is the hardest thing to create in JavaScript. It will be hard to create an API that doesn't have to expose too much in the way of anonymous callback functions and event-based programming. If we can handle that behind the scenes, the child will better be able to program in the way they think, in a linear, straight-forward fashion. The task of making JavaScript appear more linear keeps me up at night.

helping to expose the creative power of the browser without burying it under a proprietary, pre-packaged interface is a worthwhile project and I hope this idea will continue to grow.

Thanks. It's great to know there are people out there that understand the concept and the direction of what I'm suggesting.

append delete #8. Shawn bennet

Thanks for such a nice write -up. This is a very useful as i am at learning phase of programming and website design. Hope more article will be getting soon from you. Much appreciated.

https://www.sagipl.com/website-design/

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn