Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

Since F# is typed, have a look at FastApi in Python. It's a better inspiration than flask: it uses dep injection with typing to configure your endpoints. It's very flexible, infinity composable, and such a nice experience.

Django's API is now clearly dated. I still use it massively though, because it's insanely productive for CRUD apps, which are 99% of my client requests.

They made some hard choices about the auth and db layer, and they are imperfect, but when left to do the choice myself in other frameworks, I often miss Django. You really value all it gives you once you've lost it.


Thank you for mentioning FastAPI. Looks awesome. Recently I started using Flask, as Django feels like too much overhead for smaller projects. FastAPI looks like a good alternative to Flask.


> Django feels like too much overhead for smaller projects

It depends. My advice is always: stick to django no matter what, unless you are a seasoned web devs. I've seen too many flask projects with terrible architecture decisions and security holes because flask assumes (by nature) you can take those decisions.

Those decisions are not easy to take. They require a deep knowledge of the field.

So yes, one may chose flask or fast api as a lighter alternative, provided they know very well what they are doing, or that the consequences of not knowing are small. The later is not always simple to evaluate however, especially if you are not experienced. You don't know what you don't know after all.

If somebody doesn't know if they are an experienced web dev, or the consequences of their choices, they should use Django.

It will save them from SQL injection, XSS, Cross request forgery and click hijacking. It will provide an pluggable auth backend should you need it later. It will force you to put some parts of your code in separate sillows. This is a good thing for most people.


Frankly if you go with the most popular extensions: Flask-SQLAlchemy, Flask-Login and Flask-Admin you will have more or less all the features of Django with a nicer API, better documentation and more flexibility


I've been using all of them, and no, not at all. Flask-admin is a far cry from the django admin. It's also buggy sometimes.

Flask-SQLalchemy is not well integrated at all. E.G: try to play with it in the shell, the session management is annoying as hell.

As of flak-login, it doesn't have a tenth of the

Also you forgot: csrf handling, i18n, xss, click hijacking, cache backends, and so on. That's again, more plugins you have to select.

And that's a lot to configure, learn doc, then upgrade when the times come, on top of that.

All of them will, obviously, not be compatible with SQLA 2 next year, because the projects are not a whole, so it's going to be even more fun on the months to come.

I really think a beginner should not use that.


This is a good summary. Sometimes I too forget how much stuff Django provides out of the box for free. But now it is an old and boring tech, apparently. Oh well.


agree it depends, and I haven't looked at Django for years - so can't comment on it.

However, I have been using FastAPI with Jinja2 & htmx to create web APIs and UIs for some of our services. Individually, they're great; collectively they're a joy. I'm no front end dev, but even I can put together functional, decent-looking apps in a few hundred lines of code. They bare comparison to angular apps that can easily be an order of magnitude more code.


I just wanted to mention that I considered FastApi but the amount of reflection and magic required to go this route was a bit too much to my liking in F#. Just a personal preference.

I mostly agree with you on Django though. But as you said - most apps are CRUD apps.


There are many misconceptions about async python I keep seing again and again. I'd like to offer an alternative point of view:

- async python is faster, but for a very specific niche of workload. Most tasks you do don't fit that workload at all. Which mean most of the time, you should NOT use async Python. And it's ok. Don't make your code complicated when you don't need it. Chose a tech for the need, not the hype.

- async python is not just for performances. It helps with making some specific kind of concurrency easy to reason about, because the context switch is explicit, and the chain of event can appear linearly in the code, thanks to await.

- it's ok to have some sync processes and some async processes. It's not one or the other.

- async is not a replacement for threads or processes. In fact, there are good use cases for having several processes, each with several threads, each with one event loop. Which also means that if you benchmark your WSGI code with 16 workers, you should do so as well with your aWSGI one.

The corollary to this is that some web site loads are very well suited for async (e.g: an SPA with a lot of connectivity which delegates long running code to other services), but a lot are not. If each request makes a long SQL query, seeks the hard drive, dynamically performs i18n and adds some calculation on top, it may very well block the event loop for too long, killing any benefit.

So when would you use async python ?

- For performances, when you need to maintain numerous long connections. E.G: doing websockets ? Use asyncio. Serving static files without nginx ? Use asyncio. Want to create a web crawler and your memory budget does not allow to open 10000 threads ? Use asyncio.

- For the interface, use the async/await keywords everywhere you need need inversion of control for I/O. It's not just about perf here, it's also a mechanism to delegate arbitrary parts of your code with a common standard interface around a fancy state machine + scheduler. You can use that to abstract all your I/O and switch backends at will, while offering callback inlining.

But again, you have awesome threading and multiprocessing pools with python. Not to mention tools like zeromq, scrapy or celery, which do a lot for you. Don't run to async just because "it's faster".

Having async by default in frameworks like fastpi opens up a ton of possibility though. Live settings, pub/sub between processes, websockets...


> It helps with making some specific kind of concurrency easy to reason about, because the context switch is explicit

Assuming you're disagreeing with this, yeah, I've seeing "easier concurrency" be a massive footgun because you have code that's safe as long as an await doesn't get added in the wrong place.


I am not, I've been using the wrong working.

I would say it's pretty hard to add an await in the wrong place, although not impossible. I think it's easier to:

- forget an await

- forget a asyncio.wait or a asyncio.gather

The later is very common, and is being addressed by the structured concurrency movement we've seen with Trio and the likes. This should end up in mainline python eventually because it is, indeed, a problem.

However, it's still way easier to shot yourself in the foot with concurrency and threads than with asyncio.

However, it is harder to startup with asyncio than with threads, because there is more to learn just to boot.


> forget an await

Do you use a typechecker?


Always. But not using an await is not a type error. It's perfectly valid to not call await. There are valid reasons to do it.


I can’t tell if your first list is misconceptions or your rebuttals to misconceptions. You said it’s misconceptions but I think it’s your rebuttals.


You are right, I edited it.


I have an alternative (although unproven) theory.

I have been practicing meditation for 15 years, sometimes in batch of 100 hours.

The more I practice, the more the time slows down. Not just while meditating, but after the fact as well. Although it fluctuates and I'm not back to my kid self, it feels that I have tremendously more time now than a few years ago.

I suspect that it's tied to how much present you manage to be.

When you are a kid, you are deeply immersed in whatever you are doing, and less and less so after that, especially in our age of distractions, multitasking, and intellectual work loads.

I think that the more you are immersed in the daily boring stuff, like just walking, doing chores, or taking your shower, the more you register the time you spend doing said activity, and the time seems to pass slowly.

In fact, I am sometimes under the impression my minutes, not just feel longer, but actually contain more, because I do so many things and then looking at the clock, it hasn't moved much. This sensation increases when I meditate a lot.


I agree with this completely. As I get older, a much more significant amount of my time is spent on the future. Planning for social events, planning when to do housework or chores, planning projects for work. I think you also do more long-term planning at work as you get older. When I was 22, three months seemed like a long time for a project and a long way away for events. Now I know a quarter (12 weeks) is not much time at all, and getting event invitations for a year in advance seems normal, and time slips by in between.

To your point, meditation helps me quite a bit (along with long cardio and limiting media consumption)


Where would you start right now if you were starting to meditate with no prior experience, knowing what you know now with 15yrs of experience?

I'm going to take what you recommend and run with it.


Sit for 5 minutes and try to count to 10 incrementing on the exhale. If you notice yourself thinking of something other than your body sensations like the breath or the counting, start from 1.

This was my first foray into meditation.


There are a lot of different meditation techniques and teachers, and they are as different as are sports and coaches: your body gets exercise, but that's the only common ground. But here it's the mind.

I can only tell you what I have done, the cost and benefit I personally experienced. I cannot make recommendations as it would be utter B.S.

I'm pretty good with my brain, but my attention was lacking to say the least. In search for a solution, I tried meditation on my own. I read books, and tried to sit down by myself.

I failed. Repeatedly.

Frustrated by what was the first time not being good with my head, I ask my doctor, who I knew was a Buddhist doing meditations retreats in caves, to help me find a teacher.

I insisted I wanted meditation only. No mantra or singing. No mythology or holly texts. No prayer or God. No offering, ritual or altar.

She told me the closest thing to what I was looking for was a course of "Vipassana Meditation, in the tradition of S.N Goenka".

It's a meditation technique that you learn during a 10 days courses. Shorter periods are NOT available as a beginner, and the 10 days are really necessary. I advice strongly against quitting in the middle of a course, for your own mental health, even if you believe you can. Once your are in it, you should finish.

You _will_ want to quit. Almost everybody does. Sometimes, I still do on the first day, when I start a new course.

The 10 days are not devoid of mysticism, religious undertone, etc. but they do teach you a technique that can be practiced as an atheist, or a practitioner of another religion, with minimal fuss. Keep in mind, though, that if you are scientifically inclined, the 10 days will grind your gears in many ways. After so long, it still triggers me sometimes, but I've being involved with those people quite deeply now, and I find solace in the fact they are benevolent and dedicated to helping.

I actually lived a year in one of the (numerous, almost 200 in the world) meditation centers, I dated one their accountant (!), and being part of a lot of their activities. They are just regular human beings, with the good, and the bad, but they really want to help, and they do. The accounting books are clean too ^^

The course is free, and you don't need to pay for the teaching, nor the accommodation, or the food. Ever. They will regularly remind you they need donation, and even tell you it's good for you :) I do donate, but it is completely optional, and some people never give anything. It's considered perfectly ok.

As for the 10 days course, it is _hard_. The discipline is strict:

- waking up at 4 am

- no food after 12

- you put any distracting object in a safe you can't access before the end, including your phone, books, wallets or notebooks

- you can't talk, do much exercise

- you meditate 10 hours a day

The hardest part is not the silence, the food or the sleep though. It's the meditation. Provided you practice correctly, it will be extremely challenging. Boredom, physical discomfort or pain, distress, depression, break down, sadness, etc. are only a fraction of the things you may, or may not have to face. And that's only what you can put words on, which is, to my surprise, only a very tiny part of the experience.

The cost, hence, is high.

It's even higher if you decide it's worth it for you to carry on with it daily. It takes time, and effort.

Also, it's a slow process. A steady one, mind you. My life has changed in ways I believe would have not been possible otherwise. Some progresses fade without practice. Some gains are for life even if you stop.

But I've been at it for some time now, and I will continue for the rest of my life. The trade off proved worth it for me.

The most obvious benefits that I personally experienced:

- my social, love and professional life have completely shifted. I had what looked like autistic traits, but they have melted. I'm considered an extrovert now.

- I am happier. It was not a straight transformation. I had depressive periods. But the trend on 15 years is that, all in all, I'm much, much happier than when I started. This by itself makes the technique worth it, as it leads you, little by little, to decouple happiness from circumstances.

- I know myself better. This means I accept myself more as I am, I have less illusion about myself, and also I live my life according to that knowledge, instead of hitting an invisible wall. If I'd share what I learned with you, you would think it's trivial, obvious things. But making them yours make all the difference.

- I'm more productive. It's a small detail compared to the rest, but a nice boost.

- I am more at peace with the suffering of our human condition. Less afraid of death, less angry with people destroying things, less depressed by the state of society. I forgive a lot now. Including myself. I'm ok hurting people too, which is strange to say, and not what you think would be the result of meditation.

In fact, I became less minimalist and more materialist with time. I don't look the stereotype of a wise, zen person. Also, some areas in my life I desperately wanted to work on didn't move at all. I eat too much, I still get angry for some things that are so superficial in retrospect. So be careful with expectations.

You can find more information about this particular technique and the related courses here:

https://www.dhamma.org/en-US/index

Yes, I'm well aware that the website looks like a cult.

It's even worse when you are in a course, with the Pali wows and the recordings repeating again and again the same instructions.

You will have to assess that by yourself.

Whatever you chose to do, I hope you'll find something that works for you.


I've been pracitising meditation for nearly 10 years, and I also experience this effect.

I think the more you meditate, the more you unlearn precious patterns, memories, etc. that were clogging up your brain. Then you have more time to experience the present moment, and your brain has more capacity to process what's going on now rather than what happened to you previously.


I meant 'previous' not 'precious'. How can I edit a post I made? I've seen what I think was other people editing their posts


There is an "edit" link, but it disappears if your comment is too old.


Just to add another data point: I've been meditating for 8 years now. I did a 10-day vipassana course 3 years ago. I meditate everyday (usually using Sam Harris' app, but not always).

As much as I'd like to agree with you, I'm not sure I can, i.e. I can't say that time seems to pass less quickly since I've started meditating regularly.

Maybe this has something to do with the fact that I have a 3-year-old son (i.e. I always feel like I should have more time, even when I consciously plan to not do anything)? Maybe I don't meditate "the right way"? Or maybe I'm just not a good judge of how I perceive time. I don't know.


I could be completely wrong, time passing is a very subjective experience after all, and humans are very keen on creating theories based on impressions.

I would add I started experiencing time slowing down once I did a one year stay at a Vipassana center. I also meditate 2 hours a day now. My first 10 years of meditation, I didn't felt it.

So maybe, it's dose dependent.

Or maybe it's all in my head :)


I wish I could find the time to meditate for more than 10-20 minutes everyday. But between family, sleep, exercise, work, hobbies, friends, etc., it's difficult to do it, unless I sacrifice something else. It seems like it's part of the problem: feeling that you have too many things to do will lead to the impression that time passes too quickly.

But I can definitely believe that the more you meditate, the more you will experience things differently. My 10-day vipassana course was already an intense experience compared to meditating 10-20 minutes every day!


> family, sleep, exercise, work, hobbies, friends,

Not to mention you should cook, buy fresh food, stay informed, be politically active, learn new things, keep your house clean, recycle, do health checks up, get a hair cut, but don't use your car for everything and spend some time in nature. Don't forget to read, meet new people, get to zero inbox and fix your shower curtain.


Exactly. It never ends. :) Life is all about prioritizing things. And probably compassion/self-compassion (i.e. don't be so harsh with yourself and other people - which helps with priorities, BTW).


Exactly, in fact, I'm glad a software hue finally takes on the hard task of setting the meaning of my life right.

All those futile things about people, spirituality and creating stuff were exhaustively complicated.


You joke, but earning the right to change the colour of the hn top bar was an existential turning point for me.


It's most likely that the GIL will be removed in the next 5 years: https://docs.google.com/document/u/0/d/18CXhDb1ygxg-YXNBJNzf...


It has a GIL for now.

But if you are interested on removing the GIL, you gonna love 2022: https://docs.google.com/document/u/0/d/18CXhDb1ygxg-YXNBJNzf...


You certainly can, as pyodide proves it, but it's a complicated task. Pyodide is upgraded only once in a while to a upper python version because of how much work it is.

This makes it much easier.


In this particular case, the fact it's written in rust gives it some very interesting properties:

- it makes compiling your entire project into a standalone executable trivial

- the interpreter can be compiled to WASM way more easily than with something like pyodide

- you can provision python with cargo, which mean no more fiddling with pyenv, deadsnake, epel, etc. and yet getting a consistent, to the minor version, python distribution

- rewritting you hot path in rust becomes first class citizen. Since the python story is, start with python, and when you need to scale, you can always create an extension later, this is really attractive.

All that has only value, of course, if the project reaches a good compat and is supported.

But still, the possibilities it offer are not negligible.




This looks really promising.


We do tax them with VAT, which brings a LOT of money.

We could, and should tax them more on earnings too, despite loop holes and tax heavens.

But even if you could just get VAT on drugs and prostitution, that would be HUGE. Not to mention profits would go to legal businesses, which would stimulate the economy, instead of going into criminals pockets, which hurts society.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: