Just include Windows.h and write LPCSTR or whatever exactly it is. Or make your own semantic typedef. The way I've heard it explained is that with "char *foo", you don't think of the type of foo as char*, you think of the type of *foo as char.
|
|
# ? Sep 28, 2022 20:59 |
|
|
# ? Jun 8, 2024 09:11 |
|
That fits how the language works but it's not natural, obvious or right.
|
# ? Sep 28, 2022 21:54 |
|
code:
|
# ? Sep 28, 2022 22:18 |
|
Options: true/false/guest
|
# ? Sep 28, 2022 22:46 |
|
Back when I wrote C++ and had no coworkers so I could do whatever the hell I wanted I went with the King Solomon-esqueC++ code:
|
# ? Sep 28, 2022 23:03 |
|
Char multiplied by lol
|
# ? Sep 28, 2022 23:05 |
|
ultrafilter posted:That fits how the language works but it's not natural, obvious or right.
|
# ? Sep 29, 2022 01:20 |
|
ultrafilter posted:That fits how the language works but it's not natural, obvious or right. Please stop quoting comments from my pull requests
|
# ? Sep 29, 2022 05:20 |
|
The real thing that throws me is that * on a value dereferences it, i.e. it changes it from address-of-T to T. But * on a type does the opposite, it changes it from T to address-of-T. It should be: code:
|
# ? Sep 29, 2022 09:36 |
|
C is a nice language where everything makes sense and it's not too complicated. Let's start with the numberline. Is -1 less than 1? Okay, well, you see-
|
# ? Sep 29, 2022 11:05 |
|
NihilCredo posted:The real thing that throws me is that * on a value dereferences it, i.e. it changes it from address-of-T to T.
|
# ? Sep 29, 2022 12:06 |
|
I teach a computer systems course at university level, and each year I have to carefully demarcate which difficulties are inherent to the domain (manual memory management, fixed-size types, programming without abstraction layers) and which are due to design flaws in C (stupid pointer syntax, weak type system, implicit casts, atrocious function pointer syntax).
|
# ? Sep 29, 2022 13:00 |
|
NihilCredo posted:The real thing that throws me is that * on a value dereferences it, i.e. it changes it from address-of-T to T. As someone who’s bounced off C and CPP for years and is now taking another shot at it in order to do some embedded dev, this part has caused me so many issues. You think that it must be a problem in how you’re thinking about variables, addresses and pointers and it causes you to think you don’t “get it” And for whatever reason, people don’t call it out. Like if I’m teaching CPP the first thing I’ll teach is this bullshit and how it’s dumb. * operator doing two totally different things like that is ridiculous. Wish I had realized it years ago and just accepted it and moved on lol. I also think it’s stupid to try and teach pointers without teaching references hand in hand. Ughh While I’m on a rant, c++ using << and >> operators in iostream in every tutorial is ridiculous. Like, let me put a super esoteric, advanced concept in front of people just learning the language. That won’t cause them to think it’s just magic lol Arby’s drive thru… can I get extra horsey sauce please
|
# ? Sep 29, 2022 14:31 |
|
Athas posted:I teach a computer systems course at university level, and each year I have to carefully demarcate which difficulties are inherent to the domain (manual memory management, fixed-size types, programming without abstraction layers) and which are due to design flaws in C (stupid pointer syntax, weak type system, implicit casts, atrocious function pointer syntax). Start teaching it in Rust
|
# ? Sep 29, 2022 14:41 |
|
Yeah I think a big part of why a lot of people think "pointers are hard" when first introduced is that c uses * for two different things, both pointer related. And they try to understand what * does, without it being clear that it's actually doing two different things.
|
# ? Sep 29, 2022 14:43 |
|
namlosh posted:As someone who’s bounced off C and CPP for years and is now taking another shot at it in order to do some embedded dev, this part has caused me so many issues. like it's dumb but i've been writing c++ since the 90's so * doesn't even register among all the other dumb poo poo i see about the language. c++ is one of the worst taught subjects in school to the point where it makes me suspicious of cs education in general. some people will just take c++ classes and think that they're any good at the language, or even literally put "c/c++" on their resume, when in reality you could literally write "gently caress you" on your resume as a joke and get a better reaction from me than if I see "c/c++" (and I mean literally "C/C++", it's reductive to group the two together and many C programmers would happily murder C++ programmers if given the opportunity, it'd be like putting "Israel/Palestine" as a line on your resume).
|
# ? Sep 29, 2022 15:45 |
|
C's idea of "declaration follows use" was a really bad one, but it's one that you really need to introduce early because it's what makes C declaration syntax merely stupid instead of completely incomprehensible.
|
# ? Sep 29, 2022 16:21 |
|
Fortunately in C++ the number of times you want to manually declare a pointer are pretty limited. Smart pointers, vectors, and arrays cover most of the use cases of pointers while also having destructors Of course, teaching how those work without letting learners mess around with raw pointers sounds so difficult that there may be no teaching advantage
|
# ? Sep 29, 2022 16:28 |
|
Whatever C++ is, a good choice for an introductory teaching language it isn't.
|
# ? Sep 29, 2022 16:32 |
|
namlosh posted:do some embedded dev
|
# ? Sep 29, 2022 17:25 |
|
Yeah, my school didn't touch C++ at all -- it was C and VHDL for low-level stuff, Java and Python for everything else. Some courses also had a "you can turn in assignments in any language you can convince the TA to mark" clause, so I also got some practice with Erlang, Postscript, Lua, and Scala. It wasn't all good (I can, for example, point at their decision not to explicitly teach debuggers or version control on the assumption that everyone coming in either is already familiar with them or can be brought up to speed by a classmate outside of class hours), but I think the call not to touch C++ in the undergraduate curriculum was a good one.
|
# ? Sep 29, 2022 17:32 |
|
My CS degree was mostly “here’s the language we’re using in this course, here are some links to learn it if you don’t already know it”. We did do one C++ class but it was mostly about software design concepts and not the language itself.
|
# ? Sep 29, 2022 17:35 |
|
My college was all about C++ because one of the bigger profs did a lot of work on STL. I spent more time getting mad at the compiler than I did learning data structures and algorithms.
|
# ? Sep 29, 2022 18:08 |
|
my worst introduction to a language was a bored TA explaining "Verilog's kinda like C without recursion" which is... a little lacking
|
# ? Sep 29, 2022 18:20 |
|
I'm using Verilog right now You could fill this thread with verilog poo poo
|
# ? Sep 29, 2022 18:41 |
|
Is it Verilog or VHDL (or both?) that's full of language features that only work for simulation and can't actually be synthesized into hardware?
|
# ? Sep 29, 2022 18:49 |
|
Both do that. Using them to design a circuit needs both a language for describing the circuit and a language for saying how to test it. It would probably have been better design to make a harder line between those parts, though they do need to interact a long (i.e. "in this test, we will connect circuit A to circuit B, then wiggle input pins on A and check that the right signals come out of B")
|
# ? Sep 29, 2022 19:03 |
|
OddObserver posted:Is it Verilog or VHDL (or both?) that's full of language features that only work for simulation and can't actually be synthesized into hardware? ive seen a Verilog tutorial "hello world" that's just that, using $display("hello world") to make the simulator print those characters
|
# ? Sep 29, 2022 19:17 |
|
I assume the correct way to teach C++ is to teach C and then, afterwards, say "you know that thing in C that was annoying/kept causing bugs? here's a C++ feature or stl class that helps with that" I'm self-taught so all I can really say is that the results on google are very not-good at explaining which parts of the C++ language are there mostly to be backend to the stl/your own low-level classes, and which ones you're actually supposed to be interacting with on a regular basis
|
# ? Sep 29, 2022 19:22 |
|
My experience is the opposite of everyone else's. My alma mater taught us C++ almost exclusively when I was there in the mid '10s, with a little Java here and there. I think the idea was that learning C++ would teach you the technical fundamentals of data structures (since you have to do a lot of set up and break down work yourself) before you learn a language like Java that does a lot of the grunt work for you. I came out of my university experience a better programmer, but it's rare when I see a coding job that requires C++. Everything now is either Python or Java.
|
# ? Sep 29, 2022 19:26 |
|
I believe Verilog was actually designed for logic simulation first, and only later was it adapted for synthesizing hardware.
|
# ? Sep 29, 2022 19:43 |
|
I am happy with how my school taught. Introductory "How to program computer?" was a school-wide required class and taught using Java (I think it is Python now). C++ was introduced in "Intro to Data Structures" alongside the main data structure content. Everybody taking that was already familiar with imperative languages in general, and C++ is a decent tool for a class that's about stack/queue/linked list/heap/priority queue/binary tree/red-black tree/hash table/... and how to implement them/computational complexity of them. Then there was more C++ stuff in "Into to Algorithms" later.
|
# ? Sep 29, 2022 19:59 |
|
I learned C++ as my first language but that was in 1998 so a lot of the nicer features just weren't there yet. I think there's a lot to be said for teaching pointers early on because no high level language is really successful at abstracting them away, but I don't know if a first course is the right time to do it.
|
# ? Sep 29, 2022 20:53 |
|
I learned an eclectic mix of languages at college. The intro courses used C++, the courses that were basically "practical software engineering" (i.e. working in teams, Agile, sprints, etc.) used Java, our Programming Languages course cycled through various functional languages before going to Java and then letting us pick whatever for our final project (write a very basic compiler), the combined low-level/networking course started with C, moved to Python for sockets, and then inexplicably had us learn MIPS assembly, and the parallel programming course in my senior year used C. This was all from 2014 to 2018, incidentally. Ironically, I actually learned most of my programming knowledge through bashing my head on C# on my own time.
|
# ? Sep 29, 2022 21:55 |
|
Plorkyeran posted:C's idea of "declaration follows use" was a really bad one, but it's one that you really need to introduce early because it's what makes C declaration syntax merely stupid instead of completely incomprehensible. I’ve gotten to the point where I just typedef everything to make Linus sad. dougdrums fucked around with this message at 22:12 on Sep 29, 2022 |
# ? Sep 29, 2022 22:10 |
|
dougdrums posted:I’m always really about this until some time later when I have to define a function pointer that returns a pointer. I've been writing C++ since 2001 and professionally since 2006, and I long ago just resigned myself to the fact that I'm never going to remember function pointer syntax, so I google it or copy/paste an existing typedef.
|
# ? Sep 29, 2022 22:16 |
|
Doing it in two steps makes it much easier.code:
|
# ? Sep 29, 2022 22:22 |
|
I especially like the syntax for calling a member function that's been passed as a pointercode:
|
# ? Sep 29, 2022 22:35 |
|
cheetah7071 posted:I especially like the syntax for calling a member function that's been passed as a pointer I especially do not like it.
|
# ? Sep 29, 2022 23:22 |
|
|
# ? Jun 8, 2024 09:11 |
|
Almost all of my courses were taught using C, except the OOP course was taught in Java. There was one course where we wrote a system with a C backend and a Python GUI, and I think the for the Software Engineering courses, the groups decided on a language. We went with Python. Probably my most embarrassing thing was not being able to finish the project in my compilers course before the end. I spent too much time looking at the internals of Clang and had a fair bit of trouble handling custom typedefs and how to determine if a string was a type or an identifier.
|
# ? Sep 30, 2022 03:46 |