News for hackers. Stuff that matters.
Re:Ask HN: What made you change your mind about a programmin... by salex89 on Sunday March 03, 2019 @08:28PM (#19298122)
Using it as my main language: Python (2.7). How the hell did this thing become so popular?

I've used it for all sorts of stuff earlier, less complex than the other. Scripts, devops, ETL... But then I got into a company that is using it for some quite serious stuff, a large codebase. Holly smokes this thing does not scale (in terms of development efficiency and quality) well. I swear at least 70% of our bugs is because of the language and half of the abstractions are there just to lessen the chance of some stupid human mistake.

Sorry, but I will not pick it ever again for even a side project.

Re:Ask HN: What made you change your mind about a programmin... by anyfoo on Sunday March 03, 2019 @08:52PM (#19298189)
I started using python 3 with mypy, which provides (optional) static typing, and my gosh has it reduced the time I spend looking for stupid problems by orders of magnitude.

I got a somewhat direct comparison when I mypy-ified a small program where I used a lot of async and await (basically implementing own event loops and schedulers, it was interfacing very custom hardware that handled very different but interacting streams at once).

So basically I did it because I was tired of not noticing mixing up "foo()" and "await foo()", but then the static typing continued to catch a myriad of other, unrelated problems that would have ruined my day way late (and often obscurely) at runtime.

For small ("scripty") to moderate sized things, mypy absolutely recovered my faith in it.

I also completely switched to python 3 after being in python 2 unicode hell just once. There are very good reasons for python 3.

Re:Ask HN: What made you change your mind about a programmin... by o10449366 on Sunday March 03, 2019 @09:42PM (#19298396)
Agreed. As part of the transition process from Python 2 to 3, I pushed for typing on all of the critical components. I had to fight the management a little on the commitment, but in the long run it's saved us a ton of time identifying and preventing bugs and its made the entire codebase much more cohesive.
Re:Ask HN: What made you change your mind about a programmin... by em-bee on Monday March 04, 2019 @11:48AM (#19302630)
does the management agree with that assessment? these kind of changes are often hard to evaluate because ot is not easy to compare. did development really go faster because of types, or do we just think it did?

i agree that typing saves time but i am struggling to produce evidence for that

Re:Ask HN: What made you change your mind about a programmin... by anyfoo on Monday March 04, 2019 @04:15PM (#19305599)
It's not very hard to find the evidence before you move to static typing.

Just think about this not uncommon scenario: "The program crashed two hours into testing because apparently, we somewhere set this element in this deep structure to an integer instead of a list, and are now trying to iterate over that integer. But we cannot easily fix it, because we don't know yet where and why we set it to an integer."

The compiler would have immediately given you an error instead.

So, collect all the errors that are, e.g.:

- Addressing the wrong element in a tuple,

- any problems arising from changing the type of something; not just the fundamental highest level type ("list" or "integer"), but small changes in its deeper structure as well, e.g. changing an integer deep in a complex structure to be another tuple instead,

- "missed spots" when changing what parameters a function accepts; this overlaps with the former point if it still accepts the same arguments on the surface, but their types change (in obvious, or subtle "deep" ways),

- any problems arising from nesting of promises and non-promise values,

and many, many other problems where you can trivially conclude that the compiler would have spit out an error immediately, and explain to management how various multi-hour debugging session could have been resolved before even running your thing.

Re:Ask HN: What made you change your mind about a programmin... by nikofeyn on Monday March 04, 2019 @09:32AM (#19301505)
as a serious question, why even use python if you have to go through hoops to make it work even half as well as other languages? are you reliant upon some python only library?
Re:Ask HN: What made you change your mind about a programmin... by nikisweeting on Monday March 04, 2019 @11:37AM (#19302519)
My experience when switching to other languages is "why do you have to go through so many hoops to make this work even half as well as Python"...
Re:Ask HN: What made you change your mind about a programmin... by magduf on Monday March 04, 2019 @04:06PM (#19305496)
In my experience, Python is usually used because of a low barrier-to-entry and the availability of a lot of libraries. It's great for slapping something together quickly to do something useful. However, if you want something that's high-performance and well-engineered, it just isn't the right tool for the job usually.
Re:Ask HN: What made you change your mind about a programmin... by targafarian on Monday March 04, 2019 @11:08AM (#19302265)
> go through hoops

mypy and types are only "hoops" in comparison to non-annotated Python (in terms of added syntax / coding effort), yet compared to explicitly typed languages where you have to declare types, that's just standard thing you have to do so there is no extra effort in comparison to these other languages (and then the judgment that it only works "half as well" is controversial (Edit: or at least needs qualification)).

Re:Ask HN: What made you change your mind about a programmin... by nikofeyn on Monday March 04, 2019 @01:44PM (#19303973)
i prefer ml dialects like f# or ocaml or something like racket that gives you both static and dynamic languages that can interoperate. in f# and ocaml, the type inference handles most things, although you do need to manually declare types sometimes. it is often a good idea anyway.

and what i mean by hoops is that python is not designed to have static types. thus, any type system added is tacked on by definition and will lead to "hoops". in something like f#, at no point will the existence of its type system and inference be a surprise. the language is built around and with the type system.

Re:Ask HN: What made you change your mind about a programmin... by salex89 on Monday March 04, 2019 @04:10AM (#19299848)
I suppose you are right. But with a huge code base, migration is not an overnight process...
Re:Ask HN: What made you change your mind about a programmin... by arbie on Sunday March 03, 2019 @10:16PM (#19298517)
Couldn't agree enough. I have seen Perl (with automated PerlTidy on check-in) scale to levels I would never even attempt with Python.
Re:Ask HN: What made you change your mind about a programmin... by simonh on Monday March 04, 2019 @02:38AM (#19299482)
Having worked on Quartz, probably in the handful of biggest Python code bases on the planet, that's just not my experience at all. It scaled very well and was a fantastic environment to work in. It certainly wasn't ideal for every use case, but then what is?
Re:Ask HN: What made you change your mind about a programmin... by fierro on Sunday March 03, 2019 @08:34PM (#19298143)
I think dynamically types languages are on their way out. There aren't many good arguments remaining in favor of them.
Re:Ask HN: What made you change your mind about a programmin... by ken on Sunday March 03, 2019 @08:47PM (#19298178)
I don’t think that’s the problem. I wouldn’t use Python (especially 2.x), but I’d have no hesitation with using Common Lisp. It has lots of great features for programming in-the-large that Python simply lacks.
Re:Ask HN: What made you change your mind about a programmin... by yuchi on Sunday March 03, 2019 @08:51PM (#19298188)
Genuinely asking: could you provide some specific example? What does CL has that Pythos doesn’t? (Disclaimer: i never worked on neither)
Re:Ask HN: What made you change your mind about a programmin... by chalst on Sunday March 03, 2019 @10:18PM (#19298531)
If I had to point to something, I would single out CL's powerful support for multiple dispatch. I'd hesitate to recommend CL to undisciplined programmers, because it is too easy to write code that works but you don't understand a week later.
Re:Ask HN: What made you change your mind about a programmin... by ken on Monday March 04, 2019 @02:11AM (#19299382)
(I hammered out that answer right before I had to run on stage. A couple other big items I forgot:)

A proper numeric tower. Python has complex numbers, but they don't seem well integrated (why is math.cos(1+2j) a TypeError?). Fractions are frequently very useful, too, and Python has them, in a library, but "import fractions; fractions.Fraction(1,2)" is so much more verbose than "1/2" that nobody seems to ever use them.

Conditions! Lisp's debugger capabilities are amazing. And JWZ was right: sometimes you want to signal without throwing. Once you've used conditions, you'll have trouble going back to exceptions. They feel restrictive.

(I've come to accept that in a language with immutable data types, like Clojure, exceptions make sense. Exceptions feel out of place, though, in a language with mutability.)

Other big wins: keywords, multiple return values, FORMAT (printf on steroids), compile-time evaluation, a native compiler (and disassembler) with optional type declarations.

Lisp is unique among the languages I've used in that it has lots of features that seem designed to make writing large programs easier, and the features are all (for the most part) incredibly cohesive.

Re:Ask HN: What made you change your mind about a programmin... by chalst on Monday March 04, 2019 @08:02AM (#19300876)
Conditions, yes.

If you have multiple dispatch, then building/supporting a numeric tower is natural.

In your other reply you pointed out macros. They are a mixed blessing, easily misused. Other languages have them but use them more sparingly and making it harder to overlook their special status, which leads to better "code smell" in my opinion.

Do take a look at Julia. It has learned deeply from CL and innovated further.

Re:Ask HN: What made you change your mind about a programmin... by ken on Monday March 04, 2019 @12:42PM (#19303247)
I can imagine how multiple dispatch could make a numeric tower a little easier to implement, but the limitations I see in Python and other languages don't appear to stem from that. You can already take the math.cos of most types of numbers (int, float, even fractions.Fraction, ...) just fine, or add a complex and a Fraction. Python has long dealt with two types of strings, several types of numbers, etc., with the same interfaces. This isn't a difficult problem to solve with single dispatch.

Macros are easily misused, true, but so can any language feature. I can go on r/programminghorror and see misuses of if-statements. It's the classic argument against macros, and I hear it a lot, but I can't say I've seen it happen.

25 years ago, conventional wisdom said that closures were too complex for the average programmer, and today they're a necessary part of virtually every language. Could we be reaching the point where syntactic abstraction is simply a concept that every programmer needs to be able to understand?

I think "macros are easy to misuse" comes from viewing macros as an island. In some languages (like C), they are: they don't really integrate with any other part of the language. In Lisp, they're a relatively small feature that builds on the overall design of the language. Omitting macros would be like a periodic table with one box missing. It'd mean we get language expressions as native data types, and can manipulate them, and control the time of evaluation, but we just can't manipulate them at compile time.

Re:Ask HN: What made you change your mind about a programmin... by ken on Sunday March 03, 2019 @10:39PM (#19298597)
Multiple dispatch is a big one.

Also, macros, which are what (the view layer of) CLOS is built with. In most other object oriented languages, the language isn’t powerful enough to implement its own object system.

Having the full power of function calls in all cases (named or anonymous) is incredibly helpful. I know the Python party line is “just use def” but adding a line here and a line there adds up fast. A syntax for function objects is also great.

I’ll also call out the ability to use dynamic or lexical scoping on a per-variable basis. That has saved me hundreds of lines of work, and made an O(1) change actually an O(1) patch.

Re:Ask HN: What made you change your mind about a programmin... by jononor on Monday March 04, 2019 @09:36AM (#19301525)
I think the dynamic/static typing dichotomy is on its way out (finally!). In dynamic languages optional/gradual typing is getting adopted (ex: Typescript/Flow for JS, Mypy for Python). In static languages type inference is getting standard (ex: Rust/Scala/Kotlin, auto in C++11).
Re:Ask HN: What made you change your mind about a programmin... by chalst on Sunday March 03, 2019 @10:14PM (#19298507)
I have a very high opinion of Julia's dynamic type system. Some static type systems are not very expressive, e.g., Elm, which encourages hacky workarounds. Julia's type system encourages specificity, which exposes problems early.
Re:Ask HN: What made you change your mind about a programmin... by SolarNet on Monday March 04, 2019 @01:47AM (#19299293)
That's because it's a strong type system (as opposed to python's weak one where objects can change their shape anytime). Even calling it dynamic is a sort of lie since the compiler is always able to reason about the types it is given due to the way Julia's JIT compiler works. It's "dynamic" in the same way passing around `void*` (or `object`) is "static".

That being said Julia's type system is definitely the way of the future in my opinion.

Re:Ask HN: What made you change your mind about a programmin... by jcbrand on Monday March 04, 2019 @04:40AM (#19299986)
Python is strongly typed.

See here: https://wiki.python.org/moin/Why%20is%20Python%20a%20dynamic...

"objects can change their shape anytime" is a function of dynamic typing and is orthogonal to strong or weak typing.

Re:Ask HN: What made you change your mind about a programmin... by SolarNet on Tuesday March 05, 2019 @02:33AM (#19308815)
In a dynamic language "strong" vs "weak" typing really depends on the standard library. All the examples in the given link - for example - focus on the addition function in the standard library. So here are some counter examples:

Everything can be used as a bool. This was often used to check for None, but had some issues when used with - for example - datetimes which evaluated midnight as false. In part due to the fact the integer 0 evaluates to false.

Changing type unexpectedly is the key example given in your link (`"foo" + 3` is `"foo3"`). Meanwhile in python `foo.method()` can change the type of the variable foo. Which is a level of fuckery commonly found in javascript.

Let alone the fact that dynamic duck typing encourages weak typing over performing explicit conversions. This is embodied by "easier to ask forgiveness than permission" which says it's better to catch the type conversion exception than check if the type is an integer ahead of time. Which then leads to implementing javascript-esque add functions anyway.

I'll grant you python is stronger than some other dynamic languages, but it is still at least half an order of magnitude weaker than Julia, which is strong in ways approaching Haskell.

Re:Ask HN: What made you change your mind about a programmin... by spricket on Sunday March 03, 2019 @10:37PM (#19298591)
I agree, because type inference in some (Typescript) is good enough that there's almost no overhead. Back when it took twice as many lines with types it made sense. But the overhead in typescript is maybe 10%, worth it anymore? I don't think so
Re:Ask HN: What made you change your mind about a programmin... by chuckdries on Sunday March 03, 2019 @11:18PM (#19298741)
I think we have a ways to go. Typescript's type system is very feature complete (which is a good thing, but it also means there's a lot to learn, and I feel like I have to think about type definitions more than I ever did with other languages), but also, fantastic libraries like Ramda have a lot of trouble with expressing their types with Typescript. It's a tough problem to solve, and I still use both, but I'm just saying we're not there yet.
Re:Ask HN: What made you change your mind about a programmin... by spricket on Sunday March 03, 2019 @11:40PM (#19298823)
I agree that the type system is very complex. I've spent a lot of time wrapping my head around it and still get confused sometimes.

Unfortunately Typescript's type system is largely driven by the need to represent anything you can do in JS, for library compatibility reasons.

The main designer also wrote C# and Delphi. In a lot of ways, C#'s type system is better (less complex), but Typescript has the huge advantage of working with existing JS

Re:Ask HN: What made you change your mind about a programmin... by koyote on Sunday March 03, 2019 @10:17PM (#19298525)
Hah, I had the same thought when I first started using Python for some personal stuff many years ago. I enjoyed using it and it was quick to get some code out but I thought to myself "surely if you build anything large with this language it will be a massive pain to maintain".

Fortunately(?), I never worked for a company that used it for a large codebase so I never found out if my assumption was correct or not.

Re:Ask HN: What made you change your mind about a programmin... by jononor on Monday March 04, 2019 @09:47AM (#19301635)
You need a QA strategy to match the technology in use. No static type checking means many mistakes will need to be caught in another way. For instance with automated tests, or design-by-contracts. Which might also catch some things that static typing would not cover.

In a non-trivial system with solid engineering, QA concerns quickly go beyond details like which programming language is used. Like how to QA entire systems, sub-system interactions, ensure low time from bug discovered in production to fix deployed, eliminating recurring sources of issues etc.

But if the culture that caused the choice of a dynamic language is "oh its just so much easier and productive to not have to write types all the time!", then you are going to be in for some serious mess and pain in a larger system. That is not a technical problem with dynamic typing/language though :)

Re:Ask HN: What made you change your mind about a programmin... by koyote on Monday March 04, 2019 @04:19PM (#19305636)
That's a very good point: different languages require different QA strategies (do statically typed languages require less unit tests?).

My initial thought when working with Python wasn't from a bugs/QA point of view but merely looking at the productivity of a developer working on a large code-base. Things like accurate auto-complete, code discovery, architectural understanding, knowing what 'kind' of object a function returns and so on become more important once the codebase and the amount of engineers working on it increases.

Re:Ask HN: What made you change your mind about a programmin... by jononor on Monday March 04, 2019 @09:57AM (#19301716)
As another example, consider unsafe/safe like C/C++ versus Java/C#/Rust. Serious systems are built in C (cars, airplanes, medical devices) and it can be done OK - but it requires serious investment in QA, targeted at weaknesses of the language.
Re:Ask HN: What made you change your mind about a programmin... by tootie on Sunday March 03, 2019 @09:11PM (#19298280)
I've mostly done Java in my career and I tend to stick to it (or Kotlin now). I've always said the power of java isn't in solving programming problems, it's in solving organizational problems. The killer feature that vaulted it to the top and still hasn't been beat is javadoc.
Re:Ask HN: What made you change your mind about a programmin... by ChristianGeek on Sunday March 03, 2019 @10:40PM (#19298599)
The killer feature that vaulted Java to the top was cross-platform compatibility (regardless of the flaws), including AWT and Swing.

Source: Have been coding in Java since 1.0.

Re:Ask HN: What made you change your mind about a programmin... by dehrmann on Monday March 04, 2019 @12:09AM (#19298940)
Not javadoc the standard, but javadocs for the standard library. It explains behavior in much more detail than other languages' docs, so I'm rarely surprised.
Re:Ask HN: What made you change your mind about a programmin... by chalst on Sunday March 03, 2019 @10:03PM (#19298472)
Why do you think javadoc is better than docstrings? There are docstring-based languages that encourage good practice and can produce what I regard as excellent integrated docs. E.g., Julia's Documenter:

https://juliadocs.github.io/Documenter.jl/stable/

Re:Ask HN: What made you change your mind about a programmin... by cauthon on Monday March 04, 2019 @01:15AM (#19299182)
Is there a language that has a better (i.e. more user friendly and decently performant) implementation of iterators and stream processing?
Re:Ask HN: What made you change your mind about a programmin... by nanomonkey on Monday March 04, 2019 @12:58PM (#19303472)
Clojure's stream processing, and sequence functions are worlds better than Python. Clojure's sequences can be lazily evaluated which allows for much more performant computation. And for stream processing you can't beat composable reducer functions.

The user friendliness comes both with how uncomplicated it is to write them, but also how easy it is to process them in parallel (a nightmare in Python).

Re:Ask HN: What made you change your mind about a programmin... by dehrmann on Monday March 04, 2019 @12:07AM (#19298932)
I've used it at in a few jobs. Once place, mostly a Java shop, used it almost exclusively in a system that had grown to the point that it'd be hard to replace. The most insightful comment I got about it was that it's not that Python doesn't scale in terms of service instances or performance--it doesn't scale with codebase size and onboarding new developers.
Re:Ask HN: What made you change your mind about a programmin... by scottlocklin on Sunday March 03, 2019 @10:44PM (#19298612)
I quit around 2.2, never looked back. Python was a breakthrough scripting language ... in the 90s.
Re:Ask HN: What made you change your mind about a programmin... by diminoten on Monday March 04, 2019 @03:27AM (#19299660)
Realistically, how could you know if it's still any good if you haven't used it since 2.2? It's basically a different language now.
Re:Ask HN: What made you change your mind about a programmin... by scottlocklin on Monday March 04, 2019 @08:23AM (#19301002)
The same way everyone else does: fixing other people's broken code. It actually hasn't changed much since 2.2.
Re:Ask HN: What made you change your mind about a programmin... by diminoten on Monday March 04, 2019 @01:34PM (#19303855)
It's changed fundamentally since 2.2...

Also if you're fixing broken Python code, you're using Python, so no that doesn't really track.

Re:Ask HN: What made you change your mind about a programmin... by scottlocklin on Monday March 04, 2019 @02:20PM (#19304350)
You know, sometimes people have to fix trashfires; that doesn't mean they'd start one.

What fundamental changes do you see since 2.2? If you're talking about the object model; objects in python were garbage before and after 2.2, and as a paradigm, it's mostly useless bureaucracy. Bleeding edge 90s ideas.

Re:Ask HN: What made you change your mind about a programmin... by ummonk on Monday March 04, 2019 @03:31PM (#19305064)
The addition of type annotations alone makes it a hugely different language.
Re:Ask HN: What made you change your mind about a programmin... by xyzzyz on Monday March 04, 2019 @03:43PM (#19305211)
The annotations that nobody actually uses? Call me back in 2030, when they become halfway popular.
Re:Ask HN: What made you change your mind about a programmin... by ummonk on Tuesday March 05, 2019 @03:46PM (#19314068)
Depends on the size of the codebase. They're used extensively at my company (Facebook).
[dead]
Re:Ask HN: What made you change your mind about a programmin... by dang on Wednesday March 06, 2019 @04:02PM (#19322759)
Whoa—you crossed into getting personal here and got personally nasty soon after. That's bannable territory. No more of that, please.

https://news.ycombinator.com/newsguidelines.html

Re:Ask HN: What made you change your mind about a programmin... by scottlocklin on Tuesday March 05, 2019 @11:46AM (#19311804)
You very obviously didn't use pre 2.2 python. There were objects. They were shit! They were shit afterwords!

I'm guessing based on your incredulity about 15 or 20 years older than you.

Re:Ask HN: What made you change your mind about a programmin... by diminoten on Tuesday March 05, 2019 @12:34PM (#19312312)
Our age difference explains a lot of your recalcitrance towards new (to you) things.
Re:Ask HN: What made you change your mind about a programmin... by scottlocklin on Tuesday March 05, 2019 @01:22PM (#19312777)
It amazes me that you dismiss someone with 20 years more experience than you as somehow knowing less.

Python isn't new to me: it's old, and it's crap, and its "evolution" is towards a dead end. Stuff like nodejs will eventually supplant it if it hasn't already, and with good reason (not that I am a huge fan). Python was a novel design and a great choice ... back in the 90s. I mean, use it if you like it; use Forth or Lua or whatever you like. I think it's terrible and should be abandoned wherever possible.

Re:Ask HN: What made you change your mind about a programmin... by diminoten on Tuesday March 05, 2019 @07:44PM (#19315552)
You didn't die. Congrats, but that doesn't give you knowledge I don't have.

Python should be new to you, or at least newer than when you first encountered it. The fact that it's not means you have no clue what changed, so you have no clue if it's any better.

The only thing that needs to be abandoned is this fake idea that older people carry knowledge that can't be expressed except in the form of trust. If you've got reasons, let's hear 'em, but "I'm old" isn't a reason to do anything.

Re:Ask HN: What made you change your mind about a programmin... by scottlocklin on Tuesday March 05, 2019 @08:55PM (#19315851)
I already gave you reasons; the fact that you can't understand them because you're a language zealot isn't my fault.

Mind boggling really.

Re:Ask HN: What made you change your mind about a programmin... by diminoten on Tuesday March 05, 2019 @10:27PM (#19316182)
"Because it's garbage" isn't a reason.
Re:Ask HN: What made you change your mind about a programmin... by FraaJad on Monday March 04, 2019 @08:10AM (#19300924)
what do you use now?
Re:Ask HN: What made you change your mind about a programmin... by icebraining on Sunday March 03, 2019 @08:40PM (#19298158)
Can you give an example of one such abstraction?
Re:Ask HN: What made you change your mind about a programmin... by FraaJad on Monday March 04, 2019 @08:15AM (#19300954)
You are using Python2.7 in 2019. there is your problem.

I understand if you inherited/maintaining a legacy application, you may not have had a choice about 2.7, but if it's a significantly large project and you are not making any attempts to use Python3 (and many of the improvements that come with it, including optional typing as one commenter mentioned, don't blame language, unless you have a solution that is magically going to fix all the problems from a language that is pretty much in "maintainance-mode! please use the new version" mode).

Re:Ask HN: What made you change your mind about a programmin... by 8bitsrule on Sunday March 03, 2019 @09:10PM (#19298275)
When I looked at Python, it looked interesting. Then I found out that -white space is important-. I thought about what it might be like to worry about that, and decided -not for me-.

When CPUs ran at 1 MHz, I wasn't so sure about FORTH with its RPN. But it ran a lot faster than interpreted BASIC, and was a lot faster to write than assembler. Once the world discovers the source of all its woes and goes back to wide-open, 8-bit systems, I'll go back to FORTH.

Re:Ask HN: What made you change your mind about a programmin... by baobrain on Sunday March 03, 2019 @10:24PM (#19298547)
> Then I found out that -white space is important-.

I hear this a lot and I think it's a misunderstood statement. Python does not care if you do not have a space in assignments or arithmetic or between commas or parentheses.

What Python does care about is the indentation of the source code. The indentation is what guides the structure - which is already what we are doing with most languages that don't care about indentation!

What I really mean to say is there are plenty of valid complaints with Python, but white space just is not one of them. If you are writing good code in a language with C-syntax you are doing just as much indentation.

Re:Ask HN: What made you change your mind about a programmin... by Grue3 on Monday March 04, 2019 @04:09AM (#19299845)
>which is already what we are doing with most languages that don't care about indentation!

No that's not what the other languages are doing. They have explicit structure defined in the code (with Lisps being at the extreme end), which allows the development environment to automatically present the code in a way that's easy to read. This frees the developer from the job of manually formatting their code like some sort of caveman.

As someone with 8+ years of experience of programming in Python for a job, I've seen countless of bugs spawned by incorrectly indented code, which is incredibly difficult to spot. I've seen people far more experienced than me make these bugs because they didn't notice something being misindented. To me, the fact that we have to deal with this is laughable. Especially considering it's so easy to fix Python the language so that indentation becomes unambiguous: add an "end" statement for each deindent (aka closing brace).

Re:Ask HN: What made you change your mind about a programmin... by baobrain on Monday March 04, 2019 @09:27AM (#19301462)
> No that's not what the other languages are doing.

Is this a claim that people do not indent in other languages and leave it to the dev environment? Yes, those languages don't rely on indentation but people do still manually indent or rely on their environment to indent it for them to make the code remotely readable. I for one cannot read Java without it also being indented correctly.

> This frees the developer from the job of manually formatting their code like some sort of caveman.

I honestly don't understand this part. What tools are you using that don't do indentation for you? Emacs and vim extensions, vscode, Pycharm, atom...all of them have very intuitive indentation for when you type. The most you have to do is hit backspace after finishing a block.

> Especially considering it's so easy to fix Python the language so that indentation becomes unambiguous: add an "end" statement for each deindent (aka closing brace).

As someone with a lot of Ruby experience, the "end" is absolutely not more clear than indentation. There's a reason environments highlight do-end pairs together: because it's hard to know which ones match which.

Re:Ask HN: What made you change your mind about a programmin... by Grue3 on Monday March 04, 2019 @02:53PM (#19304682)
>people do still manually indent or rely on their environment to indent it for them

Nobody manually indents their code. Almost any language other than Python is unambiguous to indent, so the computer does it for you.

>I for one cannot read Java without it also being indented correctly.

That's easy, just copy paste Java code into an editor and press a button to indent everything. Voila! Good luck if you're dealing with Python code which got misindented somehow (e.g. copying from some social network website which uses markup that doesn't preserve whitespace, which is most of them).

>What tools are you using that don't do indentation for you?

Python code cannot be re-indented unambiguously. So if you copy paste a chunk of Python code from one place to another, you can't just press a button to reindent everything. You have to painstakingly move it to the right level and hope that it still works. In Common Lisp I just press Ctrl-Alt-\ and everything becomes indented correctly.

>The most you have to do is hit backspace after finishing a block.

That works if you only write new code and never have to change existing code.

>There's a reason environments highlight do-end pairs together: because it's hard to know which ones match which.

No, the open/close brackets allow the IDE to highlight them so that the programmer can clearly see the scope of the code block. This is a useful feature of the language. In Python it's almost impossible to see which deindent matches what if the function is long enough/deep enough.

Re:Ask HN: What made you change your mind about a programmin... by hackinthebochs on Sunday March 03, 2019 @11:58PM (#19298893)
>but white space just is not one of them.

This position is hard to maintain after you've spent an hour trying to debug a nonsensical error just to realize you opened the python file in an editor that used a different tab/space setting than the file was created in. Significant whitespace is one of the biggest misfeatures in programming history.

Re:Ask HN: What made you change your mind about a programmin... by JimDabell on Monday March 04, 2019 @04:03AM (#19299821)
I've been writing Python for over 20 years, and I don't think this has happened to me one single time. I'm not some kind of super programmer; I make as many mistakes as anybody else and spend too long debugging stupid mistakes occasionally.

I've mixed spaces and tabs before on a handful of occasions, and it's always told me straight away what the problem is.

Here is an example of mixed spaces and tabs for indentation:

https://repl.it/repls/NegativeExemplaryBackups

You'll see that it raises an error:

    TabError: inconsistent use of tabs and spaces in indentation
…and points you to the exact line with a problem.
Re:Ask HN: What made you change your mind about a programmin... by hackinthebochs on Monday March 04, 2019 @11:27PM (#19308105)
Here's an example of an incomprehensible error related to mixing whitespace, where its not obvious its a mixed whitespace issue:

https://repl.it/repls/MotionlessLustrousScan

Re:Ask HN: What made you change your mind about a programmin... by JimDabell on Wednesday March 06, 2019 @04:59PM (#19323318)
Are we seeing the same thing?

    IndentationError: unindent does not match any outer indentation level
The very first thing I would look at is the indentation if I got an error like that. You hardly need to "spend an hour trying to debug a nonsensical error" when you see an error like that.
Re:Ask HN: What made you change your mind about a programmin... by hackinthebochs on Wednesday March 06, 2019 @07:08PM (#19324331)
Does "indentation error" immediately scream check for a whitespace mismatch to you? Because it doesn't to me.
Re:Ask HN: What made you change your mind about a programmin... by JimDabell on Thursday March 07, 2019 @02:36AM (#19326233)
"Indentation error" screams "fix the indentation", and code is indented with whitespace, so yeah.

When something tells you "indentation error", where's the first place you would look, if not the indentation? When you know you have a problem with the indentation, what do you think you have to change, if not the whitespace? There isn't a lot of opportunity to go in the wrong direction here.

Don't get me wrong, Python definitely has unexpected, difficult to debug behaviour for newbies (e.g. mutable default arguments). But this in particular isn't one of them. This is 2+2=4 level stuff.

Re:Ask HN: What made you change your mind about a programmin... by hackinthebochs on Thursday March 07, 2019 @06:26AM (#19327212)
This is a strange response. The only thing I can say is that "indentation issues" does not imply "mixed whitespace issues". Your responses are implicitly conflating the two.

>what do you think you have to change, if not the whitespace?

Note that the same error shows up when you have an inconsistent number of spaces to indent a block.

Re:Ask HN: What made you change your mind about a programmin... by JimDabell on Thursday March 07, 2019 @03:30PM (#19332028)
> > What do you think you have to change, if not the whitespace?

> Note that the same error shows up when you have an inconsistent number of spaces to indent a block.

And what would the solution to that be, if not changing the whitespace?

Every single piece of information available is strongly pointing in the same direction here.

Re:Ask HN: What made you change your mind about a programmin... by hackinthebochs on Thursday March 07, 2019 @03:57PM (#19332326)
I swear its like we're speaking two different languages. I really don't see the utility in further effort trying to find common ground.
Re:Ask HN: What made you change your mind about a programmin... by hackinthebochs on Monday March 04, 2019 @10:05AM (#19301784)
It's nice when it does offer that specific error, but I've burned many hours over the years when it fails to recognize that as the issue.
Re:Ask HN: What made you change your mind about a programmin... by randomsearch on Monday March 04, 2019 @03:28AM (#19299661)
Anecdotally, from several sources teaching in tech, it’s the significant white space that makes python much more approachable to non-nerds. For some reason matching nested braces isn’t palatable to them. I attribute Python’s wide adoption in the non-nerd world in part to this (the other part being the ecosystem).
Re:Ask HN: What made you change your mind about a programmin... by goto11 on Monday March 04, 2019 @02:45AM (#19299512)
Surly that could only happen if you used a mixture of tabs and spaces for indentation.
Re:Ask HN: What made you change your mind about a programmin... by hackinthebochs on Monday March 04, 2019 @10:06AM (#19301797)
The point is that if you open a file with a different editor it was created with, its very easy to mix tabs and spaces without any kind of indication that that's what is going on.
Re:Ask HN: What made you change your mind about a programmin... by ryl00 on Sunday March 03, 2019 @11:19PM (#19298746)
But doesn't the whitespace issue gimp Python's lambda syntax? AFAIK you're limited to one expression or function call, to get around the fact that you can't just inline a completely new function (with its associated control flow structure).

And what about one-liners, a la Perl? Stack Overflow answers seem to imply either embedding newlines in your string, or using semi-colons (as a Python newbie... you can use semi-colons?!)

Re:Ask HN: What made you change your mind about a programmin... by cauthon on Monday March 04, 2019 @01:13AM (#19299176)
> AFAIK you're limited to one expression or function call, to get around the fact that you can't just inline a completely new function (with its associated control flow structure)

On the other hand, if your function needs a flow structure that's more complicated than a single line, should you really be inlining it?

And I think any such use case that you really want to inline can probably be accomplished with list comprehensions

Re:Ask HN: What made you change your mind about a programmin... by AlotOfReading on Sunday March 03, 2019 @11:03PM (#19298681)
Why should code in a REPL be indented correctly? What if you copy from your own terminal (which may only support spaces) to your codebase, which may be in tabs? It doesn't make sense for a language exclaiming the principle of we're all adults here to not allow you to schedule irrelevant formatting fixes yourself.
Re:Ask HN: What made you change your mind about a programmin... by JimDabell on Monday March 04, 2019 @03:57AM (#19299790)
> When I looked at Python, it looked interesting. Then I found out that -white space is important-. I thought about what it might be like to worry about that, and decided -not for me-.

I did the same thing. In fact, this is why I came to comment on this thread: my initial reaction was to turn my nose up at the significant indentation. Then I gave it a try, and I got over it in about five minutes. It just wasn't the big deal I thought it was. I've heard a lot of other people say the same thing.

Re:Ask HN: What made you change your mind about a programmin... by Sohcahtoa82 on Monday March 04, 2019 @03:40PM (#19305182)
> Then I found out that -white space is important-.

The only time this should ever be an issue is when you're copy/pasting code from a web page or other source that doesn't preserve white space when you copy.

Otherwise, I'll never understand why this is so hard for people. No matter what language you're using, you should be properly indenting code blocks 100% of the time, and if you're doing that, Python's white-space-as-syntax will never be a problem.