[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 36 KB, 1333x402, C-vs-C.jpg [View same] [iqdb] [saucenao] [google]
12590840 No.12590840 [Reply] [Original]

Which language should I learn first coming from Python? From what I've read, C's syntax and standard library is easier to learn and it gives you more of an opportunity to learn more about low-level stuff like garbage collection, while C++ is more convenient if you want to make applications

>> No.12590858

>>12590840
Learn C++. It has all the important features of C pretty much but it's just a bit more powerful.

>> No.12590958

>>12590858
By that logic, wouldn't learning C and then C++ be basically as easy as learning just C++?

>> No.12590970

>>12590958
>by that logic
hello midwit

>> No.12591155

>>12590840
first of all, regardless of the question, don't ever try to learn C++, it's a cluster fuck with shit tons of rules, as much as exceptions to those rules, many different way of doing the same task. there are like 10 people in the world that knows all of the C++, even stroustrup admitted that he doesn't hold every rule in his memory just like he doesn't do it for math.

programming languages are not math, you should know every rule and use about 90% of the language for any nontrivial program. In C you will use 90% of the language, I don't know immediately which part I wouldn't use very often, maybe union and bit fields. for C++ every company uses a specific subset of the language to keep sanity, for instance google doesn't use exceptions, some companies will not use templates etc.

coming back to the question, C is a great language, I am a bit biased because it was my first language and I used it exclusively more than a decade, but the things it thought me still helps me today even when I write in python.

learn C, learn memory management, implementation of algorithms and data structures, some automata theory, you will be a much better programmer.

>> No.12591175

>>12590840
C is a lot easier to learn but a lot less useful when it comes to using advanced abstractions familiar in python. C++ gets around that problem with the cost that is a fucking clusterfuck without having at least 7 years experience.

>> No.12591204

>>12590840
C++20. You'll pick up C along the way.
>>12591155
Take your wrong pasta back to >>>/g/

>> No.12591224

>>12591204
What about C++11/14/17? Are those not recommended anymore?

>> No.12591231

programming is a waste of time but if you must, learn lisp.

>> No.12591238

>>12590840
C is good to practice working with some of the guts of the machine without pushing yourself into OS or embedded. it's a very tiny language that doesn't stop you from doing much - but that means that you might lead yourself into a lot of frustration if you're not careful. A sharp knife is simple and effective but easy to cut yourself with if you don't pay attention.
Other than actual utility? I love projects that use C (mostly embedded variants or OS level stuff), but as far as pure ubiquity or immediate utility, there are other languages for that. I'd say C is good as a language to learn with, do hobby projects with, or do proper OS level stuff, but not for other professional work.

>> No.12591239

>>12590858
No, there's some things you have to do in annoying and pointless ways in C that can be done more cleanly in C++, e.g. handling structs. There's no point learning something like that in my opinion. I did learn C first personally but I don't see a great reason to.

>> No.12591245

If you’re a NEET with plenty of free time to reinvent the binary tree a quintillion times, use C.
If you’re a NEET with plenty of free time to wait for endless compile times and debug autistic error messages, use C++.

>> No.12591284

>>12591155
>it's a cluster fuck with shit tons of rules, as much as exceptions to those rules
That doesn't matter if you're not writing a compiler. You don't need to understand copy epsilons to write hello world.
>many different way of doing the same task
Which often compiles down to the same source code. Having choice is a good thing that only turbo autists slander.
>there are like 10 people in the world that knows all of the C++,
And how many people know [math]ALL[/math] of the standard library of C# or Java? C++ is nothing compared to that.
>programming languages are not math,
objectively not true
>you should know every rule and use about 90% of the language for any nontrivial program
Holy fuck the sheer cancer. You're obviously that shitty Java programmer that uses classes for everything with needless inheritances, polymorphism, factory classes, decorator classes et al in all your programs.

Programming languages are tools. You don't need 90% of your toolset for every job and having multiple usable tools to accomplish a task that you decide on preference is not a bad thing.
>learn C, learn memory management,
You can do that in C++ except better as you can use better syntax like "new int[10]" rather than "malloc(10*sizeof(int))"
>implementation of algorithms and data structures,
You can do that in C++ but better as you don't need to worry about freeing on every exit path with destructors, manually init() with constructors, generic algorithms and overloaded functions, and so forth...
>some automata theory
What does that have to do with choice of programming language?

>> No.12591290

>>12590840
Lisp.

>> No.12591331

>>12590840
Depends what you are doing. Why only those 2 languages. If only those 2 just start with C so you can experience the upsides and asspains.

>> No.12591337

>>12591239
If you're a hardware programmer, C is still useful due to low memory requirements.

>> No.12591416

>>12591284
>Holy fuck the sheer cancer. You're obviously that shitty Java programmer that uses classes for everything with needless inheritances, polymorphism, factory classes, decorator classes et al in all your programs.
>Programming languages are tools. You don't need 90% of your toolset for every job and having multiple usable tools to accomplish a task that you decide on preference is not a bad thing.
I phrased that badly. what I mean is that there's no redundancy in the language, every feature is necessary so you end up using 90% of the language for a nontrivial program.
using features for the sake of it is the cancer, you shouldn't even have those redundant features in the language, that was my actual point.

>> No.12591441

>>12590840
What's wrong with python?

>> No.12592000

>>12591441
It is too slow and not suitable for sophisticated software. If you wanna up your game that is beyond using it as matlab or using it to write web scrapers or data-mining then you gotta drop python.

>> No.12592026
File: 32 KB, 391x391, cX9EIQxo.jpg [View same] [iqdb] [saucenao] [google]
12592026

>>12590840
Forget C++, as another anon puts it, it's a clusterfuck. It's a shame that such a language is still growing in complexity nowadays.

C is the lingua franca of programming languages, most FFI and ABI still rely on C as of today. It doesn't make it a great language to use for general needs but it's pretty neat as a bare metal language. You'll feel the primitive feel of it fairly quickly though, not to mention its crazy semantics for undefined behaviours (an entertaining read: https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html).).

If you want a language that occupies the same niche as C++ but actually learnt for decades of research in PLT, you should really aim for Rust instead.

>> No.12592031

>>12590840
The universal rule for deciding what language to learn or use for a project is to answer the question: what do most people programming similar things use?

If you use the industry standard, there will be way more resources available, lots of questions already answered, and plenty of already-built functionality.

What is the project you're trying to work on?

>> No.12592088

>>12590840
Learn C++ first

>> No.12592151

>>12590958
no because you would have to learn two languages.

>> No.12592381

>>12590840
C is a trash obsolete language
functions are not first class objects
there are no lambdas
no object system
no generics
you can't even have a function argument or return value be an array, or indeed any non-primitive data type
doing anything other than basically a hello world program requires error-prone low-level hacking
C++ adds all these things and more, while actually being a faster language
that said, decades of poor-planning and insistence on maintaining backward compatibility have made C++ overly complex, syntactically noisy and awkward, but it's miles better than C regardless of what idiot cniles will tell you.

>> No.12592388
File: 45 KB, 634x650, c0c.jpg [View same] [iqdb] [saucenao] [google]
12592388

>>12591155
>programming languages are not math
>he doesn't know about the Curry-Howard-Lambek isomorphism

>> No.12592429

>>12590840
>learn more about low-level stuff like garbage collection
There is no garbage collection in the C languages. It's expected of you to clean that yourself.

I'd say go with C++ and a lot of people with seethe over this but they are basically the same language, C++ is just C with objects and basic quality of life stuff. I learned C++ first and I had no trouble writing in C.
The differences are extremely minor compared to say Python vs C.

More often I find myself wanting the conveniences of C++ when writing C instead of being perplexed by some new mysterious feature.

c++:
string hi = "hi";

C:
char hi[2] = "hi";

>> No.12592581

>>12592429
>char hi[2] = "hi";
spotted retard there

>> No.12592964

>>>/g/

>> No.12592980

>>12590840
C is a robust language, widely used all over the world. I use C all the time to write analysis programs for casino games, Markov Chain Monte Carlo sims, shit like that. C is also essential for malware analysis, because most good viruses and ransomware are written in C. If you're already fluent in Python, C is the next logical step.

>> No.12592990

>>12592581
Oh right
char hi[2] = {"hi"};
This shit get so annoying at times.

>> No.12593000

Just keep using python anon. You are a scientist, you put true knowledge into a computer, and code monkeys will optimize, don't waste your life

>> No.12593009

>>12593000
but, you can do this with any language. knowing how to code without being overly concerned with technicalities that would concern a code monkey is the way.

>> No.12593025
File: 93 KB, 624x464, now_look_at_that.gif [View same] [iqdb] [saucenao] [google]
12593025

>>12592026
>rust
trannie

>> No.12593967

>>12593025
What's wrong with Rust?