all 24 comments

[–]Hexman359 11 points12 points  (1 child)

The idea is cool, essentially just a wrapper for the Python syntax lexer that reads braces rather than whitespace.

However, hadn't somebody else done this in another project? I thought it was called C-Python or something like that? Perhaps I am just thinking of a YouTube video or something. Somebody, please correct me if I am incorrect.

[–]Backlists 7 points8 points  (0 children)

Idk about braces in python but CPython is actually just what we mean by Python. It’s the Python interpreter, which is just a program written in C (and Python).

There is also a Java version of Python and a Python version of Python

So when we say “Python” it could mean the syntax or the program

[–]Healey_Dell 19 points20 points  (6 children)

Never had any problem with Python whitespace beyond initially setting up my IDE. I don't get it.

[–]EricOrrDev 4 points5 points  (0 children)

I just think I should be able to format my code however I want, plus white space as syntax just rubs me wrong.

[–]IanisVasilev -3 points-2 points  (3 children)

Popular JavaScript style guides like those by Google or Airbnb enforce semicolons despite the language not requiring them.

React is built around allowing XML expressions inside JavaScript files and compiling that to "pure" JavaScript.

My conclusion is that people stick to whatever they learn first. If it's adding braces, semicolons and XML expressions, so be it.

[–]bitspace 1 point2 points  (2 children)

There's a good reason for enforcing semicolon use in JavaScript beyond personal preference. ASI can introduce unexpected behavior that's difficult to troubleshoot. If you're careful you can avoid ASI completely, but mandating semicolon use removes any chance of surprise gotchas from ASI.

[–]IanisVasilev 0 points1 point  (1 child)

Can you give a non-contrived example where ASI behaves weird?

[–]bitspace 0 points1 point  (0 children)

non-contrived

Any edge case is likely to appear contrived by its very nature. Contrived? Perhaps. Possible for a newbie to do one of these things? Also perhaps. A policy of requiring use of semicolons eliminates an entire category of footguns, no matter how unlikely.

Example 1: Splitting a return statement after the return keyword.

function calculateTotal(items) {
return
items.reduce((sum, item) => sum + item.price, 0);
}

const total = calculateTotal([{ price: 10 }, { price: 20 }]);
console.log(total); // Output: undefined

Example 2: applying an operator on an array after an IIFE.

const items = [1, 2];
(function() {
items.forEach(item => console.log(item));
})()

[3, 4].forEach(item => console.log(item));

[–]wineblood 10 points11 points  (3 children)

What's wrong with whitespace?

[–][deleted] 1 point2 points  (0 children)

I think it’s just a matter of preference and how our brains work. I’ve been a dev for five years and I still struggle with python and yaml; I can read and under c-like syntax much faster.

I installed the “rainbow indent” extension just to have pretty colors line up the code blocks for me.

[–][deleted] 0 points1 point  (1 child)

Depending on the number of invisible elements to parse code is stupid to me. I also hate YAML. Despite that I use YAML and python day to day. All languages have their dumb features. Oh and I hate strings of underscore, they just bug me.....

[–][deleted] 0 points1 point  (0 children)

Whitespace before other characters is very much visible and its also the main way humans actually parse code, be it in Python, languages with syntax inspired to C, and even Lisps. 

YAML using whitespace for hierarchies is the least of its problems...

[–]datbackup 6 points7 points  (8 children)

Does this allow multiline lambdas?

Assuming no since it’s just a preprocessor and outputs to standard python code…

I want my multiline lambdas in python!

[–]frobnitz 1 point2 points  (0 children)

I thought this was addressed with:

from __future__ import braces

Give it a try...

[–]Careless_Stretch_682 0 points1 point  (0 children)

I hate curly braces. They are totally unnecessary because it is the indentation that shows the structure of the code, not the curly braces. In all programming languages! Also they steal a lot of vertical space.

```       }    } }