[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Are all languages equal?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 1

File: 1445206368138.jpg (101KB, 1024x904px) Image search: [Google]
1445206368138.jpg
101KB, 1024x904px
Are all languages equal?

In theory, doesn't a compiler simply translate high level code (+meme optimization) into binary machine code?
If so, could it be possible to write two identical programs (binaries) with two different languages (i.e. assembli and c).
And could it be possible to write a compiler for interpreted languages (such as python)?
Or a compiler to bridge between languages (i.e. write python in c++, c++ in python)?
>>
Assembly
>>
>>60813651
>(+meme optimization)

what did he meme by this
>>
>In theory, doesn't a compiler simply translate high level code (+meme optimization) into binary machine code?
Not in theory, that's exactly what it does.
>If so, could it be possible to write two identical programs (binaries) with two different languages (i.e. assembli and c).
What do you mean by identical? You could make two programs that do the same thing because both of these languages are turing complete. If you're asking if they would both turn out to be identical files upon compilation, then most likely not. However in theory you probably could accomplish this meaningless goal with enough autism.
>And could it be possible to write a compiler for interpreted languages (such as python)?
Yeah these exist for a lot of scripting languages since using an interpreter isn't always practical/desired. Python has a bunch of these.
>Or a compiler to bridge between languages (i.e. write python in c++, c++ in python)?
You mean like writing a C++ function for use in a Python program? Yes you can. It's called "extending" and it's a pretty common practice. Some people see Python as a shim for C.

>>60813675
I'm guessing he means when a compiler will take the liberty to turn expressions like "15 + 3" into "18." I don't know why he called it a meme though since it's pretty good functionality and often produces a better program than an assembly expert would. I can't prove it though.
>>
>>60813651
>Are all languages equal?
No.
>In theory, doesn't a compiler simply translate high level code (+meme optimization) into binary machine code?
Yes, but depending on the semantics a compiler can more or less assumptions, which leads to "meme optimizations", which is where performance comes from. It comes from both what you can express and what the language restricts.
>If so, could it be possible to write two identical programs (binaries) with two different languages (i.e. assembli and c).
Yes, but both of those languages allows semantics the other one doesn't, making each of them faster in special cases. Mostly in case of assembly though, C is actually surprisingly bad to optimize in some regards.
>And could it be possible to write a compiler for interpreted languages (such as python)?
Yes, but since it is still dynamically typed - among other things, the compiler must add runtime guards. Which is why both PyPy and Cython have special constructs that allow to express some restrictions to get some okay performance at all.
>Or a compiler to bridge between languages (i.e. write python in c++, c++ in python)?
There are actually quite a lot language interaction methods. That said, embedding Python in C++ (and vice versa) is possible, but not necessarily a good idea.
>>
>>60813651
>Are all languages equal?
Turning high level code into machine code is a big task that can be done in a variety of ways. Each language accomplishes this using its own unique method for its own unique reasons. Some languages try to have simple syntax, others want more verbose code. Some are compiled, others interpreted, some a mix of both. Some are built around objects others are purely functional. Some are even made to be difficult to use and understand on purpose.

They all do the same task in a different way, and depending on the needs of your project you'd likely choose a language that fits.
>>
>>60815120
>Which is why both PyPy and Cython have special constructs that allow to express some restrictions
Cython, yes, but PyPy is not restrictive (other than no C dependencies) because it uses JIT compilation
>>
>>60815624
IIRC PyPy has special functions that are optimized under the hood, like preallocated arrays.
JIT compilation is far from the silver bullet some believe.
Thread posts: 8
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.