Jump to page: 1 2
Thread overview
Switching from Java to D: Beginner questions, multiplatform issues, etc.
Feb 27, 2014
DS6
Feb 27, 2014
John Colvin
Feb 27, 2014
DS6
Feb 27, 2014
Jeremy DeHaan
Feb 27, 2014
Simon Bürger
Feb 27, 2014
Ali Çehreli
Feb 27, 2014
DS6
Feb 27, 2014
DS6
Feb 27, 2014
Ali Çehreli
Feb 27, 2014
DS6
Feb 28, 2014
Bienlein
Feb 28, 2014
Jesse Phillips
February 27, 2014
Though this post may seem long, my questions are indeed asked. I just kinda started typing and didn't stop; I guess this is both a question post and a vent post. Please bear with me.

Hello, I'm a hobbyist programmer, and I'm tired of the way things are going. I'm looking for a change.
I must admit, I've been pampered most of my programming life: I've consistently used higher-level languages, like Java (which I have been using as of late), that do all the work for you. But I find it's hard to quickly prototype and implement new ideas and to test new code because of that. Creating a solution to an otherwise simple task takes numerous new and extended classes and lots of time. There's always the option of choosing a dedicated external library or otherwise development environment to build off of a central idea, but I want to keep things simple and work with the core essentials and not resort to learning the ins and outs of another codebase. Sadly, Java's "core essentials" are absolutely humungous and hard to keep track of. If I feel the need to search for an alternative development environment just to get a more focused feature subset that may or may not already exist in part or in full in a language, I don't really think that language is right for me and what I want to accomplish, whatever that may be at the time.
As an example, I would occasionally find myself making some code that does nearly the same thing as an already-implemented class in the JDK/JRE, simply because I forgot to do any research on the topic beforehand or I didn't think there was already a solution for my problem.

Overall, using Java takes massive dedication for the language and a large, pre-defined, solidly-built goal, and I may not have some or all of the previous at any point in time while both fleshing out my ideas and working on already-established projects. When programming in Java, there is a large number of classes that are available for one to use, that are fully-featured and complete, and function extremely well for their intended purpose. However, the way Java is set up makes me feel like I have to twist and bend those classes into the idea I see in my head, instead of using them as a base like they're intended to be used. I could always start from scratch and build my classes how I want, using other classes only when necessary, but what's the point in that when there's already classes out there that do what I want, and probably more efficiently? Instead I dig through them until I find something that works how I want it to and may occasionally miss something that works better or fits my desires better because I simply didn't notice it or got fed up with looking and stopped. It's been like that for all of the more expansive higher-level languages I've used, not just Java.

(Aside: Don't get me wrong, I am NOT bashing Java. It's an excellent, solid framework that can handle damn near anything you throw at it, and usually in a very skilled, complete, and well-thought-out manner. It's great for both small- and large-scale, enterprise operations, and is able to function at full-capacity in the most intense of circumstances. It certainly has its place, a place it holds firmly and effectively, but I don't really think it's good for me; I'm not exactly some bigwig company that needs XYZ huge projects produced.)

It really comes down to what you're looking for. Honestly, I'm still not sure what I'm looking for, but I know I love programming and I want to find my calling for it. I've always wanted to get into general game design but I've never really found anything that truly clicks with me. I've tried other game design-specific solutions, even ones designed for Java like jMonkeyEngine, but development with these types of applications is usually very closed and has that pre-built "here use this class" feeling like Java does.
I must sound pretty hypocritical/demanding here; I want a solid base to work off of but I don't want it to feel pre-built? I suppose what I mean is that I want it to work as-is, but I also want things to be bare enough so that I can create what I want without worrying about what class to use or what method to override. Java isn't just your average framework, it has everything you could ever need... And that's not really what I want. I want a skeleton, so that I can fill in the parts that I need to how I want, without resorting to using X number of classes. Not only do I feel that restricts my creative abilities, but it's generally difficult. That's part of the reason I chose D: It has all the advantages of using a low-level language, mainly in its simplicity, but with the ease of use and completedness that comes from using a higher-level language, or as so I've read about it.

I want programming to be challenging and engaging, and moreover fun and enjoyable, while having it not being a chore just to accomplish little goals. Java kinda feels like that one aunt that is really nice but always makes too much food and tries to feed you all the time; great intentions but too much to digest at once, especially if you're only looking for a small meal.
I want a language that is fully-featured but doesn't try to have a class for every potential problem I have, which I originally though could be a good thing but hasn't really turned out too well for me in my experience. So, in order to step away from the raging, overbearing sea that is Java, I decided I'd try out a lower-level language, to see if it was any easier/more efficient to prototype code. I chose D over the omnipresent C/++ (which I was largely contemplating using), due to how it seems more stable. C's niche is that it's been around for too long; it's too widespread and its specifications too lax to have a good, concrete base. Equally so, trying to cater to the older crowd by trying to implement new features while staying true to backwards-compatibility is NOT a very effective or forward-thinking solution!

Okay, down to the questions I have about D:
 - Why should I use D over another language? What general benefits does it provide me, in relation to the points I made about it above? Is it a solid base to build off of, but still simple in nature? Aside: I do NOT mean simple as in easy to use, I'm fine with a little difficulty and "putting your nose to the grindstone" as the saying goes; I mean simple as in not having to learn the names of thousands of classes, methods, and fields, just to accomplish rather trivial goals.
 - How is multiplatform compilation handled by D? I've never much looked into how lower-level languages handle compilation and such, so I can't claim to understand the topic very well; as I said above I've been pretty pampered by the high-level languages of our day and age, and as such haven't looked into a lower-level language this intensely. Can I compile Linux binaries from Windows, and vice-versa? Is this possible, and if not, why?
 - How well supported is D? I've read that D is still relatively... Not new, or young, but less known than other languages. Does it have support for major libraries, like SDL? Aside: Whether or not these libs are "official" or not doesn't matter to me, they usually aren't anyway.
 - After some idle searching, I found the Derelict3 GitHub project. That was quite the impressive list of bindings. That leads me to my next question: How are bindings and other libraries of the sort handled by D? I understand my questions and musings thus far have been about the core D experience, but some extra information on the more popular/useful external libraries wouldn't hurt. Aside: External libraries to extend the capabilities of a language and to add new features, as opposed to providing a more focused feature set that don't even need to be used to achieve the same functionality, like many Java libraries do, are okay in my book.
 - How is D used in the enterprise world? Is it used by professional career-bound programmers? How viable is D in a general enterprise situation? If it isn't viable, what other choices are there for such endeavours? What kinds of situations can D handle and where would it excel over other languages?
 - Lastly, and probably most important, is D code scalable and easy to maintain? You never know, something I make could gain popularity and I would suddenly need to mass-produce and heavily modify my code to suit the needs of whatever crowd of people suddenly want my services, whatever services I may offer. Is going large-scale from an initially small-scale project or otherwise prototype at least comparable, say, Java (which is quite easy to manage large-scale if you do things right)?

In closing, I in advance appreciate and thank any responses to my rambling. It's 3 AM and I think I'm going to sleep now. I look forward to any possible discussion tomorrow.
February 27, 2014
On Thursday, 27 February 2014 at 10:23:40 UTC, DS6 wrote:
> Okay, down to the questions I have about D:
>  - Why should I use D over another language? What general benefits does it provide me, in relation to the points I made about it above? Is it a solid base to build off of, but still simple in nature?

It's a flexible, well designed language. Many things that are complex and/or slow in other languages can be written in a readable and performant manner, with fewer nasty surprises.

>  - How is multiplatform compilation handled by D?

Fine as long as you stick with x86/x86_64 CPUs and a normal desktop operating system, i.e. Linux, Windows, OS X, ***BSD

Support for other types of systems is work-in-progress, mostly focused around gdc/ldc as dmd is an x86/x86_64 only compiler. Bear in mind that the same frontend is used for all 3 compilers, dmd is the reference compiler, gdc/ldc lag 1 release behind dmd.

>  - How well supported is D? I've read that D is still relatively... Not new, or young, but less known than other languages. Does it have support for major libraries, like SDL? Aside: Whether or not these libs are "official" or not doesn't matter to me, they usually aren't anyway.

You can use any C library from D, but you have to port the headers. This has been done for many libraries, see here: http://code.dlang.org/
There are some nice D-style wrappers that exist as well.
Links to other languages include https://github.com/JakobOvrum/LuaD, https://bitbucket.org/ariovistus/pyd
C++ libraries are less well supported, but there has been a certain amount of success.

>  - How is D used in the enterprise world?

Depends on your definition of enterprise. There are companies that use D (http://wiki.dlang.org/Current_D_Use).

>  - Lastly, and probably most important, is D code scalable and easy to maintain? You never know, something I make could gain popularity and I would suddenly need to mass-produce and heavily modify my code to suit the needs of whatever crowd of people suddenly want my services, whatever services I may offer. Is going large-scale from an initially small-scale project or otherwise prototype at least comparable, say, Java (which is quite easy to manage large-scale if you do things right)?

In my opinion, D code is highly scalable and maintainable. In particular, the strength of D's metaprogramming makes for flexible code.



Overall, D is a pragmatic language.
February 27, 2014
On Thursday, 27 February 2014 at 10:52:51 UTC, John Colvin wrote:
> It's a flexible, well designed language. Many things that are complex and/or slow in other languages can be written in a readable and performant manner, with fewer nasty surprises.

I find I usually run into some "nasty surprises", especially when dealing with complex tasks, in Java, having to constantly recompile and retest my code. This is a welcomed change.

> Fine as long as you stick with x86/x86_64 CPUs and a normal desktop operating system, i.e. Linux, Windows, OS X, ***BSD

If I ever decide to go multiplatform with my applications, those would be all I would target anyway. My code would be open-source regardless, so it's not like someone couldn't port it.

> Support for other types of systems is work-in-progress, mostly focused around gdc/ldc as dmd is an x86/x86_64 only compiler. Bear in mind that the same frontend is used for all 3 compilers, dmd is the reference compiler, gdc/ldc lag 1 release behind dmd.

I've grown up on x86 so other architectures are pretty far in the future.

> You can use any C library from D, but you have to port the headers. This has been done for many libraries

What exactly is the difference between C and D headers?
=
> Links to other languages include https://github.com/JakobOvrum/LuaD

That is a _very_ welcomed link. Lua would have to be my favorite scripting language to use.
There are numerous Java ports for Lua, but they're much harder to develop for than the original C variant.

> Depends on your definition of enterprise. There are companies that use D (http://wiki.dlang.org/Current_D_Use).

Interesting that Facebook uses it, not to mention even such a high-scaled company should praise D over C++.

> In my opinion, D code is highly scalable and maintainable. In particular, the strength of D's metaprogramming makes for flexible code.

Metaprogramming is always welcomed; makes things much easier in the long run.
I'll probably find this out on my own eventually, but does D support operator overloading? That would be simply amazing.

> Overall, D is a pragmatic language.

Thank you for taking the time to answer my questions, I am much more interested in D now.
February 27, 2014
On Thursday, 27 February 2014 at 22:40:36 UTC, DS6 wrote:
> What exactly is the difference between C and D headers?

D does not have any separation between header and code files like C or C++. There are files with the .di extension which are similar, but not quite the same. What he meant is that you need to bring the declaration code found in header files into your D code so that the compiler knows they exist.

February 27, 2014
> What exactly is the difference between C and D headers?
D itself does not use headers at all. But you will need "D headers", if you want to call a C library from D. The translation is mostly syntatic and straight forward like:
* replace #define-constants with enums
* replace macros with (templated) functions
* replace #ifdef with static-if / version
etc...


> Metaprogramming is always welcomed; makes things much easier in the long run.
> I'll probably find this out on my own eventually, but does D support operator overloading? That would be simply amazing.
Absolutely it does. Even in a more "meta"-way than c++:

struct S
{
    int x;
    S opBinary(string op)(S other) // overloads + - * / % all at once
    {
          return mixin("x "~op~" other.x");
    }
}
February 27, 2014
On 02/27/2014 02:40 PM, DS6 wrote:

> What exactly is the difference between C and D headers?

D code that needs to use a C library must use "D bindings" of that C library. Here is Deimos, a collection of D bindings of many C libraries:

  https://github.com/D-Programming-Deimos

More information:

  http://dlang.org/interfaceToC.html

> Interesting that Facebook uses it, not to mention even such a
> high-scaled company should praise D over C++.

A recent article about that:


https://code.facebook.com/posts/729709347050548/under-the-hood-building-and-open-sourcing-flint/

> I'll probably find this out on my own eventually, but does D support
> operator overloading?

But of course: :)

  http://dlang.org/operatoroverloading.html

Ali

February 27, 2014
On Thursday, 27 February 2014 at 22:58:40 UTC, Ali Çehreli wrote:
> But of course: :)

Yeah I found that out already; I have schoolwork to do but D is really interesting and stuff and argh.
I think one of the things I also like about D so far is the community.
Most Java communities, when I asked questions about hard/not-before-accomplished tasks, were either completely ignored or "LOL GO USE THIS LIBRARY" when I wanted to do it myself. I have a feeling it's not going to be like that here, with the way all of you cool doods have been replying.

Also, not having headers is totally rad. I never liked headers. Having the compiler handle that for you is very nice.

Also also, I've noticed that D supports lax typecasting through the "auto" type, oh God I didn't even know that that is wonderful.
February 27, 2014
Also *3: Not having to make an account to post here is also nice. I don't really like signing up for things.
February 27, 2014
On 02/27/2014 03:09 PM, DS6 wrote:
> Also *3: Not having to make an account to post here is also nice. I
> don't really like signing up for things.

Because this is actually a newsgroup (i.e. NNTP), pretending to be a forum. :)

Ali

February 27, 2014
On Thursday, 27 February 2014 at 23:12:16 UTC, Ali Çehreli wrote:
> Because this is actually a newsgroup (i.e. NNTP), pretending to be a forum. :)

I could kinda tell from both the URL and the "Posting to digitalmars.D.learn" line.
I've never used a newsgroup before, cool.
« First   ‹ Prev
1 2