Programming language choice and purpose

I've been learning C as my first language from K&R. I like it, but from what I've heard it's pretty fiddly compared to other languages. From another thread here, it seems like it's only really good for stuff like systems programming or kernels. Stuff where you're close to the hardware.

If I want to make more high-level programs, should I drop C and learn something else instead? I'd like to to learn something that's good for games, and for utility programs (a specific project idea I'd like to take on is a cross-platform replacement for EVEMon for EVE Online), but I don't know what language is really suited for what task, and I'm not sure there's any real consesus sometimes. For example, some say C++ is the best for games, and some say it's C# or something else.

If you have a language recommendation, if you could also recommend some good learning material, I'd appreciate it.

Other urls found in this thread:

en.wikipedia.org/wiki/Memory_safety
cve.mitre.org/cgi-bin/cvekey.cgi?keyword=buffer overflow
cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-7415
love2d.org/
blog.separateconcerns.com/2015-06-18-love-hate-luajit.html
twitter.com/SFWRedditImages

Fuck off.

I suppose it would have been more accurate to ask if I should _delay_ learning C. I want to be able to write software that is useful to me as soon as possible, so instead of learning C and finding that it's not well suited to the task and immediately moving on to some other language, I'd prefer to just get to that other language now and learn C later.

perl5

This and bash. Ignore the sperg who inevitably runs in screaming about POSIX or some shit, you asked how to write useful software.

perl5, bash, and sed.
all a real programmer needs

First of all, C is the best language for everything, you fucking Pajeet. Second, it's the best language for quick results. Third, it is specially good for high level stuff like dynamic webpage generation or game scripting.

So fuck of with your illiterate Pajeet memes, because only Pajeets don't know C and don't use C for everything. Pick up K&R and burn all your other programming books or gtfo out of my Holla Forums

By "useful," really I was referring to what I wrote in the OP: games, and an EVEMon replacement. Things like that.

If You Cant Code It In C You Arent A Real Programmer

C# is garbage and not cross-platform
C++ > C
just learn perl5 for general purpose
ignore every post that says C is all you need

Trips confirm. This influx of non C programmers can only come from halfchan newfags.

NORMIES GET OUT
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Can you write a kernel in C++, huh? Thought so. C is still superior.

C++ is full of bloat and it is a convoluted mess. I can't understand how it works under the hood so it's shit.

...

So should I learn C++ for games and stuff and perl5 for everything else, or what do you mean?

Exactly.

Don't listen to him. C++ is a pajeet meme. Real programmers use C only,

Can you recommend any good C++ books that don't assume you already know how to program in another language?

And is there something that's analogous to K&R for C++; a book that everyone always recommends everyone learning C++ should learn?

I wantunderage screechchanners to leave.

No because the language is a horrible mess and full of decades worth of memes. No one person can even comprehend all of C++. It is not humanly possible because of how much useless shit is in the language.

Windows NT.

Don't forget awk, fags.

"The C++ Programming Language" by Bjarne Stroustrup himself, perhaps?

...

C++ is like taking C and trying to turn it into python by adding layer after layer, and when it turns out that some layer is shit, you just cover it with more layers, when you're not sure how to implement something you either implement it both ways, or you don't implement it at all, leaving the old stale bottom layer, that probably wasn't written with multithreading in mind, exposed as the only way to do the thing.

Also don't fall for the "C++ is portable, because STL" meme, it's bullshit.

C++ is acceptable language if you use small subset of it together with some library that deals with the stuff that's missing (POSIX C stuff for example).

Do NOT learn C++ before you learn C. They tried to hide C under "nice, intuitive layer" but they failed spectacularly, you'll only be lost and confused. C is relatively small language, so it's easy to learn. Also if you go straight into C++, you'll be so busy fighting the language that you won't have the time to learn to program (as opposed to just writing code).

My first language way back in middle school was C++. Teacher was a street shitter. I don't know what he was thinking but it is a terrible first language.

c++ is an okay language with god-tier libraries. which makes c++ a great language to learn. you are just whiners. if c++ is too hard for you then you shouldn't be in tech in the first place. fucking deal with it. have a nice day.

You type like a street shitter and you're saying it's better to learn C++ before C. Post discarded.

From my perspective I would suggest continuing with C if you are already getting familiar with it, though for alternate languages to learn it depends on what you're trying to accomplish:

Getting a corporate job? C++, Java, Javascript, Python, and maybe Golang.

Want to learn something for fun? Haskell, Lisp, etc.

This is a really open-ended topic so don't take too much of what you see on Holla Forums as "the one truth", as most people here aren't actually programmers but enjoy LARP'ing as one for shitposting purposes.

Learn:

C++: As fast as C, but provides useful zero-overhead abstractions to make things saner. The size of the language is a plus, as it allows you to pick and choose the best tool for the job.

Scheme: Attached file related.

not necessarily. plenty of higher-level applications are written in C. it's just that using C for most of those is a bit of an overkill.

I find C++ loathsome and cumbersome, but it's the language of choice for 3D games nowadays, and you can transition smoothly from learning C to learning C++.


this.
if you are using a Unix-like operating system learning the shell and related tools is the most useful skill you could ever learn. It won't help you writing videogames, but it will make you a master of time savings.


you don't need to capitalize every word

Don't listen to Holla Forums autists who do not even write any code for real life projects.
C is a meme.
It's used for kernels and drivers only because there's no other choice yet (however Rust is getting more and more ready for these things), and C has no way to save yourself from shooting yourself in the face (i.e. exposing vulnerabilities).
Even the most advanced C programmers often make these mistakes, of course you are not smarter than them (nobody on Holla Forums is).

Do your own research and pick the right tool for the job.
Also read this en.wikipedia.org/wiki/Memory_safety

What part of "don't do stupid shit" is so hard for you idiots?.

Might as well skip straight to the climax buddy.

Common Lisp.

I wandered around programming languages for a LONG time always finding something about them that made me irrationally irritated. Then you discover the Zen of Common Lisp.

(Since you're learning C I recommend doing the "Making a lisp from C" book.

OP, avoid that language unless you like bad compilation times and getting nagged all the time with false positive errors by some annoying "borrow checker" aberration. Don't put some obsessive safety paranoia above a good understanding of the real underlying machine model.

Why are C fags so butthurt that Rust is killing their language?

Everyone should drop C. It's a useless piece of shit that remains around because of legacy codebases and stockholm syndrome.

You just keep telling yourself that user.

Why are Rust fags so triggered by people who don't like their safe space language?

Rust is everything C wishes it could be. If you weren't too much of a coward to abide by a simple code of conduct this would be a non issue.

...

Into the fucking trash

quite, trash it is

I have to admit, Rust is unparalleled when it comes to codes of conduct. If you want to become an expert at knowing xir's proper pronouns, avoiding microaggressions and checking your privilege, the rust community is the place for you.

Is that really all you've got? Back into your rubbish bin Ada fag.


It filters the pond scum out and it works quite well.

I'll get back to you with more once Rust actually becomes a stable, standardised language.

That's right, if you value professionalism and honest discussion above feelings-driven triggerfests, you are "the pond scum". This philosophy is promulgated by Rust's creators and is a core aspect of the Rust ecosystem.

Small languages for small minds.

Don't jump around too much out of fear you're doing the wrong thing. Learning C is definitely not a waste of time even if it doesn't end up being the best tool for some future projects.

One moment:
The other moment:

Come on guys, make up your minds.

Unless you need it for employment, literally the only thing you need to know about C is how to interface with it. It's never the best tool for future projects.

POO IN THE LOO

cve.mitre.org/cgi-bin/cvekey.cgi?keyword=buffer overflow

jesus...

Given not all of these have to be written in C, but most are. In special, I would like to bring attention to CVE-2016-7415.

cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-7415

ICU is an old library written in C and C++ by IBM (!). It's used in a lot of software because it's the go to library for anything Unicode related.

Basically, even the most serious and prestigious tech company in the world has fucked up in one of their C programs, even though C supposed to be an ebin Pajeet repelent so complicated only geniuses (like us Holla Forumsnologists, amirite?) who would never make a mistake writing a program with it.

Yeah, it's fast, but I'd rather have a slightly slower program that didn't decide to go rogue and fuck my system's shit up from time to time because humans are prone to error.

OP here. I'm reading Programming Principles and Practice using C++. Some of the syntax seems a little odd, but overall the things the book has covered so far make C++ look easier to use than what K&R showed of C. I can sort of see it being easier to do more complex stuff with this, especially if C has a lot of security "gotchas." I'm glad I decided to delay learning C.

C++ has as many gotchas as C, and then some
Luckily you won't be messing with them as much thanks to the stdlib abstractions

If you want to learn C++, learn C first or use a book like Gattis, that basically teaches you how to program using C++ as if it were still C at first. You'll also learn about programming and programming languages in general.
Also, if C is your first language, I wouldn't use K&R. K&R assumes you know how to program, just that you don't know C. C was my first language. I actually learned from C for Dummies after I got K&R and realized I had no idea what I was doing. It used to be two volumes, but they condensed it to one. I don't know if the new version is any good.

is bullshit. Smarter people pick the best tool for specific jobs. It just so happens that people are lazy and want one language that's at least *good* for everything. Sure, C, is a *good* choice then, but it's still not perfect, which triggers the pseudo-tumblr 8chanites.

Realistically the way to go with tech things, and anything really in general is to try it yourself and see how YOU like it. OS, Language, etc...

The sad thing about this field of interest you have is that you need to learn one thing to learn another to learn another. Maybe you are stronger than I, but i feel like this gets in the way and is discouraging.

If you want to get into game making, and still learn *programming* and *making games* you need a high level scripty type language(python, perl5, lua), and a very good gaming library/engine(the pieces are there, you simply assemble the puzzle that is the game)

I highly recommend love + lua:
love2d.org/

i reccommend

That just seems backwards to me. It doesn't look like C++ is meant to be used at all like C, and learning C first would just put more time and effort in between me and what I want to do. I can always learn C later.

I'm reading PPP, and it does that too.


I like C++ so far. The only thing that I've found annoying about it is that code examples on the web seem to sometimes have different syntax from what's shown in the book I'm reading. This book is fairly new, so I'm guessing the examples on the web use older syntax that still works for compatibility reasons or something.

Maybe in the long run. For now the only discouraging thing I've run into was finding that C probably doesn't suit my needs all that well, but only after spending a fair bit of time on it. Feels a bit like going back to square zero.

I'm not expecting to learn everything at once. I'd rather have a solid foundation from a good understanding of a "real" programming language, and then go from there. I'm also not expecting to make games for sale any time soon. I imagine I'll probably clone Pong or Snake or some other simple thing like that. Honestly though, what I want to make even more than any game right now is that EVEMon replacement.

I'm almost done with part 1 of PPP, but I've run into a snag with one of the exercises in chapter nine. Are there any non-elitist forums where a beginner might go to for help with C++?

Three words: Unicode string manipulation.

bump

bump

correction: all a real homosexual* needs

Yes, C is not well-suited to what is considered high-level programming today and for your first language, you should consider something that doesn't drown you in pointless minutiae like C so you can first learn how the basic concepts work before you bother with memory management etc.
Something like Python is simple enough to get you started and because it is popular you can easily find good introductions to programming using it. Something like Common Lisp is a good thing to keep in mind for later: A lot of "revolutionary" "new" language features are actually just cribbed from Lisp, so learning the original thing will prevent you from falling for most fad languages to come. However, CL is rarely somebody's first language, so most books assume that you can already program.

For completeness, I have to mention Structure and Interpretation of Computer Programs. It's an intro to computer science from the eighties and heavier on math than other books, but it doubles as a great intro to general programming that covers many programming paradigms.

C++ is commonly used in professional settings, but it's not because the language is so great. In fact, the language is fucking terrible and it's used only because you have basic OOP in a language where you can make things fast enough for AAA games with enough effort and it's relatively easy to find people who know C++. The bold part is crucial from a business standpoint; if you want to make games on your own, it's not so important and you should stay as far away from it as possible. Most games don't need the speed of C or C++, don't let the LARPers on AGDG trick you.

...

Talking shit about this programming language or that is all well and good, but could someone tell me where I could go to for help with C++ while they're at it?

I'd like to actually learn at least one language well instead of hopping from one to another every couple of weeks.

The mental ward is a good place to start.

You would usually think it's a parody of your average Holla Forums Ctard, but...
blog.separateconcerns.com/2015-06-18-love-hate-luajit.html

“There are two approaches to software design: Such that there are obviously no deficiencies and such that there are no obvious deficiencies.”
Hoare was right again, I wish more people would read older material and stop repeating the same mistakes.
Good on the author though, he's on the right path.

You need to have autism to learn C++. I speak from experience.

I found Project Oberon 2013 very educational. A whole computer system, from Verilog up, explained in one (good) book. About 10 KLOC.

Except Lua is obviously flawed due to how fucking slow it is. Seriously, look up The Computer Benchmarks Game, and check how it chokes so hard on half of the programs that it manages to be twice as slow as Python. This man's argument is pretty much "I don't understand JIT, therefore it's evil".

Most of that guy's posts are him working for startups and also posts about web development in Lua (probably the reason he doesn't need performance), so I wouldn't take his article as a perfect and informed opinion.

Luajit is pretty speedy for an embedded language. It's much less shit than python in practice.

LuaJIT is so fucking fast it is considered to be only thrice as slow as C, and even faster than Java (which, despite popular belief, is actually pretty fast). I can't see any reason anyone would use Lua over LuaJIT unless they were trying to write an implementation or were basically the hipster reincarnation of Uriel.

Lua is more often used than luajit due to it weakening security. It requires writable executable pages.

That would be in kernels that don't allow JIT in general, such as grsec Linux, but you only see these in high security environments. It doesn't mean LuaJIT is vulnerable or decreases vulnerability, just that other things like programs written in unsafe languages may be, and thus the NX bit is used across the whole system for a total ban on possible shellcode injection.

For computers that are already expected to be JIT ready, like most desktop computers are, using LuaJIT is plenty fine.

Anyway, if you wanted high security, you should probably consider other languages

Find the contradiction.

What if the website keeps getting more and more users and soon he finds his Lua scripts can't keep up? Many companies solve this by throwing more and more resources to their setup, but that may not always be possible.

For the record, Lua seems to be twice as slow as PHP 7, although that's coming from a benchmark that shows Java as being the fastest language ever (nested for loops test, so it makes kind of sense) so I would consider the results to be vaguely orientative at best.

It's important for application security as well.
Adding jit adds danger as it disables a security feature application-wide in C which is a tough sell considering lua isn't going to be the bottleneck, anyway.

You can always profile and fix the code or, if you really reach your limits, change the implementation at that point. Not everything needs the last bit of performance and in fact most applications will be bottlenecked by I/O. As there is basically no difference in I/O speed between languages, the benchmark doesn't really say a lot. After all, if you have a really tight loop, the FFI exists.


Simple software is also nice if you want security because it's easier to secure what you fully understand.

That's some pretty serious wew yer puttin out. So for basic network performance I need multiqueue support, full control over affinity, a way to guarantee data never is touched by a different thread even if that means having to leave a core idle (this is increasingly important and no one outside of the field even seems to acknowledge it), a way to avoid ever copying data on the same core, and support for sendmmsg. I also need edge triggering if you want to count that as I/O speed. What non-C language is going to compete with that?

IHBT.

Is heap overflow really as bad as stack smashing?

Well, would you look at all those buzzwords.

Java

To a retard, yes. These are basic and necessary things in networking and are a decade old.

Good joke, user.

All that wall of text implying that you have a real use case for packet steering, yet you sperg out when reminded what real world users write their userspace networking in. You're the joke.

Yeah nah, it's buzzwords.

Umm, user..

I took the bait, right?

I work on a VPN product that uses 10Gbit ethernet (and hopefully soon, 40GbE). Without multiqueue it'd struggle to hit line rate even with encryption disabled. It's not an unusual feature by any means and your unfamiliarity with how common it is now says you must be in the kiddie pool.
Huh, I could have sworn I replied because you said all languages have virtually the same I/O performance which is a fucking stupid thing to say.

Why do you think edge triggering in C is unusual?

Show me where I said that. No bonus credit for linking to a completely different person's post

Different persons, I stopped replying after because it was obvious you were either trolling or trying to change the topic in order to win an internet argument. Remember how the discussion originally was about web sites and normal applications before you tried to make it about the backbone of a VPN service?

I've only replied to correct you idiots saying I/O perf is the same across languages. Everything else you think is being said is in your head.

Yeah, sure.

Statements happen in context, you autist.

Because you're either emulating edge triggering, which can be done in other languages, or implying C has some compiler intrinsics for edge triggering, in which case you are probably using a custom compiler that could have been prepared for literally any other language.

...

...

Kill yourself.

You seem confused. In C we use what the OS provides which is ideally epoll on Linux which is pretty flexible. Higher-level languages usually force you to use their own event abtractions and they're usually pretty bad, often not supporting the patterns used by high performance code.

Save this board from self-styled performance experts, Jesus Christ.

...

See . C is not special so "what non-C language is going to compete with that?" is a dumb argument

and wheee, the goalposts go for their next ride

...

You usually can't. And there's good reason for that: it's done completely different on Windows and is not portable at all.
MS has gone through several iterations. A long time ago it involved WaitForMultipleObjects and NIGHTMARE code the horror of which you can't even imagine to work around the 64 handle limit. Then there
was WSAEventSelect, then using that with IOCP, ... I think their current best performance is with long async WSARecv with socket buffers set to 0 (better hope you didn't need autoscaling) but I haven't had to work on our Windows shit in years so I dunno. They've had a very hard time figuring this stuff out.
The big difference in compatibility is Linux uses a reactor pattern while Windows uses a proactor pattern. You can try to make it feel reactorish on Windows for compatibility reasons but it's a big sacrifice as the code loses control of when and where (the thread) reads occur on. A lot of higher-level languages do this but it kills performance.

What is an FFI?
No shit, neither is epoll in C, for the same reasons you laid out. What is your argument at this point? Do you even have one? It's like you want to ramble about pointless tangents in order to impress some invisible teacher.

Not all high-level languages let you make syscalls, it's pretty rare. And Go and D don't count as they can be paused by the GC - they have unarguably shit I/O performance.

This must be a troll. Sorry for shitting up the board with this, it's my fault for replying.

In D, you can either detach a thread from runtime to avoid garbage collection or go as far as disabling GC altogether (for the exception of running out of memory) during runtime. The fact that D GC is deterministic also helps preparing the program for smooth operation.

It would still cause problems as /some/ CPU thread is going to have to deal with doing GC and in modern networking code there is one thread per CPU thread each waiting on its own multiqueue bucket. One of them will stall. At about 7us between packets for my code, a 'quick' 10ms stall would be a lot of lost packets.

err I should mention, when detaching a thread to act as a network helper thread.

You forgot you CAN disable GC. Just init everything you need during the init sequence and then disable the GC. After all, this kind of program doesn't seem to be the type of program that would be constantly generating and destroying objects (and if you need to do so, you can still manually destroy them).

It has a small amount of dynamic memory but most is pre-allocated slabs/pools mainly to keep max memory bounded but also for performance. The small amount of dynamic stuff that would be too painful to make pools of for each type would be the trash buildup if this was GCed.
If so then D would be usable.

D is usable, unlike C's boehm-gc

Ada.