9 ms·
I understand why the OP likes C. I was looking at a couple of old projects of mine and I remember the satisfaction at least in one (a SASL library) of how I mad
by t43562 4y ago
I understand why the OP likes C. I was looking at a couple of old projects of mine and I remember the satisfaction at least in one (a SASL library) of how I made various classes of error impossible using a fairly simple strategy and my own string handling routines. In a memory safe language with lots of assistance for threading there would never have been that pleasure. It was not amazing or anything but it was elegant to my eyes.
I feel I have to develop an economy of effort in C because there usually isn't a dumb and easy way to do things - this pleases me.
C has a mental model that seems relatively simple - I feel I can reason about what's going to happen to a greater degree than higher level languages.
C++ is the worst IMO because it has lots of abstractions but they don't make programming simpler because you pretty well have to understand the low level aspect of what they're doing to get performance - so the complexity is much greater.
Rust seems to put a lot of difficulty up front which is of no value in the kind of typical short program I write most of the time. I just didn't enjoy it. If I had something complicated to do I might eventually appreciate it.
The more high-level the language the less one tends to understand it and that's unsatisfying.
Having said all of that though, I tend to "just write python" whenever I can. If it's a throwaway program one doesn't need more and if it turns out to be necessary to interface to some library or other I know C well enough to sort that kind of thing out. I use threading.....never - at least never by choice.
- atorodius 4y agoI have found pleasure in combining „just write python“ with some C compiled code linked in and bridged via numpy for performance critical loop. I just love how fast I can write code in Python for when I do side projects
- dilawar 4y agoYou may want to checkout pybind11 library. And checkout NIM lang too.
- TkTech 4y agoPybind11 has significant overhead that makes it non-viable for some projects, even if it has a nice API. For pysimdjson we switched back to cython for an order of magnitude improvement.
- nodemaker 4y agoCurious. Which overhead are you referring to for pybind11?
- TkTech 4y agoIts magic function wrapping comes at a cost, trading ease of use for runtime performance. When you have a single C++ function to call that will run for a "long" time, pybind all the way. But pysimdjson tends to call a single function very quickly, and the overhead of a single function call is orders of magnitude slower than with cython when being explit with types and signatures. Wrap a class in pybind11 and cython and compare the stack trace between the two, and the difference is startling. Ex: https://github.com/TkTech/pysimdjson/issues/73 https://github.com/TkTech/pysimdjson/issues/73
- nodemaker 4y agoAh yeah that makes sense. I would rather call a single C++ function from Python that calls other C++ functions (or itself). In case of pysimdjson however, Cython makes much more sense. Overall this is way better than writing everything in Rust.
- qsort 4y agoI'm pretty much in the same boat and I don't even like Python the language. The ecosystem and extensibility is just so insanely productive it even rivals Excel... In re Rust: I feel one of the mistakes most people make is taking Rust to be a general purpose "default language" for everything, like C and C++ used to be. But like you wouldn't write C++ for most stuff even if you were magically granted the ability to never ever write unsafe code, writing web services in Rust just means making your own life harder. It's a great tool, I'm happy it exists and I follow its development, but we must accept it exists in a different space than, say, Python or Ruby or Javascript. I feel physical pain as I say this, but most stuff should probably just be Java.
- biorach 4y ago> I feel physical pain as I say this, but most stuff should probably just be Java. This has been on my mind a lot lately, causing similar anguish. I'd note that, from what I hear, C# would also fit the bill, but be as unappealing to me. I really wish that there was a language with the productivity, ecosystem and ergonomics of Python, with the speed and efficiency of Java and C# and a type system that increases productivity rather than word count. Go seems... fine, but, I dunno, slightly regressive. I'll probably use it where performance and scaleability matter.
- kaba0 4y ago> I really wish that there was a language with the ~productivity~, ecosystem and ~ergonomics~ of Python, with the speed and efficiency of Java That would be.. Java :D While I’m quite a big Java fan, for the other parts some other JVM language can easily fit the bill and you even get a choice. Scala, Kotlin, or maybe even Clojure if you don’t mind dynamic types.
- biorach 4y agoYeah maybe, I hear Java has improved markedly since my bad experiences with it (admittedly a long time ago now). I should swallow my distaste and give it a fair trial. From a distance it still looks somewhat verbose and unergonomic. The others look like really really nice languages and I'd love to use Scala for a solo project. However I guess I need something that's a) truly general purpose b) not going to scare away collaborators or potential hires c) going to be around for a long time d) not going to require evangilization at, say, a start-up. Kotlin... I guess I'm wary of it being the new Coffescript - i.e. that it spurs Java into improving to such a degree that it removes the need for Kotlin in the first place. And yes, having just spent a long time transitioning a project from JS to TS, I'm not sure I want to start anything serious without at least half-decent static typing - a major reason I'm looking for an alternative to Python, which is just not quite there.
- aldanor 4y ago> a lot of difficulty up front which is of no value in the kind of typical short program I write most of the time Wonder what are the examples of 'short programs' where you'd just zip out raw C as a default language, and it would be simpler/faster to implement than in Rust?
- t43562 4y agoThe comparison is really to python rather than C. I C mostly when I'm trying to fix some compilation bug in a library or when I'm trying to call some glibc or other OS level bit of code to achieve something- e.g. on a Raspberry Pico. Using C for anything is just rare for me and C++ and Rust even more so because they don't add anything that I need usually.
- jjtheblunt 4y ago> Rust seems to put a lot of difficulty up front I've found myself thinking, time and again, is Rust exposing, to the programmer, what have traditionally been details handled to varying degrees by sophisticated compiler optimizations? If so, a great optimizing compiler might deliver binaries as performant as a Rust expert could, but with less programmer effort? (I can't answer that, only haven't found a counterexample as a one time optimizing parallelizing compiler person.)
- oconnor663 4y agoIn my experience, the details Rust is exposing are less about performance and more about correctness. For example, Rust forces you to be explicit about: - who owns what - how long things live - which values might be null or missing - which functions might return errors - how strings are encoded (https://twitter.com/timClicks/status/1450943515635056648 https://twitter.com/timClicks/status/1450943515635056648) - which types are thread-safe There are some performance gains to be had in that list, but for the most part it's about asking the programmer to be explicit and avoiding convenient-but-risky defaults that lead to lots of bugs.