|
Is there a name for this coding style?C# code:
|
# ? Oct 16, 2012 18:09 |
|
|
# ? May 29, 2024 21:17 |
Zhentar posted:Is there a name for this coding style? Pocket Notepad Breaking. (Lines broken as to fit it on a pocket-sized note pad. Just invented the name.)
|
|
# ? Oct 16, 2012 18:25 |
|
I've been given a C++ console application that receives data from an external source (across the internet) at random intervals and just writes it out to the console. I want to be able to capture the output and parse it on my own terms. I was planning on just capturing the cout with a .net program that wraps around it, but I was given this suggestion: "...use the console application to handle the C++ side of things and demarshal the message into text, then use a netcat service to re-broadcast to your API" Can someone parse this into english for me? How do I 'demarshal' console output? Or is this just code for what I was planning on doing anyway? What about the netcat part?
|
# ? Oct 16, 2012 20:01 |
|
Zhentar posted:Is there a name for this coding style? brain-damaged
|
# ? Oct 16, 2012 21:24 |
|
nielsm posted:Pocket Notepad Breaking. That would be more like code:
|
# ? Oct 16, 2012 23:39 |
|
shrughes posted:That would be more like I would think it's more like: foreach ( var v in someCollection)
|
# ? Oct 17, 2012 02:13 |
|
Here's a question because I don't know where to start: I want to make a device you can plug into a computer's USB or serial port. On the other end is a many-pin connector and any number of adapters to fit this connector. I want to be able to plug different connectors into the device (RJ-45, molex, DB-9 etc) and send a signal on one pin and have the computer display what pin it is. It seems just as do-able for the computer to send a signal through a pin and allow my meter or attached probe to pick it up. I was thinking of trying to throw something together purely hardware controlled but my knowledge of that ends past basic resistors. I could still make a standalone box to do this but I don't even know what kind of parts to cobble together. I saw the other thread with the Embedded Programming, and that looks like it could be a good starting point, but I'd want somebody with some knowledge to say that's the route to go before I buy a board. If you had to make something like this (it's for testing cable harnesses) how would you go about it? I know nothing on any platform so it's all an even playing field for me
|
# ? Oct 17, 2012 02:51 |
|
I've made an IR transceiver once, connected to the serial port. It was a very rough design, just a few resistors/transistors. Just make sure not to fry the port/other things, serial port has pretty high voltages compared to the normal TTL levels. Better/easier would be some USB on-chip controller, you can get those very cheap and they are easy to program (also good luck finding serial ports on most modern motherboards). My serial device needed a dedicated driver because what I interfaced with used pretty high frequency PCM modulation with low error tolerance, and standard Windows API wasn't good enough to provide necessary timings. TLDR: it's very doable, my advice would be to read up on USB protocol and concentrate on that route. omeg fucked around with this message at 10:16 on Oct 17, 2012 |
# ? Oct 17, 2012 10:14 |
|
Hello! Quick question about machine epsilon, in FORTRAN in particular. Basically I just don't get why, given the definition of machine epsilon, I'm finding a yet smaller number that satisfies the definition. There is either a) an error in this simple code that's escaping me or b) something about machine epsilon relative to FORTRAN I'm not getting. I'm using gfortran to compile and aquamacs to write if that's relevant. code:
Jenkl fucked around with this message at 20:28 on Oct 18, 2012 |
# ? Oct 17, 2012 19:13 |
|
It might help if the first condition checked if c was smaller than e, rather than comparing an undeclared variable to e.
|
# ? Oct 17, 2012 22:28 |
|
Zhentar posted:It might help if the first condition checked if c was smaller than e, rather than comparing an undeclared variable to e. Ah! Crap, sorry I actually had more stuff for myself before I stripped it down for Goon consumption, forgot to change that. I'll edit that now. It doesn't change the output or my question.
|
# ? Oct 18, 2012 20:28 |
|
I'm trying to get acclaimed with shared memory programming, so I wrote this very simple program. It doesn't work but I can't explain why.code:
pre:gcc -ggdb -L./ -Werror main.c -o p2 main.c: In function main: main.c:8: error: shmid_ds undeclared (first use in this function) main.c:8: error: (Each undeclared identifier is reported only once main.c:8: error: for each function it appears in.) main.c:8: error: expected ; before info make: *** [all] Error 1 Edit: I fixed this, I needed to put struct in front of shmid_ds. oRenj9 fucked around with this message at 21:14 on Oct 18, 2012 |
# ? Oct 18, 2012 21:07 |
|
I'm having a problem re-formatting some text with a VIM script. Here's a sample of the input text: code:
I'm searching by :%s/^[a-zA-Z], but that's going to end up replacing the first character of the name. The same thing for the [ /b ] at the end if I use :%s/[a-zA-Z]$/ I'm stumped at how to preserve that first and last character of the name. I'm probably not thinking of something stupid easy.
|
# ? Oct 18, 2012 23:11 |
|
Henrik Zetterberg posted:I'm having a problem re-formatting some text with a VIM script. Doesn't vim support capture groups? Like you could put parentheses (or escaped parentheses? Vim's regex stuff is weird) around the first part and then replace with \1 plus your markup. Edit: There is almost certainly a better way to do this, but this works: %s/\(^[A-Za-z]\)/\[b\]\1/g MacGowans Teeth fucked around with this message at 01:58 on Oct 19, 2012 |
# ? Oct 19, 2012 01:48 |
|
Try this: :%s/^\(\D.*\)$/[b]\1[\/b]/ Should match any line that doesn't start with a digit, group the text of that line, and replace it with the group surrounded by the tags. I just tried it with your input and it looked good, but I suck at regexes so there are probably problems I didn't think of.
|
# ? Oct 19, 2012 01:49 |
|
Civil Twilight posted:Try this: Your regex will work fine. Fun tip for situations where part of the search or replace text contains a '/' though: code:
code:
|
# ? Oct 19, 2012 14:12 |
|
This maybe the wrong thread for this and if so let me know. I need to design an XML serialization spec and the problem is that I know very little about XML. Does anyone recommend a book on XML that will get me running and talks about how to design an XML spec?
|
# ? Oct 19, 2012 15:14 |
|
One could say you are suitably qualified, no one else knows how to do it well either
|
# ? Oct 19, 2012 17:14 |
|
Those VIM searches worked perfectly. I had never used the parenthesis in a search before, so this is new territory for me. Thanks dudes!
|
# ? Oct 19, 2012 17:26 |
|
O_Kafetzis posted:This maybe the wrong thread for this and if so let me know. XML isn't designed for object serialization and you shouldn't abuse it for that purpose.
|
# ? Oct 19, 2012 18:14 |
|
SOAP
|
# ? Oct 19, 2012 18:17 |
|
pseudorandom name posted:XML isn't designed for object serialization and you shouldn't abuse it for that purpose. To my knowledge SOAP is more of a communication protocol and that means I would still need to design a spec for the objects.
|
# ? Oct 19, 2012 18:53 |
|
O_Kafetzis posted:Wait so what is XML good for besides using all of the RAM parsing it? On a more serious note, why is XML not good for object serialization? XML is a document markup language. It is good for marking up documents. For instance, one of the editions of the Encyclopedia Brittanica was marked up with SGML, a predecessor* to XML. If you're not marking up documents, XML is probably a poor choice - the operation you're performing is "shoehorning" in the technical parlance. A quick test for whether XML is a good choice for whatever you're trying to do is to think whether the final product will look like this: code:
code:
|
# ? Oct 19, 2012 19:10 |
|
O_Kafetzis posted:To my knowledge SOAP is more of a communication protocol and that means I would still need to design a spec for the objects. It was kind of a joke post, but it has the tools already made for you to define your objects and from them generate a spec that can be consumed by your users. That's the whole premise of using the web services stack. Another alternative for serializing objects is Google's Protocol Buffers. I use these extensively in my projects since the overhead is small and it produces objects usable in multiple languages and platforms, unlike SOAP which doesn't have native support in mobile platforms.
|
# ? Oct 19, 2012 20:13 |
|
And if you need your serialization to be text, JSON.
|
# ? Oct 19, 2012 20:24 |
|
Otto Skorzeny posted:If it looks like the former, you're probably on the right track! If it looks like the latter, *thwacks you on the nose with a rolled up newspaper* NO! BAD PROGRAMMER! I don't care what format we use as long as it is human readable. Thank you pseudorandom name and Hard NOP Life, I will look into JSON and Google's Protocol Buffers.
|
# ? Oct 19, 2012 20:54 |
|
O_Kafetzis posted:The serialization would probably look more like the latter. I only started with XML because that is what my boss is suggesting for me to use. Which means I will have to explain why not XML if I am going to push for that route. The whole point of XML is to be an extensible markup language, for annotating text - not a serialization format for arbitrary data. A lot of people try to use it as one, but that doesn't make it a good idea, and it's debatable whether the results qualify as "human readable". About the only thing it has going for it as a serialization format is that XML Schemas make it easy* to validate the well-formedness of a message. Protobufs are a binary serialization library; they have a human-readable operating mode but it's meant for debugging, not deployment. If your output needs to be human-readable, JSON is probably what you should look at first. * for XML, anyways
|
# ? Oct 19, 2012 21:36 |
|
O_Kafetzis posted:The serialization would probably look more like the latter. I only started with XML because that is what my boss is suggesting for me to use. Which means I will have to explain why not XML if I am going to push for that route. Are you in Java? GSON makes this easy.
|
# ? Oct 19, 2012 22:10 |
The .NET Framework 4 (and maybe earlier) has native JSON serialization, you can maybe take a look at the kind of output that produces. I've used it once and it looked quite reasonable. (It's certainly much more compact than the equivalent XML.)
|
|
# ? Oct 19, 2012 22:11 |
|
baquerd posted:Are you in Java? GSON makes this easy. My company is very careful about licenses. So a new library would have to go through legal, which may mean why my boss is talking about XML, as we already have a library cleared for that. In any case, I will keep looking at those 2 soluations. As I do not know yet if it always being human readable is a hard requirement. Please exuse any misspellings as I am typing this on phone.
|
# ? Oct 19, 2012 23:01 |
|
O_Kafetzis posted:I need to design an XML serialization spec and the problem is that I know very little about XML. Does anyone recommend a book on XML that will get me running and talks about how to design an XML spec? If your heart is set on XML, I would invest some time learning how to make an XML schema. You may also want to find a shoulder to cry on too. MrMoo posted:One could say you are suitably qualified, no one else knows how to do it well either Yep. O_Kafetzis posted:Wait so what is XML good for besides using all of the RAM parsing it? On a more serious note, why is XML not good for object serialization? The promised advantages of xml are namespaces, schemas and the ability to embed one document inside another - mathml, svg, etc. quote:To my knowledge SOAP is more of a communication protocol and that means I would still need to design a spec for the objects. SOAP is a way to make it easy to gently caress over people writing clients for your services. Roughly speaking: SOAP - Make it easy to expose a list of classes into a wsdl file and leave the mess to the client writer. If it doesn't work straight off, you're left with a mess of encapsulation. JSON over POST - Make it easy to write a client, although somewhat time consuming, relatively easy to debug. JSON with links - Although not as simple to write a client, it makes it easier to change things without breaking clients. I've only heard one success story with SOAP - where the consumer and provider used the same platform, toolset, worked in the same company, and in the same office. From my limited experience of trying to interface with SOAP, the wsdls are rarely for the service offered, rarely work outside the tool that generated it, and it is often easier to take an example XML dump and write code to manually submit the request. As for XML serialization within SOAP, i've seen more examples of smuggling - htmlentities encoding of XML (so it doesn't have to pass any schema), and JSON strings inside SOAP envelopes. Hard NOP Life posted:Another alternative for serializing objects is Google's Protocol Buffers. I use these extensively in my projects since the overhead is small and it produces objects usable in multiple languages and platforms, unlike SOAP which doesn't have native support in mobile platforms. I'd recommend protobufs over JSON or XML for object serialization. It seems to work. JSON is ok for object serialization when you only need to serialize the objects JSON supports. You can sorta shoehorn other objects inside, but it is clunky, messy and annoying to detangle at the client side. O_Kafetzis posted:In any case, I will keep looking at those 2 soluations. As I do not know yet if it always being human readable is a hard requirement. It depends what you're serializing. Just because it is in XML or JSON doesn't make it human readable, as Otto's example demonstrates.
|
# ? Oct 20, 2012 16:59 |
|
I implemented a SOAP client once. Wouldn't recommend, it was basically reverse engineering (I ended up packet snitffing a working client and re-creating what it did in my own client).
|
# ? Oct 20, 2012 21:15 |
|
WCF makes SOAP relatively easy if you view the fact that it uses SOAP as an implementation detail that you never try to take advantage of in any way.
|
# ? Oct 21, 2012 00:37 |
|
Indeed. I've been using WCF for about a year, and have never had to look at XML. This makes me happy.
|
# ? Oct 21, 2012 01:08 |
|
What do you guys think about Lisp dialects? I've been learning Common Lisp recently (SBCL) and I like Scheme too but it just seems less powerful and "complete." Not to mention it lacks in the speed department quite a bit. I also think that Paul Graham is on to something with Arc, axiomatic development is a good idea, it's just taking way too long to actually get it developed.
|
# ? Oct 21, 2012 04:12 |
|
luxxx posted:What do you guys think about Lisp dialects? I love Lisp on paper, but in practice the only variant that I've ever actually gotten things done with is Clojure. Which I do recommend if you have several gigabytes of free memory for the dev tools.
|
# ? Oct 21, 2012 05:01 |
|
ToxicFrog posted:I love Lisp on paper, but in practice the only variant that I've ever actually gotten things done with is Clojure. Which I do recommend if you have several gigabytes of free memory for the dev tools. I've always hated the JVM. I really don't like working with Java methods, and I like the ideas that Clojure is putting into action, but using macros alongside long Java methods kinda hurts me. Lisp and Java are two completely different paradigms. I mean, Chris Granger (guy who is making Light Table IDE) has said that it's mostly just a product of Clojure's greatness, but I'm just not willing to bend. Not to mention, there's the problem of the actual code. It's hard to maintain Lisp code. That's the biggest thing that's held back Lisp and kept it from transcending from academia to industry. I love writing Lisp, it makes me feel right, but sometimes I'll have to go back and make it do something different, and I'll realize that I have no idea what it's doing. Having to learn my own code is counter productive. I don't know. Lisp needs *something*, but I just don't know. Paul Graham needs to hurry the hell up with Arc.
|
# ? Oct 21, 2012 05:43 |
|
If you write unmaintainable code I don't think you can blame Lisp. Common Lisp is perfectly usable in the real world, I work for a company that develops in it almost exclusively. We don't find our code harder to maintain because it's Lisp, but of course some discipline is required -- if you build new languages/interfaces/protocols, you probably should document them.
|
# ? Oct 21, 2012 11:15 |
|
luxxx posted:Not to mention, there's the problem of the actual code. It's hard to maintain Lisp code. That's the biggest thing that's held back Lisp and kept it from transcending from academia to industry. Lisp dialects have been used in industry many times. Lisps seeming lack of popularity is often down to more social factors. quote:I don't know. Lisp needs *something*, but I just don't know. Syntax would be a start. Also enough of a language so people stop having to implement their own inside of it. quote:Paul Graham needs to hurry the hell up with Arc. Yeah, I do need more laughs about a 100 year language that went out of its way to strip out unicode support.
|
# ? Oct 21, 2012 11:39 |
|
|
# ? May 29, 2024 21:17 |
|
.
maskenfreiheit fucked around with this message at 21:29 on Apr 28, 2019 |
# ? Oct 21, 2012 16:12 |