Post 9uiEqGyjVZYH79HMDQ by Jari@koyu.space
(DIR) More posts by Jari@koyu.space
(DIR) Post #9ui6VUBIQWOqLZjStM by sir@cmpwn.com
2020-05-04T17:49:37Z
0 likes, 0 repeats
For every bug solved by a "safe" language, 10 bugs were solved by making the program more simple
(DIR) Post #9ui8iJEocmfI51cYc4 by wolf480pl@mstdn.io
2020-05-04T18:15:04Z
0 likes, 0 repeats
@sir some "simple" ideas are surprisingly hard to express in low-level languages.
(DIR) Post #9ui8uIjKL3Y5yobupE by sir@cmpwn.com
2020-05-04T18:16:13Z
0 likes, 0 repeats
@wolf480pl I feel that the opposite is true
(DIR) Post #9ui9HkfMdgJvHZwHVw by wolf480pl@mstdn.io
2020-05-04T18:21:29Z
0 likes, 0 repeats
@sir it may be that there are both kinds of ideas.Consider, for example, string concatenation.In Python, with all it's flaws, it's fairly easy to concatenate strings correctly.In C, you could use strncat, but then it's easy to get the size wrong. Or you could use strlcat if you have libbsd. It's easier to get the size right in this case, but you still need to pay attention.
(DIR) Post #9ui9b5OTnYEt4QGE9w by wolf480pl@mstdn.io
2020-05-04T18:24:58Z
0 likes, 0 repeats
@sir And if you want to avoid truncation, you need to measure those strings' lengths, and allocate a large enough buffer. But:- adding two sizes can lead to integer overflow (probably not in this case, cause those strings fit in memory... right?)- remember to add one byte for the null terminator- you should handle allocation failure (or hope the compiler's handling of UB in case of null dereference isn't too onerous)IOW, you need to be careful how you concatenate strings.
(DIR) Post #9uiAxE3cMsOyGTcjRY by ignaloidas@mastodon.gamedev.place
2020-05-04T18:39:12Z
0 likes, 0 repeats
@sir Doesn't mean you can't do both
(DIR) Post #9uiCX2pTgto9oweZw8 by kungtotte@fosstodon.org
2020-05-04T18:57:49Z
0 likes, 0 repeats
@wolf480pl @sir simple and easy are orthogonal concepts."foo" + "bar" in Python is very easy, but it's not simple because all of those points you raise (including handling unicode properly) is taken care of by the language behind the scenes, so it's in actuality a very complex event when you consider all of the moving pieces.String concatenation in C on the other hand is very -simple-, but it's not easy because you have to consider all those other things yourself.
(DIR) Post #9uiCaNdEnu0rCvWE64 by wolf480pl@mstdn.io
2020-05-04T18:58:28Z
0 likes, 0 repeats
@kungtotte @sir now, which of those is more bug prone?
(DIR) Post #9uiCebEq9oAmZ87RRY by sir@cmpwn.com
2020-05-04T18:59:11Z
0 likes, 0 repeats
@wolf480pl @kungtotte depends on what kind of bugs
(DIR) Post #9uiD3GBrYBIQWfU9a4 by wolf480pl@mstdn.io
2020-05-04T19:03:41Z
0 likes, 0 repeats
@sir @kungtotte Well, ok, the python one will be more likely to have resource exhaustion bugs.If you consider being generally slow as a bug, Python will have that, too.Memory corruption bugs will obviously happen more often in C. Even if you count the underlying implementation of string concatenation, I'd expect it to have less bugs than 100 implementations of string concatenation in C written by hand.Bugs in business logic are IMO equally likely in both languages.What did I miss?
(DIR) Post #9uiDKLvtSAM7G6AMr2 by kungtotte@fosstodon.org
2020-05-04T19:06:46Z
0 likes, 0 repeats
@wolf480pl @sir the reference implementation of Python is written in C, so by extension all of the issues with the C code are present in Python as well, only now they're hidden from view.And, if they're able to write correct string concatenation in cpython, surely it's an achievable task for anyone else?
(DIR) Post #9uiEaSjy0hRQxYpj8q by wolf480pl@mstdn.io
2020-05-04T19:20:53Z
0 likes, 0 repeats
@kungtotte @sir I never said it isn't achievable.It's just that if 100 people write it from scratch, the total number of bugs in all those 100 implementations of string concat will be greater than the total number of bugs in Python's implementation string concat.
(DIR) Post #9uiEqGyjVZYH79HMDQ by Jari@koyu.space
2020-05-04T19:13:38Z
0 likes, 0 repeats
@sir meanwhile...Poetting: "let's make systemd more complex"...Me: runit it is so fast and simple and it is a c program with only 509 lines of code! Great! :blobcat_MUDAMUDAMUDA:
(DIR) Post #9uiEuLEjcQ5NTkhh8y by sir@cmpwn.com
2020-05-04T19:21:45Z
0 likes, 0 repeats
@wolf480pl @kungtotte I think this is unfair to C, by picking out one of its weakest points (string handling). How about networking? Compilers? coreutils? Package managers?
(DIR) Post #9uiFJURkVtpJHZmbNA by wolf480pl@mstdn.io
2020-05-04T19:29:00Z
0 likes, 0 repeats
@sir @kungtotte I never said C is bad overall.I just said there are _some_ things which are more error-prone in C than in higher-level languages.Obviously there are many examples which go the other way.Implementing a binary network protocol is much easier if you can just read(3) directly into packed structs.Coreutils probably benefit from being close to syscalls/libc, too.Package managers... not sure, never tried. Lots of graphs, but C is decent at pointer structures.
(DIR) Post #9uiFhEMfxOPAM6jKpU by alcinnz@floss.social
2020-05-04T19:32:23Z
0 likes, 0 repeats
@sir What if you did both? Make the program more simple & write in a "safe" language?
(DIR) Post #9uiFoATGpdB8J57fo8 by sir@cmpwn.com
2020-05-04T19:32:52Z
0 likes, 0 repeats
@alcinnz if only there were a programming language out there which was both safe and simple
(DIR) Post #9uiIHV4rUrXyWRovAG by avalos@cybre.space
2020-05-04T20:00:57Z
0 likes, 0 repeats
@sir @alcinnz Go.
(DIR) Post #9uiIOsWIji2NFtAmsi by sir@cmpwn.com
2020-05-04T20:01:57Z
0 likes, 0 repeats
@avalos @alcinnz close, but goroutines suck
(DIR) Post #9uiIf8gQPR4U1Bf6bg by avalos@cybre.space
2020-05-04T20:05:42Z
0 likes, 0 repeats
@sir @alcinnz They can totally stop sucking if you use them correctly.
(DIR) Post #9uiIo0nB7LH29P3GUa by alcinnz@floss.social
2020-05-04T20:07:15Z
0 likes, 0 repeats
@avalos I would've said I enjoy Haskell for compute-intensive (once you get away from I/O it's very conceptually simple!) tasks, but I really don't want to get into a language argument with @sir .
(DIR) Post #9uiJarY0HHujfUFPs0 by paul@post.lurk.org
2020-05-04T20:15:58Z
0 likes, 0 repeats
@sir What do you mean by "simple" here?
(DIR) Post #9uiJn9D6QvxjvKKU5I by sir@cmpwn.com
2020-05-04T20:16:20Z
0 likes, 0 repeats
@paul many things
(DIR) Post #9uiK4hTiHNih7uT71k by paul@post.lurk.org
2020-05-04T20:21:34Z
0 likes, 0 repeats
@sir Indeed, which is why I was hoping you could elaborate more. Was just curious about what you mean. Specifically, how does one (attempt to) measure simplicity in the context of software engineering?
(DIR) Post #9uiKDXljkPkVcV7FCa by sir@cmpwn.com
2020-05-04T20:23:21Z
0 likes, 0 repeats
@paul there are a lot of poor measures, like lines of code vs number of features, number of dependencies and transitive dependencies, and so on. But they're all bad proxies for something which is really rather abstract
(DIR) Post #9uiOeEVHsp75VNP5Ye by wowaname@anime.website
2020-05-04T21:13:35.710802Z
0 likes, 0 repeats
@wolf480pl @sir @kungtotte libc sucks, c is only really good for systems programming, in general higher-level programming NULL is a concept we should avoid, we should have better and stricter typing, and better abstraction of common idioms