|
VikingofRock posted:Templates cover a lot of the same functionality that you would use traits / interfaces for; just think of the constraints as being implicit from the function that you are writing ("I use the + operator here") instead of explicit ("my arguments implement Addable"). yeah, it's a very different approach. my main worry is ambiguity, it seems like you could easily have two different types that each have a "foo" method with the same input/return types but wildly different semantics. it's like duck typing.
|
# ? Aug 31, 2018 18:26 |
|
|
# ? Mar 28, 2024 18:45 |
CRIP EATIN BREAD posted:c++11 has traits as part of its stdlib Not really in the same way that e.g. rust has traits, which is what I was talking about here. C++ traits are more like type tags; in C++ terms I'm talking about concepts.
|
|
# ? Aug 31, 2018 18:27 |
|
DONT THREAD ON ME posted:yeah, it's a very different approach. my main worry is ambiguity, it seems like you could easily have two different types that each have a "foo" method with the same input/return types but wildly different semantics. it's like duck typing. You sure can! C langs allow you to easily shoot yourself in the foot, in exchange for low level fuckery and other neat poo poo you can do.
|
# ? Aug 31, 2018 18:28 |
|
CRIP EATIN BREAD posted:c++11 has traits as part of its stdlib i saw these but it looks like they're for adding type tags to your types so you can do reflection and stuff
|
# ? Aug 31, 2018 18:28 |
DONT THREAD ON ME posted:yeah, it's a very different approach. my main worry is ambiguity, it seems like you could easily have two different types that each have a "foo" method with the same input/return types but wildly different semantics. it's like duck typing. This is exactly true, but in practice it doesn't really bite you too often.
|
|
# ? Aug 31, 2018 18:28 |
|
ratbert90 posted:I was taught this about inheritance from my mentor: yeah i believe that unless you're wrapping some framework class you should generally limit yourself to 1 level of inheritance. but it's one of those things that really depends on whether you're writing library code or not. DONT THREAD ON ME fucked around with this message at 18:33 on Aug 31, 2018 |
# ? Aug 31, 2018 18:30 |
|
DONT THREAD ON ME posted:i saw these but it looks like they're for adding type tags to your types so you can do reflection and stuff idk, boost's entire geometry system has a way of doing things like: code:
|
# ? Aug 31, 2018 18:35 |
CRIP EATIN BREAD posted:idk, boost's entire geometry system has a way of doing things like: Jesus, it's their first week of C++! Don't show them boost, you'll scare them!
|
|
# ? Aug 31, 2018 18:52 |
|
DONT THREAD ON ME posted:yeah i believe that unless you're wrapping some framework class you should generally limit yourself to 1 level of inheritance. Good man. I guess I am a outlier in my programming tranining for sure. I started with C, my first project was board bring-up for a TI processor running on Kernel 2.6.32-17 I was taught by a awesome EE who has been programming mostly in ASM/C/C++ for 30 years and taught me to be incredibly pragmatic. He instilled on me: 1) Be pragmatic. If your code is clever, it's probably not a good thing. 2) It's all just memory. 3) Stick to conventions. 4) All programming languages are tools. Some better than others. (When discussing mainstream languages, poo poo like Brainfuck not-withstanding) He's still a good friend to this day.
|
# ? Aug 31, 2018 18:54 |
|
VikingofRock posted:Also now that I've thought a little more on Go's shallow-copy-on-assignment, I'm a little perturbed by it. It seems to me like that breaks encapsulation a bit too much. For example, if I'm using a Point3D type, I shouldn't worry if internally the x, y, and z coordinates are stored as three separate member floats or as a single vector of three floats. But with shallow copy semantics, all of the sudden those are very different semantically if I pass a Point3D to a function and then mutate one of the coordinates. It is very easy in all languages like this to accidentally have a reference to a shared object when you thought you had a copy. C#, python, java, go. My coworkers got bit by it in python just yesterday
|
# ? Aug 31, 2018 18:59 |
|
DONT THREAD ON ME posted:go was my first introduction to pointers and it's a confusing language to learn them in. this is why you should stick with C for a while, it’ll beat into you exactly what’s happening under the hood because you have to think about both the language model and the machine model to make it work also, and I know this sounds like my gimmick, but I unironically suggest doing a Luigi30 and writing a little OS in 68000 assembly using whatever that cool simulator environment was that she used it’ll teach you an enormous amount about computer architecture, almost as much as taking a class of that title will (having done the emulator 101 thing covers the rest), and it’ll also give you a good idea of what it’s like to do development in a very cleanly designed architecture compared to all the hacked together crap we have to deal with today
|
# ? Aug 31, 2018 19:10 |
|
eschaton posted:this is why you should stick with C for a while, it’ll beat into you exactly what’s happening under the hood because you have to think about both the language model and the machine model to make it work c is v good to learn pointers in, but it's for sure not what is happening under the hood at least for modern processors: C Is Not a Low-level Language
|
# ? Aug 31, 2018 19:13 |
|
eschaton posted:this is why you should stick with C for a while, it’ll beat into you exactly what’s happening under the hood because you have to think about both the language model and the machine model to make it work yeah i'm absolutely going to do an OS, I just want to take a little break from assembly after the emulator. so I think i'm gonna do a C++ roguelike and then the OS.
|
# ? Aug 31, 2018 19:29 |
|
VikingofRock posted:Jesus, it's their first week of C++! Don't show them boost, you'll scare them! boost is where the c++11 traits came from, lol. in fact a lot of stuff in boost just ends up in the stdlib. pretty sure where the filesystem parts of stdlib came from in c++17. *checks google* quote:The Filesystem library, ISO/IEC TS 18822:2015, provides facilities for performing operations on file systems and their components, such as paths, regular files, and directories. yep
|
# ? Aug 31, 2018 19:30 |
|
VikingofRock posted:Jesus, it's their first week of C++! Don't show them boost, you'll scare them! honestly i'm weirdly prepared for C++. On the one hand, my C and understanding of the low level machine has a long, long way to go. On the other hand, I've spent the last two years wading through Cats/scalaz/Rust so insane metaprogramming, smart pointers, move semantics, etc, are not very scary for me. DONT THREAD ON ME fucked around with this message at 19:35 on Aug 31, 2018 |
# ? Aug 31, 2018 19:33 |
|
DONT THREAD ON ME posted:honestly i'm weirdly prepared for C++. On the one hand, my C and understanding of the low level machine has a long, long way to go. On the other hand, I've spent the last two years wading through Cats/ScalaZ/Rust so insane metaprogramming, smart pointers, move semantics, etc, are not very scary for me. may the lord bless and protect you
|
# ? Aug 31, 2018 19:36 |
|
namaste
|
# ? Aug 31, 2018 19:37 |
|
DONT THREAD ON ME posted:yeah, it's a very different approach. my main worry is ambiguity, it seems like you could easily have two different types that each have a "foo" method with the same input/return types but wildly different semantics. it's like duck typing. as opposed to nominative typing which relies on you naming your types so you avoid the above problem
|
# ? Aug 31, 2018 20:37 |
|
Bloody posted:what the gently caress (re: why the hell i'm writing a webassembly -> verilog compiler, from a few pages back) mainly i just want to be able to write my high-level DSP cores in rust. i don't want to actually write a rust / llvm compiler backend tho, i find llvm IR kinda exhausting, so i figure i'll just work with webassembly instead, which rust can target. it's a reasonably lightweight IR format. more broadly, i think most languages are going to end up with webassembly backends in the near future. all the JVM languages, haskell, and typescript have wasm targets in progress right now, and i figure other people are gonna follow suit, to try to get a slice of that sweet sweet frontend pie. so, i support a bunch of languages pretty easily. and maybe, in the future, once there's an FPGA on every cpu die, Joe Doesn't Understand Hardware can write his code in TypeScript or whatever, and use my tool to accelerate parts of it on the FPGA. or, y'know, not. but it's a fun side project.
|
# ? Sep 1, 2018 10:43 |
|
DONT THREAD ON ME posted:yeah, it's a very different approach. my main worry is ambiguity, it seems like you could easily have two different types that each have a "foo" method with the same input/return types but wildly different semantics. it's like duck typing. Yup, that can definitely happen and it hurts to debug. OTOH the "ducktyping" nature of templates also means that different types from libraries that have never heard of each other can both be passed to a template as long as their "foo" method does conceptually the same thing In the end I firmly prefer the fact that I don't need to have things derive from Callable and can instead just provide them with operator(). ----edit---- Also a free advice: Use Catch for testing Xarn fucked around with this message at 13:43 on Sep 1, 2018 |
# ? Sep 1, 2018 13:23 |
|
CRIP EATIN BREAD posted:boost is where the c++11 traits came from, lol. when c++11 finally came out we ended up just renaming a bunch of boost types to their std equivalents. in particular shared_ptr/unique_ptr and the thread/lock types i like boost asio a fair bit and hope something like that gets into stdlib soon
|
# ? Sep 1, 2018 16:25 |
|
DONT THREAD ON ME posted:honestly i'm weirdly prepared for C++. On the one hand, my C and understanding of the low level machine has a long, long way to go. On the other hand, I've spent the last two years wading through Cats/scalaz/Rust so insane metaprogramming, smart pointers, move semantics, etc, are not very scary for me. imo: - don't use exceptions - mark all destructors virtual - templates are effectively a preprocessor stage - use smart pointers everywhere (e.g. unique_ptr for members rather than raw pointers) - don't bother with c++ streams just use the c printf stuff, unless theres something better in the last 5 years idk
|
# ? Sep 1, 2018 16:34 |
|
how should I do exception handling? I'm most comfortable with Either's and saw someone recommend using them but no idea if that's a good idea or not. I'd rather learn to do what actual real programmers programming C++ do which I'm guessing is exceptions.
|
# ? Sep 1, 2018 17:17 |
|
all of the C++ code i've looked at so far would be bad code in other languages.
|
# ? Sep 1, 2018 17:35 |
|
DONT THREAD ON ME posted:all of the C++ code i've looked at so far would be bad code in other languages. don't worry, it's bad code in c++ too
|
# ? Sep 1, 2018 17:41 |
|
c++ is tmtowtdi in a static language, lol
|
# ? Sep 1, 2018 17:45 |
|
DONT THREAD ON ME posted:all of the C++ code i've looked at so far would be bad code in other languages. same, but Java
|
# ? Sep 1, 2018 18:15 |
|
i need to learn a little c++ soon, even though i mostly use unity. so much game dev material has examples in c++ so it’s not really avoidable. the last few pages are extremely relatable.
|
# ? Sep 1, 2018 18:18 |
|
animist posted:(re: why the hell i'm writing a webassembly -> verilog compiler, from a few pages back) post the github
|
# ? Sep 1, 2018 19:16 |
|
akadajet posted:same, but Javascript
|
# ? Sep 1, 2018 19:20 |
|
DONT THREAD ON ME posted:all of the C++ code i've looked at so far would be bad code in other languages. congrats, you've mastered c++
|
# ? Sep 1, 2018 20:49 |
|
god i really can't imagine actually voluntarily choosing to use c++ in 2018 when literally any other workable option is available
|
# ? Sep 1, 2018 21:08 |
|
Progressive JPEG posted:imo: What the gently caress is this horse poo poo?
|
# ? Sep 1, 2018 21:20 |
|
Bloody posted:post the github https://gitlab.com/kazimuth/brine pay no attention to all those PDFs stored in git-lfs that I definitely didn't rip from sci-hub
|
# ? Sep 1, 2018 21:53 |
|
cjs: parsing dates in Go This might be the stupidest thing I've ever seen in a "standard library" outside of like brainfuck or LOLCODE. https://pauladamsmith.com/blog/2011/05/go_time.html quote:Go takes an interesting approach to parsing strings to time objects, and formatting time objects as strings. Instead of using codes like most languages to represent component parts of a date/time string representation—like %Y for a 4-digit year like “2011” or %b for an abbreviated month name like “Feb”—Go uses a mnemonic device: there is a standard time, which is: The comments on snack overflow pretty much sum it up (https://stackoverflow.com/a/25845327/221648) quote:Layout numbers? What? Why? Argh! – Darth Egregious Aug 5 '15 at 15:59 quote:@Fuser97381 I share your agony... – RickyA Aug 5 '15 at 16:18 quote:What were they thinking ! ? or smoking ? – Jishnu Prathap Mar 1 '17 at 5:02 quote:These "layout numbers" are one of the most stupid ideas I've ever seen in my life as a developer. Christ, who ever came up with this idea needs to slap and kick himself in his nuts. – Yehonatan May 16 '17 at 6:40
|
# ? Sep 2, 2018 00:26 |
|
my coworker: the rules don't make much sense but as soon as you learn them all go is really easy
|
# ? Sep 2, 2018 01:13 |
|
gonadic io posted:the rules don't make much sense but as soon as you learn them all programming is really easy
|
# ? Sep 2, 2018 02:02 |
|
Progressive JPEG posted:imo: lol how are you so wrong on every one of these points
|
# ? Sep 2, 2018 02:15 |
|
I agree on point one, C++ exceptions are atrociously bad
|
# ? Sep 2, 2018 02:21 |
|
|
# ? Mar 28, 2024 18:45 |
|
Progressive JPEG posted:- don't bother with c++ streams just use the c printf stuff, unless theres something better in the last 5 years idk https://github.com/gabime/spdlog
|
# ? Sep 2, 2018 02:27 |