5 ms·
... Don't laugh: C I learnt programming mainly through various scripting languages, some of which had some relatively simple visual output available, which I p
by tomxor 7y ago
... Don't laugh: C
I learnt programming mainly through various scripting languages, some of which had some relatively simple visual output available, which I personally found invaluable for learning and visualizing.
I realized that better visual output was the main thing holding me back from doing more in C since there are so many options, often complex, involving much boilerplate. So my mini project is essentially exploring the simplest, most minimal possible ways of drawing pixels on the screen in Linux.
So far tried fbdev (but doesn't work well with X), now playing with XCB.
- DizzyDoo 7y agoOut of interest, why would people laugh at someone learning C? I know plenty of people using C in all manner of domains, choosing it over C++ or Rust for fair and sensible reasons - I'm not a C person myself, but it certainly seems extremely useful to have in the toolkit!
- shrimp_emoji 7y ago>choosing it over C++ or Rust for fair and sensible reasons I don't think such reasons exist. I don't think C/C++ should be used when superior alternatives exist (Rust). It's like smoking; you're just hurting yourself. Unless you're being like the programming equivalent of a steam engine enthusiast or a historian. (In a world where most of the industry is still using steam engines cuz we're in too deep and must ride the inertial tide for at least a few decades.)
- wyck 7y agoI've noticed this a lot on hackernews, there is an apprehesion to say certain things as though there is some sort of pedigree or gating when discussing topics, especially when it's personal...there isn't. Case in point: The comment below mine...
- tomxor 7y agoI want to learn C not (only) because I think it's useful, but because I think I might like it. I have a particular interpreted language that I like, enjoy and know inside out, now I want to know a compiled one in a similar way. To answer your question: I get the impression from various tech news on "hot new languages" that C is the incumbent systems language that people put up with but don't really love, and yet I want to try and love it. I've developed a taste for minimalism, simplicity and a degree of brevity in programming, I have a feeling I might find C more suited to me than C++, Rust, Go, Java etc for this reason despite the lack of "modern" features.
- juped 7y agoI love C. Lots of people do.
- selfish-duck 7y agoI started coding 10 years ago (damn I just figured that...) learning C at my engineering school for 2 years. Never had to use it ever since (mostly working front-end and webAPIs) but I'm still glad I studied it to learn the programming foundations. I would probably choose Rust or Go today though.
- MaxBarraclough 7y ago> why would people laugh at someone learning C? I suppose because of the perception that many programmers already know C. Which is true, but only some fraction know it well, which is far more important in C than in most modern languages.
- zetalemur 7y ago> So far tried fbdev (but doesn't work well with X), now playing with XCB. Another idea would be to use SDL which essentially provides functionality to make windows, draw pixels and handle input/output. If you do not want to use any library at all and do not mind low "resolution", you could use your terminal as window and regard characters as pixels. Sure, there is the curses library to abstract away different terminals, but if you do not care about platform independence you can just directly write escape sequences to the terminal.
- tomxor 7y agoI was indeed trying to avoid the big libraries, since this is just for personal use I don't care about cross platform which allows me to escape these potentially - I may well end up back at the SDL + OpenGL level later when features or performance are a concern. My current goal is to find a balance of least dependencies and least boilerplate to draw a pixel buffer so i can play with C, nothing more. Once I can do that without lots of fluf then i may be attracted to more advanced or complex methods later on when performance is desirable. I have done some visual things with the console and printf alone in the past which gave me a taste of C, but now I want some real pixels :)
- mntmoss 7y agoYou may want to try raylib. It's written by a teacher who uses it in the classroom and geared for this kind of "let me code games in C but with only one dependency" goal. It does more than you need but that's a common theme of useful libraries.
- tomxor 7y agoThanks, that sounds about right, i'll take a look.
- jfkebwjsbx 7y agoThen you should be using X11 directly!
- idoby 7y agoWhy would I laugh? I've done a lot of C programming over the years and I still consider it one of the most elegant languages I've had the opportunity to work with. With the right skillset, you can be as productive as a programmer of any other language or system. And it's great to see where some of the things we take for granted in programming, come from. If you want to draw pixels, give Cairo a try. It's fun to use!
- tomxor 7y agoNice to hear from people still enthusiastic about C :) Thanks for the suggestion, I hadn't considered Cairo, for some reason I thought it was only for SVG, maybe from it's use in Firefox. I will try it out once I get out of XCB territory.