Jump to content

monoceres

MVPs
  • Posts

    4,054
  • Joined

  • Last visited

  • Days Won

    6

monoceres last won the day on March 7 2014

monoceres had the most liked content!

2 Followers

About monoceres

  • Birthday 05/23/1990

Profile Information

  • Member Title
    unit -> unit
  • Location
    Linköping, Sweden

Recent Profile Visitors

4,126 profile views

monoceres's Achievements

Universalist

Universalist (7/7)

198

Reputation

  1. Many years ago, when the world was still young, I worked on something similar... I never finished it and I added many new features to the language so it’s more like a derivative language. Anyways, the code (including compiler and runtime) is publicly available on GitHub: https://github.com/andreasjhkarlsson/ai5 maybe it will provide useful for your project.
  2. Unfortunately the overly verbose casting syntax in C++ makes you crazy instead!
  3. I really like static typing, but the somewhat heavy verbosity of javascript still makes me a little bit turned off. Now, introduce type inference (like f# for example) into coffeescript, that would be really nice! Still, I like this new trend with languages compiling into javascript. With increasing performance and light weight applications it becomes much more practical than previous examples (google web toolkit comes to mind). The fact that you can interact directly with the libraries from the blossoming javascript community makes it even more interesting.
  4. I see. I think just C# answered several of my questions
  5. Developing languages is very fun! I'm currently doing that also. I'm mostly interested in implementation of Sputnik: What language is it written in? Are you using a parser generator or have you written a custom parser? What kind of garbage collecting are you doing, reference counting? And if so, have thought about cycles and how reference counting affects multi-threading? Have you optimized for speed, and what are currently the biggest bottlenecks in the language. Unicode support? What are your thoughts in platform dependence?
  6. I think it's unfair to put the weakness of an android security component on the bitcoin system. No crypto system is fully secure, especially in the beginning, what makes them ultimately safer is patching and informing the users about best practices. As bitcoins have been designed from the beginning with security as an absolute core, I think it's about as secure as you could expect by now. Also, I wouldn't be worried about DOS attacks as btc is decentralized. Third party exchangers might be targets, but that doesn't make the money on your hard drive any less secure.
  7. If you had any idea what you're talking about you would realize how ridiculus this statemment is. The bloom filter is used to speed up processing for lightweight clients (like smartphones). Do you really think a basic property of a common data structure would compromise one of the worlds most well crafted, intricate cryptographic system?!
  8. Got me thinking and reading about bloom filters.
  9. Yup, and to counter argue I can say that I have worked with the QT framework which makes GUI in C++ non more horrible than in any other language.
  10. What's so special about this? It's just some rules used by NYTimes to make sure their code base is following the same style. It's far more important that everybody in a team follow the same conventions than that the code is 100 % correct from a philosophical standpoint (which of course isn't even objective(-c)).
  11. I don't know that much. The only time I have even written anything in a purely functional language was in a intro course at university where we had to implement Fibonacci number generators with lisp. At that time I didn't even understand recursion very well so the whole thing was lost on me I understand that it's interesting to learn. Having programmed with OOP for many years means you have seen most tricks and the limits of the paradigm seems everywhere suddenly.
  12. Very nice! I've been thinking of sinking my teeth into some functional languages for a while now after realizing that I was more or less doing functional programming in javascript. The thing I love about functional programming is how expressive it is. Especially with asynchronous callbacks, closures and currying. Haskell is top of the list so I will probably start with it as soon as I finish my current hobby project. The following seems to be the definitive beginners guide to Haskell: http://learnyouahaskell.com/
  13. I advice you to read up on grammars (EBNF), regex (for the lexer) and recursive descent parsers. With these three tools you will come a long way in making a good language. Error handling is massively simplified in a recursive descent parser. Since the parser is more or less a direct reflection of the grammar, everything that doesn't fit the grammar is directly identified as errors. Lets take a simple language that can add two digits together. The grammar in EBNF looks like this: <adder program> = <digit>,{"+",<digit>} <digit> = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" Some valid inputs for this grammar is: 1 1+2 1+2+1+5 While some invalid inputs are: [empty string] 1+ +1 2+4+ For fun, I wrote a little parser that evaluates the grammar: #include <array.au3> ; Grammar: ; <adder program> = <digit>,{"+",<digit>} ; <digit> = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; ; Displays error and terminates program. Func error($message) MsgBox(0,"Error",$message) Exit 1 EndFunc ; Token types Global Const $DIGIT = "digit" Global Const $PLUS = "plus" Global Const $END = "end" ; Returns a token! Func Token($type,$value=0) Return $type&"|"&$value EndFunc Func GetTokenValue($token) $arr = StringSplit($token,"|") return $arr[2] EndFunc Func GetTokenType($token) $arr = StringSplit($token,"|") return $arr[1] EndFunc ; Turns a string into an array of tokens. Func Lex($input) Local $res[1] ; Regex that matches tokens. Local $patterns[2][2] = [[$DIGIT,"^\d"],[$PLUS,"^\+"]] ; Repeat while there is characters left in input. while $input <> "" For $i=0 To UBound($patterns)-1 $value = StringRegExp($input,$patterns[$i][1],3) ; Did the pattern match! if not @error Then $value = $value[0] $input = StringTrimLeft($input,StringLen($value)) _ArrayAdd($res,Token($patterns[$i][0],$value)) ; Restart pattern loop. ContinueLoop 2 EndIf Next ; No pattern matched? Throw!! error("Could not scan string: "&$input) WEnd ; Insert special token for parser! _ArrayAdd($res,Token($END)) Return $res EndFunc Global $tokens Global $pos Global $current ; Throws error if current token is not of type. Func Expect($type) If GetTokenType($current)<>$type Then error("Expected token with type: "&$type&", got: "&GetTokenType($current)) EndFunc ; Returns true if current token is of type, else false. Func Accept($type) Return GetTokenType($current) == $type EndFunc ; Moves on to next token. Func Advance() $pos += 1 $current = $tokens[$pos] EndFunc ; Returns the value of digit token. Func Digit() Expect($DIGIT) Return Int(GetTokenValue($current)) EndFunc ; Parse/Executes an AdderProgram. Func AdderProgram() ; Setup parser $pos = 0 Advance() ; We know that each program starts with DIGIT. $sum = Digit() ; There can be infinite many repeating plus operation Advance() While Accept($PLUS) Advance() ; After accepting a PLUS we know there is a DIGIT following. $sum += Digit() Advance() WEnd ; We should have now reached the end of the program. ; If we're not at the END token, the program did not match grammar! Expect($END) Return $sum EndFunc $program = InputBox("Adder","Enter adder program:") $tokens = Lex($program) MsgBox(0,"Answer",$program&" = "&AdderProgram())
  14. I'm a complete idiot when it comes to music theory so I cannot really experiment with this, but I can recognize the great work. As someone who is very interesting in computer language theory and interpreter/compiler construction I have some feedback: You should definitely write a grammar for the language. EBNF is simple and the advantages of having your language in an abstract form is really useful and makes stuff a lot easier. Plus anyone else wanting to implement a interpreter/compiler knows exactly what to target. Split your interpreter into different parts. For something like this I think the following would be nice: - Lexer: Converts program into tokens. - Parser: Converts the tokens into an abstract syntax tree. This is basically the grammar represented in a tree data structure. If you have written in a grammar, it's easy to write a small recursive descent parser to parse the programs or use a parser generator such as ANTLR to generate a parser for you. - Evaluator: Simply takes your syntax tree and executes it. Having this separation is great because it's easy to debug, maintain and extend. It also allows you to do cool stuff like compile your programs without redoing all the work. Otherwise, it's a really cool project and hearing music from my speakers was a joy!
×
×
  • Create New...