5 ms·
The compiler doesn't optimize at all right now, but aims for simplicity. There was an article some time back about the best switches to use for most C compilers
by greggirwin 10y ago
The compiler doesn't optimize at all right now, but aims for simplicity. There was an article some time back about the best switches to use for most C compilers: compile for size. It often gave some of the best performance IIRC, the rationale being better cache use on chips.
- throwaway7645 10y agoWhen will it optimize, or will it? I'd like to see some benchmarks on the main page for a couple of algorithms like Fibbonaci in both Red & Red System compared to a popular scripting language like Python and a popular office language like Java. I would hope Red is close to Python in speed and Red System to Java. Obviously it won't be yet, but performance is important and if it isn't a priority, I'll look elsewhere (note that I don't mean that negatively...I'm very impressed with the Red community, I just want to have my 1929 Latour with my Kobe beef riding in my personal spaceship alright ;) ). Forgive me.
- greggirwin 10y agoAs you know, benchmarks are often fun but just as often meaningless. And premature optimization being the root of...anyway. ;) It may come. JIT is planned. I don't know of any language that wants to be slow, and I can only speak for myself, but I think Red's goal is one of overall performance. In 1991, people told me I couldn't use VB, because it was too slow. I countered that my app would be 12-18 weeks faster than their C app. :) Still, this is 2017 and we have options. Red won't be fast enough for everyone, or everything. But it will be faster than a lot of alternatives for many purposes. What kind of stuff do you need maximum performance for, how much of your work is that, and what are some of your real-world examples and performance criteria? I work best with concrete examples.
- throwaway7645 10y agoOne of the things that initially excited me was being able to write code like Python for parsing and automating office tasks and then dropping down to RedSystem for numerical work like matrices and various algorithms and perhaps some embedded work like talking to an arduino. If it could truly do that, I'd give up needing to know 9 languages depending on what I'm doing.
- greggirwin 10y agoThat is exactly its goal.
- throwaway7645 10y agoAwesome. That's why I hope the System code is fairly fast, because compilation won't matter if it is still super slow. If y'all do a version on the JVM you get fast, but also a bloated dependency and then you're not much different than anything else with a JVM backend (Scala, Clojure, Groovy, Perl6, PicoLisp...etc). I really am excited by Red btw. Hopefully performance can be a thing at some point before 1.0. The Perl6 people released their 6.0c (basically 1.0) where the language is mostly frozen, and are now spending 90% of development time on optimizations (honestly I pulled that number out of my butt, but the ratio is in that favor) because it is so slow for most things currently. I'm not sure if that was smart as now people are thinking"I waited 15 years for this?". Overall another great language I'd happily throw away Python for, but it has some work to do before I can really use it. I hope Red doesn't fall into the same trap.
- greggirwin 10y agoOne of the nice things about Red is the low barrier of entry, for experimenting and getting a taste. If you can drop an EXE somewhere, you can run it and try things. If you can run "red -c ..." you can compile and include Red/System code.
- thinline 10y agoYou might also want to look at ren-C (https://github.com/metaeducation/ren-c https://github.com/metaeducation/ren-c), a fork of the open sourced Rebol 3 (which isn't an active repo). It can be build with an embedded TCC so you can write C in-line for functions where you need a speed boost.
- vanderZwan 10y agoExcept for the embedding part, Julia is pretty good for all other purposes already, isn't it? And I say this as someone who is excited by both Red and Julia.
- nickpsecurity 10y agoYou're focing a lot on just one point. Many people will sacrifice ultra-optimization or even optimization itself for productivity and flexibility. There's whole industries dedicated to it. A cheat, though, would be extracting lowest-level form to C to leverage their compilers. Lots of languages did that.
- throwaway7645 10y agoAgreed, but those languages aren't trying to be a "Full-Stack" language. With great power...blah blah you get the point ;)
- nickpsecurity 10y agoPreScheme, Nim... Very powerful. Compiled to C for performance.
- throwaway7645 10y agoYea, kinda see what you're saying, but not 100% at least with Nim. It has a nice high level syntax, but no REPL shell, so not quite as high level as Red. Using on Windows also requires MinGW, which is kind of hacky.
- greggirwin 10y agoPer Nick's comment, above, Red likely won't generate C, because that would add a dependency on a C toolchain. Red is completely self-contained, and would like to stay that way. However, you could write those tight bits in C and put them in a DLL or something, to call from Red.
- throwaway7645 10y agoAlso very nice. If I added a C dependency like GSL as a DDL, Red could compile a binary using it?
- greggirwin 10y agoIt has an FFI, but no static linking to C libs at this time. Not sure if that will come, but technically it's possible, as Red's linker is written in Red/System. I'm a huge fan of Pieter Hintjens' work, and have written lots of code generators and FSM stuff, inspired by GSL and Libero.
- pekr 10y agoI am not a profi coder, mostly a self community coordinator, but am with Rebol and Red since its beginning, so I do remember, what was said, and what not. As for the optimisation, recently a generated exe is kind of cca 4 times slower than C, if I remember correctly. With optimisations, it was said we should get into 1.5-2 territory, whereas anything below such numbers, would require quite extensive work. Please Red gurus correct me, if I remember it incorrectly ...
- throwaway7645 10y agoI could easily live with 1/2 C's speed with Red's power. That is reasonable.