language-comparisons

YAML compared to XML [closed]

ε祈祈猫儿з 提交于 2019-11-28 16:12:46
问题 I read that after years yaml will be used instead of xml. Please compare the relative advantages and disadvantages of each specification. 回答1: YAML is much less verbose. The signal-to-noise ratio is higher without all the brackets. This makes it subjectively easier to read and edit for many people. On the flip side, it's slightly (only slightly) harder to parse. The biggest difference, though, is that XML is meant to be a markup language and YAML is really more of a data format. Representing

Disadvantages of Scala type system versus Haskell?

筅森魡賤 提交于 2019-11-28 15:52:44
I have read that Scala's type system is weakened by Java interoperability and therefore cannot perform some of the same powers as Haskell's type system. Is this true? Is the weakness because of type erasure, or am I wrong in every way? Is this difference the reason that Scala has no typeclasses? The big difference is that Scala doesn't have Hindley-Milner global type inference and instead uses a form of local type inference, requiring you to specify types for method parameters and the return type for overloaded or recursive functions. This isn't driven by type erasure or by other requirements

What advantages does modern Fortran have over modern C++? [closed]

一世执手 提交于 2019-11-28 15:39:19
问题 I'm trying to decide between Fortran and C++ for an application in scientific computing. It's not clear to me if Fortran still has advantages over other languages when it comes to performance. For example, I believe since Fortran enforces strict aliasing, better optimizations could be made by the compiler when compared to C before C99. I'm unsure of how C++ fits in here. Any guidance? 回答1: I took a look at some of the stuff in the latest Fortran standards, and frankly I'm impressed. A lot of

is there an virtual environment for node.js?

两盒软妹~` 提交于 2019-11-28 15:13:02
I've searched the wiki modules page, but I can't find anything similar to virtualenv (python) or rvm. Anyone here separates node.js in their own env? I really don't like to install npm system-wide. bxjx If having system wide npm packages is your main issue, then maybe consider using the very cool 'bundle' command with npm. This is closer to freezing gems or using bundler in rails, rather than rvm. It's super easy. Just create a package.json file: { "name": "yourapp", "version": "0.0.1", "dependencies": {"jade": "0.4.1"}} and then run: npm bundle vendor or if your npm version is >= 1.0 run: npm

Should I learn Haskell or F# if I already know OCaml? [closed]

折月煮酒 提交于 2019-11-28 13:44:04
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not

F# equivalent of `is` keyword in C#?

一笑奈何 提交于 2019-11-28 12:01:52
My first F# day. If I have this: let cat = Animal() Now how do I check at later stage if cat is Animal ? In C# bool b = cat is Animal; In F#? @ildjarn deserves the credit here for answering first, but I'm submitting the answer here so it can be accepted. The F# equivalent of the C# is keyword is :? . For example: let cat = Animal() if cat :? Animal then printfn "cat is an animal." else printfn "cat is not an animal." For demonstration only (don't define an is function): let is<'T> (x: obj) = x :? 'T type Animal() = class end type Cat() = inherit Animal() let cat = Cat() cat |> is<Animal> /

Does PHP have an equivalent to Python's list comprehension syntax?

断了今生、忘了曾经 提交于 2019-11-28 05:36:46
Python has syntactically sweet list comprehensions: S = [x**2 for x in range(10)] print S; [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] In PHP I would need to do some looping: $output = array(); $Nums = range(0,9); foreach ($Nums as $num) { $out[] = $num*=$num; } print_r($out); to get: Array ( [0] => 0 [1] => 1 [2] => 4 [3] => 9 [4] => 16 [5] => 25 [6] => 36 [7] => 49 [8] => 64 [9] => 81 ) Is there anyway to get a similar list comprehension syntax in PHP? Is there anyway to do it with any of the new features in PHP 5.3? Thanks! Maybe something like this? $out=array_map(function($x) {return $x*$x;},

Is there a Python equivalent to Ruby symbols?

假如想象 提交于 2019-11-27 14:28:35
问题 Is there a Python equivalent to Ruby symbols? If so then what is it? If not then are we stuck with using strings as our keys in dictionaries only? 回答1: No, python doesn't have a symbol type. However string literals are interned by default and other strings can be interned using the intern function. So using string literals as keys in dictionaries is not less performant than using symbols in ruby. 回答2: As others have said, there is no symbol in Python, but strings work well. To avoid quoting

What are the PowerShell equivalents of Bash's && and || operators?

对着背影说爱祢 提交于 2019-11-27 12:41:07
In Bash I can easily do something like command1 && command2 || command3 which means to run command1 and if command1 succeeds to run command2 and if command1 fails to run command3. What's the equivalent in PowerShell? What Bash must be doing is implicitly casting the exit code of the commands to a Boolean when passed to the logical operators. PowerShell doesn't do this - but a function can be made to wrap the command and create the same behavior: > function Get-ExitBoolean($cmd) { & $cmd | Out-Null; $? } ( $? is a bool containing the success of the last exit code ) Given two batch files: #pass

Is there const in C?

寵の児 提交于 2019-11-27 11:18:42
This question may be naive, but: is there const keyword in C? since which version? are there any semantic and/or syntactic differences between const in C and C++? There are no syntactic differences between C and C++ with regard to const keyword, besides a rather obscure one: in C (since C99) you can declare function parameters as void foo(int a[const]); which is equivalent to void foo(int *const a); declaration. C++ does not support such syntax. Semantic differences exist as well. As @Ben Voigt already noted, in C const declarations do not produce constant expressions, i.e. in C you can't use