|
BigRedDot posted:I guess this is some religious allusion but I have no idea what it means. "Penny wise, pound foolish", roughly (think about the size of a gnat and a camel)
|
# ? Apr 15, 2011 03:56 |
|
|
# ? Jun 1, 2024 16:26 |
|
MEAT TREAT posted:This is probably the biggest gap in my programming knowledge, but how the hell can I know if my high level (Python, Java, C#) code is provoking cache misses? Is there some profiling tool that can tell me? Second, if you were working in C, you could putz about with cachegrind, although I don't think anything meaningful could be extracted from it for anything interpreted or run in a vm or jitted. I suppose you could consider at a conceptual level that caches try to take advantage of temporal and spatial locality, eg. repeated references to a thing or references to adjacent things both take better advantage of a cache than references to random objects (although I don't know if Python provides a true contiguous array, but Java and C# both do). This would be very far down on my priority queue of poo poo to consider if I had VHLL code that needed to go faster. MEAT TREAT posted:Do I have to necessarily be programming in some kind of assembly code to get the most out of my embedded hardware, or is just following certain best practices? I've never done any kind of embedded/mobile coding so I'm quite curious to know more on the subject. This really depends on what you mean by "get the most out of". If your embedded application needs to do something at a given high frequency (megaherz PWM or communication by a protocol or whatever) and you don't have on-board dedicated hardware to do it, you might indeed hit a wall if you can't drop down to at least C, and there are certain annoyances with some compilers that target embedded platforms that make writing routines in assembly either necessary or the easier path in certain circumstances. That being said, if you're just trying to build something to blink LEDs and sound buzzers and run a stepper motor you'll probably be fine with whatever (even BASIC stamps can be surprisingly capable).
|
# ? Apr 15, 2011 04:11 |
|
Otto Skorzeny posted:there are certain annoyances with some compilers that target embedded platforms that make writing routines in assembly either necessary or the easier path in certain circumstances. VisualDSP++ I am looking at you.
|
# ? Apr 15, 2011 05:08 |
|
mr_jim posted:None of the "C-like" languages are all that close to C. Usually that term just means that they use {} to delimit blocks, and they have similar syntax for control structures and function calls. Or, in the cases of C++ and Objective-C, they started out as extensions of C. But they all require a different approach to programming than C. Objective-C I would argue is the closest "C-like" language, in fact you can't call it "C-like" as it's actually just a superset of C. All the magic that goes on is contained within the Obj-C runtime library. When compiled, ObjC code is turned into strict C before being fully compiled into object files. That's important to remember because Objective-C is C and all the same rules, especially of memory management apply. In fact, the first major language I learned way back was Objective-C and the language is inseparable from strict C. If you learn ObjC, you already know C and if you know C, you know 98% of everything about ObjC. That's not an exaggeration either; the real beauty behind ObjC is that it adds so little while you gain so much. The only real downside is that it's the polar opposite of C++; the two languages approach and tackle object orientation using completely different concepts. Unfortunately for someone like me who has learned both but strongly prefers one, it has ruined the other. I cannot look at C++ code without cringing the entire time.
|
# ? Apr 16, 2011 21:39 |
|
The King of Swag posted:Objective-C I would argue is the closest "C-like" language, in fact you can't call it "C-like" as it's actually just a superset of C. All the magic that goes on is contained within the Obj-C runtime library. When compiled, ObjC code is turned into strict C before being fully compiled into object files. All of that is true. When I said that Objective-C requires a different approach, I was thinking in terms what it adds to C, not what it changes. A program written in Objective-C that makes use of the features that it adds (objects, messages, and dynamic typing) will be structured differently than one written in C.
|
# ? Apr 16, 2011 21:48 |
|
Super-newbie Prolog question: I have a particular, not-necessarily-commutative defined relationship: code:
code:
My prior experience with Prolog was five years ago for three weeks in a class I ended up dropping, so I really don't know how to "think Prolog" yet.
|
# ? Apr 16, 2011 22:36 |
|
The King of Swag posted:Objective-C I would argue is the closest "C-like" language, in fact you can't call it "C-like" as it's actually just a superset of C. All the magic that goes on is contained within the Obj-C runtime library. When compiled, ObjC code is turned into strict C before being fully compiled into object files. Objective C has exceptions now, so it isn't a strict superset of C.
|
# ? Apr 16, 2011 23:10 |
|
pseudorandom name posted:Objective C has exceptions now, so it isn't a strict superset of C. Alright, I'll bite: show me an example of C code that can't be compiled by an Objective-C compiler due to Objective-C exceptions. (Also, "now"? Hasn't Objective-C had exceptions for a decade?)
|
# ? Apr 17, 2011 00:21 |
|
GrumpyDoctor posted:Super-newbie Prolog question: try code:
|
# ? Apr 17, 2011 05:26 |
|
pokeyman posted:Alright, I'll bite: show me an example of C code that can't be compiled by an Objective-C compiler due to Objective-C exceptions. foo.cpp: code:
code:
pseudorandom name fucked around with this message at 05:54 on Apr 17, 2011 |
# ? Apr 17, 2011 05:29 |
|
tef posted:try That's symmetry, not transitivity. You want something like code:
|
# ? Apr 17, 2011 07:24 |
|
pseudorandom name posted:...And, yes, you can fake exceptions using setjmp() and longjmp(), but... The Apple docs flat out say that exception handling is faked using setjmp() and longjmp() and thus is subject to any limitations associated with those functions. Part of the problem is that you're confusing the NextStep library (exceptions require the use of NSException) with the ObjC runtime. Now, the latest versions of the runtime do natively support exceptions, but if I understand the gcc documentation correctly, they're still broken down into setjmp.h trickery during compile-time. pseudorandom name posted:I'm assuming you meant "show me an example of Objective C code that can't be compiled to C due to exceptions", because that's what we were talking about. No, he meant what he typed. ObjC being a superset of C means it encompasses C in its entirety and thus there is no functional C code that won't compile properly in ObjC. This is in contrast to C++ which builds from C, but is not a superset of C, as C will not necessarily compile correctly under C++. Edit: Just want to add that ObjC by its nature has to be broken into valid C before final compilation into object files, because there isn't actually an ObjC compiler. Both gcc and LLVM are C compilers that use flags to link the ObjC runtime and to optimize for ObjC memory usage patterns, but they can still only compile C code (Apple's LLVM implementation may have some weird exceptions, I'm not sure). The King of Swag fucked around with this message at 07:50 on Apr 17, 2011 |
# ? Apr 17, 2011 07:35 |
|
ultrafilter posted:That's symmetry, not transitivity. You want something like And that's an incomplete transitive relation, because it only allows you to step over a single intermediate. code:
The trick here is that we're avoiding an infinite recursion while searching transitive_relation by compelling the solver to reduce by at least one simple_relation each time. This way the solver always makes progress of some sort.
|
# ? Apr 17, 2011 08:30 |
|
The King of Swag posted:The Apple docs flat out say that exception handling is faked using setjmp() and longjmp() and thus is subject to any limitations associated with those functions. Part of the problem is that you're confusing the NextStep library (exceptions require the use of NSException) with the ObjC runtime. Now, the latest versions of the runtime do natively support exceptions, but if I understand the gcc documentation correctly, they're still broken down into setjmp.h trickery during compile-time. The King of Swag posted:No, he meant what he typed. ObjC being a superset of C means it encompasses C in its entirety and thus there is no functional C code that won't compile properly in ObjC. This is in contrast to C++ which builds from C, but is not a superset of C, as C will not necessarily compile correctly under C++. I was responding to your comment that The King of Swag posted:All the magic that goes on is contained within the Obj-C runtime library. When compiled, ObjC code is turned into strict C before being fully compiled into object files. (gcc actually goes to the extent of having entirely separate binaries for each of the source languages, called cc1, cc1plus, cc1obj, and cc1objplus, respectively. clang has a single binary that can operate in the different modes as necessary. But there's no cfront nonsense anywhere.)
|
# ? Apr 17, 2011 09:33 |
|
pseudorandom name posted:I'm assuming you meant "show me an example of Objective C code that can't be compiled to C due to exceptions", because that's what we were talking about. You assume wrong. I was responding to you saying pseudorandom name posted:Objective C... isn't a strict superset of C. I think I just misunderstood you originally and that we actually agree: Objective-C is not a subset of C. (Which is trivial given that Objective-C is a strict superset of C.) This seems to be what you're arguing in your other posts. C works in both compilers, Objective-C only works with Objective-C compilers.
|
# ? Apr 17, 2011 10:49 |
|
ultrafilter posted:That's symmetry, not transitivity. You want something like misread the question coming in at 5 am whoops
|
# ? Apr 17, 2011 11:18 |
|
rt4 posted:PHP is like rubbing my brain on a metal grater Sounds like it's close to the metal to me! edit: Regarding the "C-like" discussion, all I ever take it to mean is that the syntax is similar. If you know C++ and look at the source code for a C# program you're going to be able to follow it... right up until you run into a lambda expression or something. rolleyes fucked around with this message at 16:03 on Apr 17, 2011 |
# ? Apr 17, 2011 15:59 |
|
ShoulderDaemon posted:And that's an incomplete transitive relation, because it only allows you to step over a single intermediate. It's still not working though. code:
|
# ? Apr 17, 2011 18:26 |
|
Ok I jury-rigged this up but it feels really inelegant:code:
|
# ? Apr 17, 2011 19:32 |
|
Is this a good place to ask about software licensing? I have made what I think is a pretty useful PHP parser generator, and I want other people to be able to use it. I do want my name to always be attached to modified/improved versions made and distributed by other people, but I am not sure how I feel about commercial use. Somebody suggested this to me and I thought it looked pretty good and then somebody else went "no no no" because apparently it is incompatible with other software licenses. Basically, I don't particularly want to be taken advantage of, but I'm not a lawyer. Does anybody have any personal recommendations or experience?
|
# ? Apr 18, 2011 19:05 |
|
where is the can of worms emote when you need it
|
# ? Apr 18, 2011 19:14 |
|
qntm posted:Is this a good place to ask about software licensing? I have made what I think is a pretty useful PHP parser generator, and I want other people to be able to use it. MIT License is the simplest way to let people use your code without effort or pissing around. quote:I do want my name to always be attached to modified/improved versions made and distributed by other people, but I am not sure how I feel about commercial use. This seems like a good idea until you end up with a readme bigger than the code base listing every single contributor. Also, attribution requirements don't play well with gnu software licenses, and they are pretty popular. My advice would be to care less about what people do with your code. If they like what you've done they'll give you credit anyway.
|
# ? Apr 18, 2011 19:17 |
|
Really, i'd rather talk about the code: Looking at your code, it isn't a parser-generator, but a parsing library, given it doesn't produce a php file as output from the grammar specified. Yacc is normally a LALR(1) parser generator, not an LR(1) p-g. There is a difference in how the LR states are calculated for LALR (LR(1) has an insane amount of states). LR(1) handles left recursion, so I find it strange that your parsing library does not handle it. You've actually written a top down parser library (that's LL-esque if you're keeping track), but I can't see any lookahead used to disambiguate states. It doesn't seem to handle choice but ordered choice from a passing inspection.
|
# ? Apr 18, 2011 19:28 |
|
GrumpyDoctor posted:Ok I jury-rigged this up but it feels really inelegant: Left recursion's a bitch :-) You could fix this by using a different resolution method, or ensuring you only use right recursive terms in prolog, i.e terms 1+2 in shoulderdaemon's post (but note the conclusion below) ShoulderDaemon posted:
Given it is prolog, search always proceeds from left to right, so the third relation here will cause infinite loops, but the first two should work, on an acyclic dataset. But going by your little statement above it seems that you also have loops in your data i.e a relation(a,a) term in your dataset, you'll have to exclude them from the recursive case to prevent loops. Which means you end up doing your 'inelegant' solution, recording the path to prevent looping. tef fucked around with this message at 19:42 on Apr 18, 2011 |
# ? Apr 18, 2011 19:39 |
|
tef posted:Really, i'd rather talk about the code: Ah, indeed. I didn't twig that there was a clear distinction there. I was actually toying with attempting to output PHP code, but it turned out to be very difficult to achieve starting from my specific implementation. Also there is no easy way to print out a callback as text in PHP. quote:Yacc is normally a LALR(1) parser generator, not an LR(1) p-g. There is a difference in how the LR states are calculated for LALR (LR(1) has an insane amount of states). LR(1) handles left recursion, so I find it strange that your parsing library does not handle it. Yeah, I spent a horrifying amount of time trying to straighten all of this out by reading Wikipedia but I just could not get a clear handle on any of it. If you think it is a top-down parser library then you are more likely to be correct than I am. There is no lookahead used to disambiguate states because any potential ambiguity is specifically disallowed at parser instantiation time. The code is at http://qntm.org/railroad2 for anybody playing at home. Will look into the MIT license.
|
# ? Apr 18, 2011 22:21 |
|
Also to be honest I see no problem with having a potentially huge list of contributors attached to a piece of work that they all contributed to?
|
# ? Apr 18, 2011 22:28 |
|
qntm posted:There is no lookahead used to disambiguate states because any potential ambiguity is specifically disallowed at parser instantiation time. A top down parser starts at the top of the parse tree and moves down the parse tree, so you start at the top of the parse tree, work out what comes next and try to parse it. So you go from <expression> to <literal> + <expression> to <number>, the idea being that you predict what comes next and try it. Top down parsers are Combinator Based, or, PEGs, Recursive Descent and LL. Top down parsers have problems with left-recursion, because as starts at the top and explores, a rule like <expr> :== <expr> + <literal> will continue to search in a loop. To deal with this people remove the left-recursive terms, or cry. Top down parsers often use backtracking to deal with choices in parsing, exploring each rule until it fails or it succeeds. A bottom up parser on the other hand, starts with <number> and then moves up to <literal> and then <expression>. You start at the bottom of the parse tree and move up, building the parse from the root nodes. Bottom up parsers are LR, LALR, SLR and a whole bunch of others. Bottom up parsers are often implemented with automata. As it is processing the input it has to make two choices, 'shift' - keep reading and carry on, or 'reduce' - read enough input, can now turn what i've shifted into a bit of the parse tree. In trying to remove any ambiguity and have a deterministic parse, the parser must do one or the other. Unlike a top down parser, there isn't prediction, bottom up parsers read (shift) enough until it knows *exactly* what it is. When the parser doesn't know exactly what to do, it has what is known as a conflict. These can take many forms, shift/reduce and reduce/reduce conflict. Bottom up parsers often use lookahead to reduce or deal with these conflicts, peeking ahead at the input stream to work out what to do. This is the number after LR in brackets. LR(0) has no lookahead. So, given you can't use left recursion, but you seem to be building states and you don't use lookahead, you seem to have built a LL(0) parser :-) If all this seems a little interesting and you'd like to know more I would heartily recommend 'Parsing Techniques 2nd Edition' http://www.amazon.com/Parsing-Techniques-Practical-Monographs-Computer/dp/038720248X it's awesome, comprehensive, accessible and generally explains most of this stuff. It's awesome. I haven't begun to get into left corner and non-canonical stuff or generalized parsers. Maybe I should get around to writing that book....
|
# ? Apr 18, 2011 23:02 |
|
qntm posted:Also to be honest I see no problem with having a potentially huge list of contributors attached to a piece of work that they all contributed to? Given you're writing it for php, they won't be distributing the software, so you won't get the attribution you desire. gnu have a nice page on why they don't like the attribution clause, http://www.gnu.org/philosophy/bsd.html personally I find it (requiring attribution) a little passive aggressive :-) tef fucked around with this message at 23:13 on Apr 18, 2011 |
# ? Apr 18, 2011 23:04 |
|
Public domain bitches. (See also: CC0)
|
# ? Apr 18, 2011 23:53 |
|
intellectual property is theft just call me joseph proudhon
|
# ? Apr 19, 2011 00:23 |
|
What will you tell us next? Women should keep to secretarial work as to not drive down programming wages?
|
# ? Apr 19, 2011 00:26 |
|
tef posted:intellectual property is theft i recently realized that mutualism and distributism are pretty similar
|
# ? Apr 19, 2011 00:50 |
|
tef posted:Maybe I should get around to writing that book.... I would read a book you wrote, especially if it were about why PHP is a stupid jerk, but parsing is pretty cool too.
|
# ? Apr 19, 2011 01:02 |
|
rt4 posted:What will you tell us next? Women should keep to secretarial work as to not drive down programming wages? programmers need to own the methods of production, i.e have the source to their compiler
|
# ? Apr 19, 2011 01:15 |
|
You can statically link to the standard library, but only if you use the government's compiler collection.
|
# ? Apr 19, 2011 01:25 |
|
pokeyman posted:Public domain bitches. Public domain doesn't let you disclaim any liability.
|
# ? Apr 19, 2011 01:27 |
|
pokeyman posted:Public domain bitches. I release under the WTFPL: code:
|
# ? Apr 19, 2011 03:01 |
|
clockwork automaton: right on! I've done the same for years.
|
# ? Apr 19, 2011 03:06 |
|
pseudorandom name posted:Public domain doesn't let you disclaim any liability. No, it just doesn't do so automatically. It doesn't stop you from doing so if you feel you must.
|
# ? Apr 19, 2011 03:30 |
|
|
# ? Jun 1, 2024 16:26 |
|
clockwork automaton posted:I release under the WTFPL GPL-compatible too! I love it.
|
# ? Apr 19, 2011 03:31 |