Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
PM 2Ring
Posts: 3713
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: Coding: Fleeting Thoughts

Postby PM 2Ring » Thu Aug 02, 2012 6:06 am UTC

Ben-oni wrote:
sourmìlk wrote:How do I know if I'm writing decent code? I think I am, because I understand it and can reuse it easily to do what I want, but that's remarkably subjective. Is there really a way to tell if you don't work in a team?

One simple test is to ask how hard it is to change the code. If the code needs to be altered to do something fairly close to what it currently does, well-structured code need only be altered in a few locations. The more invasive the changes need to be, the worse the code.


What Ben-oni said.

Also, if you can read your code a year or so after you wrote it without dying of embarrassment, it's probably decent code. :)

And you can always post code samples here and see what sort of criticism it gets. :mrgreen:

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Thu Aug 02, 2012 6:39 am UTC

My code would need some aesthetic cleaning up before that could happen. Also comments >.>

And this just gave me an awesome idea to improve one of my classes. To the IDE!

EDIT:
I pretty much finished it. It was extremely easy to swap out the old code and now all the code is much nicer and more flexible. I just have a bit of debugging to do.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Thu Aug 02, 2012 11:42 am UTC

Xeio wrote:
You, sir, name? wrote:I think, by adding more explicit guarantees against side effects, you could reap the benefits of implicit parallelism.
Yea, but short of a functional language where side effects can't happen (monads? bleh), how do do that? Or is the answer to just make all objects immutable that don't exist exclusively inside the current scope (assuming you can guarantee that somehow)?


By making it possible to declare (and enforce) side-effect-free code. I imagine a function attribute similar to const, except a bit stricter.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11128
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Thu Aug 02, 2012 1:51 pm UTC

In theory, like constexpr! (C++11 feature)

However, constexpr is sadly highly limited, as it is intended to be compiled-and-run-at-compile-time, and the standards committee decided to be nice to compiler vendors.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Thu Aug 02, 2012 4:12 pm UTC

Yakk wrote:In theory, like constexpr! (C++11 feature)

However, constexpr is sadly highly limited, as it is intended to be compiled-and-run-at-compile-time, and the standards committee decided to be nice to compiler vendors.


Yeah, that's sort of what I was thinking of. Shouldn't be that hard to enforce in practice. Just consider everything that isn't a stack variable const and you're half there.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11128
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Thu Aug 02, 2012 5:47 pm UTC

constexpr makes reading from non-constexpr variables verbotin as well. A function whose behavior changes based on things that aren't arguments to the function is not as bad as one that changes global state, but is still really hard to reason about -- it isn't referentially transparent, unless you consider the entire program's state as its input. You can easily have nasty threading race conditions as other data changes on you.

constexpr arguments may or may not be constexpr. If they are, then the function can be evaluated at compile time. If they aren't, then the function is merely purely functional, and you could do something like memoization on the call. And a constexpr function passed to a parallel for each could be presumed to behave "nicely"...
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Thu Aug 02, 2012 8:56 pm UTC

If one were to adapt constexpr to allow implicit parallelism, I think The C++ Way would be to allow external state dependency, despite how it allows foot-shooting if one for example would mix implicit and explicit parallelism. Any variables changed through explicit parallelism should be marked as volatile, and that's something pure functions legitimately should not be able to depend on.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

troyp
Posts: 557
Joined: Thu May 22, 2008 9:20 pm UTC
Location: Lismore, NSW

Re: Coding: Fleeting Thoughts

Postby troyp » Mon Aug 06, 2012 2:04 am UTC

Ben-oni wrote:No. I'm telling you three times, no.

Call-by-reference semantics requires an lvalue in the function call, and assigning to the parameter changes the variable passed in. Call-by-value does not. The difference between passing references by value and call-by-reference may be semantics, but that's why it's referred to as language semantics.

It annoys me, too. Everyone always calls Python call-by-reference as well. It's more than just semantics (or rather semantics is more than just semantics, IYKWIM). It's a matter of practical importance. eg, if you try to define a binary function that swaps the values of its arguments, you'll find out whether your language is pass-by-reference or not.

I guess in an "ideal" pbv language with references, it would be different. *Every* value would be a mutable object and there would be a common mechanism for extracting the content or "value" (ie. all distinguishing features) of an arbitrary object. Then if you wanted to "assign" to a function parameter, you'd just mutate it instead (a.content = b.content rather than a=b). So it really would be equivalent to pass-by-reference.

But in any real language, (for performance reasons if nothing else) that's not going to be possible. So calling such a language pass-by-reference really is misleading, as well as false.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Tue Aug 07, 2012 7:51 pm UTC

Anyone have any suggestions for how to do lexing/parsing in C++ that isn't terrible? (Flex/Bison, ANTLR, Boost Spirit, and recursive descent are all horrible in their own, unique ways.)

Mostly this post is a rant, but if you have any actual suggestions I'll take them.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11128
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Tue Aug 07, 2012 8:00 pm UTC

What are you lexing/ parsing?
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Tue Aug 07, 2012 8:12 pm UTC

Yakk wrote:What are you lexing/ parsing?

At the moment, a simple form of S expressions, but it's also a more general question as I've been frustrated by this in the past.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Tue Aug 07, 2012 8:17 pm UTC

You, sir, name? wrote:despite how it allows foot-shooting

This is actually what I like about C++: it allows foot-shooting. It doesn't patronize me by saying "No, you can't do that. Sure, it makes sense, but you might be able to abuse it!" Instead, it says "Go ahead and try it for all I care, but if you shoot yourself in the foot, don't come complaining to me."
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

Роберт
Posts: 4285
Joined: Wed May 14, 2008 1:56 am UTC

Re: Coding: Fleeting Thoughts

Postby Роберт » Tue Aug 07, 2012 9:33 pm UTC

sourmìlk wrote:
You, sir, name? wrote:despite how it allows foot-shooting

This is actually what I like about C++: it allows foot-shooting. It doesn't patronize me by saying "No, you can't do that. Sure, it makes sense, but you might be able to abuse it!" Instead, it says "Go ahead and try it for all I care, but if you shoot yourself in the foot, don't come complaining to me."

C++: it does what you tell it to do without questioning your authority or sanity. Great if you told it to do the right things.
The Great Hippo wrote:[T]he way we treat suspected terrorists genuinely terrifies me.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Tue Aug 07, 2012 9:43 pm UTC

Well yeah, the ability to tell it to do great things is it's strength.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11128
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Wed Aug 08, 2012 12:36 am UTC

EvanED wrote:
Yakk wrote:What are you lexing/ parsing?

At the moment, a simple form of S expressions, but it's also a more general question as I've been frustrated by this in the past.

Last time I did this I wrote a generator based tokenizer (for escaped brackets) then a simple n-art tree generating recursive descent (well not much of a grammar) parser.

The actual comprehension was then a pretty simple program on that parse tree.

Know what they say about lisp? Ya it happened.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Wed Aug 08, 2012 1:07 am UTC

Yakk wrote:Know what they say about lisp?


Er, actually I don't.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

Ben-oni
Posts: 278
Joined: Mon Sep 26, 2011 4:56 am UTC

Re: Coding: Fleeting Thoughts

Postby Ben-oni » Wed Aug 08, 2012 2:36 am UTC

sourmìlk wrote:
Yakk wrote:Know what they say about lisp?


Er, actually I don't.

He's saying he wrote a simple interpreter to do the "comprehension" of the parse tree, i.e., Greenspun's Tenth was fulfilled.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Wed Aug 08, 2012 9:48 am UTC

Oh, okay. I'm not sure I agree with Greenspun's Tenth, but admittedly I haven't looked at too many large projects.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

Ben-oni
Posts: 278
Joined: Mon Sep 26, 2011 4:56 am UTC

Re: Coding: Fleeting Thoughts

Postby Ben-oni » Wed Aug 08, 2012 5:04 pm UTC

sourmìlk wrote:Oh, okay. I'm not sure I agree with Greenspun's Tenth, but admittedly I haven't looked at too many large projects.

You know it's tongue-in-cheek, right? It's the kind of observation that's half-jest, half-true; as in, it happens just often enough that we can chuckle over it.

User avatar
Dropzone
Posts: 405
Joined: Sun Dec 30, 2007 10:12 pm UTC
Location: North Lincs., UK

Re: Coding: Fleeting Thoughts

Postby Dropzone » Thu Aug 09, 2012 12:44 am UTC

Quick HTML question: does anyone know whether, if I indent my code like this, the leading and trailing whitespace inside the title element is likely to cause problems/considered bad style? All the browsers I've got installed do the sensible thing and ignore the whitespace, but I can't find anything in the HTML5 spec that guarantees that'll happen.

Code: Select all

<!DOCTYPE html>
<html>
    <head>
        <title>
            This is the page title
        </title>
    </head>
...

User avatar
Bubbles McCoy
Posts: 1106
Joined: Wed Jul 09, 2008 12:49 am UTC
Location: California

Re: Coding: Fleeting Thoughts

Postby Bubbles McCoy » Thu Aug 09, 2012 1:06 am UTC

HTML ignores whitespace in most cases, hence the occasional need for things like non-breaking spaces. I don't believe titles are considered an exception to this rule.

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Coding: Fleeting Thoughts

Postby Steax » Thu Aug 09, 2012 1:32 am UTC

From my experience (never really paid this much attention), HTML collapses appended whitespace into a single space character. Non-breaking spaces are used when you need more than one space. I'm suspicious the title tag is a browser exemption because browsers trim it for practical use.
In Minecraft, I use the username Rirez.

User avatar
Aaeriele
Posts: 2127
Joined: Tue Feb 23, 2010 3:30 am UTC
Location: San Francisco, CA

Re: Coding: Fleeting Thoughts

Postby Aaeriele » Thu Aug 09, 2012 5:03 am UTC

HTML does effectively collapse whitespace to a single space character except when inside of a pre tag, textarea, or attribute.

Thus, something like...

Code: Select all

<span>                             foo            </span>            <a href="bar">bar</a>


is effectively the same as

Code: Select all

<span> foo </span> <a href="bar">bar</a>


but not the same as

Code: Select all

<span>foo</span><a href="bar">bar</a>


Also, I believe most browsers tend to strip any whitespace off of the ends of the title tag, so indenting a title doesn't matter because the tabs are stripped from the ends and collapsed in the middle.
Vaniver wrote:Harvard is a hedge fund that runs the most prestigious dating agency in the world, and incidentally employs famous scientists to do research.

afuzzyduck wrote:ITS MEANT TO BE FLUTTERSHY BUT I JUST SEE AAERIELE! CURSE YOU FORA!

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Coding: Fleeting Thoughts

Postby Steax » Thu Aug 09, 2012 6:49 am UTC

It looks like it only applies to whitespace after the first non-whitespace character in a tag. The preceding ones are simply ignored, based on my two minutes of testing, even for inline elements.
In Minecraft, I use the username Rirez.

User avatar
Aaeriele
Posts: 2127
Joined: Tue Feb 23, 2010 3:30 am UTC
Location: San Francisco, CA

Re: Coding: Fleeting Thoughts

Postby Aaeriele » Thu Aug 09, 2012 7:12 am UTC

Steax wrote:It looks like it only applies to whitespace after the first non-whitespace character in a tag. The preceding ones are simply ignored, based on my two minutes of testing, even for inline elements.


Yeah, you're right. http://jsfiddle.net/CwUt6/1/
Vaniver wrote:Harvard is a hedge fund that runs the most prestigious dating agency in the world, and incidentally employs famous scientists to do research.

afuzzyduck wrote:ITS MEANT TO BE FLUTTERSHY BUT I JUST SEE AAERIELE! CURSE YOU FORA!

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Coding: Fleeting Thoughts

Postby Steax » Thu Aug 09, 2012 7:14 am UTC

It's probably one of those things browsers always did to maintain sanity, and everyone just started thinking it's how it's supposed to be.
In Minecraft, I use the username Rirez.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6578
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Thu Aug 09, 2012 11:00 pm UTC

If Eclipse is so great, why do I need a plugin to design windows in Swing?

Seriously, though, I'm more of a backend developer, but I decided to learn Java and GUI development at the same time as learning a new IDE... it's kind of slow getting started, and not very fun. I have a feeling it's going to be a bit of a headache because my requirement is to make a user-customizable interface (drag and drop buttons, similar to many toolbars like the one in Firefox, but not actually a toolbar). When I figure this out, I'll redo it in Scala and see what I like better.
Summum ius, summa iniuria.

User avatar
Dropzone
Posts: 405
Joined: Sun Dec 30, 2007 10:12 pm UTC
Location: North Lincs., UK

Re: Coding: Fleeting Thoughts

Postby Dropzone » Fri Aug 10, 2012 12:18 am UTC

I googled some more, and found this - apparently, HTML5 deliberately avoids specifying what should happen to whitespace, because that's defined by the CSS specification instead. This seems... less than helpful when it comes to metadata elements like title, which CSS doesn't apply to.

Thesh wrote:If Eclipse is so great, why do I need a plugin to design windows in Swing?
Eclipse is made up entirely of plugins - even if you're just using it to write Java, you're using a plugin. It looks like the current "Eclipse IDE for Java Developers" package includes a GUI builder plugin, too. I don't know how long that's been the case for, as I don't use the premade packages myself (Eclipse is complicated enough without a load of plugins I don't need). For that matter, I don't use a GUI builder, but then I've only ever had to write fairly simple GUIs.

If we're complaining about Eclipse, though - I wish they'd hurry up and implement Java 8, I want lambdas :evil: There's actually one class in my current project that was so awkward to implement without lambdas, I ended up taking it off the Eclipse build path and using a batch file to compile it with the JDK 8 javac instead.

On a related note, I find it amusing how much less verbose Java lambdas are than C++ ones, considering what Java's usually like:

Code: Select all

// C++
[=](int x) { return k * x; }
// Java
x -> k * x

User avatar
Xanthir
My HERO!!!
Posts: 5410
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Fri Aug 10, 2012 1:36 am UTC

Dropzone wrote:Quick HTML question: does anyone know whether, if I indent my code like this, the leading and trailing whitespace inside the title element is likely to cause problems/considered bad style? All the browsers I've got installed do the sensible thing and ignore the whitespace, but I can't find anything in the HTML5 spec that guarantees that'll happen.

Code: Select all

<!DOCTYPE html>
<html>
    <head>
        <title>
            This is the page title
        </title>
    </head>
...

The rules for whitespace collapsing are detailed here: http://dev.w3.org/csswg/css3-text/#white-space-rules.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Fri Aug 10, 2012 4:59 pm UTC

I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Fri Aug 10, 2012 7:20 pm UTC

You, sir, name? wrote:http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html

Jesus H. Christ

I think that is the most wonderful thing I have read in a while.

And by "wonderful" I mean... well, some combination of "wonderful" and "terrifying" and "awful" that I can't quite precisely put my finger on. But I definitely had a huge smile on my face when reading it.

Edit I think I will start describing things like that as "wonderterrible." Or maybe "wondertrocious"?

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5101
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Fri Aug 10, 2012 8:04 pm UTC

Works in the debug mode for the program I'm working in*:

Code: Select all

if(System.DateTime.TryParse(value, &date)){
Works when the program is actually running:

Code: Select all

if(System.DateTime.TryParse(value, date)){
I fear for my sanity that the same code does not work in both.

*It uses a sort of hybrid javascript/C# monstrosity.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Fri Aug 10, 2012 8:17 pm UTC

EvanED wrote:
You, sir, name? wrote:http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html

Jesus H. Christ

I think that is the most wonderful thing I have read in a while.

And by "wonderful" I mean... well, some combination of "wonderful" and "terrifying" and "awful" that I can't quite precisely put my finger on. But I definitely had a huge smile on my face when reading it.

Edit I think I will start describing things like that as "wonderterrible." Or maybe "wondertrocious"?


I think the term you're looking for is "magnificently perverse".
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Xanthir
My HERO!!!
Posts: 5410
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Fri Aug 10, 2012 10:27 pm UTC

You, sir, name? wrote:http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html

Jesus H. Christ

You can do a surprising amount with only ()[]+!. Adding in {} is practically easy-mode in comparison. It's really easy once you get used to the coercion rules. ^_^
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

troyp
Posts: 557
Joined: Thu May 22, 2008 9:20 pm UTC
Location: Lismore, NSW

Re: Coding: Fleeting Thoughts

Postby troyp » Sat Aug 11, 2012 12:03 am UTC

Surely obfuscated Javascript isn't new? It seems like such an attractive target for obfuscation. Not very rich, maybe, but it certainly has the means to wreak confusion...

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Sat Aug 11, 2012 5:49 am UTC

troyp wrote:Surely obfuscated Javascript isn't new?

Hell, I've never seen Javascript code that doesn't appear to be obfuscated.

ba-dum tsh!
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

User avatar
PM 2Ring
Posts: 3713
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: Coding: Fleeting Thoughts

Postby PM 2Ring » Sat Aug 11, 2012 7:22 am UTC

troyp wrote:Surely obfuscated Javascript isn't new?

Surely, troyp. But polite people like to keep their more obfuscated examples private. Eg, I wrote a thing in JavaScript that compresses normal JavaScript code using LZW and then encodes it base 64 style, and tacks on a tiny bit of "normal"JavaScript to decode, decompress and run the original code. But you don't see me polluting the Web with it. :)

sourmìlk wrote:Hell, I've never seen Javascript code that doesn't appear to be obfuscated.

Good call, sourmìlk.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Sat Aug 11, 2012 9:43 am UTC

PM 2Ring wrote:Good call, sourmìlk.

If you say so. Honestly, for a person whose job is development of web-based software, I haven't really touched javascript. I basically do everything server-side with C#* because I'm developing tools for internal use, and we don't need none of that fancy "updating without refresh" stuff everybody is always going on about.

* - For the record, though, I don't do that because I'm so in love with C#. It's a nice language, but the .NET libraries are horrible. I get the feeling that C# was designed by computer scientists rather than programmers.

On an unrelated note, I'm looking at GLM, and while they've done some cool things (like implementing swizzling), I can't get over how they did it. They hard coded all possible arrangements of vector elements when swizzling, and they could do this because they wrote separate classes for four separate vector sizes, and separate classes for various matrix sizes. I don't see how they can live with themselves. The ends do not justify the means!
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

elminster
Posts: 1560
Joined: Mon Feb 26, 2007 1:56 pm UTC
Location: London, UK, Dimensions 1 to 42.
Contact:

Re: Coding: Fleeting Thoughts

Postby elminster » Sat Aug 11, 2012 6:41 pm UTC

I do like C#. You can still do low lvl stuff of C++, but has loads of high level stuff to handle all the generic stuff. Although I still find it odd with the amount of "new" keyword usage. Firstly I think "why would I create a new Size object to just set the size", then I think "Ok where's the matching delete", shortly before remembering that it's C# and not C++.
Unfortunately I've run into problems a few times where the underlying systems were unable to cope, or they behave in unintuitive ways. e.g. The bitmap stuff doesn't handle very large bitmaps.
Image

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: Coding: Fleeting Thoughts

Postby TheChewanater » Sun Aug 12, 2012 3:47 am UTC

sourmìlk wrote:On an unrelated note, I'm looking at GLM, and while they've done some cool things (like implementing swizzling), I can't get over how they did it. They hard coded all possible arrangements of vector elements when swizzling, and they could do this because they wrote separate classes for four separate vector sizes, and separate classes for various matrix sizes. I don't see how they can live with themselves. The ends do not justify the means!

Well, their goal was to implement a particular subset of the GLSL specification, so I guess they had to. After all, the convenience of being able to use GLSL's semantics makes up for the inelegance of the implementation. (I say this after using GLM for a project where I had previously tried to write my own vector and matrix classes, which is not as fun as it sounds.)
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 5 guests