Hacker News new | ask | show | jobs
by brirec 2135 days ago
This probably makes me sound like an old man, but probably the biggest thing keeping my interest in Python too low to really learn it was the syntax. I really like the c-like syntax of many languages, and Python’s use of significant whitespace instead of braces just seemed too foreign to me.

That said, even if it gives me the syntactic sugar I crave I don’t know how much I’d be willing to trust a little-used language that compiles to something more common, because I’d worry about how its maintenance goes.

If the software goes unmaintained, would the syntax of Python outgrow it and break it? Maybe new features wouldn’t be usable? So while that syntactic sugar is indeed tasty, I don’t think this is what I need to get going in Python.

5 comments

I thought Pascal was weird, but that's because I learned BASIC first. I thought C was weird but that's because I learned Pascal before.

There happen to be a handful of popular languages that are C-like in scope syntax, but it is important to get beyond the first thing you happened to learn. It is like only eating the cuisine from the country where you were born.

I learnt BASIC when I was young, and then (Borland Turbo)Pascal after that, and C family languages (including C and Java and such) after that. Then I learnt Python, and even wrote a lot of it at Uni and for various jobs -- enough that I'm pretty firm in my distaste for significant whitespace, and I don't believe it's because I started with C.

It may be popular, but it presents a number of challenges in Python and in other languages like YAML. If you're going to buck the C trend, at least make it somewhat ergonomic like Lua which I learnt recently and kind of like.

It’s funny both you and the GP comment followed the same exact steps as I did. I guess I technically learned Pascal with with Turbo Pascal and also with Delphi. But yeah it’s funny because Python is where I ended up. What I like about it is that it seems very pragmatic. There is no sloppiness in it but also no high dogma of how things ought to be if you want to be sure your program is correct. It lets you get stuff done and gets out of your way.
Me three, and I think the intented blocks were a masterstroke. Why do so many others have redundant braces or begin/end markers while still need to indent?
I started with x86 Asm and was exposed to C and Pascal at roughly the same time (as well as XPL0: https://en.wikipedia.org/wiki/XPL0 , which is described as a mix of the two but is really like "C with Pascal syntax"), and much prefer the brevity of the C syntax. I suspect that's the reason a lot of other languages also adopted it.
Are chillies the braces of cuisine?
If you can’t get over the syntax differences I can’t imagine why you’d ever want to program in Python. You don’t need to force yourself to like or use Python in the same way some people just don’t want to eat fish, or choose to be vegetarian. It’s not for everyone. Why try to shove a square peg in a round hole?
Lots of great statistical and NLP libraries are written in Python. I'd actually argue Python is one of the few languages without a great alternative for certain niches right now.
Then have a look at Julia, you can use all those libraries from Julia and its own as well.
Interop comes in many flavors. If I were to consider Julia a replacement for Python, I'd need to know that Julia can interop seamlessly with it, like Kotlin can with Java.

How do you feel about the user experience for Julia/Python interop?

I can only tell you that I consider it excellent and that I would rather use Julia with PyCall than Python.
Julia has an excellent interop story with many languages. Probably C, Fortran and Python are the most polished.

Check out https://github.com/JuliaPy/PyCall.jl

I strongly dislike python, but I do have to use it because so many libraries are written for it.

It's the pragmatic choice.

Look at Julia and PyCall.jl, as well as its own libraries.
Except, if your job requires it.
I am the opposite. I love the whitespace significant syntax in Python. I indent my code in languages like C and Java anyway, so why bother with braces. Also, a missing brace takes a long time to find, because autoformatting tools go crazy and the error isn't usually quick to find by the compiler so it fails tens of lines below where the brace is actually missing.
Opposite. I can't stand languages that require programmer to do menial tasks such as add additional punctuation to indicate blocks that are clear from indentation. Or for end of line when there's a carriage return.

And that produce visual noise and based on many formatting standards enforce wasted vertical space (curly on its own line) being able to see more code on screen without scrolling.

I have to type that whutespace. Whitespace indentation and line breaks are the most significant visual elements. Why would the compiler ignore that?

I just put 'pass' at the end of each block... Emacs could actually do proper auto-indenting then.
haha yes I wish emacs could do that too but the thought of a redundant pass in every block would probably bother me more than the lack of auto-outdent.

That colon that starts every indented block is like an unmatched opening brace though.

Thing I know from implementing simple line protocols. Pythons encoding just blows. Languages with defined begin and end tokens are better.
Dumb question, what's the use case for a line protocol?
Just stupid serial protocols to talk between devices. Often you have problems with picking commands and responses out of noise and or garbage. Think half duplex RS485. Protocols that use one token for delineating messages have poor error recovery/synchronization. I think pythons grammar is rather poor as a result. Other languages are far better. It's important because it effects tooling because tooling often has to deal with broken input.
Eh, I wouldn't assign that too much importance. Most C/C++ tooling practically gives up on a missing closing brace and almost never gives the right error message.
C and vastly more so C++ have a lot of other problems. C compilers can give the right error message 95% of the. But They have an excuse since they are older languages. Python was developed in an era when people knew better.

Java and C# are examples of well designed grammars. Tooling was a first class requirement for C# and it shows. Where python will never have great tooling.