Show HN: A modern BASIC-like teaching and learning programming language
easylang.online
easylang.online
Having taught programming before, one thing that many people find confusing at first is using "=" for both assignment and equality; statements like "x = x + 1" make no sense as a math equation.
I think supporting (but not requiring) "let" (or equivalently "make" or "set") helps go over that hump, although I last taught basic to someone 30 years ago... e.g., if you accept
let a = 3
or make a = 3
makes it a little easier to grok let x = x + 1
(although the x on the left is "now" and the x on the right is "before"). Alternatively, using something like "x <- x + 1" is much clearer, and just as clear for "x <- 3" (especially with a right font or glyph). Unfortunately, there is no single ascii character/glyph that intuitively conveys assignment; K uses ':' which is ok, Pascal uses ':=', neither of which is good for Basic and the like, I think.Essentially all Basic interpreters in the 80s accepted "let" to start assignment, but did not require it. Some (e.g. ZX Spectrum Basic) did require it.
The problem is that a first-time learner already has their mind full with information (we can only ever hold ~7 items in working memory, cognitively, so make sure each one counts when teaching anything).
Also, it is unrelated to what I said - namely that “let” disambiguates the two meanings of the equal sign, which from my (and not just my) experience is a heavy cognitive load on people new to programming.
> But statements such as "x = x + 1" ARE confusing to newcomers, from my experience
Merely elaborating.
Indeed, `let` does reduce cognitive load, it's one less "new thing" to keep in working memory¹ (this is the specific part of human cognition that we use to reason directly, "human RAM" for lack of a better term).
I'm not sure how it's unrelated... nevermind. I got misunderstood in my comments all day, must be Venus. :)
____
1: https://en.wikipedia.org/wiki/Working_memory
____
Edit: I fail to see why this:
> This reasoning taken a little farther would say that APl is by far the cognitively easiest language, which is demonstrably false.
Could you explain?
> APL is by far the cognitively easiest language, which is demonstrably false.
(that was a lower case L typing on phone, sorrt). APL code is incredibly short - 7 APL chars are usually equivalent to 50-100 in other languages. One would expect that would make it easy to master & read, but experience from the last 60 years or so shows that's not true.
For clarity, we SHOULD use `let` with beginners, and any such pre-existing concept whenever possible. There's a time to reinvent some wheels I guess, but while first learning to drive certainly isn't it.
APL, haha gotcha. Way to zero-in on the edgest perfect case! It indubitably shows how a "short" form is not necessarily cognitively "light", which has everything to do with familiarity in my book— a sizeable body of knowledge already internalized, already abstracted into a symbol or form— e.g. "let x", or a function whatever the abbreviation, the logical construct if... then... else, etc.
Indeed should I speak to you in "objects you know" as a basis for language, chances are translation is possible between my ideas and those fundamental bricks of yours— some arragement thereof, that encodes whatever I want to convey. This is where/how actual pedagogy begins for me (totally layman perception, no formal training whatsoever).
But failing the basic math background, these concepts fall back one-step removed from cognitive ease. I find it's extremely useful to speak in whatever domain language fits the student's background. Meet them halfway there so to speak, if I can help it.
Something like
const bool press = (evt->flags & EVT_FLAG_PRESS) != 0;
is common, idiomatic and nice in my world (for some made-up key event handler). const bool press = !!(evt->flags & EVT_FLAG_PRESS);This made Squeak Smalltalk code look wrong, like "x _ x + 1", depending on the font you used and some people wanted to allow underscores in identifiers to make it easier to interface to other languages. So "x := x + 1" was added as an option and there have been some crusades to convert all older code to that.
The write-up is coming in a few days.
It's hard to beat the simplicity and immediacy of writing a few lines of code and having a simple physics simulation (the bouncing ball example here). I can see this being extremely popular and useful to kids!
Thank you for your work. When trying to teach my child basic coding concepts along with their math homework, the barrier often is the IDE.
The web-based staring point is incredibly useful. Fire up the web browser and show the math example is excellent. I have started using the web-based Pyret with my 9-year-old. As we do her math, we mirror the math and geometry problems and solve them in the browser environment. The simplicity to code, run, eval is key.
https://www.pyret.orgI will give Easylang a try on her next set of problems. Strong Work!
https://blog.steve.fi/how_i_started_programming.html
And I had a lot of fun recently writing a simple BASIC interpreter, largely inspired by Sinclair's basic:
https://github.com/skx/gobasic
I'm pretty pleased with the ability to write images, via a browser-editor, even if it is static and not animated.
I wonder, though, if it would be easier if you avoided computerese in your naming? Keywords like "func", "subr", and "str_chars" are part of what makes people's heads spin when they first look at code. If they were just named "function", and "subroutine", and "character_string" (or just "string" or "characters") it would be a little harder to type, but much much easier to read. And you know what they say – you'll read a lot more code than you write.
Other than that, this looks really nice. Nice work!
https://easylang.online/ide/?code=%23%20turtle%20graphics%0A...
https://docs.python.org/3.3/library/turtle.html?highlight=tu...
https://greenteapress.com/wp/think-python-2e/
(Case Study: interface design http://greenteapress.com/thinkpython2/html/thinkpython2005.h...)
The book is very good for first-time learners IMHO.
Has anyone looked at Computer Science Logo Style (http://people.eecs.berkeley.edu/~bh/)?
Few comments:
- It would be nice to have a proper full reference of the language (maybe it exists but I couldn't find it), with all details put together in one document. I had to dig through tons of tutorials just to see how floats are defined.
- How do you add comments in the code?...
- The editor removes empty lines - so if you try to separate logical blocks/paragraphs you can't do it. This coupled with lack of comment support hurts code readability. Maybe it could collapse >1 empty lines to just 1 empty line inside.
- Defining floats: if you have a program that deals with both floats and has int-based for loops, you can't use "floatvars" if I understand correctly. Now, having to add "#" as a suffix for each float variable greatly hurts readability since you now have lines like "z# = x# * x# + y# * y#"
- Editor - tries to be too smart at times which hurts basic editing functionality like undo; if I add a line and type something, the cmd-z doesn't remove that line, it only removes text in the line. Also, if I type something syntactically wrong, the editor first tries to format/transform the code and only then shows an error but doesn't then return the code to what it looked like; this makes it hard to fix errors.
- Re: editor, why just not use a mature engine like CodeMirror? (and add your own syntax highlighting / hints, etc)
- Why all those "." instead of "end" in loops/ifs inside functions? This is not explained anywhere and looks a bit obscure in tutorials
- Color system with 000-999: a lot of boilerplate to deal with it, troublesome to create palettes and it's only 10 bits of color. Might be helpful to have a color function that takes three separate ints (or even floats 0.0-1.0, opengl-style).
But generally, kudos, good job :)
You raised some important and also some sore points.
@documentation: there is still some work to be done. The tutorial "Code snippets" contains most things.
@comments, empty lines: lines beginning with # are comments. Empty lines are not possible, but empty comment lines.
@floats and ints: by default variables are integer and floats are marked with #. With floatvars variables are floats and integer are marked with % - as in some BASIC variants.
@editor: this is a bit strict, but with beginners the concept works quite well. On enter, the code is parsed down to the current line and returned "correctly" formatted. Unfortunately "undo" does not work well.
@end: the dot is quickly typed and also makes the code more clear (a bit like in Python) - since the dot seems strange to many people, I added end as an alternative.
@color: these 3 digit numbers are short, and sufficient for most cases and more flexible than color names. There are also built-ins to fine-tune the colors (0.0-1.0) (color_red, ...)
One last question I forgot to mention - is there a 'mod' function/operator? (like %, %=)?