24 ms·
How I Came to Write D (2014)
- wglb 8y agoTake note: "Who the hell do you think you are thinking you can write a C compiler?" If you take that challenge it will seriously elevate your computer programming skills. In some circles, this will get you immediately hired. Try a simple language, maybe devise an emulator to go along with it.
- deleted 8y ago[deleted]
- mlthoughts2018 8y ago> “In some circles, this will get you immediately hired.” Is this true though? I mean Google famously didn’t give a shit about hiring Max Howell (creator of homebrew) because of hazing-style pointless whiteboard trivia [0]. I’d guess the number of circles where a thoughtful side project that digs into deep computer science fundamentals as well as difficult implementation specifics would even get you the slightest attention for an interview is close enough to zero as to render it meaningless. If you think about a lot of possible different self-study options, ranging from cramming and shallow memorization of leetcode garbage or Cracking the Coding Interview, all the way to patiently applying craftsmanship and self-learning to a side project that exercises and demonstrates core fundamentals in a pragmatic way, the shallow memorization garbage will earn you money, while the side project will earn you an email with a hyperlink to HackerRank. It is one of the worst aspects of our industry, and a major reason why I would advise younger people to treat the idea that there are direct, stable, good-paying jobs with job security in the tech industry with a lot of skepticism. It’s an industry constantly trying to invent new ways to shift the demographics more and more into the least experienced and least expensive quantiles of candidates, and to arrange businesses where actual software labor productivity doesn’t have a strong tie to the company’s bottom line, except maybe for a tiny population of experts. [0]: < https://www.quora.com/Whats-the-logic-behind-Google-rejecting-Max-Howell-the-author-of-Homebrew-for-not-being-able-to-invert-a-binary-tree https://www.quora.com/Whats-the-logic-behind-Google-rejectin... >
- pjmlp 8y agoIn my experience, you are quite right. Most HR departments will only care about latest set of projects and education, barely giving any value to side projects. Yes, there are those that care about side projects, passion and such, but most of them tend to be startups and sometimes not with the desired set of benefits or requiring relocation.
- wglb 8y agoTo whatever extent you can get hiring decisions moved out of HR, I would recommend doing it.
- dionian 8y agotrue. though the problem extends to developers and developer managers as well. I've seen so many colleagues say stuff when discussing a candidate like "Well they just could write <x> algorithm on the board correctly. I found an edge case" or whatever. I've actually not been offered interviews in part because of failed whiteboard coding questions where the developers just weren't impressed. Yet once I land a job I usually tend to be in the top 25%, because most of the requisite skills are not algorithms, which I'm not particularly practiced at ...
- WalterBright 8y agoHR people often know little about programming, and will just compare bullet lists of requirements with the resume bullet points. People with unusual skills don't get hired through the HR front door, they come in the side door.
- giancarlostoro 8y agoThis is so true. I got my first (and current) programming job cause someone I knew at college recommended me. I didn't talk to HR till after they decided to hire me. So networking is important. Keep in touch with developers you meet at different jobs. You never know when they might land you your next job. It can be easier to skip HR and go straight to the person who will actually be your boss (directly or indirectly) for the hiring process imho. Edit: wrote "talk to me" instead of "hire me"
- ashleyn 8y agoOne day I decided to write a simple lexer-parser. It's really not black magic as it's commonly made out to be. You read in one character at a time to build "tokens" (e.g. one-to-n character sequences meaning something like "assign", "equals", "add") and then you use recursive methods to return data structures built out of the tokens. Honestly, the hardest part is remembering mathematical precedence, which doesn't even have much to do with parsing per se. Of course, a compiler backend is a much deeper concept, getting into things like register colouring and such. If you were to write a simple stack-based VM, it'd be much simpler. I've thought of doing exactly this for embedded systems projects where all I have is Assembly, or a very bad C compiler.
- SilasX 8y agoYes, that was my experience on the nand2tetris course, which teaches that as project 10 and 11: http://nand2tetris.org/course.php http://nand2tetris.org/course.php Interestiny, the toy language you’re writing a compiler for doesn’t have operator precedence except for parentheses, so it sidesteps that problem.
- Forge36 8y agoAnnoying thing I learned from doing that: source code does not follow a recursive structure. Preprocessor directives allow for some really strange structures. Of course it only caused my problems for a single file at work. I think a custom stack I can read through when the parsing gets weird makes slightly more sense in retrospect.
- setr 8y agonever wrote a c parser but I don't see why the preprocessor would change it from being recursive as long as C is; after preprocessing finishes, you should just have normal C?
- userbinator 8y agoA recommended article for those who want to know more about how to parse expressions with precedence very simply and easily: https://www.engr.mun.ca/~theo/Misc/exp_parsing.htm https://www.engr.mun.ca/~theo/Misc/exp_parsing.htm
- Lerc 8y agoI'm taking this path. So far I have The emulator -> https://github.com/Lerc/kwak-8 https://github.com/Lerc/kwak-8 An assembler -> https://github.com/Lerc/AvrAsm https://github.com/Lerc/AvrAsm A texbed playground -> http://fingswotidun.com/avr/AvrAsm/Testbed/ http://fingswotidun.com/avr/AvrAsm/Testbed/ In hindsight, attempting an assembler before a full compiler is a really good idea, It lets you encounter a lot of the pitfalls before you hit them in a much more difficult environment.
- WalterBright 8y agoIt'll also help you when your language needs a built in assembler! https://dlang.org/spec/iasm.html https://dlang.org/spec/iasm.html
- wglb 8y agoAnd as an example of someone who took this particular bull by the horns: https://news.ycombinator.com/item?id=16900938 https://news.ycombinator.com/item?id=16900938
- VHRanger 8y agoD is a great language. It simply lacks in hype like other languages in the same space. Otherwise I find little to complain about it as a casual user
- chemicalcrux 8y agoThat's been my experience as well. I haven't done a great deal of work with it, but the work I did felt very nice. It's a refreshing improvement upon older, flawed languages...but doesn't seem to have the evangelical community that, say, Rust has behind it. I wonder why that is? Maybe it just needs a cooler name (:
- giancarlostoro 8y agoThe Dust programming language? Joke aside, I fear "D" came before Search Engine product names were considered. Sadly sometimes I google "dlang" and still get some odd results.
- lordnacho 8y agoI hear so many great things about D, but I haven't started coding in it yet. A friend of mine has gotten in there, coding up his new trading platform in it. Also virtually all his social media posts are about D, so he's keen. Suppose I am a c++ guy who does a lot of time sensitive code. Who else has made the leap, and what were your impressions? How often do you turn up nothing on stackoverflow? How often do you find there's no lib where you'd expect to have a few in c++?
- rufius 8y agoThis is sort of a sideways answer... I wrote some D code for a bit and I enjoyed it. The FFI story is solid and that made interop nice. That said, GC may be a concern for timing sensitive code. That said, since Rust hit 1.0 and the language got cleaned up, I’ve stopped writing D at all. Not plugging Rust, just the facts. Better language for my space.
- VHRanger 8y agoYou can link to c++ code in D (you do need to declare function signatures on the D side, etc.) but overall c++ compatibility is good, so it's less of a problem than you'd expect
- lordnacho 8y agoYeah but then I need a compelling reason to glue those things together in a new language?
- johannes1234321 8y agoThe reason is that you are more comfortable or efficient in the new language, but want to access legacy. Having to recreate everything for scratch is a massive effort, however gradually refactoring an application and having access to huge amounts of third-party libs is an enabler. (while all those libs will use non-idiomatic patterns, so it has to be contained)
- WalterBright 8y ago
- leshow 8y ago> The path that led Walter Bright to write a language, now among the top 20 most used, began with curiosity — and an insult. Is D really a top 20 language? I don't remember seeing it anywhere close to the top 20. https://www.tiobe.com/tiobe-index/ https://www.tiobe.com/tiobe-index/ has them in 31
- octohedron 8y agoExactly, just read the first line of the article and closed it.
- ac2u 8y agoShould have read the publish date just above the first line ;P
- qznc 8y agoIt was at #12 in March 2009: https://www.tiobe.com/tiobe-index/d/ https://www.tiobe.com/tiobe-index/d/
- akvadrako 8y ago
- z3t4 8y agoD is one of the few languages that allows named scoped imports.
- wtetzner 8y agoScala is the only other one I'm aware of.
- vanderZwan 8y agoI think that was a thing that Alex highlighted as an unexpectedly great thing in the language in one of his D talks (on mobile, can't find it right now) because it enabled all kinds of neat organisational tricks
- twic 8y agoWhat are those? I don't know D, and I had a quick Google, but couldn't find anything by exactly that name - apologies for the lazy question.
- skocznymroczny 8y agovoid foo() { import std.stdio; writeln("sup") }
- xfer 8y agoYou can do that in Ocaml too, let open Foo in expr.
- gmfawcett 8y agoIt's tricky to do an apples-to-apples comparison. Imports in D conflate two distinct concepts (in a helpful way): declaring a module dependency, and introducing names into the local namespace. Not all languages work the same, though. Ocaml, for example, has great support for namespace updates (`let module M = TheModule in ...` and `let open TheModule in ...` and `module MyModule = struct open TheModule ...`). But they are slightly less significant in Ocaml, because any module that has been linked into the program is available everywhere in the program: you can just write `let result = TheModule.call_something () in ...`, anywhere you like, with no "imports". Linkages (dependencies) are handled externally at the tooling level. It's certainly convenient that an `import` inside a D function body can tackle both issues at once.
- curtis 8y agoBack when Andrei Alexandrescu was working at Facebook, I had hoped that Facebook would adopt D as a standard language. That didn't happen, and it seems unlikely that D will get a powerful corporate sponsor. I think that would have greatly helped D not just in terms of resources, but also in terms of popularity. In an ideal world, good programming languages would win or lose on their own merits, but that doesn't seem to be the case in the world we actually live in.
- bachmeier 8y ago> good programming languages would win or lose on their own merits Well I suppose that depends on what you mean by "merits". D has struggled with things like IDE support and breaking changes. A lot of that is now cleared up or being worked on as the language has seen increased activity over the last few years. I expect remaining issues to get cleaned up in the near future. Another thing that kept folks away was the garbage collector. Quite a lot of work is being done to make it possible to use as much of the language as possible without the GC. Nonetheless, for many potential users, fear of the GC was a reason to not use D.
- WalterBright 8y agoYou can use DasBetterC now with no GC whatsoever.
- grok2 8y agoWhat is DasBetterC?
- girvo 8y agoSubset of the D language that acts as a “better C”. No GC, manual allocation etc. and no runtime I believe.
- NonEUCitizen 8y agoD as a Better C from Walter's post: https://news.ycombinator.com/item?id=17192702 https://news.ycombinator.com/item?id=17192702
- dang 8y agoDiscussed at the time: https://news.ycombinator.com/item?id=7555426 https://news.ycombinator.com/item?id=7555426.
- WalterBright 8y agoLogged in today and saw this! Walter here, AMA!
- klez 8y agoHey, thanks for the opportunity :) Suppose I was writing systems software. Considering I know neither, why would I invest time learning D instead of C++? Does D offer anything in that regard?
- WalterBright 8y agoD has checkable memory safety. In C++, memory safe code relies on following best practices.
- jcelerier 8y ago-fsanitize=address in C++ is pretty much checked memory safety.
- pjmlp 8y agoIn which page of ISO C++ it is described? And on the C++ compilers that support such language extension, how does it work with binary dependencies?
- jcelerier 8y ago> In which page of ISO C++ it is described? why would it matter ? AFAIK D doesn't even have an ISO standard. > And on the C++ compilers that support such language extension, how does it work with binary dependencies? you at least get whole-program safety for libc calls since it works by replacing such calls through dynamic loading
- pjmlp 8y ago> why would it matter ? AFAIK D doesn't even have an ISO standard. Sure it does. D is defined by the DMD compiler as the reference implementation. Whatever DMD allows for minus implementation bugs, is what the D programming language means. C++ is defined by an ISO standard, a document that specifies what every implementation is required to implement. So any D developer can be sure their code is compliant as long as DMD accepts it, while a C++ developer needs to pay attention how close their favorite compiler is to ISO C++. > you at least get whole-program safety for libc calls since it works by replacing such calls through dynamic loading Libc is a very tiny portion of any industrial grade C++ application, and only relevant in open source systems, as it is shipped in binary form in other platforms.
- mathieuh 8y agoJust so you know, when I visited the article from my iPad I was prompted to download one of those scam iPad cleaner apps. It’s a 10” iPad Pro (maybe you can check the log and see which advertiser is being naughty).
- deleted 8y ago[deleted]
- jbb67 8y agoD is the language I really like, and always intend to use for my next project, and have been saying this for the last 5 years. Every time there is something that makes me decide to use C or C++ just one more time. I don't even think it's mostly valid reasons. Well I'm just about to restart an opengl project so I think I'll go wholeheartedly into D this time
- vram22 8y agoFor anyone new to and interested in D, here are a handful of command-line utilities and other small programs written in D (on my blog), which may help give an idea about (just some of) the kinds of things that D can do, and whet your appetite for more: https://jugad2.blogspot.com/search/label/DLang https://jugad2.blogspot.com/search/label/DLang A few of the posts in that sub-feed are about D videos and confs, so you can skip past those if you want. Some of the videos are interesting too, though.