3 ms·
This is why everyone should study compilers and machine architecture in college. Anyway, it's interesting that he chose to label what he ended up with as "Lisp
by nostrademons 13y ago
This is why everyone should study compilers and machine architecture in college.
Anyway, it's interesting that he chose to label what he ended up with as "Lisp". I would've stopped at assembly, eg. in LLVM IR:
%result = icmp gt i8 %price, 100
br i1 %result, label %Discount1, label %Discount2
Discount1:
ret i8 10
Discount2:
ret i8 5
The key idea here is that underneath everything you tell the computer to do is boolean logic and transistor circuits. Yes, even Lisp S-exprs; it's not really correct to say "Lisp has no syntax", it has a very simple syntax that is trivially parseable. Even LLVM assembly is a translation layer, as is LLVM itself; underneath it on my computer is an i86 processor, and underneath it in my phone is an ARM-architecture Snapdragon.
Once you understand that, you realize that all of these languages and frameworks and libraries and databases are just tools, and they exist for your convenience. They're there to let computers handle things that humans are really bad at. For example, memorizing memory layouts really sucks; let a computer map out your structs onto memory. Managing heap memory really sucks; let a garbage collector do it. Managing register allocation really sucks; let a compiler do it. Managing syntax kind of sucks; let a parser slap something more friendly on top of it, or don't and use Lisp. Managing vtables kind of sucks; let C++ or Java hide it behind a class, or don't and continue to use C.
Once you've gotten into this mindset, you're free from the religious wars that surround technologies, because you realize it's all just tools that compile down to machine code at the end. And you understand when a tool might be useful, and when you could just as easily implement it yourself, and when it once was useful but has since ceased to be.
- chongli 13y agoOnce you've gotten into this mindset, you're free from the religious wars that surround technologies That seems all fine and well, but you're ignoring the elephant in the room: compatibility. You aren't free to choose your tools as you please if compatibility is one of your requirements. This little bit of impurity combines with network effects to create big problems. Compatibility along with all its attendant problems is the single most valid reason for engaging in a religious war over technology.
- tikhonj 13y agoThat's one philosophy. Your code exists to be run by your computer. Personally, I take a different one: the computer exists to run my code. LLVM, x86, ARM... all just implementation details. Sometimes they're unavoidable, but c'est la vie. Ultimately, what I care about is semantics. I care about what my program means--the logic it represents. After all, that's the whole point, the end goal. The fact that it's running on a physical computer is just a detail, albeit an important one. A programming language is more about shaping my thoughts and forming my logic than actually running. Choosing a programming language is incredibly important--it affects what I can say, how I can say it and even how I think. And that's the most important part.
- millstone 13y agoThe end goal of the web browser in which I'm typing this is not to represent some piece of abstract logic, but to drive the physical hardware: to change the color of pixels on my screen, to sense and react to my input. Attempt to distill it to some piece of logic or mathematics, and you end up with something useless, an absurdity. The original task was "apply a seasonal rebate to our products," but none of the programs actually accomplished this feat. They contained some logic which might be useful in such a program, but none of them applied anything. Logic on its own is sterile.
- theaeolist 13y agoI thought the end goal is to display the page. I would say that "to change the color of pixels on my screen, to sense and react to my input" is a means to an end, not "the end goal".
- Tyr42 13y agoThis was a really neat discussion to watch. Devotional vs Observational semantics. When I'm in my algorithms class and we have a code snippet to find a minimum spanning tree, we don't even have some machine to compile it down to, but because we have denoted some meaning to bit of the program, we can even prove that the meaning of the entire program is to output the MST.
- shurcooL 13y agoThis is so, but why are our language A <-> language B translation tools so bad, that people end up having to manually convert code from one language to another (e.g. if some code exists in language A, but you need its functionality in language B)?
- etherealG 13y agobecause some of the essence of what you wanted to express is lost when you compile. it's not a one to one mapping. otherwise we would just compile and decompile into each form. intermediates like lvm come close to trying to do this i think? not sure if they allow going back to the original form from the IL though. oh, and lastly, think of trying to express a feature in 1 high level language with another that doesn't support that feature. it's quite hard to gain expression when it's not idiomatic in that language. kind of similar to spoken language actually. some concepts in some languages form as single words or phrases that never really translate well to other spoken languages because the place that other language formed never had that concept.
- userbinator 13y agoCompilers have gotten better, but in comparison to a human, they are still not particularly good at the edge cases. Things like instruction selection and register allocation in particular, sometimes I wish I had the time to write my own more intelligent algorithms for them.
- sklivvz1971 13y agoI agree. The point of a programming language is making complex stuff readable. One can certainly hand-assemble and write software as a series of byte values and I have done so in the past because of necessity. It's very boring and difficult. In this respect, I don't find Lisp readable or intuitive at all, but that's just me, I'm probably not smart enough:-)
- m0skit0 13y agoIt's not about being smart or not, it's simply getting used to it. Probably chinese doesn't seem readable or intuitive to you, but a chinese also don't find english readable or intuitive.
- Someone 13y ago"This is why everyone should study compilers and machine architecture in college." Everyone? For starters, I would exclude those studying law, medicine, most of the 'soft' sciences, and probably chemistry and physics, too. Yes, most of these might be better of having some knowledge of programming, but I doubt they really need to know what a parse tree is. Hand-waving "3+2x6" is three plus (two times six), just as in normal life" probably is sufficient for most of them. Even math majors need not know about compilers and machine architecture. That leaves a tiny fragment of 'everyone in college': just the computer science students and, to a lesser degree, the software engineering ones. I would present the latter to parse trees, but I would not go in any depth there. Really, for most people doing software engineering, compilers can be black boxes.