HNHacker News
TopNewBestAskShowJobs

Rotareti

484 karma · joined August 16, 2016

https://github.com/feluxe
submissionscomments
Rotareti··on My Python Development Environment, 2020 Edition
Since you are familiar with nodejs:

poetry == npm

pyenv == nvm

pipx == npx

No big difference, IMO.

Rotareti··on Using Firefox for a faster, calmer and distraction-free internet
I think you have two options then:

A) (if possible) migrate away from the services you mentioned.

B) lock-in deeper and deeper with the biggest advertising company on the planet.

Rotareti··on 'Alarming' loss of insects and spiders recorded
> I remember this particular data point being refuted by cars becoming more and more streamlined.

I've been driving the same car for 20 years. I remember cleaning the bugs from the roof rack after each longer trip. There were so many bugs, the front of the rack was entirely covered with a dark coat. These days the roof rack stays completely free of bugs. I simply don't have to clean the rack any more.

Rotareti··on Python at Scale: Strict Modules
Something in that direction, but I'd imagine it more like a Rust with a high-level-variant than a JS/TS with a low-level-variant ;)
Rotareti··on Python at Scale: Strict Modules
I can imagine the next big programming language will be one that is split into two language-variants: the "low-level-variant" and the "high-level-variant".

The high-level-variant is a dynamic language with optional typing, which is good for scripting, fast prototyping, fast time-to-market, etc.

The low-level-variant is similar to the high-level-variant (same syntax, same features mostly, same documentation), but it has no garbage collector, typing is mandatory and it runs fast like C/C++/Rust. Compiled packages that are written in the low-level-variant can be used from the high-level-variant without additional effort at all. The tooling to achieve this comes with the language.

A language like this would be insane, IMHO.

Rotareti··on What’s New in Python 3.8
> I would honestly like an option to "compile" python to check for typing inconsistencies

You can use mypy for that: https://github.com/python/mypy

Rotareti··on What’s New in Python 3.8
> I wonder if there is anything that can really be done, outside of something like Cython.

I compile my cli tools with nuitka [0], the resulting binaries take half the time to start. I find the difference quite notable.

[0]: https://github.com/Nuitka/Nuitka

Rotareti··on Jtc – CLI tool to extract, manipulate and transform source JSON
Thanks for the clarification! I guess it would make a lot of sense for a tool such as jtc to use SQL/JSON path language then. I'm sure it'll be the most common JSON query language soon.
Rotareti··on Jtc – CLI tool to extract, manipulate and transform source JSON
I agree. Modern SQL supports JSONPath. Postgresql 12 has support for it. A lot of people are/will be familiar with it.
Rotareti··on Web Development Simplified with Svelte
The svelte examples kept me interested until I reached the logic section [0]. Coming from JSX/TSX svelte's template language is a huge downer for me.

https://svelte.dev/examples#if-blocks

Rotareti··on Ask HN: How do you handle/maintain local Python environments?
> replace brew python with pyenv.

replace pyenv with asdf [0]. asdf is like pyenv, but it works for all major programming languages.

[0] https://github.com/asdf-vm/asdf

Rotareti··on Ask HN: How do you handle/maintain local Python environments?
I second this. asdf is awesome! It works for all major languages.

In case of Python, I use asdf to install the needed interpreter version and I use pipenv to create/handle the virtual environments. It's a perfect combo.

Rotareti··on Python Is Eating the World
You can write Python like pseudo-code. Sometimes the results look almost like plain English.

For example, if I have to design software for a micro-controller that uses C/C++ I sometimes write down the algorithm in Python (with editor support: auto-formatting, etc.), then I implement it in C/C++. There is no better way to write pseudo-code that I know of.

Python is also great to create a prove of concept for something. It allows for rapid prototyping due to the simple syntax, the high-level features, the huge ecosystem and the dynamic type system. Most of the time the result is good enough for production. You can add type annotations and get statically typing via mypy [0] to harden the code base. This works really well. (See: JS->TypeScript).

Python has a well developed FFI which allows you to call C/C++/Rust, without large performance hits. I think this is one of the main reasons for Python's success. It can be used as a high level interface to a huge low level ecosystem. ML wouldn't exist in Python without that.

Python is a great language to create simple scripts as well. I use it as a bash replacement.

But beware: Python can get really ugly if you rely too heavily on OOP/Inheritance. There is a lot of ugly Python code out there. I think Python shines the most if you use it in a procedural/semi-functional style and describe data-types for your business logic (almost) entirely with (dump) dataclasses [1] and namedtuples [2].

Beware2: Python's packaging story (package manager, etc) is currently in a messy state. There are good solutions, but it's difficult to find the right tools for a newcomer. I think it will take a couple of years for the dust to clear, but you might want to check out pipenv [7] or poetry [8]

These packages will make your life a lot easier. I use them for every project:

- black [3] or yapf [4] (auto-formatter)

- mypy [0] (statically typing with editor support for VSCode)

- pylint [5] or flake8 [6] (linter)

[0] https://github.com/python/mypy

[1] https://docs.python.org/3/library/dataclasses.html#module-da...

[2] https://docs.python.org/3/library/typing.html#typing.NamedTu...

[3] https://github.com/psf/black

[4] https://github.com/google/yapf

[5] https://github.com/PyCQA/pylint/

[6] https://github.com/PyCQA/flake8

[7] https://github.com/pypa/pipenv

[8] https://github.com/sdispater/poetry

Rotareti··on A nice app on Elm street
To me the biggest difference is that [Reason]React focuses on components which encapsulate state, while Elm focuses on data structures and pure stateless functions. Both approaches have pros and cons. You can design a [Reason]React app similar to an Elm app, if you use pure stateless components exclusively and handle your state with few reducers, but you won't get the same smooth experience which you get with Elm. I still favor React though. React's component interface adds some friction and complexity, but it's also a nice abstraction which helps a lot with code sharing, especially when sharing with third parties. Thus the striving ecosystem (UI frameworks, UI builders, etc.) in React.

I made a round trip over the last years from React/TS to Elm to ReasonReact back to React/TS. React/TS is the least attractive, but it's the one I get most done with. Plus the situation in React has gotten much better since Hooks, PureComponents, Context API. I'm glad the mess with class components is finally over.

Rotareti··on A nice app on Elm street
Complaining about unstableness, while chasing fads. Thoughts and prayers are with you ;)
Rotareti··on Fairphone 3 Teardown
I think the repairability of the Fairphone 3 is a huge step forward, but in the long run I want a phone that allows me to run an up-to-date OS for as long as I want. The Fairphone 3 will get updates for 5 years, that's not enough if you ask me.
Rotareti··on TypeScript 3.6
> "I'm familiar with tool A. Today I tried tool B and I couldn't figure out how to use it correctly, so it must be lacking. Everyone should know!"

From the points you make it seem like you haven't really figured out how to use mypy...

TS and Python/Mypy are my daily drivers. I don't find the experience working with mypy any worse than working with TS. In fact I prefer composing and consuming types via dataclasses and NamedTuples over interfaces and TS classes.

Rotareti··on Rust is the future, C is the new Assembly: Josh Triplett (Intel)
> Python extensions in Rust? That could be a good thing. Much easier to write a reliable Python extension. I imagine tooling for that already exists and I am simply unaware.

There is https://pyo3.rs/v0.7.0/

Rotareti··on From Mac to Linux – the setup I've grown to love
> The problem I find with Arch Linux, and this really only has started happening recently, is that for some reason Arch loves to break stuff.

Then I must be lucky. I've been using arch on my dev machine without notable breakages for about 2 years.

Rotareti··on Easy Python CLI with Click
Docopt is a killer arg parser for build scripts.

I drop a doc-string like this one in every build script and get the command line interfaces for free:

    """
    Install:
      pipenv install --dev
    
    Usage:
      make.py [<command>] [options]
    
    Commands:
      build    Build wheel.
      push     Push wheel to pypi.
      test     Run tests.
      bump     Run interacitve bump sequence.
      git      Run interactive git sequence.
    
    Options:
      -h, --help  Show this screen.
    """
Rotareti··on 'Plastic recycling is a myth': what really happens to your rubbish
That's like saying a household on disposables would be cheaper than one on actual dishes. I haven't done the math, but I'm almost certain it isn't.
Rotareti··on Taming OpenAPI using Racket to create a DSL
> ... and if the spec is defined first both can be done in parallel.

You could simply write the complete interface down in Python/FastAPI without actual implementation and generate the OpenAPI spec from that interface. That way both teams could start soon.

Rotareti··on How Far Out Is AWS Fargate?
> I would love to see the same done for Kubernetes. What I want is a kubeconfig file that links me to a paid account somewhere, and whenever I run `kubectl apply -f foo.yml`, I pay by the millisecond for whatever resources get created.

Have you tried digitalocean's kubernetes offering? It takes about 10 clicks to create a cluster and download a config.

Rotareti··on Python Is Eating the World
Calling the FFI a pet feature is nonsense.
Rotareti··on Python Is Eating the World
If the go-silo offers everything you need than yes, there is no need for a good FFI in go... but if you want access to the low-level ecosystems of C/C++/Rust without a heavy penalty, then it might not be an option.
Rotareti··on Python Is Eating the World
I think you don't get the point. Most people don't create such interfaces, but the libraries/systems they work with use them a lot, at least in other languages.

This is for example the reason why there won't be a large mathy/scientific ecosystem in golang.

Rotareti··on Python Is Eating the World
> Probably Go will be the next hotness in 5 years.

I think it will be difficult to grow a large ecosystem for a language with very poor FFI performance [0] in the long run. Golang's poor FFI performance is the number 1 reason I wouldn't use it for my own projects.

[0]: https://github.com/dyu/ffi-overhead

Rotareti··on Python Is Eating the World
I agree. Most of the issues the parent mentions have been solved with poetry and pipenv.

And if you need "to create a redistributable executable with all your dependencies". You can either use pyinstaller [0] or nuitka [1] both of which are very actively maintained/developed and continually improving.

[0]: https://github.com/pyinstaller/pyinstaller [1]: https://github.com/Nuitka/Nuitka

Rotareti··on The perfect language and why Go still isn't it
> I've been learning a bit of Go and I like what I've understood so far but one thing that seems somewhat lacking in the Go Eco system is mathy projects.

I think this has to do with golangs poor FFI performance.

Rotareti··on Svelte is the most beautiful web framework I've seen
I went through the svelte examples and I was exited until I reached the If block example:

    {#if user.loggedIn}
      <button on:click={toggle}>
        Log out
      </button>
    {/if}
To me such template language is a huge step back from JSX. JSX is JavaScript, thus you get the full power of the language (JS/TS) with the full support from your editor (type checking, auto-completion, etc.).
← PreviousPage 2 of 8Next →