76 points · by chkas · 6y ago · 48 comments
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.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.
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).
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);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!
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.
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!
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://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.
https://easylang.online/ide/?code=%23%20turtle%20graphics%0A...
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, ...)