|
this is probably old news, but i like being able to say "i told you so" because i think omitting braces from one-line if statements is bad and wrong and sinfulcode:
|
# ? Mar 14, 2014 12:13 |
|
|
# ? Jun 6, 2024 19:32 |
|
hackbunny posted:C++ is almost a perfect superset of C, except for non-overlapping keyword sets, some C99 features and a handful of pitfalls, small and big. some of the weirdest ABI issues in C++ (like the format of pointers to member functions) stem almost entirely from the unwritten rule that all C++ code must be able to compile to a C "assembly" form. there is no "magic" to C++ and that's why sometimes I joke that if it can be done in C++ then it's "real code" (meaning it runs on the classical Von Neumann architecture) what c isn't tied to von neumann architecture i mean it compiles on harvard architecture microprocessors u can totes compile C for the jvm, just store everything on a stack. the jvm is a stack machine for its bytecode but that doesn't mean it can't work with register based architectures there's a lot of magic in C++ i mean the rules for how syntax desugars is incomprehensible to normal humans + templates. also vtables will trip everyone up before they realize that yes, C++ style objects have a cost C has less magic but vast chunks of it are left unspecified
|
# ? Mar 14, 2014 12:26 |
|
hackbunny posted:JVM (by design not a Von Neumann architecture) hello i am babby please explain what does it mean for jvm to be not von neumann arch
|
# ? Mar 14, 2014 13:04 |
|
Shinku ABOOKEN posted:hello i am babby please explain what does it mean for jvm to be not von neumann arch von neumann architectures use the same storage for instructions and data harvard architectures use different storage for instructions and data most modern systems use a modified harvard architecture, where instructions and data are both backed by the same storage, but they're cached separately
|
# ? Mar 14, 2014 13:15 |
|
Shinku ABOOKEN posted:hello i am babby please explain what does it mean for jvm to be not von neumann arch von neumann is shared data/code memory basically harvard is separate data and code memory JVM is a von neumann stack machine some microcontrollers have a harvard architecture where u have separate code/data memory of course modern cpu's blur the distinction and caches can be split (icache v dcache) and there's segmentation/protection like no execute bits it's not really relevant to high level programming but if you're doing embedded/ low level stuff correctly placing data and code is v important
|
# ? Mar 14, 2014 13:18 |
|
if the jvm is von neumann and the cpu is harvard, does that mean the jvm ultimately translates its stuff from one style to the other, in order to communicate with the hardware?
|
# ? Mar 14, 2014 13:21 |
|
from what i recall the jvm spec doesn't address or expose code storage. bytecode would go in data ram, jitted methods in code ram. i don't think you can reasonably pin down the jvm as von neumann or harvard
|
# ? Mar 14, 2014 13:54 |
|
not being able to programmatically access the code is pretty clear harvard architecture though everything is very hybrid though (you can after all programmtically manipulate bytecode anyway, but need to use specific api entrypoints, i.e. classloaders, to do so) i don't think the distinction is terribly useful today
|
# ? Mar 14, 2014 14:30 |
|
Mr Dog posted:yeah just give me unsigned types in Java and all that remains is at best minor nuisances. http://javolution.org/target/site/apidocs/javolution/io/class-use/Struct.Member.html
|
# ? Mar 14, 2014 15:23 |
|
quote:class Struct.Signed16 it's nice that they still managed to sneak a splinter in the programmer's foot after taking the railroad spike out of his kneecap. demonstrates that they're thoughtful misanthropes
|
# ? Mar 14, 2014 15:27 |
|
FamDav posted:i would love a solid base layer common IDE component that handled code parsing, syntax highlighting, compiler/debugger integration, vcs, maybe some code sharing networking etc. and then on top of that spergs could build their intellij's, emacs, and vim. it would be cool because you could have your vim exactly as it in the terminal or your emacs or whatever but everybody is actually on the same platform. this exists, i discussed it earlier, it is called eclipse you can use the eclipse swt ui you can use vim you can use emacs in all cases you get the same compiler/debugger integration, code analysis, etc
|
# ? Mar 14, 2014 15:31 |
|
Malcolm XML posted:what ok ok my bad, I shouldn't have mixed practical considerations with theoretic concepts. I don't even know that much theory in the first place but be serious. C is built on some assumptions. there are a lot of architectures, from the obscure (Symbolics Lisp Machine) to the mainstream (.NET CLI) and anything inbetween (Cray-2, Itanium) that violate a number of assumptions (Lisp Machine's pointers are object-offset tuples; CLI has variable-sized pointers; Cray-2 requires explicit allocation and deallocation of stack frames; Itanium has double indirection for function pointers; etc.), and there has been a huge combined effort in the last decade to reverse-engineer an abstract C machine that resulted in some crazy poo poo, but... it has to feel like C. emscripten is a cool porting tool but I bet it wouldn't really feel like C. this won't feel like C either: Malcolm XML posted:u can totes compile C for the jvm, just store everything on a stack. the jvm is a stack machine for its bytecode but that doesn't mean it can't work with register based architectures haha oh wow, I suppose it's a step above that guy who made a "C-to-JVM compiler" by coupling a C compiler targetting MIPS with a MIPS simulator for JVM Malcolm XML posted:also vtables will trip everyone up before they realize that yes, C++ style objects have a cost unless you've done vtables in C before. in that case, C++ vtables make total sense and you'd feel hurt if they were implemented in any other way. same goes for multiple virtual inheritance: you can do it in C with a creative use of offsetof (basically: you write the this-adjusting thunks by hand. this deserves a post on its own some time), and I can guarantee the design of the same feature in C++ was influenced by some vocal UNIX beardo's artisanal bespoke C macro set I'll be the rear end in a top hat and suggest that you should go C -> ASM -> C -> C++ if you want to make sense of C++. and then start disassembling your C++ code (how else would you discover how ~horribly inefficient~ downcasting can be?) Malcolm XML posted:von neumann is shared data/code memory basically ok, my only direct experience with JVM is Tanenbaum's toy MIC architecture for a Computer Architecture course, but by the time I was taking the course I already had a few years of experience with x86 assembler, and I immediately noticed a thing about JVM: it has a segmented memory model. you have a constants segment, a stack segment, a code segment, etc. plus the segment is implicit in each instruction and unlike x86 there aren't segment overrides so you can't read-write data from the code segment or execute code from the constants segment. it's not a "you'll get a fault/stale data"-cannot, it's the "there is no instruction for it"-cannot. JVM memory isn't really "addressable" in the way C assumes and I can't call it a Von Neumann architecture in good conscience the fact that it's a stack vs register architecture is completely irrelevant and I don't know why you bring it up there are far more bizarre architectures in that respect (see: Itanium) that still are 99.999% Von Neumann
|
# ? Mar 14, 2014 15:41 |
|
Cybernetic Vermin posted:not being able to programmatically access the code is pretty clear harvard architecture though i don't think the distinction was ever useful
|
# ? Mar 14, 2014 16:41 |
|
the distinction is useful for creating acm award lectures to propagandize functional programming which will be quoted without understanding into eternity
|
# ? Mar 14, 2014 16:48 |
|
Another problem with C/C++ on safe/garbage collected runtimes is pointers and casting -- C is perfectly happy to let you make arbitrary pointers (including internal), peek at raw bytes, and reinterpret one type as another, which is awkward on the JVM. Emscripten/asm.js emulates this by passing around a giant Uint8Array and using it to store concrete representations, but it's awkward. C++/CLI has includes syntax for new pointer types that interact properly with the garbage collector. Kevin Mitnick P.E. posted:i don't think the distinction was ever useful You can also do stupid poo poo like hard-realtime DSPs with no caches, guaranteed execution times, and good performance by throwing multiple data buses on it. Scaevolus fucked around with this message at 17:38 on Mar 14, 2014 |
# ? Mar 14, 2014 17:34 |
|
hackbunny posted:be serious. C is built on some assumptions. there are a lot of architectures, from the obscure (Symbolics Lisp Machine) to the mainstream (.NET CLI) and anything inbetween (Cray-2, Itanium) that violate a number of assumptions (Lisp Machine's pointers are object-offset tuples; CLI has variable-sized pointers; Cray-2 requires explicit allocation and deallocation of stack frames; Itanium has double indirection for function pointers; etc.), and there has been a huge combined effort in the last decade to reverse-engineer an abstract C machine that resulted in some crazy poo poo, but... it has to feel like C. emscripten is a cool porting tool but I bet it wouldn't really feel like C. this won't feel like C either: i don't understand what you're trying to say here. the C standard does in fact describe an abstract machine. the job of the compiler is to translate source code into executable code for the target architecture that exhibits the semantics required by the standard. how that translation occurs is of course deliberately unspecified and it can be as simple or complex as is required. we're used to thinking of C as "close to the metal" but that's a historical conceit and not a requirement. things like llvm and emscripten demonstrate that this is true, not to mention the existence of a C compiler for just about any real-world architecture you could name. i don't have any idea what you mean when you say "feels like C." C is a relatively small language and you may be conflating it with some specific implantation, or personal assumptions that aren't actually present in standard C. going back to your original point, there is no rule that C++ be compilable to any form of C and i would be shocked to find out that any modern compiler works that way. in fact the two languages diverged sometime prior to the first C standard and while the superficial similarities are many, the basic differences are both numerous and subtle, and it is neither helpful nor correct to conceive of either C being a subset of C++, or of C++ being a superset of C.
|
# ? Mar 14, 2014 17:44 |
|
but i can include both stdio and iostream in one file and cout and printf at the same time therefore c++ is a superset of c gg also such a program will compile with both gcc and g++
|
# ? Mar 14, 2014 17:52 |
|
Bloody posted:but i can include both stdio and iostream in one file and cout and printf at the same time therefore c++ is a superset of c gg c/c++
|
# ? Mar 14, 2014 17:57 |
|
Janitor Prime posted:c/c++
|
# ? Mar 14, 2014 17:58 |
|
hackbunny posted:I like it. I picked it up fast and things like interleaving parameters with segments of a method name look weird at first but you get used to it quickly. the guys previously assigned to my project were just big crybabies complaining about made up non-issues and I can do more work than the two of them combined yeah my complaints about core framework are fairly small. the holes in functionality are just bizarre to me (because apple has obviously had to solve these problems so why not package it up?) but they're plugged easily enough. the language itself is pretty cool and i have to give it to apple, arc makes it feel like i'm working in a managed language. i have to be a little more careful about ownership but that's easily done. incidentally i got my start in the industry in smalltalk so the "weird" message syntax that everyone cites is a return to roots for me uikit is a huge pain though. it's amazing how often you have to write all the code from scratch to implement a "standard" idiom in ios. it's not a framework; it's a bundle of use cases that apple has happened to find useful. Dr Monkeysee fucked around with this message at 18:00 on Mar 14, 2014 |
# ? Mar 14, 2014 17:58 |
|
HORATIO HORNBLOWER posted:i don't understand what you're trying to say here. the C standard does in fact describe an abstract machine. the job of the compiler is to translate source code into executable code for the target architecture that exhibits the semantics required by the standard. how that translation occurs is of course deliberately unspecified and it can be as simple or complex as is required. we're used to thinking of C as "close to the metal" but that's a historical conceit and not a requirement so this is simultaneously true and misleading, as "unspecified behavior" in c better loving mean exactly what it means in ye olde 80s c compiler it is not nearly as difficult as it gets made out to be to just provide the flat memory space and the standard type representations, but the abstract idea of c from the specification is not really sufficient for anything real i don't think it is that bad a thing that this is the situation though, i think the authors of the c specification imagined a future where minicomputers would continue to diverge, but as it happens flat memory spaces and standardized number representations made a lot of the specification unnecessarily abstract (in that the abstractions have long since given way to a standard set of assumptions)
|
# ? Mar 14, 2014 18:00 |
|
Cybernetic Vermin posted:so this is simultaneously true and misleading, as "unspecified behavior" in c better loving mean exactly what it means in ye olde 80s c compiler except it doesn't
|
# ? Mar 14, 2014 18:03 |
|
hackbunny posted:unless you've done vtables in C before. in that case, C++ vtables make total sense and you'd feel hurt if they were implemented in any other way. same goes for multiple virtual inheritance: you can do it in C with a creative use of offsetof (basically: you write the this-adjusting thunks by hand. this deserves a post on its own some time), and I can guarantee the design of the same feature in C++ was influenced by some vocal UNIX beardo's artisanal bespoke C macro set the beardo in question is Stroustrop. the artisanal bespoke C macro set is CFront. you just described where c++ came from
|
# ? Mar 14, 2014 18:05 |
|
while cfront did emit C, it wasn't actually a set of macros or a translator in its guts
|
# ? Mar 14, 2014 18:25 |
|
Otto Skorzeny posted:while cfront did emit C, it wasn't actually a set of macros or a translator in its guts no, it's not a set of macros. yes, it is a pretty "dumb" translator. http://www.softwarepreservation.org/projects/c_plus_plus/cfront/release_e/src/cfront.pdf it's hideous but readable. like if someone tried to bodge together a C++ to C translator in perl, then ported it to 1980s C++ the worst/scariest part: wikipedia says it wasn't finally abandoned until 1993, because they couldn't get exception-handling to work properly. I know that things went even further than that, because HP continued to use/sell CFront well into the 1990s
|
# ? Mar 14, 2014 18:32 |
|
HORATIO HORNBLOWER posted:i don't have any idea what you mean when you say "feels like C." imagine running C code on an architecture where you can't address memory but on the other hand you have several features that would usually sit several layers on top of C. imagine in other words to run C on top of abstractions instead of primitives (don't get rule-lawyery on me): Scaevolus posted:Emscripten/asm.js emulates this by passing around a giant Uint8Array and using it to store concrete representations, but it's awkward. tell me with a straight face that running C code on that platform (because by hook or crook you will get it to compile) is a good idea or useful HORATIO HORNBLOWER posted:going back to your original point, there is no rule that C++ be compilable to any form of C and i would be shocked to find out that any modern compiler works that way I never thought "you can write C in C++" was even remotely controversial because of course you can, it was a design goal for the language and platform API writers have been doing it for decades. they even relented and made "#include <standard C header.h>" 100% legal again because it was colossally stupid to conditionally #include <cstdio> vs #include <stdio.h> in, say, a common header file let's say that C and C++ share a common subset, ok? nevermind that the "subset" is like 99% of C
|
# ? Mar 14, 2014 18:34 |
|
objective c, however, is a strict superset of c
|
# ? Mar 14, 2014 18:55 |
|
"i saw you committing c code. objective c only please" - my boss
|
# ? Mar 14, 2014 19:20 |
|
also: id converting silently to BOOL
|
# ? Mar 14, 2014 19:22 |
|
pseudorandom name posted:except it doesn't we might as well argue theology at that point though for all the practical relevance this has
|
# ? Mar 14, 2014 19:31 |
|
integer overflow and type based alias analysis both have undefined behavior which does not behave like the compilers of yore
|
# ? Mar 14, 2014 19:33 |
|
hackbunny posted:"i saw you committing c code. objective c only please" that sounds like a good dadjoke
|
# ? Mar 14, 2014 19:38 |
|
pseudorandom name posted:integer overflow and type based alias analysis both have undefined behavior which does not behave like the compilers of yore signed integer overflow does
|
# ? Mar 14, 2014 19:42 |
|
hackbunny posted:also: id converting silently to BOOL c's legacy is all types silently converting to other types, forever
|
# ? Mar 14, 2014 20:08 |
|
*silently converts ur resume to teh goatman*
|
# ? Mar 14, 2014 20:10 |
|
Otto Skorzeny posted:*silently converts ur resume to teh goatman* should've avoided undefined behavior in ur resume writing program
|
# ? Mar 14, 2014 20:13 |
|
message based oop is the best oop tbh also multimethods are cool but tying data to behaviour is not all its cracked up 2 b
|
# ? Mar 14, 2014 20:17 |
|
Kevin Mitnick P.E. posted:should've avoided undefined behavior in ur resume writing program heh
|
# ? Mar 14, 2014 20:17 |
|
the problem would ahve been clearer if they showed what it actually looked like. and why 1 liners without brace is retarded.code:
|
# ? Mar 14, 2014 20:35 |
|
|
# ? Jun 6, 2024 19:32 |
|
the bug wouldn't have been possible if SSLHashSHA1.update threw an exception instead of returning an error code
|
# ? Mar 14, 2014 21:05 |