The Worst Programming Language Ever
transcript
my name is mark rendall i am a.net developer but i've been working in this business for 30 years and over that time i've worked with some truly horrific programming languages i'm going to show you a couple of them and uh yeah so this is not a talk where i'm going to like audit and review all the programming languages in the world and then go ha this one is the worst because that's just mean and also it's easy and we all know which one it is um no what we're going to do is we are going to take the worst features from a bunch of programming languages that might in other ways be very very good and perfectly acceptable and we're going to mash them all together and make the worst programming language that there has ever been in the whole of history and speaking of history there is a saying that those who do not learn from history are unable to iterate on it and make it worse and so we should look back at the history of programming languages at some truly egregious terrible examples like for example cobol cobol was the first programming language that was designed by committee and it shows and it shows that the committee there was no you know when people go there are no bad ideas i think that's what happened when they designed cobalt there are no bad ideas and so every idea that anybody suggested they just went yes we'll put that in so this is hello world in cobalt uh you identify the division and the program and then you say this is the you got the procedure division and then you just say display hello world and then you stop run not sure what happens if you don't stop run the program just keeps going forever and so cobol had a lot of boilerplate and actually the idea i think behind cobol was that business people would be able to write their own applications that was the dream in the 1960s and we all know how well that's worked out business people can't even describe the applications they want much less write them but ibm thought cobalt didn't have enough boilerplate and so they made their own version of cobol and this i swear to god this is hello world in ibm cobalt um i'm not even gonna try and dig into how this works because i i can't even imagine it um but knowing how much ibm programmers get paid by the hour that's about seven and a half thousand dollars worth of code there just to print hello world then there was apl um apl was invented by kenneth iverson uh as a teaching language to use in his computer science and programming classes um it stands for a programming language because kenneth wasn't the most creative person in the world uh outside of his programming language which actually in a lot of ways was fantastic so this is hello world in apl if you just give it a string it goes well i'll just write that back out to the standard output and we're done which is completely sane this is conway's game of life in apl that one line of code is the whole of conway's game of life now you might notice some interesting things in that line of code like some of those characters are greek uh some of them are mathematical uh some of them i think are just from a fever dream that kenneth had after taking some acid with timothy leary in san francisco in order to write code in apl you actually had to buy an apl keyboard which had all those weird little squiggles on it and i that that's brilliant that's um i'm going to invent a programming language i'm going to say this is what you need to learn to pass my course and here's the keyboard it costs 800 brilliant then in the 1970s somebody invented a programming language called the compiler with no pronounceable acronym or intercal and intercal was the first or it's the first known example of a joke programming language so this was a parody of the programming languages that were around at the time like fortran and fourth and things like that and it was designed to be ridiculously difficult to code in um and just also to poke fun at other programming languages so you notice four of the lines here start with please you had to say please on some of the lines of code when you were writing into cal if you didn't say please often enough you would get a compiler error that said programmer is insufficiently com polite if you just tried to cheat and went well i just put please at the start of every line you would get a compiler error that said programmer is excessively polite and the correct ratio of pleas to to not please was not documented anywhere into cal also did not have the go-to keyword it had come from and so if you wanted to do a conditional bit and jump to somewhere else in your program uh you would have a line that said um if something and then the next line would say please do nothing and then somewhere else in your code you would have a come from statement that took control from that please do nothing line and did something else instead and semantically that's identical to go to it's just done the other way around intercal was also the worst compiler ever so at the time uh they they benchmarked it and it was designed to be as slow as if you didn't have please give up at the end by the way it would um run your cpu up to 100 usage and just stay there until you turn the machine off um they benchmarked into cal uh at the time to make sure it was as slow as it could possibly be um and they compared it to uh i think it was a fortran application running the eris civ of eritosthenes which is the prime number finder and the fortran version took half a second to find all the primes up to one million and the intercal version took 17 hours the final results of the benchmark aren't actually in yet because the jvm version is still spinning up the virtual machine yay java um visual basic another joke programming language that then accidentally got bought by microsoft and promulgated out to the world and and people used it to build things um in the 90s when uh windows 3.1 and then windows 95 came along i'd been working on unix systems and my company went oh we've got to switch to windows go and evaluate which are the best um platforms for for writing windows applications and it probably would have been visual basic but i just didn't like it um it didn't do object oriented code at the time and its data access layer was basically non-existent in visual basic three they only added that in visual basic four with the ado framework and so i went with another language gupta sql windows is there a gupta sql windows user in the room no no you're lucky bastards so this is the gupta sql windows code editor and yes that is a tree view and yes that is the editor you would edit so it's like significant white space but it's not it's actually a tree view and so you could insert a nested or insert at same level and this when you saved your code it wasn't text it saved your source code as a binary file and then the compiler compiled it into bytecode and then put it in a an executable with a header and it was just it wasn't good and so i i left that behind and moved onto net so we are going to see if we can make something worse than all of these languages except possibly into cal but let's see if we can get as bad as into cal so we need a name for our language and nice short names that are easily googleable are a key thing when you're creating a programming language so i'm going to call it bs because be able to google that and there'll be no confusion people will find that and also programming languages these days you need taglines and marketing for it and all this sort of stuff and so bs's tagline is going to be why because you that's why you can beat that on the recording so we need our design principles for our language our bs design principles now a lot of languages try to create the pit of success they try to make it easy for the programmer to do the right thing that doesn't sound like any fun at all we want to create the pit of fail actually that's that's not even that's not enough i want to create the booby-trapped aztec temple of fail in my programming language that's what it should be like coding in bs you should feel like harrison ford running away from a giant boulder and then bumping into a bunch of people pointing arrows at you with a nazi archaeologist we are not going to trust the programmer to get simple things right we're going to make that as difficult as we can because programmers know who trusts programmers to do anything we're useless we're distracted easily we're spending half our time on twitter half our time on something else half our time playing browser games and we can't even do fractions properly it's ridiculous so we're not going to trust the programmer to get simple things right but we are going to leave it all all the really complicated stuff up to the programmer to deal with and make sure that they're having to really work to get this going and we should target as many things as possible so some programming languages if you look at like rust so rust specifically targets systems level programming and then people try and use it for other things like building websites and the rust team are like why are you doing there's there are other things use node do something else but no we if we just focus on doing one thing well then then we might accidentally do that and so we're going to try and do everything so we're going to try and low level systems and embedded code and rich graphical user interfaces and websites and a something on bs type web framework and the internet of things and furbies and vr and ar and metaverse and everything else so we're going to start we're going to take sort of one of the existing programming languages we'll use that as our base because every programming language since essentially the first one has been based on one that came before it so uh c was based on b b was based on a a was based on algol algol was based on fortran it all goes back that way and so if we move that forward and go okay that's languages that were inspired by c and so we get php php is a recursive acronym it originally stood for um [Music] perl hypertext preprocessor i've noticed it stood for personal home page because the dude made it to write his personal home page and then it stood for um personal hypertext processor but now it's actually one of those recursive acronyms it stands for php hates programmers because that's the only explanation i can think of for php um so what we're going to take from php is the total inconsistency php has shouty case and camelcase and snake case and pascal case and just all the different cases all the different ways of expressing things we're going to have pointless variable prefixing php all the variables have to start with a dollar if everything has to start with a dollar why does anything have to start with the dollar we're going to have the hassle of c and c plus plus but the performance of altair basic which you know if you're not old it wasn't good so we're going to start here's our starter bs program we have a class because we're an object-oriented language and we have a public function underscore underscore construct because that's how php does its constructors we're not going to prefix our variables with the dollar symbol because we're european even post brexit i still consider myself a european so we're going to prefix our variables with the euro symbol and that has the extra advantage the it's actually quite difficult to type on most keyboards and so that will make programmers work for it we're going to use the minus greater than um symbol for dereferencing properties and fields and members inside classes because dot that's just far too easy who wants to type one character when you can be forced to type two um and we're going to have curly brace let's start with curly braces and semicolons we'll think about whether we want to keep those um and for string concatenation we're going to use commas rather than the plus symbol because yeah because we are so yes here are here are our key differences we have an underscore underscore construct we have the uh minus arrow dereferencing and we have commas for string concatenation and we have our oh and we have the colon colon for static methods as well so that's a good start what else can we look at uh let's look at python so any python programmers in the room it's it's python you know it's the most popular programming language in the world now and there is a reason for that python is is actually generally uh very good and and very reasonable apart from this one thing this is some broken python code uh this chucks an error that says invalid constant when you try to run it here's the fixed version of that same code um what was wrong with the code on the left it had a mixture of tabs and spaces for the indentation which i don't know why that happened i opened it up in my editor and i added some code and i yeah somehow it it a tab found its way in there so from python we're going to take significant white space and to be fair that we're not just picking on python here there are other significant white space languages like f sharp and haskell and ocam and probably others coffeescript whatever happened to coffeescript i used to like coffeescript despite the significant white space so we're going to use significant whitespace in bs so this is simplified bs quite a lot here we've got our class greeter there and and our public function construct and we're going to use two spaces for indentation but if you are indenting by four spaces then you use a tab if you're indenting by six spaces then you use a tab and two spaces and if you're indenting by and so on and so on and so on so let's talk about how we're going to do comments then because comments you can have line comments you can have block comments you can have all sorts of comments and you need comments in code so that people know what's going on and why you've made the decisions and so in bs because you're either using a tab and two space or two spaces or some combination of those and so in bs any line that starts with a number of spaces that modulo two is one will be treated as a comment so if you start a line with a tab and a single space or a tab in three spaces or just with seven spaces then everything after that is a comment so there you go this is a comment but you also need so c uh c and c plus have the slash star and star slash to start and begin a comment and so if you use tab space and then space tab on a blank line then it comments out everything in between those two things so that public function foo at the bottom there is actually commented out if you use the approved bs editor to edit your bs code three thousand pounds a year from my company then that will gray out ever so slightly so you'll know that it's been commented out the next thing we're obviously going to have to bring in is common to all programming languages and it is of course null every language um forgotten the guys was it alan kaye working on the small talk project and he called um he called null his billion dollar mistake and i think that's probably an underestimate i think we're probably up somewhere around a trillion by now every language ever has a null and a nothing and an undefined and a data and an empty and a nil and uh you know javascript's got like eight different things that all mean null so so obviously we're going to have that uh which means we're going to have to do checking for nulls around the place and um there's one language where when you're checking something and potentially throwing exceptions it does it ever so slightly differently to every other language and that language is ruby because ruby in its every piece of code should look like you've written a sentence and it should be readable and it should make programmers happy and so for some reason matt's decided that that involved putting in an unless keyword which was an alternative to the if keyword so instead of saying if allowed formats does not include format raise invalid format you say raise invalid format unless so you raise an exception unless everything's okay which is like me running in here and going everybody get out unless there's not a fire it's it's the wrong way round it's i why why would you do this i don't understand it so i'm putting it in my language it's brilliant it we're not going to have if at all so ruby does have if bs is not going to have if we're just going to have unless also we're going to have a single exception and then we'll leave it up to the programmer to analyze the stack trace and core dump to work out what it was that actually went wrong that exception is going to be called halt and catch fire and that is a key word and that just throws an exception uh it's basically like panic but much more dramatic so we're going to say halton catch fire and then indentation on the line after you obviously have to come out you're out denting after your halt and catch fire and say unless name does not equal null um and so the s now we have exceptions and exception handling our next feature uh does not come from a programming language at all it comes from an actual language is there anybody in from greece or who knows greek or speaks greek so this is a greek question mark not a semicolon it's a question mark that's a greek semicolon um literally unicode because the greek question mark looks so much like a semicolon the unicode just automatically maps the greek question mark code to whatever the semicolon is from the same character set and so in bs your unless statements have to end with the greek question mark not a semicolon degree question mark and we'll sell keyboards with a special key that has a greek question mark key on it and we'll put it right next to the semicolon key and you'll just have to remember which one of them is which so the next language we're going to take stuff from is javascript and let's be honest there's a ton of stuff we could take from javascript the whole prototypal class based system and and just only having floating point numbers that would be a good one but what we're going to take from javascript is this so in javascript blank string does not equal the string 0 but 0 does equal the blank string and zero does equal the string zero so yeah figure that one out false equals undefined false doesn't equal undefined and false doesn't equal null but null does equal undefined and that comes back as true javascript has type coercion um and if you use double equals or bang equals to do a comparison then javascript will do its level best to make what you're doing true and it's just because it's like well programmers want things to be true we are seekers after truth i should make as many things true as possible i should jump through hoops to make things true so we're going to have this as well but we're going to take it up a notch and we're going to say that zero equals the empty string and zero equals the zero as a string and also zero equals the word zero in a string and 22 divided by seven equals the emoji for pi um so javascript uh because people kind of went this is not helping me i need to actually know whether two things are the same or not please please please can we turn this off but the problem with javascript is you can't fix it because there's tens of billions of lines of code of it out there in web pages and some of it hasn't been updated since 1996 and so you can't fix javascript and so they went all right we'll add so if you use equals equals equals then it'll do strict equality and so none of these things then you'll get this through properly and so we're going to do a strict equality check as well if you don't want type coercion but rather than saying uh equals equals equals we're just going to like make the the the equals operator important by putting an exclamation mark after it so bang equals bang means strict does not equal i call that the shopping trolley operator so if you want to do a strict equality check you have to negate the strict inequality operator so the strict equality operator is bang bang equals bang which i call the person on the hoverboard pushing a shopping trolley operator okay let's talk about strings so uh strings we've got multiple formats for strings we've got ascii and ansi and and uh unicode and unicode split up into utf-8 and utf-16 and utf-32 nobody uses utf-32 anymore windows uses utf-16 internally for everything but the web uses utf-8 most programming languages these days say utf-8 so goes strings and python strings i think now are utf-8 and so we deal with utf-8 unless we've actually loaded a library to do something differently but i want to be able to cope with all kinds of strings so if you have a string literal that's enco enclosed in single quotes that's an ascii string if you enclose it in pairs of single quotes that's an ansi string if you enclose it in double quotes then it's a dbcs string if you enclose it in pairs of double quotes then it's an ebcdic string that's important because we want to be able to run bs on ibm mainframes because we're going to replace cobol with bs because those are the only people in the world who are going to look at this language and go yeah that's better if you enclose your string in what i as an english person think of as french quotes then it is a utf-256 encoded string so utf-256 uses 256 bits for ev it's a 256-bit number for every character in the alphabet and this is brilliant because unicode um utf-8 uses this variable length encoding ut some of them are sort of one byte and some of them are four bytes um we're just going to go to hell with that we're going to use 16 bytes for every is it 16 or 32 i can't do math um whatever it is we're going to use 256 but we will never run out of address space for characters no matter because that actually allows us to have a character for every subatomic particle in the solar system that's a lot of characters and i'm going to make a website where you can upload any bloody picture you like and i'll give you back the utf-256 encoding for it and then you can use it in a string and then all the programs in the world will have to come to my web server to download the character for that youtube 256 thing [Music] if you enclose your string in pairs of french quotes then it's utf-256 but with string interpolation string interpolation is not possible with any of the other string types because q visual basic six in this instance but you know um this was there were lots of things to love about visual basic arrays started at one unless you did something somewhere in one place in the program and then suddenly all the arrays throughout the entire program started at zero and that was fun when somebody checked that change in but no visual basic for a raise decided that uh the square brackets might be a little bit hard for visual basic programmers to find on their keyboards they knew where the round brackets were everyone knows where the round brackets are so let's just use the round brackets for arrays and array indexing as well so that's that's how visual basic does things so we say dim f round brackets 10 as integer and then later on you see something going f1 and you're kind of like are you calling a function f and passing one or are you getting the first thing out of that f array also visual basics default integer type despite being a 32-bit language or a 32-bit compiler had 16-bit integers and so if you wanted a 32-bit integer you had to use long and if you wanted a 64-bit integer you had to write a com add-on in c plus plus so we're doing that we like that we're going to have round brackets for our um for our array indexes and also our integers are just going to be 17-bit um because we've bought shares in all the memory companies and so we don't care about those other um 15 bits that are that are being left empty because that's just making people buy more memory and that's making our share value go up it's brilliant c and c plus plus i did see programming my first uh my first job um it was on the job training it was like an apprenticeship and i turned up on my first day and they gave me a copy of kernighan and ritchie's c programming book and they said work through that at that terminal there so i sat down at the time i'm like how do i open a text editor and he went oh type vi and the name of the file and it'll just create it for you sorry vi hello dot c and then trying to start typing and there was a little semi-circle of all the other programmers who'd been there a bit longer standing around me going hey he's just learned vi so yes but um c had this brilliant feature uh called macros which was essentially just string substitution through the code and at the time there was a big you know the holy war so like vi versus emacs and net versus java and um and all these different things you know uh react versus angular at the time it was c versus pascal believe it or not pascal was actually considered a viable programming language back in 1989 and that one of the arguments that the c people had was that c was better because you could declare a few macros at the start of your c program and then it would compile pascal code but there was nothing you could do to pascal to make it to compile c code and kind of like that i like what you've done but it's not a good argument but i like macros they they can make surprising things happen so we're going to have macros in bs modern languages um like rust for example have what's called hygienic macros so they're actual little processes that run inside the compiler and can do intelligent things and i like that idea of being able to do something a bit more intelligent than just basic string substitution and actually there's already a fantastic way to do more complex string substitution so i'm just going to use regular expressions macros in bs are regular anything you can express in a regular expression you can turn into a macro in bs and the specific regular expression syntax is the one that you use in vi or vim for search and replace so when you do column percent s slash something slash something else slash g this is this is the same thing here so this i've done define and then a capture group and then thing and you've got the carrot at the start and colon at the end and then a dollar to say the end of the string so this will match an entire string and then it will replace that with class and then whatever was captured in that group so now in my code when i write my greeter thing colon this macro will come along and replace that and turn that into class greeter are you not entertained so yes because because what could possibly go wrong with that so there are some things i'm not quite sure on um i'm still sort of thinking them through static or dynamic typing so static type i personally prefer a statically typed language i'm a c-sharp developer um and uh it's other languages come along and i look at them and go do i still want to be a yeah no i'm fine um because c sharp is is great and it's statically typed there are times when that can be a bit annoying and you sort of think i wish this could be dynamic and then you actually use the c sharp dynamic keyword and you go no i don't um but uh so yeah there's there's a lot to be said for static typing there's a lot to be said for dynamic typing very quick prototyping very easy to do test driven development in a in a dynamically typed language because you can you can literally write the test first and it will run uh in a statically typed language if you write the test first and you haven't written any of the implementation it'll just go i'm not compiling um so yes so you know it's it's it's six of one half a dozen of the other and then i discovered that there's a thing called gradual typing which facebook um use in their their programming language flow and actually typescript originally did this it was optional so you could put a type hint python has this now as well as of like 3.8 i think python has type hints so you don't have to but you can put a type hint in there to say this variable should be a string or it should be an integer or it should be something um and so yeah facebook and flow has this and so we're going to do this gradual typing thing in bs we're going to introduce a new keyword is probably uh and because you know it's colon that could mean anything at all so we're gonna have is probably a we're gonna do localized versions of this as well so so we'll do a norwegian version with whatever the norwegian for is probably uh is is going to be in there as well also um grammar is very important and in the english language we have two indefinite articles a and an and we use an when the word after it starts with a vowel or an h if you're very posh um and so this is going to do grammar checking as well and so you say is probably a string but is probably an integer and if you get that wrong that'll be a compiler error but it'll just say invalid constant script or compiled so you know i quite like the idea of scripted languages because it forces you to send your source code out there and then anybody who wants to can look at it and see how terrible it is but compiled is good too because if you compile the code then it makes it much harder to work out why it's running really really slowly which is of course because we've put for x equals zero to a million nop in the machine code that has been output or we can do semi-compiled so a lot of languages are semi-compiled like c-sharp and java for example is compiled to an intermediate byte code and then you ship that and then it gets jit compiled um and so uh we're going to go for that semi-compiled thing we're going to generate this intermediate code but we should also make sure that this compiles to ecmascript 3 so that people can write things that still run in internet explorer 6 because it's still getting out there um how many times do you see it you're watching on news particularly hospitals this is the terrifying thing and somebody's being interviewed and you look behind them and you're going that's windows xp why have you got windows xp in your hospital why what are you doing memory management um i like garbage collected languages they make life nice and easy you just create things and then when you're finished with them there's an automated process that comes along and goes oh you're not using that anymore i'll get rid of that for you and clean up behind you um having worked in c for five years where you had to malloc memory that you wanted and then put text into it and then remember to free it again later otherwise everything just went to hell and the really brilliant thing with with c even back in like 19 1991 there was a thing called lindt which could run over your c code and it would point out to you when you had mallocked and you didn't appear to have freed that anywhere and you kind of like if you can do that in the lint why don't you just do it in the king compiler make my life easy rust has got this whole thing going on with only one thing at a time can own a variable which it's it's a nightmare there are two things so nothing is taken from rust in this by the way because um rust is is very close to being the perfect language um and rust's uh borrow checker and and lifetime checkers and all this sort of stuff they make life very difficult but the reason they're making life very difficult is because the things you're trying to do are really really bad and you shouldn't be doing them and they have the potential to cause your program to crash and do unexpected things and rust knows this and so rust isn't going to let you do these things but if you haven't tried rust just grab it and and work through the first couple of chapters of the rust book and do something wrong because the error messages in rust it's like it's like a hug from the compilers they're they're there you did your best yes yeah no you see you see here where you've done this no you can't do that no no it's bad no what you probably want to do is this it teaches you rust the compiler teeth is lovely so yeah we're not doing that definitely our error messages are going to be hell we're going to force our programmers to free everything they're not going to mallock them they're not going to know that they've allocated them we're just going to make them free them we're going to use delete and delete is going to start with a capital letter unlike every other keyword because delete is important you don't want to leak memory and you have to delete everything if you've used a variable you have to delete it so there's no pass by reference so the the name parameter that's been passed into our construct here that's a copy of the name parameter wherever that came from so now you own this this name variable here so you have to delete that when your function is finished any parameters you took in any variables you created the only thing you don't delete is if your function returns something then i actually know you have to delete that as well because when it returns it it'll make a copy of that and then the thing that called the function will own that and so after the return statement you have to delete the variable you just returned it's gonna be great what could possibly go wrong everything that's the point loops i'm a big big big big believer in the the principle that if it's broke you shouldn't fix it and if it isn't broke you should fix it until it breaks and then run away hire me but no there's there are four loops there are while loops there are four reach loops there are iterators there are do while loops there's all different ways of doing loops but we all know the best way of doing loops thank you into cal thank you basic is go to so modern languages c has go to c sharp has go to i actually use go to in c sharp um not a lot but you know when you have a try method in c sharp and it's got an out and you're going to do a bunch of things to see if you can set that out variable and then you're going to return true or you're going to set that out variable to its default value and return false and if there are like three or four different ways that trying to do this can fail you don't want to repeat that set it to its default value and return false so you put set it to its default value and return false at the bottom of your c sharp function and you put a fail label on it so fail colon and then as you're going through you just go go to fail go to fail go to fail and then just before you fail you set it to what it should be in return through it and there's nothing wrong with doing that and people go oh you've put goto in your code people literally have like um like net code analyzers that they've written with roslyn just just to look for the word go to just go ah you're bad and you're kind of like a no i'm not because it's in there and if it's in there you should be allowed to use it and b write some code that doesn't use go to and then go and look at the intermediate language that is generated from that what do you find in gotos all over the place so i'm putting them in my code but we're not going to have labels we're going to have line numbers we're only going to have line numbers though for lines that you are going to because what's the point of having line numbers for anything else and because i am a big fan of douglas adams line numbers have to be a multiple of 42 uh so you have line 42 and then the next line that you want to go to is going to be line 84 and we're going to go up like that and they have to be sequentially increasing and by 42 each time throughout your entire program and so if you need to introduce a new one halfway through you're going to have to manually renumber all the go-to lines underneath that we'll sell a refactoring tool that will do that for you twenty thousand dollars so we're gonna say 42 echo thing uh and and whatever else and then go to 42 unless uh the decremented times is strictly equal as your bang bang equals bang operator to zero and so this will print that string that number of times um the terrifying thing that i realized as i was writing this example code is you could write a compiler that would do that that that that would potentially work please don't please i did this talk at build stuff in 2014 and and two different groups of people went off and started github repos i was just kind of no no no no there are much better or worse things you could do with your time so modern programming languages we've got multi-core processors now we've got um my home machine has got 16 cores and each one of them is hyper threading so it's 32 logical calls in my machine so we have to support parallelism we have to be able to parallelize tasks so they can run as fast as possible which means we need to to do threads um and there's lots of different ways that go has go routines and there are says thread factory thread uh was it threadpool.q user work item and all these sorts of things and i was trying to think how can i bring bring threading into bs and i thought well you know the basic people they like having words for things like they're like lots of keywords and stuff so let's do something to to please the basic people so if you want two pieces of code to run at the same time in bs you just say do this and this and it will run both those lines of code at the same time so it will run hello and goodbye at the same time who knows which one of those will finish first it's indeterminate as threading should be so and that's that that makes sense to me that's that's completely fine the problem though with this way of doing threads which i am now married to um and i i cannot possibly contemplate any other way of doing threads is is it's not dynamic so if i get an array of something and i want to run an operation on each element in that array and i want to do that in a multi-threaded way so like parallel.4 or parallel.4 each in c sharp um there's there's no way of doing that because it's i it's got do and and and and and and so i i racked my brains and i thought there must be a solution to this and then i realized that there's a terrible language from way back in the mists of time that i hadn't taken anything from yet which was fourth fourth was was a truly weird language back in the 1950s i think fourth came from and fourth was the first language that had the evaluate instruction so in fourth you could write some code in a string and then say to fourth compile that and run it dynamically at runtime and actually so many languages um still have you know you can do that in c sharp with uh with the rosalind compiler you can generate an in-memory assembly and run it at runtime and and there are brilliant and clever things you can do with that javascript famously json javascript object notation the original idea with json was that it was not just an object format it was also valid javascript and so you could just say eval a string and it would become an in-memory object and people went that's genius and other people went so if i put a function in that string i can do pretty much whatever i want on your computer and the people who invented jason when oh no there are bad people in the world who knew um but no so we're going to bring in eval for for bs lang and so if i want to do something dynamically with threads then i can just build up a string and so i'm going to work through this so we start with i as -1 oh the gradual typing thing if the thing you're passing in is an array then you don't say like string bracket bracket you say things are probably strings or the equivalent plural conjugation of to be in the relevant language so we say i to minus one and we create an empty uh that's a an ascii string no it's an ansi string whatever it is um and then we say line 42 we're going to uh set threads to do um uh else we'll set threads to and will append um and to threads unless i is equal to one oh i forgot to mention earlier on so yeah visual basics arrays started at one most other programming languages arrays start at zero bs lang's arrays start at minus one and then go down because they can and it is actually laid out backwards in memory uh which will please all the java people with their big endian integers so yes so we start at minus one this threads 42 threads is this else threads is that um and then unless so what we're saying is unless i equals minus 1 do the line above else do the the line that starts with 42. that's an inverted if statement using unless there you go ruby that's how stupid unless is okay then we add the line to say the things that we've currently got in our string and then we go to 42 unless negative and less decremented i is less than the length of things the length oh less than minus the length of things so despite the fact that arrays start at minus one and then go down when you call len on an array it will return a positive number and actually that's fine because we are all completely used to the fact that when we get the length of an array in any programming language except visual basic to be fair um it will be one more than the highest index in that array so if you get up a bound it'll be one less so yes then there is a a static method that is in all no there is a method in all caps on the string type in bslang called evaluate which will just cause it to run and then we have to delete threads and i obviously because we're finished with them wouldn't you love to turn up to work every day and just know that you were going to work with this language wouldn't that make you happy no oh suit yourself um this is the the last item this is something that dylan beatty actually drew my attention to yesterday in go so in every other language and go does things differently and i'm pretty sure it's just because they're bastards um they've just added generics in go 1.18 finally after saying generics make things too complicated for ages now write the same function over and over and over again for every possible type this array could be they've added generics but for for generic type parameters and and type arguments it's not angle brackets it's square brackets which they do also use for the array indexer apparently you can't use angle brackets because they're also the less than and greater than operator and so if you're assigning two variables uh if you say a comma b equals and then you've got these things you have to the passer would have to read ahead to work out what was going on so right make the passer read ahead to work out what's going on what the wrong with you it's not like the passer's got better things to do than read my code is it but anyway they're doing that but goes uh date handling whether you want to format a date or pass a date so if we want to format a date we can pass an explicit string usually lowercase yyyy uppercase m for the month and you've got mm if you want to print it with two digits and then mmm will do like jan feb mar and mmm we'll just print the whole thing dd for day hh for 12 hour clock capital hh for 24 hour clock lower case mm for minutes lower case ss for seconds lowercase fff for fractions every programming language in the world uses that now as far as i can tell it's it's like this it's not an iso standard not like the iso date format but it is pretty much standard go doesn't go uses january the 22nd 2006 at three minutes past four and five seconds uh mountain time so seven hours behind gmt that is goes magic date and so however you want to format your date you write that date in that format and then it will turn whatever date you've actually got into that same format because they're bastards that's the only thing i can think of it's this is documented in their code it has go doesn't use yymmdd layout so they know it exists they know about it but no they're not going to use it instead you format a special layout parameter monday january the 2nd 150405 mst 2006 the same way as the time or date should be formatted it has to be that exact date and time and then there's this line this date is easier to remember when written as 0102 345 pm060700 okay but have you ever seen a date written like that i have never ever in my life seen somebody format a date like that and bloody americans they put the month first 0-102 the 2nd of january no that's the 1st of february so it's too good it's going in um but i'm going to use as my date uh the 21st of november 2014 at 10 minutes past five eastern european time uh which is the start of the first time i ever gave this talk um and so i mean that's okay it's it's not one two three four five six seven like goes one's uh is but you may find it easier to remember when it's written as twenty one oh five ten zero zero pm uh apostrophe 14 plus zero two zero zero um because there you go that's super helpful i learned a norwegian word if you're not norwegian that means you're welcome because i thought that was more appropriate than thank you so yes those those are my ideas for the worst programming language ever and and i do really want to thank go for that last contribution that's that's really tickled me um does anyone in the audience we've got about uh seven minutes left on the clock does anyone in the audience have a a favorite feature from their language that they think we should adopt that they'd like to share no that's fine if you don't sometimes oh yes hello you despite well yes matlab and it echoes out anything you don't and with a semi-colon it matlab echoes out anything you don't end with a semicolon any line it echoes out whatever you did on that line what i do is i go to the last slide as i'm as i'm doing the presentation and i add speaker notes for it if i like it i like it where's my view thing ah speaker note speaker note speaker notes outline view no notes page there we go um so matlab echoes out any line that doesn't end with a semicolon or a greek question mark obviously in in in bs so yes that that's brilliant i love that so yeah i'm gonna put that in for a future one hello yes i think maybe i'm swearing in church but do you have anything to say about also or else and also or else from vb i'm not even familiar with those okay right so it would not evaluate further things if ah yes so if you did in in vb 6 if you did this and this and this and this it would evaluate all of them even if the first one was false yes that's right and so they added because you can't break existing behavior because people could be relying on side effects from the third thing in the and sequence happening even when the first one was false and so they introduced and also um to say the that which was the early terminating and operator in if statements um yeah i'd forgotten about that yeah okay those are in there as well um so yes yes hello yes oh so if statements should require you or sorry unless statements should require you to break so and functions i i like that you're a twisted puppy so so here um we would say 42 threads equal something break else threads equals break um unless blah blah blah go to 42 break unless negative negative i and then after delete threads and i we'd put break yeah thank you not going to be able to fit these on the slides next time i do this talk break at end of every scope yep that's fantastic anybody else have any suggestions yes hello at the can back function without braces so like you call it function yeah but it's just written as a variable oh yes i've seen ruby does that as well doesn't it if you're not passing parameters you don't have to specify the parens yeah i'll put that down there optional parens when function has no params yeah that that's awesome hello yes i think the language is a bit too effective with less than double minus you would um but uh so yeah and i thought about that the sort of um pre-ink and posting course or something like that um and doing it as a function with like a ref parameter um but then i thought if we put plus plus and minus minus in there we might trick programmers from c like languages to going oh they're serious that's good yes yes you do have that um yep dash gt ah there's a there is a left i want to say it's vb but i don't think it is um there was a programming language i think it was one of the ones i evaluated at the same time as vb and uh and gupta sql windows because i looked at power builder did anyone ever use power builder that sucked informix new era but i've seen a language which has greater than and greater than equal and less than and less than equal as keywords and doesn't support just the the mathematical operators for those things because apparently according to unicode what we call the less than and greater than characters are not actually the less than and greater than characters they're a type of paren the mathematical characters for less than and greater than are hiding somewhere else in the unicode character set we've been sold a lie so yeah um right yes one more hello you often have to prefix functions in build functions right yes so prefix everything with bs yes oh so so some things will and some things yeah okay so prefix uh let's say 69 because that all that number makes my son laugh he's 10. um thank you youtube uh of um standard library uh members with bs fantastic right our time is up thank you all so much for coming um thank you for for coming to the conference generally i hope you had a great time please safe journey home and uh take care of yourself and i hope that we will be back here in may june next year and we can do this all again cheers [Applause]
- from
- Talks
- added
- 2026-10-10
- likes
- 0
similar
-
-
The Programming Language Wars youtube.com
-
-
Implementing Programmer Anarchy vimeo.com
-
The Art of Destroying Software youtube.com
-
Falsehoods about Programming chiselapp.com
A humbling and fun list on programming and programmers themselves.
Talks › Categories > Software Development: “by Mark Rendle (NDC Oslo 2021) [1:00:40]”