October 19th, 2004, 07:22 AM
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
October 19th, 2004, 07:56 AM
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:
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:
I hope this helps. Good luck with the project ,
Last edited by netytan; October 19th, 2004 at 08:38 AM.
October 19th, 2004, 08:55 AM
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
Here's something worth reading:
Strong versus Weak
October 19th, 2004, 03:03 PM
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.
Originally Posted by netytan
October 19th, 2004, 03:13 PM
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 03:16 PM.
October 19th, 2004, 05:16 PM
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 .
Originally Posted by Tkinter_Bell
October 19th, 2004, 05:17 PM
Agreed C is not object oriented, C++ is
Originally Posted by netytan
October 19th, 2004, 06:20 PM
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.
October 20th, 2004, 04:44 PM
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.
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://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
October 20th, 2004, 04:57 PM
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.
October 22nd, 2004, 07:37 AM
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
Originally Posted by netytan
A quote “If it is impossible, what are you waiting for ,go do it”
October 22nd, 2004, 04:03 PM
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.
Originally Posted by Scorpions4ever