4 ms·
So the Ruby guys have an unfair advantage. As a non-Ruby guy hope they fix this. But it still feels bad. I only found that site a few days ago and it looked all
by kronos29296 9y ago
So the Ruby guys have an unfair advantage. As a non-Ruby guy hope they fix this. But it still feels bad. I only found that site a few days ago and it looked all flashy compared to codeforces but now - It raises severe questions about its accuracy. Kinda like Chrome dinosaur high scores.
- jhbadger 9y agoIf they allowed FORTH it would be even worse -- everything in FORTH is redefinable -- you could make 1 equal to 2 if you want.
- mpd 9y agoI don't believe there's anything that would prevent that in Ruby, though I'm sure the Forth way would be more elegant.
- kronos29296 9y agoThe other sites don't seem to have this problem as they compare STDOUT. CodeWars should also do something like this.
- pmontra 9y agoNot in the easy way, not with MRI $ irb 2.4.1 :001 > 1.class => Integer 2.4.1 :002 > class Integer 2.4.1 :003?> def 1 2.4.1 :004?> 2 2.4.1 :005?> end 2.4.1 :006?> end SyntaxError: (irb):3: syntax error, unexpected tINTEGER def 1 ^ (irb):6: syntax error, unexpected keyword_end, expecting end-of-input That's not unexpected as small numeric literals are magic in Ruby, for performance reasons. More evidence: 2.4.1 :001 > class Integer 2.4.1 :002?> define_method(:one) { 1 } 2.4.1 :003?> end => :one 2.4.1 :004 > Integer.one NoMethodError: undefined method `one' for Integer:Class 2.4.1 :005 > Integer.new.one NoMethodError: undefined method `new' for Integer:Class 2.4.1 :006 > Integer.new NoMethodError: undefined method `new' for Integer:Class 2.4.1 :007 > class Klass 2.4.1 :008?> define_method(:one) { 1 } 2.4.1 :009?> end => :one 2.4.1 :010 > Klass.one NoMethodError: undefined method `one' for XY:Class 2.4.1 :011 > Klass.new.one => 1 So Integer is not like other classes and the actual reason for that http://archive.oreilly.com/pub/post/the_ruby_value_1.html http://archive.oreilly.com/pub/post/the_ruby_value_1.html TLDR MRI gets the value of the number directly from value of the C pointer and saves the lookup. It's a 1 in the lowest bit and the integer value in the others. That's why 0.object_id == 1, 1.object_id == 3, etc Obviously that's implementation dependent but I guess no Ruby implementation is going us to redefine integers if MRI does not.
- kronos29296 9y agoIs that why nobody uses it anymore? Only thing I know about it is that it used stack like expressions. (kinda like RPN but for everything)
- Lev1a 9y agoI think nowadays more interpreters/compilers are being written for FORTH than stuff in the language itself.
- kronos29296 9y agoKinda like BrainF* I see. Turing complete but a readability nightmare. Maybe I should try to write one for FORTH like for BrainF*. Was an interesting exercise especially the loops.
- Jach 9y agoNo, the parent is wrong. Maybe on Github Forth interpreters dominate as people's pet projects but there's a good chunk or niche of the embedded industry writing real Forth code every day for new things, not just legacy support. But their code usually isn't on Github. It's a great language for bare metal programming and quite readable, unlike BF which is intentionally unreadable. Forth was designed for low level really (edit: though I remembered there's this if you want an idea of the philosophy http://thinking-forth.sourceforge.net/ http://thinking-forth.sourceforge.net/), I think it's less suitable for higher level general purpose programming just for its untyped nature alone. https://www.forth.com/embedded/#Annotated_example_source_code https://www.forth.com/embedded/#Annotated_example_source_cod... contains a version of the canonical washing machine program. \ Top-level control : WASHER ( -- ) WASH SPIN RINSE SPIN ; You can then look at the definitions for 'WASH' and 'SPIN' and 'RINSE' and so on until you get down to what IO bits you're turning on or reading when and for how long.
- milesvp 9y agoMy understanding is fourth is still alive and well in the embedded world. A fourth compiler can be written in very few instructions, which is very important when you don't have a lot of memory to work with. http://demin.ws/blog/english/2012/09/27/fcode/ http://demin.ws/blog/english/2012/09/27/fcode/
- ransom1538 9y agoI have begun rewriting all our backend with FORTH.
- mcguire 9y agoSo the demo video should be posted next weekend?
- khedoros1 9y agoI had a friend who was obsessed with Smalltalk in college. He enjoyed showing classmates that you could do things like redefine true and false in the language.