TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why and How I Switched from Python to Erlang

118 点作者 rodmena将近 9 年前

10 条评论

rdtsc将近 9 年前
I use both Python and Erlang. Python is to get small stuff done quickly language for me. And &quot;small&quot; doesn&#x27;t have to be just a demo or hello_world example, it can be a whole full back-end of a business.<p>(And btw when I say Erlang I also mean Elixir, they both share the same VM so most things apply to both).<p>But Erlang is a the secret sauce (so to speak) for a high concurrency fault tolerant backend. &quot;Fault tolerant&quot; should probably go first. The reason is the observation that the higher the concurrency or complexity in the system, the higher the need for fault tolerance. If you only serve 10 connections and the backend segfaults, 10 clients have lost connectivity, you get 10 angry phone calls. If you serve 1M connections and your backend segfaults, you get 1M phone calls. Exaggerating here of course to get the idea across. But this is not just a marketing gimmick, this translates to money in the pocket in operational costs. Some subsystem crashes and restarts? Fine, let it do that if it is 4am, no need to wake people up, will fix in the morning. I&#x27;ve heard of stories of subsystems crashing and restarting for years with the main service staying up.<p>The lack of centralized state might seem minor but unless you have been debugging a shared memory systems with locks, threads and manual memory allocations, with classes that have pages of attributes defined, and trying to understand why it crashes on Wednesdays only at customer A&#x27;s site, it is easy to miss the benefit. This comes through using small lightweight processes with an isolated heap and also using functional constructs.<p>Then in general, the ability to reason about concurrency using OTP constructs (Erlang&#x27;s standard library) and processes is like going from Assembly to C in terms of distributed and concurrent systems. Can express ideas at a higher level. This means having less code to look through and maintain.<p>There are other niceties like good garbage collection performance, awesome tracing and hot code loading capability (used this a few times, so started to appreciate it more now).<p>Now, individually all of those features can probably be found in other systems and frameworks, but they are just not integrated or not quite there -- Java has code loading but it is not the same. Can always spawn an OS process to get fault tolerance, but can only spawn so many before system falls down, Go has goroutines but they also share memory, so fault tolerance is not there. Other languages have garbage collection, but most still have to stop the world sometimes and so on.
评论 #12047545 未加载
评论 #12047917 未加载
erikb将近 9 年前
Yes, for certain programming jobs (i.e. work) Erlang is much better. Let&#x27;s just assume we can mostly agree on that.<p>But &quot;I switched&quot; means you switched your main language, right? I wouldn&#x27;t switch my main tool to something with a specific usecase. Your main language should be something general purpose, because most of your life&#x27;s problems have a wide range of usecases to consider.<p>Therefore I would have expected an argument for why Erlang may be a beter general purpose language or a headline like &quot;Why &lt;project&#x2F;company&#x2F;service x&gt; switched from Python to Erlang&quot;.
评论 #12053983 未加载
_uhtu将近 9 年前
If you&#x27;re going to set pixel based margins on the left and right side of your page, you need a media query to disable it or at least lower it to 5 pixels on small screens. This is unreadable on mobile :&#x2F;
评论 #12046986 未加载
评论 #12046886 未加载
评论 #12046935 未加载
smcl将近 9 年前
I&#x27;d be curious as to why exactly the SQLAlchemy query was slower than the raw one. I get that there&#x27;s gonna be some overhead, but did you figure out exactly what was slowing it down?
评论 #12047837 未加载
ngrilly将近 9 年前
Two comments:<p>- It looks like the SQL queries produced by pure_python() and simple_sql() are structurally different, which would make any comparison worthless.<p>- How does the author solve the long running tasks (&gt; 500 ms in the article) problem with Erlang? In Python, it looks like he was using Celery with Redis then RabbitMQ. What does he use in Erlang? (Erlang message queues have no built-in persistence.)
评论 #12048088 未加载
评论 #12047932 未加载
flocial将近 9 年前
Too bad the author doesn&#x27;t show specific examples. I can sympathize with the sentiment. The problem with scaling languages like python and ruby in my experience is the number of moving parts and jump in deep knowledge required to scale when your application takes off. One day you&#x27;re happily writing compact code in your favorite language and suddenly you&#x27;re rewriting core parts in C&#x2F;Go&#x2F;Rust while learning a new language and bolting on a variety of moving parts like redis, memcached, etc. to keep your business from becoming a victim of its own success.<p>A lot of the problems are more or less solved problems with well known workarounds but it&#x27;s still a pain and probably why there&#x27;s so much buzz around finding the &quot;next (insert your favorite language&#x2F;framework)&quot;.<p>Erlang generated a lot of buzz several years ago but aside from the recent success of WhatsApp it never quite stuck. I&#x27;m curious to know how this author thinks differently.
评论 #12047183 未加载
评论 #12047052 未加载
mianos将近 9 年前
You might notice difference in performance when your sqlalchemy query is different to your raw query. If you don&#x27;t understand sqlalchemy then you are probably best to not use it. How about going to mongo?
kccqzy将近 9 年前
An SQL injection issue right there.<p>Edit: to be fair the variable proj_id sounds like it&#x27;s not taken from untrusted input, but nevertheless a bad idea.
ben_jones将近 9 年前
The title should be: Mentioning some scaling problems I heard about in Python and might have brushed up against in my own projects (likely not production ones). Oh and their&#x27;s this thing call Erlang and it&#x27;s fast!<p>I sincerely hope nobody is making changes to a working production stack based on posts like this.
jboogie77将近 9 年前
didn&#x27;t really explain how.... لطفا بیشترتو ضيح بدید
评论 #12047991 未加载
评论 #12047041 未加载