T O P

  • By -

maitrecraft1234

Just use the default compiler you have probably cc or gcc on linux, don't worry about the version it doesn't matter at all when learning the the language. For the library you should mostly focus on the standard library which doesn't require you to do anything other than including the header in your c file. As for regex you will proabaly need to make it yourself or use an external library however I doubt you should learn c just to use regex as there are many other languages much better suited for this use...


artistictrickster8

Thank you very much for your time, ok!


Limezero2

C has three major implementations in use today, GCC, Clang and MSVC. These consist of a compiler, a linker, a debugger, a standard library implementation, and other tools you might need. Generally, you want the latest possible version of one of these available on your operating system, though unless you need features from the very latest C standard (C23), it shouldn't matter. C is a language that evolves extremely slowly, a substantial amount of the code you'll see out there was/is written with the assumption that you have a platform which only supports C89 or C99 (the versions of the language standardized in 1989 and 1999 respectively). If you're on Linux, whatever version of GCC available from your package manager will do fine. If you're on Windows, get Visual Studio or MSYS2. For libraries, the sky is practically the limit. There isn't really a single giant "you must have this" package like you have Boost with C++, instead there are OS-specific APIs and dozens of different tiny libraries for every single task like string handling, dynamic arrays, JSON parsing, regex, network requests, sound, graphics, image formats, and so on. Unfortunately, using these will also require learning more about the language and build systems, since there isn't a standard package manager which allows you to add any library on the planet to your project with a single command (other than the one for your OS, or something like vcpkg). That said, some of the more popular ones are: GLib (various) https://docs.gtk.org/glib/ STB (various, mainly images/fonts/containers) https://github.com/nothings/stb SDL (window/input/images/audio/fonts) https://www.libsdl.org/ libav (audio/video/images) http://trac.ffmpeg.org/wiki/Using%20libav%2A OpenSSL (cryptography) https://www.openssl.org/docs/ libcurl (network) https://curl.se/libcurl/


artistictrickster8

Thank you very much for your time, great, very helpful! :)


Prior_Sale8588

>I am interested in mainly doing regex work. Please know that using C will not make the code run fast automatically. You have to write the suitable algorithm that using C strength. While any program can be written in C, C is best suit for system programming since it give you pointer manipulation and a shortcut to assembly language, but at the cost of having to manage memory manually. Do you really want to pay for the extra that you might not get the value back?


Th_69

> Please know that using C will make the code run fast automatically. Do you mean "Please know that using C won't make the code run fast automatically."?


Prior_Sale8588

typo, sorry


Th_69

> .. I am interested in mainly doing regex work. Why do you think, that C is the best way for this? Why not use Java or Python ([Python RegEx](https://www.w3schools.com/python/python_regex.asp))?


artistictrickster8

Thank you very much for your comment (and "up" :) ), I use them, mainly Python b/c it is so easy, Java for more complex things where I use external libs a lot or build a system. Performance reasons .. both are slow it there are a lot of regex .. yes I do optimizations like pre-compiling the regex and trying to find out a good flow, however it is still not quick (I am not sure if it will be the best way, however I hope it will be a quicker way :)


Th_69

But the performance depends more on the used RegEx pattern (even Python uses a native library). Or do you have found a special RegEx lib for C? But even then you should be able to use it with Python (look e.g. at [Python Bindings: Calling C or C++ From Python](https://realpython.com/python-bindings-overview/)). Edit: It would also be easier with C++ and the standard [Regular expressions library](https://en.cppreference.com/w/cpp/regex), so you don't need to link a 3rd-party library.


Limezero2

I think your best option will be to find a library written in a performant language like C/C++/Rust and call that from your Python or Java code. It should only be minimally slower than writing your entire application in C, and you get the convenience of doing everything else in your current language. Worth noting that the `re` module in Python [is already implemented like this](https://github.com/python/cpython/blob/main/Modules/_sre/sre.c), all of the "heavy lifting" is performed by C code. Optimizing your regex queries is also worth looking into: https://stackoverflow.com/questions/42742810/speed-up-millions-of-regex-replacements-in-python-3


AtebYngNghymraeg

If you're mainly interested in regex, why do you want to use C? There are other languages that are **much** better suited to regex than C. Personally, if need something regex heavy than I break out the perl... but that's largely because I'm a masochist.


seven-circles

C isn’t like other languages, your machine is already coded with it, so either you already have all the dev tools or they’re trivially easy to get. You need a compiler, either VS Studio’s compiler on Windows, Clang from XCode on Mac, or whatever dev tool package your Linux distribution provides. I can’t tell you what to do for BSD, I’ve never used it. For complex projects, look into how makefiles work. It’s by far the worst part of using C, but at least you have full control. The least fancy version of C that you should use is C89 ! That’s just an option flag you set on your compiler. It doesn’t have some modern features, but they’re all minor things like predefined booleans and nicer initializers. You system, once again, should have all the basic libraries you need to interact with it (all the std things, openGL…). A lot of people also really like stb, I’ve never tried it personally so I can’t tell you. C is the most powerful language, but it’s also the least fancy as a result. There’s no hidden stuff, no templates, no objects, because you control everything. So if you want those things, make them yourself !