r/programming • • Dec 05 '15

Microsoft Edge’s JavaScript engine to go open-source

https://blogs.windows.com/msedgedev/2015/12/05/open-source-chakra-core/
1.6k Upvotes

504 comments sorted by

View all comments

Show parent comments

37

u/ironnomi Dec 06 '15

Having seen both code bases extensively, I can say there can be NO direct code comparisons between the two.

In general, Apple's ObjC code easily takes up 4x the space as the typical Windows C++ code.

1

u/[deleted] Dec 06 '15

Interesting, as someone who'd love to know what happens in the little black box, is there anything you're allowed tell us that's interesting or quirky about either codebase? From some of the odd behaviours I've seen from windows over the years, I've often wondered just WTF is really going on.

4

u/tetroxid Dec 06 '15

If you're interested in the implementation of an operating system (which is actually hugely complex and awesome) I recommend reading about the Linux kernel, and the kernel's source code.

7

u/[deleted] Dec 06 '15

I've read many components, (worked a little on radeon FOSS driver support). Linux makes sense to me, and I'd say I have a decent grasp of what's going on there (at least in my own, self-assembled system). But when I use windows, I usually come away horrified by the degree to which basic functions don't seem to be encapsulated and isolated from one another (I suppose the best recent example is the discovery of how the scrollbars have a hook deep within the kernel). Id love to know what on earth is going on there. It seems to work like a house of cards, which gets progressively more antiquated as it gets deeper towards the core.

10

u/tetroxid Dec 06 '15

Yes, that was my experience as well. For example, the GUI runs in kernel space (insane, right?). I imagine it was done for performance reasons.

There is huge debt in the codebase. Bad decisions were made (hey, it happens) but they were never cleaned up. My favourite example is NTFS. The performance degradation over time is so sad it's almost funny. I also like how it allocates space for the master file table but doesn't free it once the table shrinks again, effectively occupying space even when nothing's saved there.

Another good one is that if for some reason the system tray icon for windows update cannot be displayed, windows update stops working. Yep you read that right.

Oh, and on the topic of windows update: I would love to find out what the system is actually doing while it's saying "searching for updates" for 30 minutes or longer. In my mind all it has to do is send a list of local patches and versions and compare that to a remote version. Should take seconds, like running apt-get update. But no, it takes forever. I want to know why.

3

u/Cuddlefluff_Grim Dec 07 '15

There is huge debt in the codebase. Bad decisions were made (hey, it happens) but they were never cleaned up.

GUI as a terminal server, asterisk expanded by the command line, text piping as makeshift IPC, user id's as integer, passwords stored in text files on seemingly arbitrary locations, only 1 kernel ring, single unified file system, POSIX file attributes, dot files, everything-is-a-file-except-when-it-isn't, "standards" reached by way of argument.. If you're going to focus on the bad parts, nobody wins.

2

u/tetroxid Dec 07 '15

GUI as a terminal server

Could you expand on that? Do you mean the network-transparent nature of X?

Asterisk expanded by command line

Good decision. Would you rather have every program expand it themselves, inconsistently and with huge code duplication?

Text piping as makeshift IPC

Pipes are not meant to be used as a replacement for IPC.

User IDs as integers

Would you rather have floats?

Passwords stored in text files

I prefer this to a proprietary database that is ultimately just a file. Also passwords are never stored, only their hashes and salts.

Only 1 kernel ring

That is true.

Single unified file system

It only appears that way. Anyways, I think this is a huge advantage.

POSIX file attributes

What's bad about them?

Dotfiles

It's a convention. I prefer text files over a central registry any day. Even Microsoft Engineers conceded that a central registry was a bad decision. It's an excellent idea from a software engineering and architecture point of view, but as we all know it doesn't really work in practice.

3

u/Cuddlefluff_Grim Dec 07 '15

GUI as a terminal server

Could you expand on that? Do you mean the network-transparent nature of X?

Sort of like a "micro service" which is really hip these days :P Yes, X runs as a network service, so every call to the GUI needs to go through an extra layer (with added latency). I think the reasoning was to avoid the problem of protected mode, and then you had few other reliable options in those days.

Asterisk expanded by command line

Good decision. Would you rather have every program expand it themselves, inconsistently and with huge code duplication?

In DOS, there was a software interrupt to expand asterisk parameters from the command line. Windows has since the very beginning provided this functionality as a library for C (setargv).

The bad decision of making the command line expand it is because you can do this :

mkdir .\testfolder
cat "test" > ./-r
rm ./*

and you will see that the directory testfolder also gets mysteriously deleted, becuase the file "-r" gets thrown in as a command line argument. It's not a good decision, it's terrible. It was done to save time, not because it was a good idea.

Text piping as makeshift IPC

Pipes are not meant to be used as a replacement for IPC.

I agree.

User IDs as integers

Would you rather have floats?

No, I'd like a number which could uniquely identify a user on a network or domain. On Unix (due to bad choices), this means you need an abstraction on top of the uses, but the user is ultimately always machine-bound and nontransferable. Of course, it's not a direct problem per se because you can create these huge wrapping systems that "fix" the flaws by adding a ton of crap on top of it to make it behave more like a network-enabled roaming user account.

Passwords stored in text files

I prefer this to a proprietary database that is ultimately just a file. Also passwords are never stored, only their hashes and salts.

Problem is that this technique is inherently insecure, especially when you take into consideration that a lot of Unix mentality is "just get it done". Passwords aren't even required to be hashed (like with htpasswd). Windows provides methods of storing user names and passwords in a secure, standardized way that is easy to use for the programmers.

Single unified file system

It only appears that way. Anyways, I think this is a huge advantage.

It used to be a huge advantage. In Mac OS for instance, the file system is actively hidden from the user because of its complexity.

Oh, talking of which; the root directory names and commands. Commands and directories are named like they are because of the types of keyboards they used in 1970, which made typing exhausting or even painful. There was discussions about renaming them to be more comprehensible, but it was rejected due to fear of breaking backwards compatibility.

POSIX file attributes

What's bad about them?

Not exactly the master dashboard of file system security, is it? It's incredibly restrictive, and on larger networks which requires more control you basically have to abstract it away and stuff more fine grained control into an external database and provide access via an intermediate software. When you compare POSIX file attributes to Windows ACL, you will see how incredibly restrictive it is in comparison.

Dotfiles

It's a convention. I prefer text files over a central registry any day. Even Microsoft Engineers conceded that a central registry was a bad decision. It's an excellent idea from a software engineering and architecture point of view, but as we all know it doesn't really work in practice.

No, I mean that files starting with . are hidden, which is a convention because it utilizes a behavior from ls which prevents display of files that start with . so that . and .. wouldn't show up in the list. It's a convention because someone read the source code of ls and saw that it said to exclude files if(filename[0] == '.'), and decided that just using that would let them do something that wasn't supported by the file system. It's the very definition of a hack.

Yes, the Windows registry was a bad decision. It's another place that needs cleaning and it's ultimately unnecessary because on Windows (well, post Windows 2000 anyway) programs are generally expected to be self-contained and keep to themselves. It made more sense back when programs shared more code and modules (due to memory restrictions), now it's just a nuisance. The Windows registry has always been a problem, and unfortunately I don't see it getting removed any day soon..

My point is that there are more than enough bad stuff to obsess about in any operating system. Windows isn't all bad, there are plenty of good parts as well.

2

u/dvdkon Dec 07 '15

There are ACLs in Linux and other UNIX-like OSs, too. They just aren't used most of the time, because they're not needed. Just look at the permissions on Windows' system files and then on UNIX system files.

0

u/Cuddlefluff_Grim Dec 07 '15

You mean chown, setuid and setgid? That's what I'm talking about, it's extremely limited compared to Windows, and for Windows the attributes can be set for a domain user (or multiple domain users or groups) and not just machine-local objects - which the attributes inherently are in Unix unless you provide some sort of abstraction layer to provide more functionality. This is a well known limitation in Unix.

→ More replies (0)

1

u/tetroxid Dec 07 '15

The bad decision of making the command line expand it is because you can do this: <...>

So what is the alternative? Having rm ignore all files and directories starting with a dash?

No, I'd like a number which could uniquely identify a user on a network or domain.

Every proper Unix environment has LDAP servers providing globally unique IDs for users and groups for this reason, just like every proper Windows environment has a domain controller.

Problem is that this technique is inherently insecure

How so? They're hashed and salted, what more do you want?

Passwords aren't even required to be hashed (like with htpasswd).

That's not true, passwd will give you a list of algorithms to choose from but plain passwords are not supported.

Windows provides methods of storing user names and passwords in a secure, standardized way

Proprietary database that has to be reverse-engineered because Microsoft refuses to provide documentation. And they're not secure, not really, see: https://en.wikipedia.org/wiki/NT_LAN_Manager#Vulnerabilities

standardized way that is easy to use for the programmers

Unix has had the same system calls for authentication and authorisation for ages. Not sure how it could be any easier. Also see PAM vs. no chance to ever customise the authentication and authorisation on Windows ever.

In Mac OS for instance, the file system is actively hidden from the user

Not really. iOS yes, it doesn't really allow access to the filesystem. On OSX, the filesystem is perfectly accessible by the user. Open a terminal on OSX and look around.

Commands and directories are named like they are

Personal preference I guess. I much prefer ls | grep to get-system-files-of-current-directory-cmdlet | search-for-pattern-cmdlet --from-property system.files.filename or whatever it is.

When you compare POSIX file attributes to Windows ACL

Unix had ACLs before Windows even had a file system with permissions of any kind (HP-UX had them in 1992, for example). I agree, the default Unix permissions dating back to the 60s don't cut it today (that's what ACLs are for, no third party software layer necessary). try man setfacl

read the source code of ls and saw that it said to exclude files if(filename[0] == '.'), and decided that just using that would let them do something that wasn't supported by the file system. It's the very definition of a hack.

Yes that's true, originally it was a bug in in ls, and because people started using it for hiding files it was never fixed. I agree, it's a hack.

I'm not saying windows is all bad, I'm just saying Microsoft could do a lot better. And I mean a lot. Windows could be a super nice operating system instead of a good-enough-for-some-things operating system.

By the way, thank you for taking the time to respond in detail. I enjoy discussions like this.

2

u/Cuddlefluff_Grim Dec 07 '15

So what is the alternative? Having rm ignore all files and directories starting with a dash?

There is no alternative right now because too much software depends on this behavior, unfortunately (the bane of software).. Preferably, programs should be responsible for expanding wildcards themselves, which can be a function provided by the operating system via a function call. This has other repurcussions, like that some programs will accept wildcards and others won't, but it will at least be correct.

Every proper Unix environment has LDAP servers providing globally unique IDs for users and groups for this reason, just like every proper Windows environment has a domain controller.

Yep, but this means creating user accounts which are machine-local, but linked to a central server which introduces a huge number of unnecessary steps - especially when we take shared network resources into account.

How so? They're hashed and salted, what more do you want?

For one, people could stop using shadow-files and instead go with more standardized modern approach which is available on *nix, except people don't use them because it's more complicated than just using htpasswd. I don't think people use this system because it's smart or secure, it's a choice of simplicity.

That's not true, passwd will give you a list of algorithms to choose from but plain passwords are not supported.

Passwd is for local system user accounts. You're right, plain text is not supported there. But a very commonly used method for programs to store their own users (like a server application) is htpasswd which does support plain text. Its default is also MD5 which is well known to be too easy for GPU's to bruteforce to be considered secure.

Proprietary database that has to be reverse-engineered because Microsoft refuses to provide documentation. And they're not secure, not really, see: https://en.wikipedia.org/wiki/NT_LAN_Manager#Vulnerabilities

Yes, NTLM was a security nightmare.. Which is why it was replaced in 2001 :P The bug was discovered essentially 9 years after NTLM was officially replaced with Kerberos (of course, Windows is largely bound to a corporate culture, so replacing it takes a long long time)

Unix has had the same system calls for authentication and authorisation for ages. Not sure how it could be any easier. Also see PAM vs. no chance to ever customise the authentication and authorisation on Windows ever.

Windows uses standardized authentication methods; Kerberos and LDAP. There are many alternatives to authentication for Windows, Citrix being one of the more popular.

Not really. iOS yes, it doesn't really allow access to the filesystem. On OSX, the filesystem is perfectly accessible by the user. Open a terminal on OSX and look around.

The finder will not show you the entire file system unless you basically wring its arms behind its back. The terminal is only used by people with non-Mac backgrounds. I have an example here from a personal experience actually.. I was going to demo a site for a customer, and we used all internal IP's for our demonstration (we had actually arranged a meeting for them to come look at it, but they suddenly said they hadn't time), so I had to get them to add a line in the hosts file. So they said I could talk to their "Mac and network expert". He didn't know what the hosts file was, and he most certainly had no idea that there was a root directory on the computer that contained the /etc folder. He had no idea. You can access the entire filesystem on a Mac, but it actively hides most of it. And for good reason.. How would a non-techie have any idea what /opt, /etc, /proc, /bin, /sbin and /var are? I've heard multiple stories of people deleting the /bin folder because they think it's the recycling bin (yes, seriously).

Personal preference I guess. I much prefer ls | grep to get-system-files-of-current-directory-cmdlet | search-for-pattern-cmdlet --from-property system.files.filename or whatever it is.

Yeah, well now that you're used to it and you on beforehand know what you need to type, it's fine. I also prefer the short-hands (which is why Powershell conveniently has aliases for them). But I don't think it's a good idea generally to create systems where you have to know things purely by means of repetition. There might be some middle-ground between Unix and Powershell in this instance..

By the way, thank you for taking the time to respond in detail. I enjoy discussions like this.

Likewise :)

→ More replies (0)

2

u/[deleted] Dec 06 '15

Yep. In many ways I suspect the degradation of windows is a kind of planned obsolescence. It'll crumble to an unusable mess within about 4 years. About equal to the release cycle of the OS.

2

u/the_gnarts Dec 06 '15

My favourite example is NTFS. The performance degradation over time is so sad it's almost funny. I also like how it allocates space for the master file table but doesn't free it once the table shrinks again, effectively occupying space even when nothing's saved there.

PST files, the local storage format of Outlook, are troubled by the same flaw. What’s worse, the size of those files is restricted to around 50 GB, which is easily reached by your run of the mill car salesman whose communication skills peak at power point. So at some point many users face the same seemingly unsolvable problem …

2

u/ironnomi Dec 06 '15

Sorry, for the most part I was only validating the code paths that our code followed. This was for a security architecture review for some code that that Japanese government was using that was deemed to be security critical.

-4

u/badcookies Dec 06 '15

You are telling me that the os is written in objective c?? Why do you think that?

22

u/ironnomi Dec 06 '15

Both OSes are written in multiple languages. Some of OSX is written in ObjC.

At least the parts I've seen were written in C, C++, ASM and ObjC (actually some of the ObjC might have been ObjC++, but my memory isn't that good.)

Windows 7 however was all either C or C++, nothing I was looking at was C#, but I'm sure parts of Win7 were written in it.

You realize of course that those lines of code are not the kernels only right? Any time you see those LoC things they mean everything that they consider part of the OS. It's going to include the kernel, the boot code, the libraries, the utilities, the interfaces, the included apps, everything.

3

u/brobits Dec 06 '15

[project singularity is a C# windows kernel by microsoft research](https://en.wikipedia.org/wiki/Singularity_(operating_system))

2

u/ironnomi Dec 06 '15

Very interesting stuff, sadly if you've read about it, the project's evolution was dismantled about 15 months ago now. :(

They were actually building the ENTIRE system using managed code.

1

u/brobits Dec 06 '15

yup, sad stuff

1

u/ironnomi Dec 06 '15

I know one of the people on the later team (thankfully he moved to Azure development) and he said that while there were some successes, the performance issues massively outweighed a lot of the protection.

0

u/badcookies Dec 06 '15 edited Dec 06 '15

I realize that, you made it sound like most of OS X was written in Objective C.

5

u/1337Gandalf Dec 06 '15

Darwin is open source, that's everything but user space (like Cocoa, and AppKit for example)

Download it and see for yourself.

0

u/badcookies Dec 06 '15

And is it written in Objective C or C / C++?

1

u/1337Gandalf Dec 06 '15 edited Dec 06 '15

It's basically FreeBSD and Mach, so C.

Apple's proprietary frameworks are probably written in Objective-C, based on the headers.

→ More replies (1)