#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Isle of dogs
    Posts
    68
    Rep Power
    10

    Need stronger typed language then Python


    I am currently developing an html editor- its going to be the worlds best of course. I am liking Python but it is a little to weak-typed for my likings. I want typed checking and interfaces so I can kill those nasty runtime errors. I would like to port some of the code to a stronger typed language like such as C or Java or something but keep TK (Tkinter) as the user interface. Converting the code does not need to be done all at once but I would like to possibly interface the 2 languages together.

    Any ideas dudes
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    C isn't an OO language, so if you want OOP constructs/concepts like interfaces then you'll be looking at Java. In which case you might want to check out Jython:

    http://www.jython.org/

    Or maybe you could use C++ but I've only heard of extending CPython with C, though it should be possible to use C++? You should read though the Extending and Embedding section in the Python docs:

    http://www.python.org/doc/2.3.4/ext/ext.html

    I hope this helps. Good luck with the project ,

    Mark.
    Last edited by netytan; October 19th, 2004 at 07:38 AM. Reason: Spelling
    programming language development: www.netytan.com Hula

  4. #3
  5. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Tkinter is a wrapper for Tk/TCL which is another language altogether.

    Some Tkinter objects are combinations of Tk widgets written in Python so unless you are very lucky you will still need to include Python in your program. (or re-write them in your chosen langauge )

    If you want to look at TCL/C integration
    http://www.humbug.org.au/talks/tcl/tclintegrate.html

    Here's something worth reading:
    Strong versus Weak


    grim
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Isle of dogs
    Posts
    68
    Rep Power
    10
    Originally Posted by netytan
    C isn't an OO language, so if you want OOP constructs/concepts like interfaces then you'll be looking at Java. In which case you might want to check out Jython:

    http://www.jython.org/

    Or maybe you could use C++ but I've only heard of extending CPython with C, though it should be possible to use C++? You should read though the Extending and Embedding section in the Python docs:

    http://www.python.org/doc/2.3.4/ext/ext.html

    I hope this helps. Good luck with the project ,

    Mark.
    C not Object Oriented? I bet I can find a crazy nut out there to disagree with you. I am sure there are elegent workarounds. I just don't like C++ it just adds complication and ugly dependencies. There so many foo-langeuge-to-c converters out there and c is so standerd also.

    J
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    It is a common misconception that Python is weakly typed - it is strongly typed, but the type checking happens are runtime rather than at compile time as in C++. The correct distinction is between static typing (at compile time) and dynamic typing (at run time).

    The advantages of static typing for writing correct programs are debatable at best, and illusory at worst. There has been a definite move away from them over the last few years. With the rise of Test Driven Development dynamically typed languages can be used as safely as statically typed ones.

    Here is an article by Bruce Eckel (author of "Thinking in C++" and "Thinking in Java") on the subject, and another by Robert Martin, former editor-in-chief of "The C++ Report".

    The real advantage to static typing is that the compiler can produce more efficient code, since it does not have to do work at runtime to look up methods and attributes.

    Take a look at Pyrex - it is the python language with additional type information, that allows the code to be translated into C and compiled. It can result in code that is orders of magnitude faster than pure python. Since it creates Python modules in C, Pyrex can also be used to interface with existing C libraries.

    Dave - The Developers' Coach
    Last edited by DevCoach; October 19th, 2004 at 02:16 PM.
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by Tkinter_Bell
    C not Object Oriented? I bet I can find a crazy nut out there to disagree with you.
    Nope, C is not object oriented language. Why is why C was extended to become C++ (static) and Objective-C (more dynamic). I'm sure you could find somone to argue this but as you said, they'd probably be a crazy nut .
    programming language development: www.netytan.com Hula

  12. #7
  13. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    Originally Posted by netytan
    Nope, C is not object oriented language. Why is why C was extended to become C++ (static) and Objective-C (more dynamic). I'm sure you could find somone to argue this but as you said, they'd probably be a crazy nut .
    Agreed C is not object oriented, C++ is
  14. #8
  15. slightly insane code guru
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Location
    Indianapolis, IN
    Posts
    871
    Rep Power
    18
    find me a native way to handle inheritance et cetera in C and I'll tell you it's object oriented. until then, it's definitely not.
  16. #9
  17. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,626
    Rep Power
    4247
    Think you just found your crazy nut . You don't need an object oriented language to implement an object oriented design. If you're going to use C++ features as the standard for object orientation, heck even python doesn't have quite a few features that C++ does (not that they can't be simulated though), and Smalltalk or ruby fans claim that C++ isn't object oriented enough. IIRC the python book even mentions that no one seems to agree what "object oriented" really means. With that in mind, it is perfectly feasible to implement an object oriented model in a non-object oriented language like C. It can be done, just going to be a bit more verbose.

    Examples:
    http://www.tux.org/lkml/index.html#s15-3 - Note that it says the VFS file system and Xt are written using object oriented techniques (objects with public and private data, inheritance, methods etc.).
    http://www.accu.org/acornsig/public/articles/oop_c.html
    http://ldeniau.home.cern.ch/ldeniau/html/oopc/oopc.html <--- deltacoder, this one is for you . Also note that Stroustrup's original C++ compiler was called cfront and actually translated C++ code to C code before compiling it with a C compiler!
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  18. #10
  19. slightly insane code guru
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Location
    Indianapolis, IN
    Posts
    871
    Rep Power
    18
    I don't think the question was "can you do object-oriented stuff in C", it was "is the language itself designed to be object-oriented". Notice the "natively" in my post. But you raise a valid point.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Isle of dogs
    Posts
    68
    Rep Power
    10
    Originally Posted by netytan
    Nope, C is not object oriented language. Why is why C was extended to become C++ (static) and Objective-C (more dynamic). I'm sure you could find somone to argue this but as you said, they'd probably be a crazy nut .
    It looks like my Spidy senses were correct after all, I did find a article about object orientation in ANSI-C (not C++ or Object C) by Axel-Tobias Schreiner in PDF

    A quote “If it is impossible, what are you waiting for ,go do it”
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Isle of dogs
    Posts
    68
    Rep Power
    10
    Originally Posted by Scorpions4ever
    Think you just found your crazy nut . You don't need an object oriented language to implement an object oriented design. If you're going to use C++ features as the standard for object orientation, heck even python doesn't have quite a few features that C++ does (not that they can't be simulated though), and Smalltalk or ruby fans claim that C++ isn't object oriented enough. IIRC the python book even mentions that no one seems to agree what "object oriented" really means. With that in mind, it is perfectly feasible to implement an object oriented model in a non-object oriented language like C. It can be done, just going to be a bit more verbose.

    Examples:
    http://www.tux.org/lkml/index.html#s15-3 - Note that it says the VFS file system and Xt are written using object oriented techniques (objects with public and private data, inheritance, methods etc.).
    http://www.accu.org/acornsig/public/articles/oop_c.html
    http://ldeniau.home.cern.ch/ldeniau/html/oopc/oopc.html <--- deltacoder, this one is for you . Also note that Stroustrup's original C++ compiler was called cfront and actually translated C++ code to C code before compiling it with a C compiler!
    The problem with C++ is that it is so complicated that it negates the any object oriented abilities it implements, I am smelling and hoping that C is a better alternative to C++ with the speed I need too.

IMN logo majestic logo threadwatch logo seochat tools logo