Python and Flaming Thunder

J

John Salerno

To whit: you pointed out the awkwardness in Python of having to
declare a for-loop variable when you only wanted to loop a specific
number of times and didn't need the variable.

Well, I wasn't so much trying to point out an awkwardness as I was asking if anyone really *found* it awkward. And of course, my question also raises the question of whether or not it's good programming to simply want to do something a certain number of times. I suppose that situation may come up, but I wonder if it can be implemented in a more significant way than simply doing something X number of times.
 
D

Dan Upton

For another example, I've always preferred languages that are English-
like because it's easier to return to your code after several years
and still know what you were doing (and it's easier for someone else
to maintain your code).

Unless of course you use reasonable variable names and have good
comments in your code. I don't think figuring out well-documented C
code would be any easier if it were in a more English-like
syntax--IMO, it's usually the understanding the interfaces or figuring
out what's going on in functions that makes reading someone else's
code tricky, not the difference between "x=" and "set x to."
 
M

MRAB

I guess I could have stated that better. Flaming Thunder is a labor
of love for me. I've programmed in almost every language since
FORTRAN and Lisp, and Flaming Thunder is the language I've always
wished the others were.

For one example, I've always preferred compiled languages because
they're faster. So Flaming Thunder is compiled.

For another example, I've always preferred languages that are English-
like because it's easier to return to your code after several years
and still know what you were doing (and it's easier for someone else
to maintain your code).

For over 5 years I've been working on Flaming Thunder unpaid and on my
own, getting the back-end up and running. 8-by-8 shotgun cross
compilers written in assembly language, that can fit all of the
libraries for both the 32- and 64-bit versions of FreeBSD, Linux, Mac
OS X and Windows into a single executable file that's less than 180K,
aren't written overnight.

So now that I've released it, it's extremely gratifying that people
think it's cool enough to actually pay $19 for it. That gives me lots
of motivation (and buys enough time) for me to add features to it as
fast as possible.

To whit: you pointed out the awkwardness in Python of having to
declare a for-loop variable when you only wanted to loop a specific
number of times and didn't need the variable. Last week, Flaming
Thunder had the same awkwardness. If you wanted to loop 8 times:

for i from 1 to 8 do <statement>

you still had to use a variable (in this case, i). This week, I've
added two new for-loop variations that fix that awkwardness, and also
allow you to explicitly declare an infinite loop without having to
rely on idiomatic constructs such as while-true. Examples of the two
new variations (for-forever and for-expression-times):

Write "Fa".
For 8 times do write "-la".
Personally (and borrowing from Python), I'd prefer something more
like:

Write "Fa".
Repeat 8 times:
Write "-la".
For forever do
(
Write "Do you know the definition of insanity? ".
Read response.
).

Repeat:
Write "Do you know the definition of insanity? ".
Read response.
 
C

Collin

Dave said:
I've read that one of the design goals of Python was to create an easy-
to-use English-like language. That's also one of the design goals of
Flaming Thunder at http://www.flamingthunder.com/ , which has proven
easy enough for even elementary school students, even though it is
designed for scientists, mathematicians and engineers.

Personally, FT is a bit meh to me. The way you issue your statements I
always think something is wrong, mainly because when I want to define,
say, x, in python I'd go:

x = "whatever"

Instantly noting that I defined x. While in Flaming Thunder I'd have to
type:

Set x to "whatever"

It just feels wrong.
 
D

Dave Parker

Personally (and borrowing from Python), I'd prefer something more
like:

Write "Fa".
Repeat 8 times:
Write "-la".

I actually kind of prefer that, too. Or

Repeat 8 times write "-la".

I'll think about it. Thank you for suggesting it.
 
D

Dave Parker

Or just:
If command is "quit" ...

Hmmm. In Flaming Thunder, I'm using "is" (and "is an", "is a", etc)
for assigning and checking types. For example, to read data from a
file and check for errors:

Read data from "input.txt".
If data is an error then go to ...

Or when assigning a type to an identifier:

HarmonicMean is a function(x, y) ...
LoopCount is a variable ...

By using = only for equality and "is" only for types, the Flaming
Thunder compiler can detect when either is being used incorrectly
because the syntax for the two is incompatible. That avoids the man-
years of wasted debugging time spent on languages that accept
statements that are easily confused, yet syntactically valid (e.g. the
confusion between = and == in C if-statments, or the confusion between
= (equality) and "is" (identity) in Python).
 
B

Bruno Desthuilliers

Dave Parker a écrit :
Hmmm. In Flaming Thunder, I'm using "is" (and "is an", "is a", etc)
for assigning and checking types. For example, to read data from a
file and check for errors:

Read data from "input.txt".
If data is an error then go to ...

Arf ! A goto !
Or when assigning a type to an identifier:

HarmonicMean is a function(x, y) ...
LoopCount is a variable ...

By using = only for equality and "is" only for types, the Flaming
Thunder compiler can detect when either is being used incorrectly
because the syntax for the two is incompatible. That avoids the man-
years of wasted debugging time spent on languages that accept
statements that are easily confused, yet syntactically valid (e.g. the
confusion between = and == in C if-statments, or the confusion between
= (equality) and "is" (identity) in Python).

Actually in Python the equality test is '==', not '='. And since
Python's types are objects - which is *definitively* a GoodThing(tm) in
an OOPL -, your point here is moot.

Also, you're overloading the meaning of 'is', which *is* (pun intented)
confusing too.
 
D

Dave Parker

Personally, FT is a bit meh to me. The way you issue your statements I
always think something is wrong, mainly because when I want to define,
say, x, in python I'd go:

x = "whatever"

Instantly noting that I defined x. While in Flaming Thunder I'd have to
type:

Set x to "whatever"

It just feels wrong.

Actually, it felt wrong to me when I first started working on Flaming
Thunder because I've been programming for decades and have had all of
the programming idioms burned into my brain.

But after getting input from children and teachers, etc, it started
feeling right.

For example, consider the two statements:

x = 8
x = 10

The reaction from most math teachers (and kids) was "one of those is
wrong because x can't equal 2 different things at the same time".
Many computer languages conflate "equality" with "assignment" and then
go to even more confusing measures to disambiguate them (such as using
== for equality, or := for assignment).

Plus, symbols are more confusing for people to learn about than
words. There are lots of people who are fluent in English, but
dislike math.

So, I opted for a simple, unambiguous, non-mathematical way of
expressing "assignment" which makes sense even to the non-
mathematically inclined:

Set x to 8.

That way, = can be reserved unambiguously and unconfusingly for the
mathematical notion of "equality" -- because it's in their math
classes that people learn what = means:

Set QuadraticEquation to a*x^2 + b*x + c = 0.
 
D

Dan Upton

For example, consider the two statements:

x = 8
x = 10

The reaction from most math teachers (and kids) was "one of those is
wrong because x can't equal 2 different things at the same time".

Sounds to me like the teacher is being difficult, and IIRC, you've
talked about having elementary school kids write in FT -- I don't
think asking "does this make sense to you" of elementary school kids
is necessarily the best metric for PL syntax/semantics.
Many computer languages conflate "equality" with "assignment" and then
go to even more confusing measures to disambiguate them (such as using
== for equality, or := for assignment).

Plus, symbols are more confusing for people to learn about than
words. There are lots of people who are fluent in English, but
dislike math.

If you can't do, or don't like, math, you probably shouldn't be
programming. If you don't have any symbolic reasoning skills, you're
largely limited to "Hello, World."
That way, = can be reserved unambiguously and unconfusingly for the
mathematical notion of "equality" -- because it's in their math
classes that people learn what = means:

Set QuadraticEquation to a*x^2 + b*x + c = 0.

You keep trotting out this quadratic equation example, but does FT
actually have any kind of useful equation solver in it? Or does it
just allow you to do something like

Set QuadraticEquation to a*x^2 + b*x + c = 0.
Set a to 1.
Set b to 0.
Set c to -25.
Set x to 5.
If QuadraticEquation is True then do ....
 
D

Dave Parker

Sounds to me like the teacher is being difficult, ...

No, proof-by-contradiction is a common technique in math. If you can
show that x=8 and x=10, then you have shown that your assumptions were
incorrect.
If you can't do, or don't like, math, you probably shouldn't be
programming.

Why not? Recipes are programs. I prefer to look at it the other way:
an easy-to-use programming language might encourage more people to
like math.
You keep trotting out this quadratic equation example, but does FT
actually have any kind of useful equation solver in it?

Not yet, but it will. Probably around July.
 
D

Daniel Fetchinson

Or just:
Arf ! A goto !

You are surely aware of the fact that the C source of python also uses
goto at tons of places. Is that Arf! too?

Cheers,
Daniel
 
D

Dan Upton

You are surely aware of the fact that the C source of python also uses
goto at tons of places. Is that Arf! too?
And in the Linux kernel, and probably lots of other places
too--several places I've seen it used, they explain it as "this helps
clue in the optimizer" or something to that effect. (That doesn't
mean it's a good idea to use it in everyday code though.)
 
M

MRAB

Hmmm. In Flaming Thunder, I'm using "is" (and "is an", "is a", etc)
for assigning and checking types. For example, to read data from a
file and check for errors:

Read data from "input.txt".
If data is an error then go to ...

Or when assigning a type to an identifier:

HarmonicMean is a function(x, y) ...
LoopCount is a variable ...

By using = only for equality and "is" only for types, the Flaming
Thunder compiler can detect when either is being used incorrectly
because the syntax for the two is incompatible. That avoids the man-
years of wasted debugging time spent on languages that accept
statements that are easily confused, yet syntactically valid (e.g. the
confusion between = and == in C if-statments, or the confusion between
= (equality) and "is" (identity) in Python).
[snip]
I wonder whether "is" could be used both for "x is value" and "x is a
type" without causing a problem:

If command is a string ...

If command is "quit" ...
 
D

Dan Upton

No, proof-by-contradiction is a common technique in math. If you can
show that x=8 and x=10, then you have shown that your assumptions were
incorrect.

Yes, I'm aware of proof by contradiction. However, I think there's a
flaw in your use of this to justify your case--proof by contradiction
would essentially be showing x=8 and x=10 simultaneously, whereas the
sequence of instructions

x=8
x=10

imply a time relation, and there's no contradiction that x equals
something at one point in time, and something else at another point in
time. (For any kid who is capable of understanding variables anyway,
just tell them something to the effect of "Plot the line y=x. Okay,
now let 'y' be time. At no point in time does x take on two values,
but it may take on different values at different points in time. Same
concept.")
Why not? Recipes are programs. I prefer to look at it the other way:
an easy-to-use programming language might encourage more people to
like math.

To continue your analogy, if a recipe is the program, a person is the
computer. Following a recipe is (relatively) easy, making up a new
recipe is relatively difficult unless you understand, or are at least
willing to tinker with, things like interactions between ingredients
and flavors. Likewise, it's tedious and time-consuming but not
necessarily difficult to follow a program (assuming you understand the
rules of the language; I suppose here you could make some argument
"it'd be easier to read it in English"), but you need to understand
more about symbolic reasoning and such to be able to do much in the
way of programming.

All the same, I suppose you might have a point there, if you can show
somebody something cool while sneaking in the math and programming
such that they learn without even realizing it--somewhat akin to the
guy who a month or so ago wanted to sneakily teach his high school
class programming fundamentals by teaching them game programming.
Not yet, but it will. Probably around July.

Maybe this should be your selling point, and maybe you should be
drawing comparisons to programming in Matlab or Mathematica.
 
D

Dave Parker

I wonder whether "is" could be used both for "x is value" and "x is a
type" without causing a problem:

If command is a string ...

If command is "quit" ...

I think you are right. I like "If command is "quit" ...". For a user
who wasn't mathemetically inclined and was doing mainly string
manipulation, I think it might be easier to read than the equivalent
"If command = "quit" ...". By making them exactly equivalent, I can't
think of any confusion that might induce bugs. If you think of any
drawbacks, please let me know. Otherwise, I'll put it in the next
time I update the parser (probably this weekend). Thank you again for
your suggestions.
 
D

Dave Parker

... --somewhat akin to the
guy who a month or so ago wanted to sneakily teach his high school
class programming fundamentals by teaching them game programming.

Yep, that's kind of my plan, too. After I get enough "computer
languagey" stuff running, I'm going to incorporate the 3D graphics
from DPGraph.
Maybe this should be your selling point, and maybe you should be
drawing comparisons to programming in Matlab or Mathematica.

That sounds like a good idea.

Personally, the first thing I wanted to get running in Flaming Thunder
was the ability to cross-compile CGI scripts for Linux under Windows,
because some inexpensive web-hosting sites (such as GoDaddy) don't
allow shell access, so I couldn't compile the CGI scripts natively.
Also, the ability to cross-compile programs for the Mac since Macs
often appear in educational settings.

Now that those are up and running and Flaming Thunder is released to
the public, I'm adding features as prioritized by customer requests.
Currently, the highest big things on the list are arrays/matrices and
3D graphics. Next on the list is improved symbolics.
 
F

Fuzzyman

I've never seen this symbol in textbooks. In textbooks, powers are
written using superscript.


I haven't seen any language using '^' as the power operator so far -
but I've seen quite a lot of them using it as the bitwise XOR operator.


Excel uses the caret as the power operator. Arguably the worlds most
widely used programming environment...

Michael Foord
http://www.ironpythoninaction.com/
 
D

Dan Upton

Excel uses the caret as the power operator. Arguably the worlds most
widely used programming environment...
I think BASIC did, too. I know I used to use it in some language and
was confused when I first tried to use it in Java and didn't get what
I was expecting. ("Some language" must be in the set (BASIC, C,
Logo).)
 
C

Collin

Dave said:
Actually, it felt wrong to me when I first started working on Flaming
Thunder because I've been programming for decades and have had all of
the programming idioms burned into my brain.

But after getting input from children and teachers, etc, it started
feeling right.

For example, consider the two statements:

x = 8
x = 10

The reaction from most math teachers (and kids) was "one of those is
wrong because x can't equal 2 different things at the same time".
Many computer languages conflate "equality" with "assignment" and then
go to even more confusing measures to disambiguate them (such as using
== for equality, or := for assignment).

Plus, symbols are more confusing for people to learn about than
words. There are lots of people who are fluent in English, but
dislike math.

So, I opted for a simple, unambiguous, non-mathematical way of
expressing "assignment" which makes sense even to the non-
mathematically inclined:

Set x to 8.

That way, = can be reserved unambiguously and unconfusingly for the
mathematical notion of "equality" -- because it's in their math
classes that people learn what = means:

Set QuadraticEquation to a*x^2 + b*x + c = 0.


Then I guess the elementary school kids will use your FT system while we
will use our naturally burned-in sense of syntax from other
programming languages, eh?

Not saying this as a negative or anything, I'm just saying that most of
us have a habit, and it's not necessarily a bad nor good habit, of doing
things the way most languages have them done. For example, x = 8 is
extremely readable, to, I assume, most of us. Set x to 8, it takes some
time getting used to. Why should we switch to a language that will take
us time to get used and some more time to understand syntax when we
already understand and can efficiently use our current languages?

It's like going to the middle of London and screaming: "HEY GUYS GUESS
WHAT! I JUST INVENTED A NEW LANGUAGE AND IT'S VERY VERY EASY TO LEARN!"
And the people who would try the language would find the way you do
everything is very different from English, or their native language, for
that matter. Best let sleeping dogs lie.

Collin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top