6 ms·
>I find that the dumbest code is the best code Not always, though. See every bug and exploit with C arrays or pointers that exists because C devs think even m
by krapp 7y ago
>I find that the dumbest code is the best code
Not always, though.
See every bug and exploit with C arrays or pointers that exists because C devs think even minimal attempts at safety are too complicated or slow, or old-style PHP code that builds SQL queries out of printf strings directly from POST values, or probably countless other examples in other languages. C++ code that uses raw pointers instead of references or that uses std::vector but never actually bothers to bounds-check anything.
It's entirely possible for code to be too dumb for its own good.
- deepaksurti 7y ago> Not always, though. See every bug and exploit with C arrays ... That can also be perceived as a a flaw of the language design in that it does not allow one to write dumb, safe and fast code. Which are such languages in existence today? edit: fixed typos
- gordaco 7y agoI would say Java, which I suspect is bound to be a bit of an unpopular opinion here (I expect more startup people than enterprise denizens in HN); but the more I think about it, the more sure I'm that it fits the bill: - Dumb: you bet. The inclusion of lambdas has shaken things a little, but usually Java code is straightforward with little space for "cleverness". The counterpoint to this, of course, would be the memes about AbstractFactoryFactoryImplementationSubclassDispatcher class names and all that, which IMHO does not represent much actual Java code out there. There are good reasons why big corps prefer Java, and readability is one of them. As a programmer, I've found it easier to jump into a Java codebase I didn't know much about than in any other language. And this has happened even when I had little experience in Java. - Safe: yes. You have to go out of your way to be unsafe in Java. Memory allocation is done for you and the try-with-resources idiom is almost as good as C++ RAII. - Fast: also yes. Usually about 2x or 3x the run time of C/C++ code, some times even less.
- Koshkin 7y agoIndeed, despite all criticisms Java as a technology is one of the best things that has happened to the software industry, next to Linux.
- danielscrubs 7y agoJava won because of its humungous and stable standard library with the full backing of Sun (and Sun was huge presence at the time). It was quite a joy to have pretty much all the functions you could ever need (not really but it felt like it at least) at your fingertips without having to do manual dependency management. As a technology it really didn't have much to give. Object Pascal was born in 1986, Ada in 1980 with language support for design by contract, JIT with Lisp in 1960 and Java came in 1995.
- neutronicus 7y agoThey did the legwork to figure out browser Applets as well.
- bitwize 7y agoIt wasn't just Sun, though they did the heavy lifting marketing-wise. The Apache Project also hopped on the Java train way early and produced a crapton of libraries which made developing internet applications way easier, especially for corporate schlubs who might have been previously exposed to Microsoft (or, ugh, IBM) systems but didn't have acceas to the internet foljlore Unix gurus had.
- jbverschoor 7y agoCleverness in this case means: - Too many jumps in code logic instead of serial logic - Premature optimization 1: messy code (using lots of unclear variables etc), this is common within calculations, and games have quite some of those. - Premature optimization 2: failing to properly architect - Single-character variables. Java IDEs default to fullvars - Bad function/method names - Not expressing what you mean (for i= vs foreach) - Too many abstraction layers / IoC - Too many sideeffects / complex code (interwoven code) - Callback hell Nr 1 is important.. You need to be able to "follow the code". If that requires you to create a DSL in order to code something async in a serial way, then by all means do so. For example with: network (duh.), but also in games: character dialogs, animations etc. etc.
- schaefer 7y ago> Which are such languages in existence today? Zig will be there soon.
- ironmagma 7y agoZig first needs to have code samples in the documentation that compile.
- monocasa 7y agoGolang is a pretty good example. > The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt. ~ Rob Pike
- Gibbon1 7y agoIt's not really the fault of programmers or the language but pernicious and stubborn failure on the part of the C Standards Committee.
- eska 7y agoThis sounds unnecessarily dismissive of C programmers. I see a lot of C programmers that shit on C++ but are intrigued by Rust, e.g. Linux kernel developers allowing modules to be written in Rust.
- neutronicus 7y agoYes, Rust is making a smart marketing decision by capitalizing on C programmers' antipathy towards C++ (and everyone else's). I don't know that this is, ipso facto, evidence of anything about C programmers other than that they really hate C++, though.
- eska 7y agoYour view sounds very jaded to me. Maybe Rust is liked more by C programmers because they prefer its approach, rather than C++'s? Calling it a marketing ploy seems without merit to me.
- neutronicus 7y agoI'm a C++ developer who occasionally writes Rust. The experience of writing new code in one is very, very similar to the experience of writing new code in the other, right down to the compile times. The lifetime analysis in Rust is nice and pretty far ahead of what static analyzers can do in C++, but Rust Generics are a pretty weak approximation to Templates. Rust has better Browser integration, C++ has Qt. One imagines the languages will catch up to one another on these fronts. C++ has Inheritance, Rust settles for Interface Polymorphism (one can reasonably prefer either). The one really big difference here is actually cultural - the Rust community all agrees on Cargo, and it's a bit happier to compile the world and distribute static binaries, which removes massive headaches for both the developer and the end user while setting the language up for an eventual, Electron-style tragedy of the commons where a user is running like 8 Rust apps with their own copies of the same 14 libraries resident in memory (but that's a good problem to have because it means you've displaced C/C++ as the linguae francae of native app development). I guess the other really big difference is that there is no legacy Rust code. I like C++, but I can understand hating it. But if you have written new code in C++17, and hated it ... I suspect you are going to hate writing Rust too. And if you love Rust and hate C++ ... I suspect what you hate is legacy C++ from 2005. Finally, I was explicitly not concluding anything about C Programmers beyond that they hate C++.
- jstimpfle 7y ago> C++ code that uses raw pointers instead of references or that uses std::vector but never actually bothers to bounds-check anything. When is the last time you accidentally mutated a raw pointer? My opinion is that references are just another C++ feature that solves a non-existent problem and has severe disadvantages. And that is non-orthogonality / combinatoric type system explosion. I've seen more than one codebase that consisted to a large degree of adapters for calling the same functionality.