News for hackers. Stuff that matters.
Re:Your programming language is probably unproductive by gravypod on Wednesday September 28, 2016 @10:45AM (#12598034)
> The introduction of braces in the code was a trigger for a number of religious wars, and it made us, developers, focus on the design of the language instead of focusing on the most important thing in our work - solving real problems.

How can you correctly solve problems without being able to look at your code and reason, instantly, about what is grouped together. Let alone tracing through your code but just seeing what statements are grouped with what.

One such suggestion, as provided by the author, is whitespace.

I can't tell you how bad of an idea this is. Just from a teaching perspective. I help tutor for CS100 at my university and a large part of the errors I have to deal with are whitespace errors. People don't understand where a block starts and ends. It's less key strokes but that doesn't mean it's easier or better.

> Languages like Java and C# made it to the almost ridiculous point where not only we have to be very explicit about every aspect of our code, but also made us split this code into an endless amount of files

I see no issue with splitting up a problem into multiple parts that, if sufficiently different, could be hidden from each other.

In the end, I don't think a language can be (un)productive. A language is the means for expressing a solution. Your job as a programmer is to conceive a solution to a problem and pick a language that will best let you express that problem.

Some times functional languages are better at this, some times other languages are better. The thing we should be arguing about is what is best expressed in which language.

Re:Your programming language is probably unproductive by 6DM on Wednesday September 28, 2016 @10:58AM (#12598135)
I started a project out using jade in nodejs, after a while I had a page with enough elements/nesting going on that I was having a hard time keeping track of what was grouped where. Particularly when taking some work a designer did, making it jade compliant, then pasting in.

Aside from a short "if" statement, I now no longer think it's sexy to abandon ending notation whether it be braces, elements, etc.

Re:Your programming language is probably unproductive by gravypod on Wednesday September 28, 2016 @11:03AM (#12598177)
I'd suggest you not leave if statements un-braced. I remember a study where they found the most common bug in most experienced open source developers was leaving out the braced initially, going back to make a change, and having that change introduce a bug.

Basically they had

   if (x)
      then()
and went back and did

   if (x)
      new_call()
      then()
and caused an error that happened silently.

This is something you definitely want to avoid and I personally don't trust myself, after a no-sleep code fixing bender, to remember to add {} around something if I'm editing an if. I'd probably forget.

Again, I'd say shorter does not mean better.

Re:Your programming language is probably unproductive by papaf on Wednesday September 28, 2016 @12:50PM (#12599219)
One way round this is to put single statement ifs on a single line:

    if (x) then();
If you add another statement to the if, its obvious from the indent that you need to use braces.
Re:Your programming language is probably unproductive by petre on Wednesday September 28, 2016 @01:21PM (#12599488)
Yup, I always do this when writing JavaScript or other languages that allow prefix single statements with or without braces. Otherwise I use braces if the statement is too long to fit in the editor w/o forcing you to scroll. Perl only allows postfixed single statements w/o braces, so you're safe:

    say "yes" if $condition;
    if ($condition) {
        say "yes";
        $affirmative++;
    }
Re:Your programming language is probably unproductive by gpderetta on Wednesday September 28, 2016 @04:35PM (#12601144)
7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]

if (x)

^~

9 : note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'

then();

^~~~

Re:Your programming language is probably unproductive by gravypod on Thursday September 29, 2016 @08:38AM (#12604764)
Relying on compiler-specific features.... where did I hear that before?

Oh yea, undefined behavior. Do you like using undefined behavior?

Re:Your programming language is probably unproductive by gpderetta on Thursday September 29, 2016 @09:26AM (#12605019)
That's just a warning. It has no effect on the generated code.

It is perfectly acceptable, and in fact considered proper engineering practice, to compile with multiple compilers to take advantage of their warning and static analysis capabilities.

Re:Your programming language is probably unproductive by parenthephobia on Wednesday September 28, 2016 @12:23PM (#12598964)
I don't see how having closing braces makes it easier to see what's grouped, though.

If you have a page with enough elements and nesting going on that indentation doesn't make its structure clear, I find it hard to believe that you'll see </div></div></div> and think "oh yes, I just closed <div class='wombat'>".

A good editor may highlight the region that a </div> covers, and/or show the opening element and/or the "path" to the current element in the status bar.

But, a good editor that understands indented syntax could do the same. It is a fault in code editors that they don't often have good features for navigating around source which uses indenting. This isn't a problem with the syntax.

FWIW, I use SLIM - which is a Jadelike language for Ruby - and I hate having to deal with raw HTML. I find it incredibly hard to navigate, primarily because of the lack of indentation. All too often you think a particular block is contained in some element but it turns out it just looks that way because somebody decided to use indentation whitespace decoratively.

Re:Your programming language is probably unproductive by emodendroket on Wednesday September 28, 2016 @04:04PM (#12600849)
> I see no issue with splitting up a problem into multiple parts that, if sufficiently different, could be hidden from each other.

I'd go so far as to say breaking a problem up into black boxes that solve smaller parts of the problem is one of the most basic skills in programming.

Re:Your programming language is probably unproductive by dllthomas on Wednesday September 28, 2016 @04:15PM (#12600955)
> Just from a teaching perspective. I help tutor for CS100 at my university and a large part of the errors I have to deal with are whitespace errors. People don't understand where a block starts and ends.

On the flip side, when I was in school and a peer asked me to look over their code, it was usually an unindented mess and they still very much had no idea "where a block starts and ends" despite the braces.

When Python was introduced, I was hopeful that a technical demand that indentation be done properly might actually help, pedagogically. On reflection, imposing this at linting with a brace-based would probably be better still, as the error messages could be substantially better targeted.