Live data from Hacker News

I'm switching to Python and actually liking it

cesarsotovalero.net

271–280 of 718 posts

Re: I'm switching to Python and actually liking it

#272

> Not only because the syntax is more human-friendly, but also because the Python interpreter is natively integrated in all Unix distros That's kind of very optimistic evaluation - literally anything beyond "import json" will likely lead you into the abyss of virtual envs. Running something created with say Python 3.13.x on Ubuntu 22.04 or even 24.04 (LTSs) / Rocky 9 and the whole can of worms opened. things like vir…

You should always use virtual envs. They're a single directory, how are they an abyss? Pip now complains if you try to install a package system wide.

For shadow IT, anything that requires "installation" vs. being in the base system or being added as a file to a project is an inconvenience.

It's why I like using Bottle for small Python frontends: download the file and import.

(I'm ranting based on personal experiences with IT in the past. Yes in general virtualenv is the baseline)

Re: I'm switching to Python and actually liking it

#273
post #80

Just a small note on the code in the linked script: API_KEY = os.environ.get("YOUTUBE_API_KEY") CHANNEL_ID = os.environ.get("YOUTUBE_CHANNEL_ID") if not API_KEY or not CHANNEL_ID: print("Missing YOUTUBE_API_KEY or YOUTUBE_CHANNEL_ID.") exit(1) Presenting the user with "Missing X OR Y" when there's no reason that OR has to be there massively frustrates the user for the near zero benefit of having one fewer if statemen…

Taking ephemeral arguments like channel ID from the environment is more offensive to observability and user comfort

Re: I'm switching to Python and actually liking it

#274
post #248

Earlier quoted context omitted.

I have way more experience with Python than Java. In at least 4 companies (including Google that I wouldn't call a javashop) we used mainly Python. Still I believe Java is a better application language. Python is a better scripting language (replacement for Bash). Small apps tend to be easier on Python, but large apps are way easier on Java, both for syntax (types) and ecosystem (libs).

That is general take as well. A lot of small apps/simulators are in python. Ops scripts tend to be python. Java for the core/data. Refactoring/tooling is easier in Java when you are dealing with a 100k codebase imo. Typescript always. Seen plenty of coding horrors in both ecosystems...

Algorithms are a lot easier to understand when they are written in Python. I'm actually right now documenting medium size Java codebase by writing pseudocode, which looks like Python. Just by doing that, I've already discovered multiple bugs, which I didn't catch by looking at the Java code.

Re: I'm switching to Python and actually liking it

#275
post #5

> Python has done a good job of hiding its legacy ugliness (such as __init__, __new__, and similar aberrations), swettening its syntax to accomodate developers with good taste. What exactly is the problem with __init__ or __new__? @dataclass is very nice syntactic sugar, but are we arguing here that having access to initializer/allocator/constructor dunder methods is "legacy ugliness"? This is the core of pythonic bu…

Bizarre is that you don’t consider it ugly. Kotlin: constructor is either part of class definition or keyword constructor. Ruby: initialize JS: constructor Python: ______new______, _______init_______ Literally this meme: https://knowyourmeme.com/memes/three-headed-dragon

The point is to keep them out of the object namespace, and works well for that.

Re: I'm switching to Python and actually liking it

#276
post #254

Earlier quoted context omitted.

I gave a talk recently at a conference about how modern Java doesn’t suck very much, and that the worst part of Java is Java developers, who seem to be completely intellectually unambitious. I don’t think Java makes anyone unambitious, I think it’s that Java is taught in schools and unambitious people don’t feel the need to learn anything else, and they get jobs at unambitious corporations. It selection-biases toward…

link to talk please if recorded. I think one comment I saw here on HN that Java is better if written in Pythonic way. I agree completely with that stance. but yeah within Java you've 'merchants of complexity' people who wanna do things in the most abstract way rather than the simple way. btw Java can be as simple as Go.

I don't think that the talk has been released on public YouTube yet (and they made it clear to not share the unlisted links publicly), but here is the posting: [url-redacted]

And the slides are available here: [url-redacted]

I'm afraid that my humor isn't really reflected in the slides, but imagine everything here is said kind of snarkily.

Java can be mostly as nice as Go, the BlockingQueues and Virtual Threads can get you pretty far, though they're not quite as nice as Go channels because there's no real way to select across multiple BlockingQueues like you can with Go channels.

Overall though, I think Java 21 is actually not too bad. Shockingly, I even sometimes have fun writing it.

Re: I'm switching to Python and actually liking it

#277

"And guess what's the de facto programming language for AI? Yep, that sneaky one." Is this referring at all to to PyTorch. If not, any guesses what the author has in mind "Not only because the syntax is more human-friendly, but also because the Python interpreter is natively integrated in all Unix distros." Is this referring to GNU/Linux. UNIX (UNIX-like) includes more than Linux; some UNIX distributions do not inclu…

[dead]

Re: I'm switching to Python and actually liking it

#278
post #132

Earlier quoted context omitted.

Probably the system of giving special meaning to what are otherwise ordinary identifiers. __ isn't a reserved keyword in Python or anything. But there's a set of conventions you're supposed to follow when naming methods and attributes, and they're visibly artificial. It would be cleaner to make the features that are a special part of the language definition also a special part of the language syntax instead of runnin…

Funnily enough, just starting your class method/variable name with __ does do magic things as a pseudo-keyword. Specifically, it mangles the name for callers outside of that class -- `self.__foo` would need to be accessed as `obj._ClassName__foo`. It's python's approach to having private methods, while remaining somewhat ideologically opposed to them existing. This doesn't apply to the dunder methods, though. They're…

What's the use case for __foo -> _ClassName__foo? I've used python a bunch but never this feature, so I'm curious.

Re: I'm switching to Python and actually liking it

#279

When did Python go out of fashion? This is the second article I've seen talking about it as if it's some kind abomination. I get that it's not the shiny new thing, but I don't understand people hating on it. Is this just junior devs who never learned it, or is there some new language out that I missed? (And please don't tell me Javascript....)

I think a combination of:

- statically typed languages got better, reducing the relative benefits of dynamic typing. people realized they didn't really hate static types, they hated the way [insert 90s-00s enterprise language here] did static types

- the GIL became more and more painful as computers got more cores

- it used to be a language for passionate hackers, like a latter-day lisp (cf that old pg essay). "written in python" used to be a signal of quality and craftsmanship. now it's the most commonly taught beginner language; millions of bootcamp devs put it in their CV. average skill level plunged.

- PSF was asleep at the wheel on the packaging / tooling problems for years. pip/venv are dinosaurs compared to cargo, nix, or even npm.

Re: I'm switching to Python and actually liking it

#280

Earlier quoted context omitted.

Because sometimes I want to have logic that spans multiple lines and I don't want to assign it a name. An easy example might be something with a `map` or a filter. For example, in JavaScript [1,2,3,4].filter(x => { let z = x * 2; let y = x * 3; let a = x / 2; return (z + x * a) % 27 == 2; }); Obviously I know I could name this function and feed it in, but for one-off logic like this I feel a lambda is descriptive eno…

Off topic: you didn’t use y.

You are right! Obviously this is just an ad hoc thing I wrote to show a point but I shouldn't be using superfluous variables.
Post reply on HN