Live data from Hacker News

I stopped everything and started writing C again

kmx.io

361–370 of 475 posts

Re: I stopped everything and started writing C again

#361
post #160

Earlier quoted context omitted.

I recently started re-reading "Programming in Ada" by J.G.P. Barnes about the original Ada. In my opinion, it was not that good of a language. Plenty of ways to trigger undefined behavior. Where C was clearly designed to be a practical language with feedback from implementing an operating system in C. Ada lacked that kind of practical experience. And it shows. I don't know anything about modern day Ada, but I can see…

> Plenty of ways to trigger undefined behavior I'm curious about this list, because it definitely doesn't seem that way these days. It'd be interesting to see how many of these are still possible now.

I didn't make a list, but let me give an example. Page 22 where variable declarations are introduced:

If a variable is declared and not given an initial value then great care must be taken not to use the undefined value of the variable until one has been properly given to it. If a program does use the undefined value in an uninitialised variable, its behaviour will be unpredictable; the program is said to be erronous.

Re: I stopped everything and started writing C again

#362
post #344
post #187

Earlier quoted context omitted.

Agreed. C, Go, Python, and Lua are my go-to languages because of their simplicity. It's unfortunate, but in my opinion, most mainstream languages are needlessly complex. In my experience, whether it's software architecture or programming language design, it's easy to make things complicated, but it takes vision and discipline to keep them simple.

> C, Go, Python, and Lua are my go-to languages because of their simplicity One of these things is not like the others! Python's complexity has been increasing rapidly (e.g. walrus operator, match statement, increasingly baroque type hints) - has this put you off the language at all?

I started programming with Python years and years ago. My journey has led me to preferring low-level languages (currently in a Zig bout), and revisiting Python has been a disappointing experience. Not necessarily bad, but instead of focusing efforts where it really matters, such as eliminating GIL, they seem to be focused on adding new syntactic sugar.

Re: I stopped everything and started writing C again

#363
post #153

Earlier quoted context omitted.

My conclusion is that C is not a good basis for what Rust is trying to do. The kind of reliability Rust is trying to provide with almost no runtime overhead requires a much more complex language than C.

... and C++ is a much more complex language than C.

True. Though there are plenty of people advocating for some small extensions to C to make it safe.

Re: I stopped everything and started writing C again

#364
post #146

Earlier quoted context omitted.

I think Rust is harder to learn , but once you grok it, I don't think it's harder to use , or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. Rust's normal error messages are delightfully helpful. For example, I just wrote some bad code and got: --> src/main.rs:45:34 | 45 | actions.append(&mut func(opt.selected)); | ---- ^^^^^^^^^^^^ expe…

> I think Rust is harder to learn, but once you grok it, I don't think it's harder to use, or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. When I say Rust is harder to use (even after learning it decently well), what I mean is that it's still easier to write a pile of C code and get it to compile than it is to write a pile of Rust code…

Getting something to compile is never the end-goal. It takes 0 effort to get Python compile.

Re: I stopped everything and started writing C again

#365

Earlier quoted context omitted.

I think Rust is harder to learn , but once you grok it, I don't think it's harder to use , or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. Rust's normal error messages are delightfully helpful. For example, I just wrote some bad code and got: --> src/main.rs:45:34 | 45 | actions.append(&mut func(opt.selected)); | ---- ^^^^^^^^^^^^ expe…

> It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall` I won't disagree that correct C is harder to write, but it's not 2005 anymore and standard tooling gives you access to things like asan, msan, ubsan, tsan, clang-tidy...

C-with-sanitizers is miles ahead of what C used to be, but just a couple weeks ago I ran into a dangling pointer bug that ASan doesn't catch. (Sidenote 5 here: https://jacko.io/smart_pointers.html) It seems like one of the big downsides of sanitizers is that they can't instrument other people's code, in this case the C standard library.

Re: I stopped everything and started writing C again

#366

Earlier quoted context omitted.

I think Rust is harder to learn , but once you grok it, I don't think it's harder to use , or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. Rust's normal error messages are delightfully helpful. For example, I just wrote some bad code and got: --> src/main.rs:45:34 | 45 | actions.append(&mut func(opt.selected)); | ---- ^^^^^^^^^^^^ expe…

* Rust errors can be equally unhelpful. Also, the error you posted is hands down awful. It doesn't tell you what went wrong, and it's excessively naive to rely on compiler to offer a correct fix in all but the most trivial cases. When errors happen, it's a consequence of an impasse, a logical contradiction: two mutually exclusive arguments have been made: a file was assumed to exist, but was also assumed not to exist…

> Rust errors can be equally unhelpful. Also, the error you posted is hands down awful. It doesn't tell you what went wrong, and it's excessively naive to rely on compiler to offer a correct fix in all but the most trivial cases

What? It tells the user exactly what's wrong

> Every program becomes a Sisyphean struggle to wrangle through all those unnecessary objects to finally get to write the actual code

That is the cost of non-nullable types and correctness. You still have to do the Sisyphean struggle in other programming languages, but without hints from the compiler.

Re: I stopped everything and started writing C again

#367
post #231

Earlier quoted context omitted.

I've seen you make these kinds of comments before on other articles. Please stop. Not everyone is perfect and can forevermore avoid making any mistakes. I strongly suspect your opinion of your skill here is overinflated. Even if it isn't, and you really are that good, everyone cannot be in the top 0.00001% of all programmers out there, so your suggestion to "simply" learn not to make mistakes is useless. This all jus…

I think a more charitable interpretation of what he said was, "after sufficient practice, I became good enough to start avoiding those pitfalls." It's not all that different from learning any challenging task. I can't skateboard to save my life, but the fact that people can do it well is both admirable and the result of hundreds or thousands of hours of practice. Skilled people can sometimes forget how long it took t…

> after sufficient practice, I became good enough to start avoiding those pitfalls.

You can only do that in code you control. You can not control the entire call stack of your functions in cooperative environments.

Re: I stopped everything and started writing C again

#368
post #346

Earlier quoted context omitted.

Nobody is telling JS developers that Rust will save them, chill.

But you'll be called things like "catastrophically unprofessional" [1] if you choose JavaScript over TypeScript, or dynamically-typed Python over MyPy. [1] https://www.reddit.com/r/Python/comments/1iqytkf/python_type...

He's right. That is catastrophically unprofessional in a professional environment.

Re: I stopped everything and started writing C again

#369
post #119
post #8

I started programming with C a long time ago, and even now, every few months, I dream of going back to those roots. It was so simple. You wrote code, you knew roughly which instructions it translated to, and there you went! Then I try actually going through the motions of writing a production-grade application in C and I realise why I left it behind all those years ago. There's just so much stuff one has to do on one…

Yeah, back in the MS-DOS and Amiga glory days when C compilers were dumb, and anyone writing Assembly by hand could easily outperform them. C source files for demoscene and games were glorified macro assemblers full of inline assembly.

Thanks for the reference to Amiga. Every random reference to my beloved computer fills me with joy.

Re: I stopped everything and started writing C again

#370
post #180

Earlier quoted context omitted.

I don't follow your first point—the compiler is pointing out exactly what the problem is (the argument has the incorrect type) and then telling you what you likely wanted to do (borrow the String). What would you see as a more helpful error message in this case?

The compiler says "expected X, but found Y". I don't know how to interpret this: is the type of the thing underlined with "^^^" X or Y? "Expected" and "found" are just like "up" and "down" in space: they are meaningless if you don't know what the compiler expects (and why should it?). What it needs to say is something along the lines of "a function f is defined with type X, but is given an argument of type Y": maybe…

You cannot be serious right now.
Post reply on HN