If you want to write fast code, you want to know about vector instructions, and that's been true since they were introduced in the x86 line with MMX back in the 90s. You don't have to leave C/C++ to use them, since any language claiming to be a systems language will expose vector instructions through a library (compiler intrinsics).While I see nothing wrong with learning x86 assembly, I think it would be more worthwhile to learn about vectorization and AVX instructions.
Then you're a little off base. Compilers do not (generally, you pedants) generate assembly code. They generate machine code, which is a sequence of de-symbolized direct CPU instructions. While assembly is "closer" to direct CPU instructions than languages like C (which was in its day considered a high-level language), it's still something where you're writing code files with a text editor which must themselves be compiled before execution, and you still have things like macros (functions, kind of) and labels for memory locations (variables, kind of), human-friendly abstractions that are done away with by the compiler when generating machine code.My main goal with picking up assembler is debugging, as strange as that might sound. I’ve been running into strange behaviors using googletest that I can’t replicate in production. Googletest’s documentation hasn’t been helpful and neither has GDB. The hope is that I can get a better picture of what’s happening by looking at the generated assembly code.
The three-year-old textbook for one of my college courses last semester said most compilers generate assembly and then use an assembler. Even if they don't, it really doesn't matter because you can easily use a disassembler to regenerate assembly from machine code.Then you're a little off base. Compilers do not (generally, you pedants) generate assembly code. They generate machine code, which is a sequence of de-symbolized direct CPU instructions. While assembly is "closer" to direct CPU instructions than languages like C (which was in its day considered a high-level language), it's still something where you're writing code files with a text editor which must themselves be compiled before execution, and you still have things like macros (functions, kind of) and labels for memory locations (variables, kind of), human-friendly abstractions that are done away with by the compiler when generating machine code.
That being said, assembly is so low-level that it may be of use to you for this goal anyway.
Yeah, with GCC you can just add "-S" to generate assembly code only.The three-year-old textbook for one of my college courses last semester said most compilers generate assembly and then use an assembler. Even if they don't, it really doesn't matter because you can easily use a disassembler to regenerate assembly from machine code.
There's a third option that can't be ignored. Pass a crafted object and pop a reverse shell. Something being passed in often represents a trust boundary and, one way or another, it needs to be explicitly sanitized. A lot of correctness ensuring stuff is no good here. They rely on ensuring correctness through and through and the whole point here is you can't be sure of anything beyond that boundary. Some operating systems do ensure correctness everywhere in one way or another, which has its ups and downs. This is basically how powershell works, though note that's not actually IPC and it doesn't integrate with other software. Windows is still fundamentally pipe based for actual IPC.With an object, the only option almost all of the time is you pass a valid object or you crash. No interpretation needed.
You should be able to compile with debug symbols turned on (-g for g++) and have gdb show you the C++ code even for calls to the STL. Then you can use stepi and disassemble when it gets to something you aren't sure about. I'd just refer to the manuals or look stuff up with google for the assembly as you're going if it's just one piece of debugging you care about. Make sure you try a debugging allocator like dmalloc first. Heap corruption can cause weird inconsistent behaviors.My main goal with picking up assembler is debugging
Yeah, even compilers that don't bother to convert it into a text based representation and then call a separate assembler will still have a pass that goes from a sensible representation of each instruction down to the ridiculous hodge podge of something like x86.most compilers generate assembly and then use an assembler
This is a common misconception. It's true enough for most purposes but the mapping isn't one-to-one for x86. For instance any register to register instruction that uses modrm addressing has two possible encodings, one where you say from register to [memory or register] and the other from [memory or register] to register. On the other side of the mapping, you have things like nop and xchg ax, ax which both assemble to 0x90.Most assembly instructions correspond one-to-one with machine instructions
CL-USER> (map 'vector #'print-post-listing collected-posts) https://kiwifarms.net/threads/programming-thread.41367/post-3231826 #01 (#3231826): Splendid Posted: Apr 9, 2018 at 9:24 PM Edited: NIL Ratings: (Like 8 Informative 6 Winner 3 Agree 3 Semper Fidelis 3 Disagree 1 Thunk-Provoking 1 DRINK! 1) https://kiwifarms.net/threads/programming-thread.41367/post-3231985 #02 (#3231985): _01 Posted: Apr 9, 2018 at 10:05 PM Edited: NIL Ratings: (Disagree 6 Agree 2 Islamic Content 1 Like 1 Feels 1 Thunk-Provoking 1) https://kiwifarms.net/threads/programming-thread.41367/post-3231993 #03 (#3231993): Splendid Posted: Apr 9, 2018 at 10:08 PM Edited: NIL Ratings: (Agree 7 Like 5 Disagree 3 Optimistic 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232008 #04 (#3232008): Marvin Posted: Apr 9, 2018 at 10:13 PM Edited: NIL Ratings: (Informative 5 Like 2 Agree 1 Disagree 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232051 #05 (#3232051): Splendid Posted: Apr 9, 2018 at 10:27 PM Edited: NIL Ratings: (Feels 13) https://kiwifarms.net/threads/programming-thread.41367/post-3232138 #06 (#3232138): Marvin Posted: Apr 9, 2018 at 10:57 PM Edited: NIL Ratings: (Disagree 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232161 #07 (#3232161): Splendid Posted: Apr 9, 2018 at 11:06 PM Edited: Apr 10, 2018 at 12:12 AM Ratings: (DRINK! 2 Agree 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232173 #08 (#3232173): AF 802 Posted: Apr 9, 2018 at 11:12 PM Edited: NIL Ratings: (Feels 2) https://kiwifarms.net/threads/programming-thread.41367/post-3232188 #09 (#3232188): Splendid Posted: Apr 9, 2018 at 11:16 PM Edited: NIL Ratings: (Agree 1 Like 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232234 #10 (#3232234): Marvin Posted: Apr 9, 2018 at 11:30 PM Edited: NIL Ratings: (Informative 3 Winner 2) https://kiwifarms.net/threads/programming-thread.41367/post-3232246 #11 (#3232246): Splendid Posted: Apr 9, 2018 at 11:34 PM Edited: NIL Ratings: (Feels 3) https://kiwifarms.net/threads/programming-thread.41367/post-3232249 #12 (#3232249): CrunkLord420 Posted: Apr 9, 2018 at 11:34 PM Edited: NIL Ratings: (Informative 6 Like 2) https://kiwifarms.net/threads/programming-thread.41367/post-3232261 #13 (#3232261): Splendid Posted: Apr 9, 2018 at 11:39 PM Edited: NIL Ratings: (Thunk-Provoking 3 Islamic Content 1 Like 1 Agree 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232267 #14 (#3232267): AF 802 Posted: Apr 9, 2018 at 11:40 PM Edited: NIL Ratings: (Agree 2 Like 1 Winner 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232275 #15 (#3232275): Marvin Posted: Apr 9, 2018 at 11:42 PM Edited: NIL Ratings: (Like 1 Disagree 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232314 #16 (#3232314): CrunkLord420 Posted: Apr 9, 2018 at 11:52 PM Edited: NIL Ratings: (Informative 3) https://kiwifarms.net/threads/programming-thread.41367/post-3232332 #17 (#3232332): Marvin Posted: Apr 9, 2018 at 11:56 PM Edited: NIL Ratings: NIL https://kiwifarms.net/threads/programming-thread.41367/post-3232374 #18 (#3232374): CrunkLord420 Posted: Apr 10, 2018 at 12:04 AM Edited: NIL Ratings: (Informative 5 Like 3) https://kiwifarms.net/threads/programming-thread.41367/post-3232387 #19 (#3232387): Tookie Posted: Apr 10, 2018 at 12:07 AM Edited: NIL Ratings: (Informative 1 Horrifying 1) https://kiwifarms.net/threads/programming-thread.41367/post-3232406 #20 (#3232406): WW 635 Posted: Apr 10, 2018 at 12:11 AM Edited: NIL Ratings: (Agree 12 Deviant 2 Disagree 1) CL-USER>
CL-USER> (sort-posts-by-most "Informative") (#<POST #768: Where Do You Find Them?, Dec 26, 2019 at 10:19 PM> #<POST #763: omnihitler, Dec 26, 2019 at 5:26 PM> #<POST #766: FuckedUp, Dec 26, 2019 at 6:40 PM> #<POST #767: garakfan69, Dec 26, 2019 at 6:50 PM> #<POST #761: Gorilla Tessellator, Dec 25, 2019 at 9:39 AM> #<POST #762: cecograph, Dec 26, 2019 at 9:13 AM> #<POST #764: ditto, Dec 26, 2019 at 5:43 PM> #<POST #765: Least Concern, Dec 26, 2019 at 6:16 PM> #<POST #769: Yotsubaaa, Jan 1, 2020 at 4:45 AM>) CL-USER>
CL-USER> (filter-posts-between "Dec 26, 2019 at 5:00 PM" "Dec 26, 2019 at 7:00 PM") (#<POST #763: omnihitler, Dec 26, 2019 at 5:26 PM> #<POST #766: FuckedUp, Dec 26, 2019 at 6:40 PM> #<POST #767: garakfan69, Dec 26, 2019 at 6:50 PM> #<POST #764: ditto, Dec 26, 2019 at 5:43 PM> #<POST #765: Least Concern, Dec 26, 2019 at 6:16 PM>) CL-USER>
(let ((rating "Informative")) (mapcar (lambda (post) (format t "[URL=~a]Post ~4,'0d[/URL], [COLOR=rgb(84, 172, 210)]~a: ~a=~d[/COLOR]~%" (get-post-url post) (get-post-number post) (get-post-author post) rating (getf (get-post-ratings post) (intern (string rating) :keyword)))) (subseq (sort-posts-by-most rating) 0 10)))
Organisations working in disparate domains are independently discovering patterns for building software that look the same. These systems are more robust, more resilient, more flexible and better positioned to meet modern demands.
These changes are happening because application requirements have changed dramatically in recent years. Only a few years ago a large application had tens of servers, seconds of response time, hours of offline maintenance and gigabytes of data. Today applications are deployed on everything from mobile devices to cloud-based clusters running thousands of multi-core processors. Users expect millisecond response times and 100% uptime. Data is measured in Petabytes. Today's demands are simply not met by yesterday’s software architectures.
We believe that a coherent approach to systems architecture is needed, and we believe that all necessary aspects are already recognised individually: we want systems that are Responsive, Resilient, Elastic and Message Driven. We call these Reactive Systems.
Systems built as Reactive Systems are more flexible, loosely-coupled and scalable. This makes them easier to develop and amenable to change. They are significantly more tolerant of failure and when failure does occur they meet it with elegance rather than disaster. Reactive Systems are highly responsive, giving users effective interactive feedback.
Reactive Systems are:
Responsive: The system responds in a timely manner if at all possible. Responsiveness is the cornerstone of usability and utility, but more than that, responsiveness means that problems may be detected quickly and dealt with effectively. Responsive systems focus on providing rapid and consistent response times, establishing reliable upper bounds so they deliver a consistent quality of service. This consistent behaviour in turn simplifies error handling, builds end user confidence, and encourages further interaction.
Resilient: The system stays responsive in the face of failure. This applies not only to highly-available, mission-critical systems — any system that is not resilient will be unresponsive after a failure. Resilience is achieved by replication, containment, isolation and delegation. Failures are contained within each component, isolating components from each other and thereby ensuring that parts of the system can fail and recover without compromising the system as a whole. Recovery of each component is delegated to another (external) component and high-availability is ensured by replication where necessary. The client of a component is not burdened with handling its failures.
Elastic: The system stays responsive under varying workload. Reactive Systems can react to changes in the input rate by increasing or decreasing the resources allocated to service these inputs. This implies designs that have no contention points or central bottlenecks, resulting in the ability to shard or replicate components and distribute inputs among them. Reactive Systems support predictive, as well as Reactive, scaling algorithms by providing relevant live performance measures. They achieve elasticity in a cost-effective way on commodity hardware and software platforms.
Message Driven: Reactive Systems rely on asynchronous message-passing to establish a boundary between components that ensures loose coupling, isolation and location transparency. This boundary also provides the means to delegate failures as messages. Employing explicit message-passing enables load management, elasticity, and flow control by shaping and monitoring the message queues in the system and applying back-pressure when necessary. Location transparent messaging as a means of communication makes it possible for the management of failure to work with the same constructs and semantics across a cluster or within a single host. Non-blocking communication allows recipients to only consume resources while active, leading to less system overhead.
Large systems are composed of smaller ones and therefore depend on the Reactive properties of their constituents. This means that Reactive Systems apply design principles so these properties apply at all levels of scale, making them composable. The largest systems in the world rely upon architectures based on these properties and serve the needs of billions of people daily. It is time to apply these design principles consciously from the start instead of rediscovering them each time.
Yeah, functional programming is great! (I mean, it's not the panacea that some of the FP evangelists like to claim it is, but it definitely gets you thinking about your code in a useful way!)I've been learning Haskell the past week or so and having learned C++ first, I originally thought it made more sense because of the static typing, but the functional nature of Haskell makes thinking about program data flow so much more... perfect? I don't understand why people jump to Python or even Java. I've had to explain to multiple people why they're actually getting that error when they followed everything, or why something is bad organization.
reduce, I can write concise code that eloquently conveys that idea!
(defun mean (&rest values) "Return the MEAN (average) of the given VALUES." ;; In n-dimensions we just do it component-wise, so have a helper function: (flet ((1d-mean (&rest 1d-values) (/ (reduce #'+ 1d-values) (length 1d-values)))) (if (realp (first values)) (apply #'1d-mean values) (apply #'map (type-of (first values)) #'1d-mean values)))))
CL-USER> (mean 1 2 3 4) ; real numbers 5/2 CL-USER> (mean '(-1.0 2.0) '(-3.2 -4.5) '(3.1 2.1) '(1.2 -0.9)) ; 2D lists (0.025000036 -0.32500002) CL-USER> (mean #(1 1 1) #(2 0 3)) ; 3D vectors #(3/2 1/2 2)
Yes it is, and don't let anyone tell you otherwiseYeah, functional programming is great! (I mean, it's not the panacea that some of the FP evangelists like to claim it is, but it definitely gets you thinking about your code in a useful way!)
This isn't a knock on you or CL, so please don't take it the wrong way, but after getting used to Clojure's syntax CL looks so... archaic?Common Lisp
Yes it is, and don't let anyone tell you otherwise
ForumPostFactory.buildPost(ForumType.Xenforo2("Kiwi Farms"), PostWriterSingleton.getInstance().write("Nuh uh. :stuck_out_tongue_closed_eyes:"));
It's the square brackets, isn't it? They look so cool and stylish in Clojure and Racket! (But I like Common Lisp's parentheses everywhere...)This isn't a knock on you or CL, so please don't take it the wrong way, but after getting used to Clojure's syntax CL looks so... archaic?
That's the return type that I'm specifying. I figured it looked nicer that way, but I didn't have to do it. I could have just returned everything in a list no matter what, e.g.It's interesting that map allows you to specify the type you map over, in Clojure it's a lazy-seq by default, and if you want to eagerly map in a type preserving manner you usually just reduce into the `(empty coll)` as a baseline.
(defun mean (&rest vals) (apply #'map 'list (lambda (&rest vals) (/ (reduce #'+ vals) (length vals))) vals)) (mean #(1 2 3) #(4 5 6)) ;=> (5/2 7/2 9/2)
That's a good question! I admit that I haven't given it thought though (and in fact, arguably I shouldn't be using apply here at all really: mean should perhaps just take a list/vector of lists/vectors, instead of me getting fancy with arbitrarily-many parameters with theFinally, I wonder what the performance implications of apply are in CL and if they're similar to Clojure, I found it's usually a bit taxing where performance counts (still ~1e-7s, and yet)
FP isn't hard. I think most problems people have with FP is that they've learned procedural programming first and are too used to it.Functional is also too hard to introduce new programmers to.
The only Singleton with any right to exist is the Single MaltNuh uh.
Consider the following: it's a bad idea that CL overloads parens to mean both grouping and invocation. let-s , cond-s, etc, also have an excessive degree of nesting. Bindings should be a list of even number of elements, not a list of pairs, why do one extra step for the compiler?It's the square brackets, isn't it? They look so cool and stylish in Clojure and Racket! (But I like Common Lisp's parentheses everywhere...)
Yeah I should have been more accurate, it's the aggregated type. The type you're collecting into.That's the return type that I'm specifying. I figured it looked nicer that way, but I didn't have to do it. I could have just returned everything in a list no matter what, e.g.
Another good thing about Clojure: Interfaces
Care to elaborate?pretty glaring gaps that cannot really be resolved
In my experience, it's usually only programmers who are brain damaged by OOP who can't be saved. Everyone else takes to it naturally.Functional is also too hard to introduce new programmers to.
If you have the time and you're feeling intellectually curious, start with Scheme. She's old and academic but has a timeless quality and beauty. You can also familiarize yourself with all the programming paradigms using Scheme.As a newcomer, which languages should I learn first? I was thinking about learning C++, but it is a big language, and I don't know if I should start with something else before getting to learn C++.