New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Comments
I agree (although I never learnt Rust), simply because you don't need to know/learn/understand as much to write a program. C is a pain when you don't fully understand it, but when you do it's great and you can write short, fast and efficient programs.
Yeah, C probably takes more time to actually write code (the language itself does basically nothing and libc isn't exactly a toolbox either). While i still somewhat doubt the learning part (if you know how programming works you can probably pick up C over a lazy weekend) learning about the possible pitfalls / appropriate constructs is a quite different topic and that's before getting into macros, which can do crazy things (combined with anonymous arrays... the possibilities...) but are basically a whole language inside a language (and make debugging hell if you aren't careful).
❤️
I would like to follow the progress though, especially if you ever start to turn it into a service of some sorts
Keep you posted, need a nice homelab and test setup first.
What do you mean? It has probably way more functions than I know, but there are lots of string functions, many syscall interfaces, malloc+free, qsort, stdio, ...
Nice! I have some business experience but not completely sure I can offer any help that you don’t already have covered, and obviously that’s further down the line, but if so, do let me know
Funfact: How do you spot someone who either got into C in recent years or never was any good at it? They write:
instead of
Explanation: In ancient times compilers weren't smart enough to realize you weren't doing anything with the value before incrementing and tended to create an unnecessary copy. That's C for you
Admittedly these days compilers way past the point where they'd make such silly optimization errors but you might still meet dumb compilers for exotic architectures and in my opinion it's a good example of the tiny little things C expects you to know for writing optimal code in general.
@totally_not_banned Funfact: How do you spot someone who’s not very good in Markdown..?
It's intresting to know, cause before the day I learn C, I hold my hand to Rust cause it looks modern and spending 2 years including push RiR to edge. I can tell Rust is great if you want touch concept 'real' programming with focus on specific point, rust probably best bet IMO. Rust also have awesome free online book for getting started if you consider to learn!
And C/C++ is how I do mostly time after that, cause many awesome library coming from here and you would missing many stuff to know If you not know it. Which you can take a look how many wrapper from another programming language it require library from C/C++ which you can tell.
In the end, as my experience using both. If you tell me to maintain writing big codebase, I rather doing loosen oopsie C/C++ rather Protective Rust.
Yeah, that's actually very true
Yeah, it has many functions but most of them don't really do a whole lot on their own. Just take something very, very simple like concatenating two strings for example. You don't have any generic way of doing that. It all depends on your setup and requirements.
Maybe you can be sure the buffer is long enough, so you can just find the end of string 1 and copy string 2 there (or just take the lazy way of sprintf with a "%s%s" format), maybe you aren't sure but don't really care if it gets cut off, maybe you aren't sure and cutting the trailing end is not an option, ... All of these will result in different code and none of them is a single operation (well mostly...) where in C++ for example (and probably Rust) you can just use the
+
operator on two string objects and (usually) be done with it.AFAIK, if you disable optimizations, the copy is still created. But I knew that actually
And that incrementing-after-evaluating is so often unnecessarily used, when I see such a mistake, I ask myself that if the programmer does that, what else might he have done wrong/inperformant? Often that are programs where sprintf/strcat are also used extensively.
Optimally you already know the length of string 1 as the time needed by strlen is dependant on the length of the string, and optimally the length of string 2 is also known so that you can simply use memcpy.
But I get your point, for many things there isn't the way to do it in C, and often (but not everytime) it's more code to do something in C.
That's the plan.
That's perfectly possible. I mean strictly speaking the compiler is actually instructed to do that and i've never really investigated it.
Yeah, it's a tell-tale sign but in some cases it's understandable why people do it. Especially with lone increments it simply feels weird to start a line with
++
but if it goes on with all the unchecked operations (which are hardly ever the right thing to do - i mean there is situations where you know the length won't exceed your target buffer but from my experience that doesn't happen all that often to the point where i pretty much forgotstrcat
was actually a thing) it probably wasn't aesthetics...In any case you seem to have the right mindset for C. The next step will be ordering the compiler around using attributes (you obviously know best, right?) and disassembling the result to see if it obeyed your wishes (the sneaky bastard likes having an attitude at times...)
Absolutely. Going straight for
memcpy
is obviously preferable if possible and it's basically the criticism of null terminated strings that they don't store their length making it cumbersome to keep track of it unless one accepts wasting cycles on superfluous calls tostrlen
.Yeah, exactly.
The past is the past. You need to focus on the future and only a future without DDoSers is a bright future.
Just tell him that it's nothing personal but you can't have him ruining your business. Then block him. That way he'll know that there's no bad blood between the both of you and he'll understand.
The only other option would be for him to delete all his friends (besides you obviously) as you can't know how many of them are DDoSers. If he can prove that he did this you could theoretically keep him around.
Oh, I only knew packed for structs/enums and noreturn for functions, will have to take a closer look, thanks.
And I just remembered a common mistake in C, which seems a bit unintuitive when you learn C: that you have to declare a function without parameter as "NAME(void)" or otherwise the parameter it takes are variable.
And do you use "register" for performance or do you let the compiler do this?
The fact that @GoodLeaf-Cloud has a 'Patron Provider' tag, is everything wrong with where this forum is going.
Well, attributes are usually not really needed nor do they make a lot of sense but as a C programmer you obviously know better
No, really, sometimes they are actually pretty useful. For something like some short generic code it might help with optimization to make the functions static, put them in a header (or just include the .c file) and force inlining. Forcing align of the last structure member can allow for a neat trick where you end your structure with a zero sized array (not really legal but most compilers still accept this and it somehow got standardized by now i think, even if i can't remember how exactly) which becomes a pointer to the start of the memory after your struct (safes a lot of error prone calculations when the struct is really the header of some dynamically allocated blob).
There's really a ton of these attributes doing all sorts of more or less specific stuff, even if they (or at least a bunch of the less common ones) aren't really portable and it's probably best to treat them with caution as chances are they'll sooner or later become a macro to deal with the fact that different compilers have different implementations.
register
itself is mostly a noop these days. You can add it but it's pretty save to say that the compiler will just do what it feels is best anyways. At least with GCC you can however specify an actual register to use (https://gcc.gnu.org/onlinedocs/gcc/Explicit-Register-Variables.html) which should be honored but your code obviously becomes platform specific then and i remember there where a couple gotchas with this (external code obviously won't necessarily honor your register usage and stuff like that, so you might need a special strategy there). In general i wouldn't do it unless there was a real good reason. If you want that level of control you're probably better off going straight to inline assembly.Using vector types (declared with some variation of attribute
vector
) where it's appropriate can be advantageous though. Obviously that's only helpful when you are dealing with actual vectors or something that has some kind of clever SSE/AVX implementation.Oh, and by the way:
goto
has perfectly fine use cases. If you can simplify the cleanup of your function by the use ofgoto
... just do it!I lost track. What did this wiggy guy do?
Wiggy is the root of all evil. He's the one bringing DDoSers into @GoodLeaf-Cloud 's honorable groupchats! Can you imagine that?
Am I the only one that got totally confused by trying to follow the conversation in the screenshots but had no problem keeping up when the discussion turned into how to optimize C?
I still have no clue who ddos'ed who or what a wiggy is, but I learned how to optimize an incrementing counter in C. Not what I expected to take away from this thread, but I'll take it.
I know nobody’s gonna read this but if you do, please give me a like. Thank you!
Honestly, it’s because @totally_not_banned knows how to form sentences that are easy to understand
Whereas skids, while they might know, prioritize sounding like they don’t give a fuck (because not caring = cool)
>
i heard hes such a big troll. very very bad man
Yes, with goto many things can be done a lot shorter and also easier to understand.
I've heard many (usually wrong) arguments in favour of gotos, but "easier to understand" is a bold one.
While it's certainly possible to get yourself in so many knots that it's the only way out, I count on one hand the number of times I've used it in the last 35 years, and still have plenty of fingers left.
I'll look for a good example as soon as I'm home, but what do you have against gotos? They essentially are just unconditional jumps, I don't see any disadvantages.
Oh, what a coincidence! People on Youtube are saying you are very toxic. Is it true?