HTML Formatter: Which language?

This is a discussion on HTML Formatter: Which language? within the Tech Board forums, part of the Community Boards category; I want to write a program to format HTML code. The program will be able to compress the code as ...

  1. #1
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528

    HTML Formatter: Which language?

    I want to write a program to format HTML code. The program will be able to compress the code as much as possible, while still maintaining readability. I also want to preserve whitespace inside <pre></pre> elements. I thought this might be a fun little project to do. Anyway, since I am a hobby programmer (aka a hack), I have only really gotten into C, Bash, and a bit of assembly. When I need to write a program, I usually default to C. This is terrible, I know - there are much better languages out there for certain things. For example, string handling and memory management in C++ is very nice in comparison to C, and I think string handling is even better in Python. Yet I have only dabbled in the latter two. Anyway, I want some opinions as to what I should do - should I make a stab at learning Python? C++ (again..), some other language, or should I just suck it up and do this in C? I am interested in hearing why you think I should use language x, as opposed to you just telling me to use language x. In other words, is this worth learning a new language, given that programming is a small 'h' hobby?

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well, do you *want* to learn a new language?

    I'm climbing into C++ --my head is swimming in namespaces at the moment-- and rather enjoying it now that I've gotten past the block; strings and references ... yay! But then I always did do things the hard way...

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    Are you restricting yourself to XHTML (which is well-formed), or old-style HTML which can have missing (or unbalanced) tags.

    Yes, learn Python.

    Actually, it doesn't matter so long as it isn't C - anything will do to get you out of your comfort zone.

    Actually, do it in C, then do the same thing in another language just for the fun of it. You'll be much more familiar with the problem then.

    > In other words, is this worth learning a new language, given that programming is a small 'h' hobby?
    You're thinking about it, so I'd say yes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by CommonTater View Post
    Well, do you *want* to learn a new language?

    I'm climbing into C++ --my head is swimming in namespaces at the moment-- and rather enjoying it now that I've gotten past the block; strings and references ... yay! But then I always did do things the hard way...
    I actually do want to learn something new (I guess I am doing some thinking out loud with this post). I know what you mean about your head swimming. For me (and I am not saying this applies to anyone but me) C++ always seemed like an insurmountably huge language. I know that may sound silly to some, but I never have seemed to be able to get into it. I will grant that part of the problem was lack of motivation (I did not have a real need to code something in C++), and part of the problem was a lack of something "real" to code on to practice my newly learned concepts. Example exercises can only take you so far.

    Quote Originally Posted by Salem View Post
    Are you restricting yourself to XHTML (which is well-formed), or old-style HTML which can have missing (or unbalanced) tags.
    XHTML

    Quote Originally Posted by Salem View Post
    Yes, learn Python.

    Actually, it doesn't matter so long as it isn't C - anything will do to get you out of your comfort zone.

    Actually, do it in C, then do the same thing in another language just for the fun of it. You'll be much more familiar with the problem then.

    > In other words, is this worth learning a new language, given that programming is a small 'h' hobby?
    You're thinking about it, so I'd say yes.
    I like your advice - it seems to me that doing this project in C & Python would be fun, and a fine way to get an idea of the level of difficulty to produce a functional program (with identical functionality) in each language, with the benefit of doing some hands on learning of Python.
    Last edited by kermit; 01-15-2011 at 02:52 PM.

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Perl all the way for this sort of stuff.

    As an aside, Go is gaining momentum and has some pretty cool new (not just copied from language X) ideas. It's a very fun language, especially coming from C :-)

  6. #6
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    951
    @Kermit: I've always thought the same thing about C++, just way too much to learn.

    @zacs7: I'm a big fan of looking at language implementation comparisons, and Computer Language Benchmarks Game seems to show Go being completely terrible in the sense that it can do some things very fast, but some things even slower than Ruby.

    I've always been a fan of using Lisp for string processing, but Python isn't bad either.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,435
    Hmm... I'd really consider Perl as zacs7 suggested, if the objective is to find the right tool for the job. You'll be happy to know you can also use perl from C, as essentially a scripting language (Embedding Perl (Using Perl from C) (Programming Perl)), which does give you quite a powerful combo for what you want to do -- given your already acquired knowledge of C. Despite my dislike of Perl, I don't pass up an opportunity to use it when the focus of my code is string handling.

    Now, Python was designed as an OO language from the start. So there's something going for it, since you'll acquire with it an important programming paradigm that will serve you for other languages in the future, most notably C++. It will also integrate into your C program as a scripting language if you wish. But it's more generic than perl in my opinion and so an excellent candidate for learning.

    Now, there's an alternative to both of them and that would be taking the jump to C++. Not because the language itself would provide you with all the tools needed to do this easily (although your project fits very well into a OO paradigm), but because with C++ you gain access to the Boost libraries which includes a very powerful string processing libraries.

    So fitting with your "I program for fun" theme, I'd choose Python first, since I believe there's a lot to gain from this combination for future projects. Essentially, the idea that one of the most powerful knowledge to be gained after learning to program in C or C++ is to learn how to use iot in combination with a scripting language. If you don't like Python, I'd give Perl a chance since it totally dominates in exactly the type of thing you want to do. Only then I'd give C++ a shot, with its very powerful access to cool libraries, but requiring an hefty investment of your time in order to get to grips with the language.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote Originally Posted by Epy View Post
    @Kermit: I've always thought the same thing about C++, just way too much to learn.

    @zacs7: I'm a big fan of looking at language implementation comparisons, and Computer Language Benchmarks Game seems to show Go being completely terrible in the sense that it can do some things very fast, but some things even slower than Ruby.

    I've always been a fan of using Lisp for string processing, but Python isn't bad either.
    Go is still very new -- late 2009 was its initial release. And there are two implementations, the 6g/8g compilers and the gccgo compiler (the latter being a front-end for GCC). They ran the tests on the 6g/8g compilers and not the gccgo compiler (which sports the GCC C compiler optimization features).

    Language speed isn't everything -- when you buy a drill, do you pick the one with the fastest RPM? I don't think so :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  2. Enough language discussions.
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 06-13-2004, 09:59 AM
  3. What's your favorite language/API
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 03-18-2003, 07:41 PM
  4. What is your favourite programming or web designing language?
    By techie in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-19-2001, 02:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21