Author Topic: Let's hear it!  (Read 1982283 times)

0 Members and 6 Guests are viewing this topic.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Let's hear it!
« Reply #9525 on: November 03, 2011, 08:43:47 pm »
AJAJ (AJAX with JSON instead) is just a lot nicer to work with.  That's the main reason I like it.

Well of course.  :)

Web development in general kinda makes me sad, though. I avoid it when I can.

I ABSOLUTELY HATE WORKING WITH XML.

Don't you have some library to use? I'm not exactly fond of it myself, but it's never been a pain to work with because there's such good support for it.

That's not the point, there's no such thing as elegant code whenever you have to work with XML, no matter what library you use IMO.

Seems to me that it really depends on the application. If the data are very naturally structured as XML, it's probably a lot easier to write nice code.

Offline Blaze

  • x86
  • Hero Member
  • *****
  • Posts: 7136
  • Canadian
    • View Profile
    • Maide
Re: Let's hear it!
« Reply #9526 on: November 03, 2011, 10:47:24 pm »
AJAJ (AJAX with JSON instead) is just a lot nicer to work with.  That's the main reason I like it.

Well of course.  :)

Web development in general kinda makes me sad, though. I avoid it when I can.

I do it as my job, so, it's hard to avoid.  :D
And like a fool I believed myself, and thought I was somebody else...

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Let's hear it!
« Reply #9527 on: November 03, 2011, 11:31:25 pm »
I ABSOLUTELY HATE WORKING WITH XML.

Don't you have some library to use? I'm not exactly fond of it myself, but it's never been a pain to work with because there's such good support for it.

That's not the point, there's no such thing as elegant code whenever you have to work with XML, no matter what library you use IMO.
Have you used .NET 3.5+ LINQ-to-XML?  It's as close to elegant as I've ever seen.  I understand VB makes it even better (it's a native data type), though I've never used that.  I like composing:

Code: [Select]
var doc = new XDocument(
    new XDeclaration("1.0", "utf-8", null),
    new XElement("Root",
        new XElement("FirstLevelDeep",
            new XElement("SecondLevelDeep",
                new XAttribute("Value", 2)
            )
        )
    )
);
produces:
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<Root>
    <FirstLevelDeep>
        <SecondLevelDeep Value="2" />
    </FirstLevelDeep>
</Root>

Traversing it is really cool too, because you can apply LINQ operations to the traversals.  For example, take my sample XML configuration file from JinxBot - http://code.google.com/p/jinxbot/source/browse/trunk/development/projects/JinxBot/Configuration/SampleConfig.xml

Here's the code that reads it: http://code.google.com/p/jinxbot/source/browse/trunk/development/projects/JinxBot/Configuration/ConfigurationLoader.cs#73

That's a little complicated, but here are the details:
Code: [Select]
<JinxBotConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Globals>
       ...
    </Globals>
    <Profiles>
        <ClientProfile ProfileName="DarkTemplar~AoA on useast.battle.net (Starcraft: Brood War)">
            <Client>SEXP</Client>
            <VersionByte>209</VersionByte>
            <PrimaryCdKey>1111111111111</PrimaryCdKey>
            <GameExePath>C:\Gamefiles\STAR\Starcraft.exe</GameExePath>
            <StormDllPath>C:\Gamefiles\STAR\Storm.dll</StormDllPath>
            <BattleSnpPath>C:\Gamefiles\STAR\Battle.snp</BattleSnpPath>
            <Username>DarkTemplar~AoA</Username>
            <LockdownImagePath>C:\Gamefiles\STAR\STAR.bin</LockdownImagePath>
            <Password>password</Password>
            <ServerUri>useast.battle.net</ServerUri>
            <ServerPort>6112</ServerPort>
            <CdKeyOwnerName>Robert Paveza</CdKeyOwnerName>
            <Ping>Normal</Ping>
        </ClientProfile>
        ...
    </Profiles>
</JinxBotConfiguration>
This code gets the root element, JinxBotConfiguration:
Code: [Select]
document.Root
This then gets the single child "Profiles" element:
Code: [Select]
document.Root.Element("Profiles")
This then gets a generator which provides foreach access over the internal "ClientProfile" elements:
Code: [Select]
document.Root.Element("Profiles").Elements("ClientProfile")
Then instead of iterating over it with a foreach, I use a projection function, which converts it into a real class object:
Code: [Select]
document.Root.Element("Profiles").Elements("ClientProfile").Select(profile => CreateProfileFromElement(profile))
That expression yield an IEnumerable<ClientProfile>, which can be foreach'd over or turned into an array or whatever.

I think it's pretty cool... :)
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Let's hear it!
« Reply #9528 on: November 03, 2011, 11:46:11 pm »
AJAJ (AJAX with JSON instead) is just a lot nicer to work with.  That's the main reason I like it.

Well of course.  :)

Web development in general kinda makes me sad, though. I avoid it when I can.

I do it as my job, so, it's hard to avoid.  :D

I avoid it because I've done it as a job, and I didn't like it. :(

I like programming, just not web stuff. Would rather be digging through data or something. hehe.

Offline while1

  • x86
  • Hero Member
  • *****
  • Posts: 1013
    • View Profile
Re: Let's hear it!
« Reply #9529 on: November 04, 2011, 07:01:26 am »
I ABSOLUTELY HATE WORKING WITH XML.

Don't you have some library to use? I'm not exactly fond of it myself, but it's never been a pain to work with because there's such good support for it.

That's not the point, there's no such thing as elegant code whenever you have to work with XML, no matter what library you use IMO.
Have you used .NET 3.5+ LINQ-to-XML?  It's as close to elegant as I've ever seen.  I understand VB makes it even better (it's a native data type), though I've never used that.  I like composing:

Code: [Select]
var doc = new XDocument(
    new XDeclaration("1.0", "utf-8", null),
    new XElement("Root",
        new XElement("FirstLevelDeep",
            new XElement("SecondLevelDeep",
                new XAttribute("Value", 2)
            )
        )
    )
);
produces:
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<Root>
    <FirstLevelDeep>
        <SecondLevelDeep Value="2" />
    </FirstLevelDeep>
</Root>

Traversing it is really cool too, because you can apply LINQ operations to the traversals.  For example, take my sample XML configuration file from JinxBot - http://code.google.com/p/jinxbot/source/browse/trunk/development/projects/JinxBot/Configuration/SampleConfig.xml

Here's the code that reads it: http://code.google.com/p/jinxbot/source/browse/trunk/development/projects/JinxBot/Configuration/ConfigurationLoader.cs#73

That's a little complicated, but here are the details:
Code: [Select]
<JinxBotConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Globals>
       ...
    </Globals>
    <Profiles>
        <ClientProfile ProfileName="DarkTemplar~AoA on useast.battle.net (Starcraft: Brood War)">
            <Client>SEXP</Client>
            <VersionByte>209</VersionByte>
            <PrimaryCdKey>1111111111111</PrimaryCdKey>
            <GameExePath>C:\Gamefiles\STAR\Starcraft.exe</GameExePath>
            <StormDllPath>C:\Gamefiles\STAR\Storm.dll</StormDllPath>
            <BattleSnpPath>C:\Gamefiles\STAR\Battle.snp</BattleSnpPath>
            <Username>DarkTemplar~AoA</Username>
            <LockdownImagePath>C:\Gamefiles\STAR\STAR.bin</LockdownImagePath>
            <Password>password</Password>
            <ServerUri>useast.battle.net</ServerUri>
            <ServerPort>6112</ServerPort>
            <CdKeyOwnerName>Robert Paveza</CdKeyOwnerName>
            <Ping>Normal</Ping>
        </ClientProfile>
        ...
    </Profiles>
</JinxBotConfiguration>
This code gets the root element, JinxBotConfiguration:
Code: [Select]
document.Root
This then gets the single child "Profiles" element:
Code: [Select]
document.Root.Element("Profiles")
This then gets a generator which provides foreach access over the internal "ClientProfile" elements:
Code: [Select]
document.Root.Element("Profiles").Elements("ClientProfile")
Then instead of iterating over it with a foreach, I use a projection function, which converts it into a real class object:
Code: [Select]
document.Root.Element("Profiles").Elements("ClientProfile").Select(profile => CreateProfileFromElement(profile))
That expression yield an IEnumerable<ClientProfile>, which can be foreach'd over or turned into an array or whatever.

I think it's pretty cool... :)

Yes, familiar with all of those API, API isn't the problem.

My biggest complaint with XML is the dependence on string literals/ constants. I know you can't get around having them and 'elegant' is probably the wrong word to use- I think the thing I hate the most about XML is the fact that code is I can't get around having to litter my code with so many string constants/ literals.  I just normally don't associate elegance with requiring code to have lots of string constants and literals.
« Last Edit: November 04, 2011, 07:05:29 am by while1 »
I tend to edit my topics and replies frequently.

http://www.operationsmile.org

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Let's hear it!
« Reply #9530 on: November 04, 2011, 02:03:06 pm »
Code: [Select]
            <Username>DarkTemplar~AoA</Username>
            <Password>password</Password>
I know your password! It's....aww crap.

Offline deadly7

  • 42
  • x86
  • Hero Member
  • *****
  • Posts: 6496
    • View Profile
Re: Let's hear it!
« Reply #9531 on: November 04, 2011, 03:33:21 pm »
I avoid it because I've done it as a job, and I didn't like it. :(

I like programming, just not web stuff. Would rather be digging through data or something. hehe.
At my work I do both while web designing. Universities have a surprisingly large amount of data relating to employees to sort through...
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
 [17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

Offline Hitmen

  • B&
  • Moderator
  • Hero Member
  • *****
  • Posts: 1913
    • View Profile
Re: Let's hear it!
« Reply #9532 on: November 04, 2011, 08:29:08 pm »
I recently started exercising and eating decently for basically the first time ever. I feel so much better in my daily life it is ridiculous. I don't have trouble sleeping anymore, I can make it through a day of work without being exhausted at the end, and feeling better about myself is leading to massively reduced anxiety. Basically win all around.
Quote
(22:15:39) Newby: it hurts to swallow

Offline Sidoh

  • x86
  • Hero Member
  • *****
  • Posts: 17634
  • MHNATY ~~~~~
    • View Profile
    • sidoh
Re: Let's hear it!
« Reply #9533 on: November 04, 2011, 09:15:32 pm »
I avoid it because I've done it as a job, and I didn't like it. :(

I like programming, just not web stuff. Would rather be digging through data or something. hehe.
At my work I do both while web designing. Universities have a surprisingly large amount of data relating to employees to sort through...

Yeah, I don't mean to say that both don't happen. I had to do some rails stuff at work last summer that still involved big data.

There are just things about web design that are really boring to me, so I like to avoid it whenever I can.

Offline Newby

  • x86
  • Hero Member
  • *****
  • Posts: 10877
  • Thrash!
    • View Profile
Re: Let's hear it!
« Reply #9534 on: November 04, 2011, 10:25:17 pm »
I recently started exercising and eating decently for basically the first time ever. I feel so much better in my daily life it is ridiculous. I don't have trouble sleeping anymore, I can make it through a day of work without being exhausted at the end, and feeling better about myself is leading to massively reduced anxiety. Basically win all around.

This is like, motivation to actually get in shape and eat healthy.
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: Let's hear it!
« Reply #9535 on: November 04, 2011, 11:11:12 pm »
My biggest complaint with XML is the dependence on string literals/ constants. I know you can't get around having them and 'elegant' is probably the wrong word to use- I think the thing I hate the most about XML is the fact that code is I can't get around having to litter my code with so many string constants/ literals.  I just normally don't associate elegance with requiring code to have lots of string constants and literals.
But the trade you get in return is that the resultant data is very easy to understand by humans.  Usually.

You can always swap out the literals with constants. 

Either way, I don't see how that's any different than, say, reading an .ini file for settings or whatnot.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline CrAz3D

  • Hero Member
  • *****
  • Posts: 10184
    • View Profile
Re: Let's hear it!
« Reply #9536 on: November 06, 2011, 12:12:44 am »
I recently started exercising and eating decently for basically the first time ever. I feel so much better in my daily life it is ridiculous. I don't have trouble sleeping anymore, I can make it through a day of work without being exhausted at the end, and feeling better about myself is leading to massively reduced anxiety. Basically win all around.

fucking....word.  I stopped smoking in March and started to hit the rec center 4 times per week.  I felt amazing.  Then, my woman got all whore-y on me and I went back to drinking + smoking + not exercising.  I felt like shit.  So, recently, I decided I shouldnt be a moron, and I stopped smoking and hit the gym again.  I feel lots better, and it's only been 2 weeks since I stopped smoking (gym sucked cuz I am getting over a cold, and I cough like an 80 year old smoker now).

Being healthy fuckin rocks.

Offline while1

  • x86
  • Hero Member
  • *****
  • Posts: 1013
    • View Profile
Re: Let's hear it!
« Reply #9537 on: November 06, 2011, 09:57:12 am »
My biggest complaint with XML is the dependence on string literals/ constants. I know you can't get around having them and 'elegant' is probably the wrong word to use- I think the thing I hate the most about XML is the fact that code is I can't get around having to litter my code with so many string constants/ literals.  I just normally don't associate elegance with requiring code to have lots of string constants and literals.
But the trade you get in return is that the resultant data is very easy to understand by humans.  Usually.

You can always swap out the literals with constants. 

Either way, I don't see how that's any different than, say, reading an .ini file for settings or whatnot.

For writing/reading to/from a configuration file, yes I'd agree, XML is no better than any other solution.  But your example is a simple case.  In fact, if it were merely a matter of storing configuration data of my own defining, I wouldn't be complaining because I wouldn't need ANY string constants/ literals for XML tags/IDs in my code.  There are two options I could choose from depending on the situation:  Define an XML schema and generate class types with the XML Schema Definition Tool (Xsd.exe), and use the XmlSerializer to serialize/deserialize the generated classes to/from the configuration file.  Or, easier, define the configuration data as DataContracts and simply use the DataContractSerializer to serialize/deserialize the data contracts to/ from a configuration file.

So yeah, I was using hyperbole in my original posts because at the time I was fed up with the current XML work I have to do which isn't as nice to work with.  I generally think XML is overused, design choices are made in its favor without any real good reason or for stupid reasons where the negatives outweigh any positives.
« Last Edit: November 06, 2011, 10:48:40 am by while1 »
I tend to edit my topics and replies frequently.

http://www.operationsmile.org

Offline iago

  • Leader
  • Administrator
  • Hero Member
  • *****
  • Posts: 17914
  • Fnord.
    • View Profile
    • SkullSecurity
Re: Let's hear it!
« Reply #9538 on: November 06, 2011, 12:52:47 pm »
+1 on the exercise thing. In the last couple years, I've dropped like 50+ pounds and 6" of waistline. Starting to feel better about myself. Honestly, a big part of it was the process of "coming out" and being proud of who I am. Who knew?

Offline nslay

  • Hero Member
  • *****
  • Posts: 786
  • Giraffe meat, mmm
    • View Profile
Re: Let's hear it!
« Reply #9539 on: November 06, 2011, 01:07:25 pm »
My biggest complaint with XML is the dependence on string literals/ constants. I know you can't get around having them and 'elegant' is probably the wrong word to use- I think the thing I hate the most about XML is the fact that code is I can't get around having to litter my code with so many string constants/ literals.  I just normally don't associate elegance with requiring code to have lots of string constants and literals.
But the trade you get in return is that the resultant data is very easy to understand by humans.  Usually.

You can always swap out the literals with constants. 

Either way, I don't see how that's any different than, say, reading an .ini file for settings or whatnot.
I disagree. XML is not easy to understand for non-trivial applications. XML reminds me of template errors generated by GCC or Visual Studio ... you could put a lot of effort to parse those errors if you wanted (I usually just go to the line instead).

If it's complicated and humans need to edit it, it's probably worth it just to write your own language and parser.
An adorable giant isopod!