To begin in D coming from Python
Jesse Phillips
jessekphillips at gmail.com
Wed Jul 23 21:47:15 PDT 2008
On Mon, 21 Jul 2008 11:51:23 +0000, Luis P. Mendes wrote:
> Hi,
>
> I use to program in Python, but I need some programs to run much faster.
> So, D seems to be as the best programming language for my needs.
>
> Still, there's a long way to go because I've never programmed in C.
>
> To begin with, is version 2 just a developer version or should I start
> by using it?
>
> In Python, lists can have variables, functions, text and others as
> elements. As far as I can recall from reading a C book, arrays in C
> don't have this possibility. What about it in D?
>
> And regarding list comprehensions like li = [elem*2 for elem in li]? is
> there something close in D?
>
> For example, how could I do something like: valores = []
> for c in lista_campos: valores.append(getattr(self,c)), so that I can
> have all the
>
> Is there also any construct similar to dictionaries?
>
> Are there D libraries to access PostgreSQL database or do I have to use
> C's?
>
> I don't know about the theoretical issues regarding language
> development, so documentation with good examples is a must have. Is
> there something like www.diveintopython.org in the short term horizon?
>
> These are just some topics I need to know about D. I'd appreciate some
> answers.
>
>
> Luis
I don't have a lot to add to what was already said, but I do want to note
that in using D you are likely going to lean quite a bit of C. This might
be directly (something is explain using C), or indirectly (D constructs
are similar to C's)
I don't have much experience with speed performance tackling, but have
read many discussions. And one thing that is not pointed out is that DMD
has not had huge development done in the area of optimizing code, and
there is GDC that will let you use the GCC backend to do more
optimization which supposedly is better than DMD, but still not the same
as native C. And Hashtables are currently very inefficient compared to
Python's.
On a note of when bearophile said that if you write code as you do in
Python, you only get about Python speed. I'm not sure how close to the
"Python" construct he is referring, but through my lack of experience
with speed comparisons, if you right code that follows the D "style" you
should see good performance. Hopefully bearophile or someone else will
correct me if this is off base.
I would definitely suggest sticking with D1, yes even for Linux.
Final thoughts, D is a very clean language with a few hiccups and
provides a range of tools. It may not suit your needs, but at the current
time the best way to know is to try it yourself. If do use it, whether a
success or failure, a report on how it went is always useful. Hope you
add yourself to the community, and if not for this task, for your own joy.
More information about the Digitalmars-d
mailing list