ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thanks for the words of affirmation. I guess I was stuck on having to decide on two, when learning both will be just as beneficial. What I've decided to do is write all my command line-based programs in C and, if I need to interact with the web such as web scraping or interacting with an API, I'll do it in Go. The syntax is just way easier to work with in that realm.
Yes well those two thoughts, I thought, were pretty much what you wrote when you started the thread.
I think it is a very common question that people raise when they don't feel they know "any" language as well as they feel they should.
But honestly, over time you may feel, as I do, that all languages are highly similar, so the syntax isn't the biggest concern. Just like you mentioned, some are better for different things, or different environments.
For the Linux command line GDB is a great debugger. You can use it through emacs, and there are some debug interfaces which employ GDB, but make it all look more like an IDE.
My debugging blogs in my signature cover some info on how to use GDB.
For the Linux command line GDB is a great debugger. You can use it through emacs, and there are some debug interfaces which employ GDB, but make it all look more like an IDE.
My debugging blogs in my signature cover some info on how to use GDB.
Thanks. I have signatures turned off, but I'll research GDB.
In terms of what I'd like to do: I'm interested in writing command-line tools, web scrapers, data formatters and other useful utilities. Sure, I can do a lot of things in Bash, but I like to write my own programs with a lower-level language.
One solution I've come up with is if I need to communicate with the Internet at all, be it hit an API or upload data to a server, I write the program in Go. Otherwise, if I want to write a computer-specific program, I write it in C.
Would love to hear from people experienced in both languages as to what my road map should be.
Just wondering why you can't use libraries like curl to do Internet connection in C. I've seen several interpreted languages that use curl underneath to do that. I've written a few programs that use Berkeley sockets to connect to the Internet. It's fairly straightforward to work with and if you're careful what functionality you use, somewhat portable across different operating systems.
If you need some libraries to help speed up the writing process in C (since most other languages use several libraries/modules/plugins, etc.), there are some interesting resources available for C. One interesting trend in C programming is the proliferation of single file and minimal libraries. You can check out projects like https://github.com/clibs/clib/wiki/Packages which try to catalog them and make them easier to incorporate in projects. If the libraries are small and readable, it's a good way to see how others solve a particular problem and whether you want to incorporate a similar solution or try something different.
Like what? Valgrind? I use clang to compile, and that tool often provides useful error messages versus gcc.
I haven't even run across the need to use valgrind yet. gdb is good and you can build it with a ncurses/pdcurses front-end. I like CodeLite as a cross-platform GUI debugger. On Windows using MinGW, there's Dr. MinGW and StraceNT. Linux offers strace. There are several programs that let you check for memory leaks including Dr. Memory, dmalloc, electric fence, etc. There are also tools like gprof that let you know what parts of your program are taking the most time to run.
Just wondering why you can't use libraries like curl to do Internet connection in C.
A lot of my projects involve gathering data from an API or scraping a website. Doing this in C, I found, was extremely difficult. Meanwhile, in Go, I can use BeautifulSoup , one of my favorite libraries ever, to get exactly what I need, while using the language's http module from its excellent standard library. I use to do this in Python but have since switched to Go.
Quote:
If you need some libraries to help speed up the writing process in C (since most other languages use several libraries/modules/plugins, etc.), there are some interesting resources available for C. One interesting trend in C programming is the proliferation of single file and minimal libraries. You can check out projects like https://github.com/clibs/clib/wiki/Packages which try to catalog them and make them easier to incorporate in projects. If the libraries are small and readable, it's a good way to see how others solve a particular problem and whether you want to incorporate a similar solution or try something different.
Thanks! I'll give this a read. I've been trying to find small web-based programs in C that I can scan. I'm still learning to read C code and jumping into massive projects is intimidating.
Thanks. I read through the project and it seems promising. Though, my only concern is it hasn't been updated in three years. Nice to know there's a libcurl wrapper.
After our discussion yesterday, I spent the day writing a C program that interacts with Dictionary.com's API. The program uses basic libcurl GET functions and cJSON to work with the JSON response. The latter library was a lot easier to use than I expected. The only issue I had was needing to clean up arrays of word definitions (removing quotation marks and extra spacing). It was a fun challenge, and I plan to put it out there for those who get their own API keys and want a quick dictionary on the command line.
Quote:
Originally Posted by ugjka
Go was built by Google whose main business is http/networking. It just makes sense it shines in that aspect
Indeed. It's been my go-to language for interacting with the web. I just like the challenge of working with http GET requests in C, as that is what most of my work consists of.
I wrote above about writing a program in C to get and parse JSON data. I'm curious to see how I can expand to create a BeautifulSoup-like program for C.
Language choices hardly matter from a technical standpoint, most of them are well developed enough that they can do pretty much anything.
The question is the human part involved :
Do you want to maintain the project for years to come?
Do you need 100% control of your program (you can't have a sudden disruption by the GC)?
Do you just want to learn or develop as a programmer?
Personally, I try to choose the right language for the job, but I find it hard to escape the apish nature of having an allegiance and disgust of other unfamiliar language (high level languages like Ruby, JS etc etc)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.