Walter Bright Ports D To the Mac
jonniee writes "D is a programming language created by Walter Bright of C++ fame. D's focus is on combining the power and high performance of C/C++ with the programmer productivity of modern languages like Ruby and Python. And now he's ported it to the Macintosh. Quoting: '[Building a runtime library] exposed a lot of conditional compilation issues that had no case for OS X. I found that Linux has a bunch of API functions that are missing in OS X, like getline and getdelim, so some of the library functionality had to revert to more generic code for OS X. I had to be careful, because although many system macros had the same functionality and spelling, they had different expansions. Getting these wrong would cause some mysterious behavior, indeed.'"
BCPL
B
We all know about the C programming language.
So shouldn't C's successor be called P?
Real developers actually use the Mac?
Problem after problem was traced back to the use of global variables. Over time I'd eliminated a lot of them, but there's a lot left. It's hard to change how a function works if there's a back channel of globals passing state around. Globals break encapsulation, making code difficult to understand.
Sounds like it's time to refactor some code there Walt.
I don't think D will ever have the high performance of C++, because D objects are all allocated on the heap. The D 'auto' keyword is just a compiler hint (last time I checked) to help in escape analysis. D has structs, but one has to design upfront if a class has value or reference semantics, and that creates a major design headache. Avoiding the headache by making everything have reference semantics negates the advantages of struct.
D is a mix of C and Java, with the C++ template system bolted on top. It is no way C++. D is not what a veteran C++ programmer excepts as the next generation C++.
From what I've understood his D implementation and Digital Mars C++ share some code. Would he bring Dital Mars C++ to MAC also? Or to Linux for that matter?
I'd be too tempted to be able to pick out my own name for a code.
You can go the outright vulgar route and call it something like Cock++. I mean, can you imagine inserting that terminology (no pun intended) into a workplace environment?
Or I'd just have as many terrible puns in it as I could... perhaps call it Hay, so I can confuse people with stuff like the Stack.
Random Thoughts From A Diseased Mind (Not For Dummies)
Can we FINALLY kill the semicolon at the end of a line? The default condition is that the end of a line terminates the command. Forcing the user to enter a semicolon command terminator when they have already indicated they want to end the command be pressing return/enter forces the user to say next command twice. Why must we promote bad design forwards?
- Zav - Imagine a Beowulf cluster of insensitive clods...
Now he's done it. Kicked off the alpabetical arms race. He himself averted it once by the Operator Gambit of + and ++. The crisis was defused.
It was stumped again this decade by what came to be called the Jungle of Earthly Delights Diversions (Python, Ruby, et al). But now he's broken the dam to the last redoubt, the alphabet. There are only so many letters! It is a limited supply! We've feared this since the mid-nineties. Who will save us now?
Behold, this dreamer cometh. Come now, and let us slay him... and we shall see what will become of his dreams.
Visual Basic sucks. BASIC rules. Long live GOTO!
1984 was supposed to be a warning, not an instruction manual.
I don't mean to be presumptuous, but might I suggest a more efficient way? If you would combine the Apple Users' Group meeting with the NAMBLA meeting, you could save a lot of time (not to mention gasoline!). After all, the membership rosters are practically identical. This would give you more time for the K-12 "chat rooms" and "Happy Meals" at Play Land. Just my 2 cents.
Simply treat both cr and lf as endlines; a compiler isn't formatting output and ignores a blank line so treating \r\n as two endlines doesn't matter. Use a visible character like the _ in vb to indicate that the next nonblank line is a continuation. I have to agree with parent that ignoring whitespace is one of the dumbest ideas ever. How often do you really needa 140 character line, versus the frequency of lazy programmers writing unreadable code because the language doesn't require even minimal formatting?
Brackets contain world's first nanosig, highly magnified:[.]
getline() and getdelim() are GNU extensions. Apple doesn't particularly like GNU. The FSF doesn't particularly like Apple (for good reasons). So, duh.
I think the fact that this post has been up for almost an hour and has only 33 follow-ons shows what the software community thinks of D.
One has to acknowledge that Back in The Day, Walter Bright did all of us a great service in producing the first PC-based C++ compiler (Zortech) which effectively forced Borland and Microsoft to take the language seriously.
Unfortunately, for all of us, he seems to be better at invention than collaboration but that doesn't devalue the contribution he made (structurally) to get us to where we are.
cheers...ank
Still hoping for Gentle Treatment...
This isn't fair, I am sure there are plenty of mac users without a fondness for young boys.
BASIC sucks. ASM rules!
The griping and misinformation here is so atrocious that I'm simply embarrassed to be reading Slashdot today.
Digital Mars D is a wonderfully designed language and I'm in the process of giving up a lifetime of C++ for it.
I'm not here to defend D or enumerate it's growing pains or evangelize it, but if you don't take it upon yourselves to be well informed, please don't repeat your biased gibberish to the rest of us.
Linux is also UNIX on the desktop. It's just an oddball version of UNIX, with a whole bunch of extra APIs that people using Linux get used to and come to depend on, so they think writing portable code means "it runs on Red Hat and Suse" (or Debian and Ubuntu, if you're on the Left Hand path), and then when they go to port to a more standard version of UNIX, they write stuff like this:
If you're writing code that depends on the expansion of system macros, or if you're depending on obscure Linux-only functions, you're writing unportable code. What really bothers me is the idea that someone writing a Linux-only program would already have run into situations where they had to conditionally compile code. Has Linux really fragmented that much?
...or there's always Greek, Hebrew, Klingon* and, hey, Chinese (that should keep us going for a while)!
Why do you think they invented Unicode?
(*Fatal Error at line 16349: statement has no honour)
In a survey of 100 programmers, 111111 thought that duck-typing was a good idea.
I think I've just given FreeBSD fans nightmares for months.
You don't understand FreeBSD fans, then. Most of the FreeBSD users I know have Mac desktops. Jordan Hubbard works at Apple now.
Mac on the desktop, FreeBSD in the back office, it's a sweet environment and everything "just works".
Dr Suess will save us! http://www.amazon.com/Beyond-Zebra-Classic-Seuss/dp/0394800842/ref=sr_1_1?ie=UTF8&s=books&qid=1235319102&sr=1-1?
Contribute to civilization: ari.aynrand.org/donate
People who have been Mac people for a long time generally don't have that workflow, as the importing of the BSD backend is a fairly recent addition to the Mac world, whereas many of the GUI conventions have been around much longer.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
OK, whats with this unix love? Yes it is a unix workstation, but so is HPUX. HPUX is ...different. You will understand if you have ever used it.
Don't talk to me about HPUX, I'm still bitter about Alpha.
Being Unix compliant does not mean a OS is good, reliable, or stable OS.
Not being UNIX would mean that it doesn't matter how good, reliable, or stable it is... it wouldn't matter, I wouldn't be using it. I've done my time in the trenches dealing with VMS, TOPS, RSX, RTE-IV, MS-DOS, CP/M, Windows, AmigaDOS, Exec/1100, many of which were by all kinds of measures good, reliable, or stable. But dealing with different operating systems sucks rotting frog innards through used oil filters, and I'm too old for that kind of manure.
Being UNIX means that, if it also happens to be good, reliable, or stable (which it does), it's worth using. If OS X was based on Copland or even BeOS I'd still be running free UNIX on my desktop.
You are not going to seriously suggest that Mac OSX supports more hardware than Linux are you?
I have a System76 Laptop running Ubuntu Linux 8.10. I have ZERO problems with hardware support of ANY KIND!
Your entire post is a complete puddle of steaming ass-goo for anyone who actually is in the know about GNU/Linux/Ubuntu. It truly is laughable!
Over-the-top Response Guy! Giving "Over-the-Top Responses" since 1970.
Seriously, name me a piece of commercial or open-source software with significant market share written in D. Library support is about 10000% more important than actual language design.
It isn't C, so therefore it doesn't *really* have a place, since it is obviously more bloated and slow than the mighty C and its strcpy. Doesn't seem like great developers really post here, anyway, based upon the comments in any programming article.
It always turns into:
1. inevitably some Javabot wanders in and makes condescending comments about how the amazing enterprisey framework they use that uses the Adapter Bridge Factory SingletonController Reducer pattern is superior to all, you just have to set up six XML config files in certain places and run two preprocessors on your code. But then when you do, its just amazingly ELEGANT!
2. People chant the same tired memes over and over without really knowing what they're saying: "LOL PERL IS LINE NOISE!"
3. Usually some college kid with a semester of CS pops by and writes several pages about how sad it is that everyone is using high level languages and wasting all the processing power of the computer. Also, how they're using Linux instead of Windows (because Linux is written in C) and how it is much faster. All this without realizing that the browser they're writing it in probably has significant portions written in Javascript.
As usual for Slashdot, there is zero nuance in the discussion. Everyone assumes their experience is what applies to everyone, and their needs are what everyone else needs.
OS X is easier to operate, and is set up to work well with Apple hardware. Those are nice features, and the reason I have an OS X laptop. But it surely isn't easy to administer. It's indeed quite terrible, since there's no package management to speak of.
Ever tried to walk through a classroom of mac-using high-school students how to get pygame installed and working on their OS? Including the proper version of python if their OS X has an old version, PyObjC, and so on? On Debian or Ubuntu, this requires double-clicking "python-pygame" in Synaptic, and all dependencies/upgrades/paths/etc. are handled automatically. In OS X it's a giant pile of manual bullshit.
And god help you if you have to resort to some mish-mash of .dmg installers, fink, and macports.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
Not all Linux software runs on the macOS either.
Yeh, there's a lot of Linux programmers who wouldn't know how to write portable code if the portable code fairy shat clue down their throats. Last decade it was SunOS programmers, the decade before that it was people who thought all the world was a VAX. The world is full of people like that.
For techies, there is no substitute for Linux or FreeBSD. (I prefer Linux, but I have friends who prefer FreeBSD.)
Ask your friends about porting Linux code from people who think portable means "it compiles on Red Hat and Suse... ship it!"
Oh, while we're on the subject, you do know that Jordan Hubbard works at Apple now, don't you?
Fabulous, he ported a language to the MAC. Ok groovey...
The bit about having to make adjustments to the library code is news why?
Not all OS's support everything in the world, that is just the way it is. If you implement a certain function or macro one way on one platform does not in any way mean that you will be able to implement exactly the same on another platform.
Hey KID! Yeah you, get the fuck off my lawn!
I was at Berkeley when 4.2BSD was being pulled together, and did some work for the 4.1C release. I was one of the guys who got 386BSD to compile clean in the first place. I had a NeXTstation on my desk for several years. I was the FreeBSD handbook guy for a while. I worked with Tru64 back when it was the only fully 64-bit UNIX. I know what "BSD" and "Mach" are, better than you and better than most of the people who contributed to that Wikipedia page.
you should be aware that this is Slashdot
Yeh, I'm keeping that in mind. Thats why I'm not going to even TRY and explain just how badly you're misreading that Wikipedia page.
I really like D, and would give up C++ for it, but the one thing I feel is really missing is bindings for Qt. :(
I suggest, while you're out there, you look up Lites, Tru64, DragonFlyBSD, and some of the other BSD variants. You can check out the kernel code for many of the BSD variants out there, including Darwin, and let us know just how far OS X is from 4.4-Lite compared to the rest.
Oh, right, this is slashdot. Asking people to do actual research is trolling.
From a pragmatist point of view it is the standard.
Bunch of kids with a trademark in their pocket.
UNIX is a family of operating systems with a native API and system call interface based on the UNIX programmer's manual, published by Bell Labs (usually the 7th edition).
That's a *useful* definition for UNIX.
This was a voluntary program in which students brought their own laptops, some of which were OS X. In general, the Linux and Windows laptops presented no problems; the OS X laptops presented difficulties due to lack of a standard user-friendly installation process.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
Windows worked perfectly fine, because it goes the other route, and lets users just run installers for anything they want (oh, and it has installers, not .dmg bullshit); only OS X presented problems. OS X can't decide if it wants users to install and upgrade things, or it wants that to be managed centrally, so you have a mish-mash of both. OS X-installed Python, of one version, user-installed Python, at a different path, of a different version. Neither Windows nor Linux require you to mess with crap like that.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
for hating Macs. I'm pretty sure that developers who work on software for OS X...use OS X. I'm not saying, I'm just saying. These complaints are trite and remind me of my high school Comp Sci classes. Evidently a majority of you clowns never grew up.
Jesus Christ. Just because you're happy with an ugly Linux box in the corner doesn't mean the whole fucking world has to be. Get a goddamn grip and shut the hell up about how you can run Debian on a cheaper box with better hardware inside and that it's better because it's free and all that lame old "real developers use Linux" evangelist bullshit. Nobody cares, because if they wanted a box that ran Linux, they already know they could easily have one - so to the legions of Captain Obviouses, stuff it.
Some of us value having a nice GUI to back up a solid set of internals without having to waste time and energy on fixing broken drivers and sticking patches on everything so that we can have a computer that does the things we ask of it without making exceptions for this, exceptions for that, patches for this, workaround for that. It's not 1993 and there's more to life than a command line. You're happy with your Gnome or KDE? Great. Not I.
Right... because apart from Linux, all Unices are exactly the same
That's why writing portable code requires experience.
Linux is a fragmented mess of incompatibility
Good thing I still have this in my paste buffer:
If I thought Linux was "a fragmented mess of incompatibility" I wouldn't have been surprised that it required conditional compilation. As someone else noted, the conditional compilation was because it had been ported to Windows as well, not because it had to include distro-specific code.
overlord.
Computer programs are lists of instructions to be executed in sequence. Since roughly the invention of writing lists have been organized on a one item per line basis. I can see the argument for allowing ; as well as EOL in order to fold short loops into a single line, but not defaulting EOL to end-of-statement makes no sense and just makes obfuscation contests possible. And comparing this to FORTRAN's requirement that you start everything in column X is a total straw man.
Brackets contain world's first nanosig, highly magnified:[.]
Qt for D is out now - http://code.google.com/p/qtd/
Programming in D is nice, but the situation is a bit annoying.
1. Tango vs Phobos. Phobos is the official standard library, but it seems most use Tango. Phobos is also pretty low level compared to Tango.
2. The reference compiler dmd is 32bit only, gdc is outdated and abandoned, and ldc is still alpha status and has missing features. Ldc is quite promising though.
3. D2 is maybe the biggest issue. It has very useful features, such as partial C++ compatibility, but D2 is a moving target and practically no library supports it. It's also unknown when or if ever D2 will become stable. I haven't seen much discussion about it in the newsgroup either.
Interesting. It wouldn't have occurred to me that they would expose the contents of the C include files as part of the D runtime, and translate the actual include files into D. Wouldn't it be better to implement the runtime exposed to the D application in a mixture of C and D, with C wrappers around the actual library calls? It would certainly make a port significantly easier!
Look at the chart in the article, and you'll see it has no multiple inheritance. Might be pretty important to some. :-)
Currently hooked on AMP
Hate to spoil a perfectly good joke, but Bright did not invent or name C++. Credit for that belongs to Bjarne Stroustrup.
Bright did create some widely used C++ compilers. But to me he will always be the author of that notorious time sink, Empire. If you count derived games like Civilization (which is just Empire with a complicated resource model) Bright has single-handedly destroyed more productivity than Pac Man and Warcraft combined!
And of course a D implementation is available!
Face it, GOTO's dead.
COME FROM is much more modern!
Things are much easier (and more current) on Gentoo and even the binary packaged Linux distributions.
So I use my Linux box for my "day job" development, and the Mac for "everything else" - but I can certainly develop on the Mac at a pinch.
you had me at #!
does anyone else remember this already being on mac? I specifically remember downloading a D compiler plugin for XCode. It had a package and everything. I just never did anything with it. Also, it is what many Doshin shooters are written in. Epecially the ones written with BulletML. Many of these are crossplatform http://www.asahi-net.or.jp/~cs8k-cyu/
It is interesting that this thread has stirred up a considerable amount of comparison of Mac to Linux. As a long time Linux user and a MAC Book Pro user of a year I have to comment.
1.
There is by far less fiddling with MACs than with Linux. That comparing a Mac portable to generic desktop hardware. I'm not sure how a reasonable person can say otherwise.
2.
Mac OS is not trouble free. Those of us with the Mac Books with WiFi problems can atest to that. Driver problems are not unique to Linux or any other platform for that matter.
3.
Interestingly while I consider the Mac to be about the best platform for commercial apps I'm not at all thrilled about the stability and over all quality of Aqua apps. Apparently Apple isn't either as they have said that they want to address this in Snow Leopard.
4.
I'm not sure that Snow Leopard can address all the issues in Aqua as the very nature of that dynamic, loosely typed environment seems to be part of the problem. After a year I'm pretty much convinced that non trivial apps on the Mac seem to go bad. Maybe that is a reflection on me but Apple does have serious problems with some of it's software.
5.
It is trivial to download and keep up to date with respect to many of the Open Source utilities. However should we really have to? This is where the vast majority of Linux distros win hands down, you don't have to wait for security and other updates to the various components in the suite. Package management is one area that Apple needs to put a lot of effort into to assure that security fixes are timely and effectively address bugs and performance issues. Waiting for months for a bulk 10.5.fx release is not OK. As a side note I've found that the third party resources like Fink to be totally useless, it is less trouble to build your self and that is saying something.
6.
You can easily run Linux in a virtual machine on a Mac. This works very well in my mind. Since I use a free VM environment it isn't perfect but it is good enough and actually provides for a better development environment.
Now onto "D".
D on Mac could be very successful if portable graphics library could be developed. Frankly I'm not impressed with Aqua and it's lack of portability is a big negative. I'm actually waiting hopefully for Snow Leopard to see if they can effectively address Aquas performance and stability issues. If that doesn't happen D with an open widget set might be more useful, acceptable and maybe even desirable on a Mac.
I have not used D the language but do like some of what I hear. Objective C seems to be to little in the way of a modern language. Now I don't consider myself to be even a remotely good C++ programmer but the language and it's standard libraries has a lot more to offer than Objective C. If D can offer up the same general feature set in an environment that is easy to master for the novice then it has big potential. As has been mentioned bindings and libraries are everything, to be successful on a Mac D would need both high level, D like access and low level access to UNIX. I need to read up on D more but it really does seem like an ideal language for those apps where Python can't do the job.
Note the last line above, I see much more of the world going to Python like environments where absolute speed isn't the issue. What that means for D is that it has to produce fast code. Further the programmer needs to be productive in D far more than Objective C.
So D needs to be fast but it also has to overcome the fact that it is late to the party. It will need to be compelling to displace C/C++ with respect to lowlevel programming and need fluid libraries to address the higher level competition. Considering the sad state of ADA, Java, C# and other languages I think D will have a tough time against the Cs.
Dave
*ducks*
i hate to troll but after looking at a comparison of C# syntax vs D syntax,
I get the feeling that they were both invented to be the "GC'ed, nicely templat'ed, clean syntax"
upscaling of C++, similar to what C++ was to C.
However, C# has the backing of M$ and D doesn't.
So in my mind, unless a miracle happens (like Qt turns out to be the primary GUI of choice for D and WPF turns out to be a REALLY bad idea)
D is dead in the water.
Disclaimer: I have tasted the white lines of C#+WPF and let me tell you, it is 100% pure coding goodness.
I dislike M$ as much as the next person but when it comes to getting the job done, C# delivers strongly.
Why would you try to use the header files from FreeBSD on Linux? The point of standard headers is that code can be written to an abstract interface exposed by the header files. When you move from one platform to another, the code works, even though the expansion of the macros is different, because the code does not make assumptions about how those macros are expanded.
Someone else suggested that you're trying to avoid redundant calls from D to C, but I suspect that you would in the long run end up with a faster and cleaner system by bypassing the stdio overhead completely, and calling read(), write(), and so on directly. The C runtime has an awful lot of historical baggage that you shouldn't need to carry over to D.
What happens when someone wants to use D on a platform that uses a glibc alternative, like uClibc? Do they have to hand-hack a new runtime?
I know precisely zero people who use OS X as a Unix, though. Many of them were indeed classic Mac users, and most of the rest still use the classic-Mac all-GUI workflow, which is still the one Apple mostly promotes, especially on the desktop.
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
D is the language that tries to do it all. And - because of that - it fails for many projects out there. I would hate to take over a project from an experienced D application programmer; you are bound to have to learn an endless number of techniques. D will appeal to many former experienced C++ application programmers, but I would not recommend it for organizations. IMHO, C# and the .net framework is seriously trying to fall into the same trap. Java is one of the few languages that is still pretty clean, and even that now has generics put on top of it (without runtime support). With that respect, not many languages have learned much from C (and possibly Pascal).
If I would use it it would be as a C++ replacement for small projects, especially those that fit to its features.
Consider:
String A := "Hello"; := A;
String B
B.append (" World!");
What should A be and what should B be? Note the "should" and ":=" - I am not talking about any particular programming language. Say you see this code in an unknown programming language what would be the first expectation for A and B?
Mine certainly would be A is "Hello" and B is "Hello World!".
And String is a complex class and certainly is not used only 0.001% of all cases.
Martin
I have another one for you.
when the GC detects 0 references, b is discarded.
Actually a good GC will discard reference objects. Consider:
Some_Class_1 A;
Some_Class_2 B;
Some_Class_3 C;
A.My_B := B'Access; := C'Access; := A'Access;
B.My_C
C.My_A
What should happen when A, B and C go out of scope. A CG based purely of reference counting could not delete them as each of the elements still got a reference count of 1.
Advanced GCs of course will detect when a ring structure becomes an island and will deallocate the complete ring. But: finding a ring structure is a complex task which can not be done at every block closure.
http://en.wikipedia.org/wiki/Single_UNIX_Specification#Mac_OS_X_and_Mac_OS_X_Server