Eli Barzilay | 1 Aug 01:24
Favicon
Gravatar

Re: [racket] syntax, differently

On Jul 31, hendrik@... wrote:
> 
> It would suffice to change the colour of a parenthesis whenever its
> mate is not at a compatible level of indentation.
> 
> Let the programmer decide what has to be done to fix this.  He can
> indicate this by continuing to edit.  He may well let coloured
> parentheses accumulate until he's ready to deal with them.

Just to give an example, I use

  (if E1
    E2
    E3)

religiously (and I have detailed reasons to do so) -- even in DrRacket
where I can't set it to follow this indentation, I fix it manually.
An editor that does anything in response to that (reindents, colors it
in red, makes a sound) would be useless to me.

--

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!
hendrik | 1 Aug 03:42

Re: [racket] syntax, differently

On Sat, Jul 31, 2010 at 07:24:03PM -0400, Eli Barzilay wrote:
> 
> Just to give an example, I use
> 
>   (if E1
>     E2
>     E3)
> 
> religiously (and I have detailed reasons to do so) -- even in DrRacket
> where I can't set it to follow this indentation, I fix it manually.
> An editor that does anything in response to that (reindents, colors it
> in red, makes a sound) would be useless to me.

Yes, if you do that religiously, you don't need anything else.
But if you ever make a mistake and the editor points it out, it might 
help you remain true to your faith.

-- hendrik
Eli Barzilay | 1 Aug 03:39
Favicon
Gravatar

Re: [racket] syntax, differently

On Jul 31, hendrik@... wrote:
> On Sat, Jul 31, 2010 at 07:24:03PM -0400, Eli Barzilay wrote:
> > 
> > Just to give an example, I use
> > 
> >   (if E1
> >     E2
> >     E3)
> > 
> > religiously (and I have detailed reasons to do so) -- even in DrRacket
> > where I can't set it to follow this indentation, I fix it manually.
> > An editor that does anything in response to that (reindents, colors it
> > in red, makes a sound) would be useless to me.
> 
> Yes, if you do that religiously, you don't need anything else.
> But if you ever make a mistake and the editor points it out, it might 
> help you remain true to your faith.

(The point there is that drracket can't do that kind of indentation,
so it will interfere instead of help.)

--

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!
Todd O'Bryan | 1 Aug 03:43
Picon

Re: [racket] syntax, differently

Given that I'm reading this with a variable-width font, what is the
style of indentation?

If it's two spaces after the first "if", can't you tell DrRacket to
indent "if" as if it were "define" and won't that fix it?

Todd

On Sat, Jul 31, 2010 at 9:39 PM, Eli Barzilay <eli@...> wrote:
> On Jul 31, hendrik@... wrote:
>> On Sat, Jul 31, 2010 at 07:24:03PM -0400, Eli Barzilay wrote:
>> >
>> > Just to give an example, I use
>> >
>> >   (if E1
>> >     E2
>> >     E3)
>> >
>> > religiously (and I have detailed reasons to do so) -- even in DrRacket
>> > where I can't set it to follow this indentation, I fix it manually.
>> > An editor that does anything in response to that (reindents, colors it
>> > in red, makes a sound) would be useless to me.
>>
>> Yes, if you do that religiously, you don't need anything else.
>> But if you ever make a mistake and the editor points it out, it might
>> help you remain true to your faith.
>
> (The point there is that drracket can't do that kind of indentation,
> so it will interfere instead of help.)
>
(Continue reading)

Eli Barzilay | 1 Aug 03:48
Favicon
Gravatar

Re: [racket] syntax, differently

On Jul 31, Todd O'Bryan wrote:
> Given that I'm reading this with a variable-width font, what is the
> style of indentation?

Replacing spaces with "~"s:

  (if~E1
  ~~E2
  ~~E3)

> If it's two spaces after the first "if", can't you tell DrRacket to
> indent "if" as if it were "define" and won't that fix it?

No, because a newline after "if" will indent the condition with two
spaces too.  (You could probably argue that this means that the
indentation for deifnitions is broken too.)  The whole point of my
indentation is that I treat the two branches as "body" expressions
rather than arguments -- unlike the condition.

--

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!
Mathew Kurian | 1 Aug 06:34
Picon

Re: [racket] syntax, differently


Hey guys,

Since I myself am beginner programmer and a student in high-school, i thought that my opinion might be beneficial to the racket community. So here goes:

I am basically going to list out the pros and cons how drracket actually places the code:

Pros:
1.----Color-coding (differenciating between the strings, chars, comments, functions, etc) (this is a very useful feature, for students who, like myself, are learning programming)
2.----The auto indent is also very good to a certain degree. (the only problem is taht 
3.----The program contour is very useful for students who are used to visual representation of the code.
4.----Highlighting of the text enclosed within a set of parentheses. (extremely useful)

Con
1.----Because some of the code can get very long (unlike some other languages), it is important for students to be able to keep the code very neat, so I think it is vital that drracket never leaves brackets partially hanging when the width of the drracket-frame-width is reached. It can get very challenging to find a simple mistake.
2.----Optimization of font-color loading (for a lack of a better word). To give you a better idea during coding take this case into consideration: In 30 minutes of coding, I can take up to 10 minutes just waiting for the program to end the current compilation [my pc specs: i3, windows 7, 4 GB DDR3 RAM, 500 GB hard drive]. So in a school environment, it would be inefficient for students to code within an alloted 45 minutes of class time.

Some Features that will be extremely useful for students (i can stress this enough)
1.----When you click on a defined function name, it is necessary that all the same phrases are highlighted throughout the whole file. 

Here is an example:
(define (paint-engine s)
    (draw-extras [lets say, i click this and the blinking cursor is between "a" and "w". then the throughout the whole file that whole phrase "draw-extras" is highlighted]
     (draw-gun
      (draw-health
       (draw-helis-health
        (draw-title......

Like I said, this is so vital for beginning programmers. It made it so much easier for me to find errors, in some cases cutting down the time taken to find errors from hours to minutes.

2.----One other feature that would be excellent is actually a popup list that comes up whenever typing the first word after every parentheses. Since this is usually a name of a function, it would be useful if drracket lists all functions that begin with the first letter typed after the parentheses. After the second letter is typed, the list narrows down the list to include the first two characters typed...and so on. For beginning programmers, I found it useful to use that feature since it easens what the students have to remember, while promoting a good programming syntax.

3.----Since drracket indents the a line after taking into consideration of the previous line and since it compiles one line after another, it maybe auto-indent the lines when you click run, so it keeps the code clean by itself (self-cleaning).

Hopefully this information actually pertains to what you all are talking about or can be useful.

And BY NO MEANS am I saying "drracket is not good", if that is what you have got out of this reply.

If you have any problem(s) deciphering my sometimes unclear statements, please don't hesitate to ask.


Matthias Felleisen | 1 Aug 19:57
Favicon

Re: [racket] syntax, differently


On Aug 1, 2010, at 12:34 AM, Mathew Kurian wrote:

1. Your comments are appreciated. Thank you. 

2.

> Because some of the code can get very long (unlike some other languages),

What do you mean with that? When I have students write large programs, my Racket programs are routinely a
factor of 3 or more shorter than those of the best of my students (5Kloc in Racket vs 15Kloc in Java or C# or
C++), tend to perform more tasks, and are more stable. 

> it is important for students to be able to keep the code very neat,

That is true in all languages, period. 

3. 

> Since drracket ... compiles one line after another, ...

DrRacket does not compile line by line. Indeed, lines have nothing to do with compilation. Please take  a
look at HtDP's extended exercises on interpreting Scheme. That'll give you an idea of what compilation is
and why lines are irrelevant. 

-- Matthias

Laurent | 1 Aug 20:10
Picon

Re: [racket] syntax, differently


> Because some of the code can get very long (unlike some other languages),

What do you mean with that? When I have students write large programs, my Racket programs are routinely a factor of 3 or more shorter than those of the best of my students (5Kloc in Racket vs 15Kloc in Java or C# or C++), tend to perform more tasks, and are more stable.

I'm not sure but I think he meant " *lines*  can get very long".
Martin DeMello | 1 Aug 20:17
Picon

Re: [racket] syntax, differently

On Sun, Aug 1, 2010 at 1:34 AM,  <hendrik@...> wrote:
>
> Don't go reindenting the entire file without explicit request.  Whenever
> something happens to me like that, I am lost in the code.  Usually the
> indentation is more correct than the parentheses, even when my editor
> provides no automatic support, and I use the indentation as a guide to
> find my way around, and to guide me when I insert parentheses.

Students, in particular, should get used to frequent autoindenting
rather than manually inserting spaces. Then, if the indentation of a
section ever looks different than you felt it should, that's where
your mistake is.

As for when to do it, I think a nice compromise between "force
autoindent-all" and "don't perform magic behind the student's back" is
to track the dirty state of autoindentation, and disallow the "run"
button until "autoindent-all" is clicked.

martin
Mathew Kurian | 1 Aug 20:44
Picon

Re: [racket] syntax, differently

Matthias Felleisen: "What do you mean with that? When I have students write large programs, my Racket programs are routinely a factor of 3 or more shorter than those of the best of my students (5Kloc in Racket vs 15Kloc in Java or C# or C++), tend to perform more tasks, and are more stable."

Reply: I apologize for not being more precise with my statement and what i meant was slightly different. Students, like myself, and especially those in the beginning of their programming career have challenges optimizing the code. So what most students would like to do (i have had to help many at my school with their code and have seen this directly) is actually write whatever they can to make the program work. For instance, they write a program with over 100 lines of code which actually only requires 50 lines of code. In both cases, the program works, although optimization is overlooked in the former case. Then realizing that their code is actually too long and too hard to work with, these same kids go back and edit their code, cutting down the number of lines in order to increase both optimization and ease of program growth.

My statement: "it is important for students to be able to keep the code very neat."
Matthias Felleisen' Reply to the above statement: That is true in all languages, period.

Reply: I agree with Matthias in this case if one is not coding with universe/world teachpacks. The basic Racket including the gui components and the other basic components look very clean and easy to understand in a large program. Usually these codes, like Matthias said, can be put in sets maxing at 3 lines, and is very neat and easy to read to a third-party. However, in the case of universe/world teachpacks, where the use of states is a vital component, a set of code can get very long, especially if the program is very complex and contains multiple structures (in some cases structures inside structures inside structures) within the states. With that said, I was trying to emphasize that it may be harder to students to keep their code neater compared to some other languages which usually have code that rarely exceed 1 line.

Example:
Racket using the universe teachpack:

(define (s-mouse-engine s x y event)
  (cond
    [(and 
      (and (> x 248)           (< x 424)) 
      (and (> y 570)           (< y 649)))
        (make-S-STATE
         (get-s-background s)                ;;I have made methods here to reduce length, but other wise it would be longer.
         (make-button
          (s-mouse-engine-worker1 event "button-img")
          (get-s-button-x s)                   ;;I have made methods here to reduce length, but other wise it would be longer.
          (get-s-button-y s)                   ;;I have made methods here to reduce length, but other wise it would be longer.
          (s-mouse-engine-worker1 event "button-initiate")))]

I hope I have clarified any of the questions and i will try to put a mock-up of what i am talking about in my previous comment.

PS: I am sorry for my error in the statement about drracket compilation.

Gmane